Add @SuppressWarnings("unused") to generated Java classes
authorTeemu Andersén <andrte@Teemus-MacBook-Pro.local>
Thu, 10 Sep 2015 16:56:50 +0000 (19:56 +0300)
committerTeemu Andersén <andrte@Teemus-MacBook-Pro.local>
Fri, 11 Sep 2015 20:33:55 +0000 (23:33 +0300)
Usually generators add @SuppressWarnings("all") to generated Java
classes to prevent IDEs from complaining about unused imports, etc.
Solving used imports seems pretty hard with current generator logic so
IMO this is the next best thing.

Yes, it’s appended to import block but that is the block that gives
these warnings in the first place.

src/idl_gen_general.cpp

index 3b597cf..fdb6df7 100644 (file)
@@ -118,7 +118,7 @@ LanguageParameters language_parameters[] = {
     "position()",
     "offset()",
     "import java.nio.*;\nimport java.lang.*;\nimport java.util.*;\n"
-      "import com.google.flatbuffers.*;\n\n",
+      "import com.google.flatbuffers.*;\n\n@SuppressWarnings(\"unused\")\n",
     {
       "/**",
       " *",