@@ -51,8 +51,8 @@ public static void main(String[] args) throws IOException, ClassNotFoundExceptio
51
51
}
52
52
53
53
/*
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
+ * */
56
56
private static void generateJsInputFile () throws IOException {
57
57
try {
58
58
traverseDirectory (inputDir , false /*traverse explicitly*/ );
@@ -69,7 +69,7 @@ private static void generateJsInputFile() throws IOException {
69
69
pw .close ();
70
70
}
71
71
72
- private static boolean isSuppressCallJSMethodExceptionsEnabled () throws IOException {
72
+ private static boolean isSuppressCallJSMethodExceptionsEnabled () throws IOException {
73
73
File jsonFile = new File (inputDir , "package.json" );
74
74
if (!jsonFile .exists ()) {
75
75
return false ;
@@ -79,9 +79,13 @@ private static boolean isSuppressCallJSMethodExceptionsEnabled() throws IOExcept
79
79
try {
80
80
pjson = new JSONObject (jsonContent );
81
81
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
+ }
85
89
}
86
90
}
87
91
} catch (JSONException e ) {
@@ -116,7 +120,7 @@ private static void validateInput() throws IOException {
116
120
/*
117
121
* Run the javascript static analysis [js_parser] and generate an output file.
118
122
* This output file should contain all the information needed to generate java counterparts to the traversed js classes.
119
- * */
123
+ * */
120
124
private static void runJsParser () throws IOException {
121
125
String parserPath = Paths .get (System .getProperty ("user.dir" ), "jsparser" , "js_parser.js" ).toString ();
122
126
@@ -134,7 +138,7 @@ private static void runJsParser() throws IOException {
134
138
e .printStackTrace ();
135
139
throw new InterruptedIOException ("A problem occured while waiting for the jsparser to finish." );
136
140
}
137
- if (p .exitValue () != 0 ) {
141
+ if (p .exitValue () != 0 ) {
138
142
System .exit (p .exitValue ());
139
143
}
140
144
}
@@ -167,10 +171,14 @@ private static void traverseDirectory(File currentDir, boolean traverseExplicitl
167
171
if (!pjson .has ("nativescript" )) {
168
172
return ;
169
173
} 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 ;
174
182
}
175
183
}
176
184
}
@@ -192,8 +200,8 @@ private static void traverseDirectory(File currentDir, boolean traverseExplicitl
192
200
private static List <String > webpackWorkersExcludesList ;
193
201
194
202
/*
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
+ * */
197
205
private static void getWorkerExcludeFile () {
198
206
webpackWorkersExcludesList = new ArrayList <String >();
199
207
0 commit comments