@@ -75,7 +75,7 @@ private static void prepareConstantsList() {
7575
7676
7777 public static String getIDName (int id ) {
78- if (constantsMap == null ){
78+ if (constantsMap == null ) {
7979 prepareConstantsList ();
8080 }
8181 return constantsMap .get (id );
@@ -103,175 +103,174 @@ public static String getSimplifiedErrorMessage(IProblem iprob) {
103103
104104 switch (iprob .getID ()) {
105105
106- case IProblem .ParsingError :
107- if (args .length > 0 ) {
108- result = Language .interpolate ("editor.status.error_on" , args [0 ]);
109- }
110- break ;
111-
112- case IProblem .ParsingErrorDeleteToken :
113- if (args .length > 0 ) {
114- result = Language .interpolate ("editor.status.error_on" , args [0 ]);
115- }
116- break ;
117-
118- case IProblem .ParsingErrorInsertToComplete :
119- if (args .length > 0 ) {
120- if (args [0 ].length () == 1 ) {
121- result = getErrorMessageForBracket (args [0 ].charAt (0 ));
106+ case IProblem .ParsingError :
107+ if (args .length > 0 ) {
108+ result = Language .interpolate ("editor.status.error_on" , args [0 ]);
109+ }
110+ break ;
122111
123- } else {
124- if (args [0 ].equals ("AssignmentOperator Expression" )) {
125- result = Language .interpolate ("editor.status.missing.add" , "=" );
112+ case IProblem .ParsingErrorDeleteToken :
113+ if (args .length > 0 ) {
114+ result = Language .interpolate ("editor.status.error_on" , args [0 ]);
115+ }
116+ break ;
126117
127- } else if (args [0 ].equalsIgnoreCase (") Statement" )) {
118+ case IProblem .ParsingErrorInsertToComplete :
119+ if (args .length > 0 ) {
120+ if (args [0 ].length () == 1 ) {
128121 result = getErrorMessageForBracket (args [0 ].charAt (0 ));
129122
130123 } else {
131- result = Language .interpolate ("editor.status.error_on" , args [0 ]);
124+ if (args [0 ].equals ("AssignmentOperator Expression" )) {
125+ result = Language .interpolate ("editor.status.missing.add" , "=" );
126+
127+ } else if (args [0 ].equalsIgnoreCase (") Statement" )) {
128+ result = getErrorMessageForBracket (args [0 ].charAt (0 ));
129+
130+ } else {
131+ result = Language .interpolate ("editor.status.error_on" , args [0 ]);
132+ }
132133 }
133134 }
134- }
135- break ;
136-
137- case IProblem .ParsingErrorInvalidToken :
138- if (args .length > 0 ) {
139- if (args [1 ].equals ("VariableDeclaratorId" )) {
140- if (args [0 ].equals ("int" )) {
141- result = Language .text ("editor.status.reserved_words" );
135+ break ;
136+
137+ case IProblem .ParsingErrorInvalidToken :
138+ if (args .length > 0 ) {
139+ if (args [1 ].equals ("VariableDeclaratorId" )) {
140+ if (args [0 ].equals ("int" )) {
141+ result = Language .text ("editor.status.reserved_words" );
142+ } else {
143+ result = Language .interpolate ("editor.status.error_on" , args [0 ]);
144+ }
142145 } else {
143146 result = Language .interpolate ("editor.status.error_on" , args [0 ]);
144147 }
145- } else {
146- result = Language .interpolate ("editor.status.error_on" , args [0 ]);
147148 }
148- }
149- break ;
149+ break ;
150150
151- case IProblem .ParsingErrorInsertTokenAfter :
152- if (args .length > 0 ) {
153- if (args [1 ].length () == 1 ) {
154- result = getErrorMessageForBracket (args [1 ].charAt (0 ));
155- }
156- else {
157- // https://github.com/processing/processing/issues/3104
158- if (args [1 ].equalsIgnoreCase ("Statement" )) {
159- result = Language .interpolate ("editor.status.error_on" , args [0 ]);
151+ case IProblem .ParsingErrorInsertTokenAfter :
152+ if (args .length > 0 ) {
153+ if (args [1 ].length () == 1 ) {
154+ result = getErrorMessageForBracket (args [1 ].charAt (0 ));
160155 } else {
161- result =
162- Language .interpolate ("editor.status.error_on" , args [0 ]) + " " +
163- Language .interpolate ("editor.status.missing.add" , args [1 ]);
156+ // https://github.com/processing/processing/issues/3104
157+ if (args [1 ].equalsIgnoreCase ("Statement" )) {
158+ result = Language .interpolate ("editor.status.error_on" , args [0 ]);
159+ } else {
160+ result =
161+ Language .interpolate ("editor.status.error_on" , args [0 ]) + " " +
162+ Language .interpolate ("editor.status.missing.add" , args [1 ]);
163+ }
164164 }
165165 }
166- }
167- break ;
168-
169- case IProblem .UndefinedConstructor :
170- if (args .length == 2 ) {
171- String constructorName = args [0 ];
172- // For messages such as "contructor sketch_name.ClassXYZ() is undefined", change
173- // constructor name to "ClassXYZ()". See #3434
174- if (constructorName .contains ("." )) {
175- // arg[0] contains sketch name twice: sketch_150705a.sketch_150705a.Thing
176- constructorName = constructorName .substring (constructorName .indexOf ('.' ) + 1 );
177- constructorName = constructorName .substring (constructorName .indexOf ('.' ) + 1 );
166+ break ;
167+
168+ case IProblem .UndefinedConstructor :
169+ if (args .length == 2 ) {
170+ String constructorName = args [0 ];
171+ // For messages such as "contructor sketch_name.ClassXYZ() is undefined", change
172+ // constructor name to "ClassXYZ()". See #3434
173+ if (constructorName .contains ("." )) {
174+ // arg[0] contains sketch name twice: sketch_150705a.sketch_150705a.Thing
175+ constructorName = constructorName .substring (constructorName .indexOf ('.' ) + 1 );
176+ constructorName = constructorName .substring (constructorName .indexOf ('.' ) + 1 );
177+ }
178+ String constructorArgs = removePackagePrefixes (args [args .length - 1 ]);
179+ result = Language .interpolate ("editor.status.undefined_constructor" , constructorName , constructorArgs );
178180 }
179- String constructorArgs = removePackagePrefixes (args [args .length - 1 ]);
180- result = Language .interpolate ("editor.status.undefined_constructor" , constructorName , constructorArgs );
181- }
182- break ;
181+ break ;
183182
184- case IProblem .UndefinedMethod :
185- if (args .length > 2 ) {
186- String methodName = args [args .length - 2 ];
187- String methodArgs = removePackagePrefixes (args [args .length - 1 ]);
188- result = Language .interpolate ("editor.status.undefined_method" , methodName , methodArgs );
189- }
190- break ;
191-
192- case IProblem .ParameterMismatch :
193- if (args .length > 3 ) {
194- // 2nd arg is method name, 3rd arg is correct param list
195- if (args [2 ].trim ().length () == 0 ) {
196- // the case where no params are needed.
197- result = Language .interpolate ("editor.status.empty_param" , args [1 ]);
198-
199- } else {
200- result = Language .interpolate ("editor.status.wrong_param" ,
201- args [1 ], args [1 ], removePackagePrefixes (args [2 ]));
183+ case IProblem .UndefinedMethod :
184+ if (args .length > 2 ) {
185+ String methodName = args [args .length - 2 ];
186+ String methodArgs = removePackagePrefixes (args [args .length - 1 ]);
187+ result = Language .interpolate ("editor.status.undefined_method" , methodName , methodArgs );
188+ }
189+ break ;
190+
191+ case IProblem .ParameterMismatch :
192+ if (args .length > 3 ) {
193+ // 2nd arg is method name, 3rd arg is correct param list
194+ if (args [2 ].trim ().length () == 0 ) {
195+ // the case where no params are needed.
196+ result = Language .interpolate ("editor.status.empty_param" , args [1 ]);
197+
198+ } else {
199+ result = Language .interpolate ("editor.status.wrong_param" ,
200+ args [1 ], args [1 ], removePackagePrefixes (args [2 ]));
202201// String method = q(args[1]);
203202// String methodDef = " \"" + args[1] + "(" + getSimpleName(args[2]) + ")\"";
204203// result = result.replace("method", method);
205204// result += methodDef;
205+ }
206206 }
207- }
208- break ;
207+ break ;
209208
210- case IProblem .UndefinedField :
211- if (args .length > 0 ) {
212- result = Language .interpolate ("editor.status.undef_global_var" , args [0 ]);
213- }
214- break ;
209+ case IProblem .UndefinedField :
210+ if (args .length > 0 ) {
211+ result = Language .interpolate ("editor.status.undef_global_var" , args [0 ]);
212+ }
213+ break ;
215214
216- case IProblem .UndefinedType :
217- if (args .length > 0 ) {
218- result = Language .interpolate ("editor.status.undef_class" , args [0 ]);
219- }
220- break ;
215+ case IProblem .UndefinedType :
216+ if (args .length > 0 ) {
217+ result = Language .interpolate ("editor.status.undef_class" , args [0 ]);
218+ }
219+ break ;
221220
222- case IProblem .UnresolvedVariable :
223- if (args .length > 0 ) {
224- result = Language .interpolate ("editor.status.undef_var" , args [0 ]);
225- }
226- break ;
221+ case IProblem .UnresolvedVariable :
222+ if (args .length > 0 ) {
223+ result = Language .interpolate ("editor.status.undef_var" , args [0 ]);
224+ }
225+ break ;
227226
228- case IProblem .UndefinedName :
229- if (args .length > 0 ) {
230- result = Language .interpolate ("editor.status.undef_name" , args [0 ]);
231- }
232- break ;
227+ case IProblem .UndefinedName :
228+ if (args .length > 0 ) {
229+ result = Language .interpolate ("editor.status.undef_name" , args [0 ]);
230+ }
231+ break ;
233232
234- case IProblem .TypeMismatch :
235- if (args .length > 1 ) {
236- result = Language .interpolate ("editor.status.type_mismatch" , args [0 ], args [1 ]);
233+ case IProblem .TypeMismatch :
234+ if (args .length > 1 ) {
235+ result = Language .interpolate ("editor.status.type_mismatch" , args [0 ], args [1 ]);
237236// result = result.replace("typeA", q(args[0]));
238237// result = result.replace("typeB", q(args[1]));
239- }
240- break ;
238+ }
239+ break ;
241240
242- case IProblem .LocalVariableIsNeverUsed :
243- if (args .length > 0 ) {
244- result = Language .interpolate ("editor.status.unused_variable" , args [0 ]);
245- }
246- break ;
241+ case IProblem .LocalVariableIsNeverUsed :
242+ if (args .length > 0 ) {
243+ result = Language .interpolate ("editor.status.unused_variable" , args [0 ]);
244+ }
245+ break ;
247246
248- case IProblem .UninitializedLocalVariable :
249- if (args .length > 0 ) {
250- result = Language .interpolate ("editor.status.uninitialized_variable" , args [0 ]);
251- }
252- break ;
247+ case IProblem .UninitializedLocalVariable :
248+ if (args .length > 0 ) {
249+ result = Language .interpolate ("editor.status.uninitialized_variable" , args [0 ]);
250+ }
251+ break ;
253252
254- case IProblem .AssignmentHasNoEffect :
255- if (args .length > 0 ) {
256- result = Language .interpolate ("editor.status.no_effect_assignment" , args [0 ]);
257- }
258- break ;
253+ case IProblem .AssignmentHasNoEffect :
254+ if (args .length > 0 ) {
255+ result = Language .interpolate ("editor.status.no_effect_assignment" , args [0 ]);
256+ }
257+ break ;
259258
260- case IProblem .HidingEnclosingType :
261- if (args .length > 0 ) {
262- result = Language .interpolate ("editor.status.hiding_enclosing_type" , args [0 ]);
263- }
264- break ;
265-
266- default :
267- String message = iprob .getMessage ();
268- if (message != null ) {
269- // Remove all instances of token
270- // "Syntax error on token 'blah', delete this token"
271- Matcher matcher = tokenRegExp .matcher (message );
272- message = matcher .replaceAll ("" );
273- result = message ;
274- }
259+ case IProblem .HidingEnclosingType :
260+ if (args .length > 0 ) {
261+ result = Language .interpolate ("editor.status.hiding_enclosing_type" , args [0 ]);
262+ }
263+ break ;
264+
265+ default :
266+ String message = iprob .getMessage ();
267+ if (message != null ) {
268+ // Remove all instances of token
269+ // "Syntax error on token 'blah', delete this token"
270+ Matcher matcher = tokenRegExp .matcher (message );
271+ message = matcher .replaceAll ("" );
272+ result = message ;
273+ }
275274 }
276275
277276 if (DEBUG ) {
0 commit comments