@@ -51,8 +51,8 @@ public static void main(String[] args) throws IOException, ClassNotFoundExceptio
5151 }
5252
5353 /*
54- * Method should traverse all js files from input folder and put the ones that need traversing in another file
55- * */
54+ * Method should traverse all js files from input folder and put the ones that need traversing in another file
55+ * */
5656 private static void generateJsInputFile () throws IOException {
5757 try {
5858 traverseDirectory (inputDir , false /*traverse explicitly*/ );
@@ -69,7 +69,7 @@ private static void generateJsInputFile() throws IOException {
6969 pw .close ();
7070 }
7171
72- private static boolean isSuppressCallJSMethodExceptionsEnabled () throws IOException {
72+ private static boolean isSuppressCallJSMethodExceptionsEnabled () throws IOException {
7373 File jsonFile = new File (inputDir , "package.json" );
7474 if (!jsonFile .exists ()) {
7575 return false ;
@@ -79,9 +79,13 @@ private static boolean isSuppressCallJSMethodExceptionsEnabled() throws IOExcept
7979 try {
8080 pjson = new JSONObject (jsonContent );
8181 if (pjson .has ("android" )) {
82- JSONObject androidSettings = (JSONObject ) pjson .get ("android" );
83- if (androidSettings .has ("suppressCallJSMethodExceptions" ) && androidSettings .get ("suppressCallJSMethodExceptions" ).toString ().equals ("true" )) {
84- return true ;
82+ Object androidJsonProperty = pjson .get ("android" );
83+
84+ if (androidJsonProperty instanceof JSONObject ) {
85+ JSONObject androidSettings = (JSONObject ) androidJsonProperty ;
86+ if (androidSettings .has ("suppressCallJSMethodExceptions" ) && androidSettings .get ("suppressCallJSMethodExceptions" ).toString ().equals ("true" )) {
87+ return true ;
88+ }
8589 }
8690 }
8791 } catch (JSONException e ) {
@@ -116,7 +120,7 @@ private static void validateInput() throws IOException {
116120 /*
117121 * Run the javascript static analysis [js_parser] and generate an output file.
118122 * This output file should contain all the information needed to generate java counterparts to the traversed js classes.
119- * */
123+ * */
120124 private static void runJsParser () throws IOException {
121125 String parserPath = Paths .get (System .getProperty ("user.dir" ), "jsparser" , "js_parser.js" ).toString ();
122126
@@ -134,7 +138,7 @@ private static void runJsParser() throws IOException {
134138 e .printStackTrace ();
135139 throw new InterruptedIOException ("A problem occured while waiting for the jsparser to finish." );
136140 }
137- if (p .exitValue () != 0 ) {
141+ if (p .exitValue () != 0 ) {
138142 System .exit (p .exitValue ());
139143 }
140144 }
@@ -167,10 +171,14 @@ private static void traverseDirectory(File currentDir, boolean traverseExplicitl
167171 if (!pjson .has ("nativescript" )) {
168172 return ;
169173 } else {
170- JSONObject nsValue = (JSONObject ) pjson .get ("nativescript" );
171- if (nsValue .has ("recursive-static-bindings" )) {
172- System .out .println (String .format ("Task: traverseDirectory: Folder will be traversed completely: %s" , currentDir ));
173- traverseExplicitly = true ;
174+ Object nativeScriptJsonProperty = pjson .get ("nativescript" );
175+ if (nativeScriptJsonProperty instanceof JSONObject ) {
176+ JSONObject nsValue = (JSONObject ) nativeScriptJsonProperty ;
177+ if (nsValue .has ("recursive-static-bindings" )) {
178+ traverseExplicitly = true ;
179+ }
180+ } else {
181+ return ;
174182 }
175183 }
176184 }
@@ -192,8 +200,8 @@ private static void traverseDirectory(File currentDir, boolean traverseExplicitl
192200 private static List <String > webpackWorkersExcludesList ;
193201
194202 /*
195- * Should provide the webpack specific files that need to be excluded from the js analysis
196- * */
203+ * Should provide the webpack specific files that need to be excluded from the js analysis
204+ * */
197205 private static void getWorkerExcludeFile () {
198206 webpackWorkersExcludesList = new ArrayList <String >();
199207
0 commit comments