@@ -85,7 +85,7 @@ public static String getIDName(int id) {
8585 /**
8686 * Tones down the jargon in the ecj reported errors.
8787 */
88- public static String getSimplifiedErrorMessage (IProblem iprob ) {
88+ public static String getSimplifiedErrorMessage (IProblem iprob , String badCode ) {
8989 if (iprob == null ) return null ;
9090
9191 String args [] = iprob .getArguments ();
@@ -97,6 +97,7 @@ public static String getSimplifiedErrorMessage(IProblem iprob) {
9797 for (String arg : args ) {
9898 Messages .log ("Arg " + arg );
9999 }
100+ Messages .log ("Bad code: " + badCode );
100101 }
101102
102103 String result = null ;
@@ -111,6 +112,15 @@ public static String getSimplifiedErrorMessage(IProblem iprob) {
111112
112113 case IProblem .ParsingErrorDeleteToken :
113114 if (args .length > 0 ) {
115+ if (args [0 ].equalsIgnoreCase ("Invalid Character" )) {
116+ result = getErrorMessageForCurlyQuote (badCode );
117+ }
118+ }
119+ break ;
120+
121+ case IProblem .ParsingErrorDeleteTokens :
122+ result = getErrorMessageForCurlyQuote (badCode );
123+ if (result == null ) {
114124 result = Language .interpolate ("editor.status.error_on" , args [0 ]);
115125 }
116126 break ;
@@ -136,13 +146,16 @@ public static String getSimplifiedErrorMessage(IProblem iprob) {
136146
137147 case IProblem .ParsingErrorInvalidToken :
138148 if (args .length > 0 ) {
139- if (args [1 ].equals ("VariableDeclaratorId " )) {
140- if (args [0 ].equals ("int " )) {
149+ if (args [0 ].equals ("int " )) {
150+ if (args [1 ].equals ("VariableDeclaratorId " )) {
141151 result = Language .text ("editor.status.reserved_words" );
142152 } else {
143153 result = Language .interpolate ("editor.status.error_on" , args [0 ]);
144154 }
145- } else {
155+ } else if (args [0 ].equalsIgnoreCase ("Invalid Character" )) {
156+ result = getErrorMessageForCurlyQuote (badCode );
157+ }
158+ if (result == null ) {
146159 result = Language .interpolate ("editor.status.error_on" , args [0 ]);
147160 }
148161 }
@@ -165,6 +178,9 @@ public static String getSimplifiedErrorMessage(IProblem iprob) {
165178 }
166179 break ;
167180
181+ case IProblem .ParsingErrorReplaceTokens :
182+ result = getErrorMessageForCurlyQuote (badCode );
183+
168184 case IProblem .UndefinedConstructor :
169185 if (args .length == 2 ) {
170186 String constructorName = args [0 ];
@@ -230,6 +246,13 @@ public static String getSimplifiedErrorMessage(IProblem iprob) {
230246 }
231247 break ;
232248
249+ case IProblem .UnterminatedString :
250+ if (badCode .contains ("“" ) || badCode .contains ("”" )) {
251+ result = Language .interpolate ("editor.status.unterm_string_curly" ,
252+ badCode .replaceAll ("[^“”]" , "" ));
253+ }
254+ break ;
255+
233256 case IProblem .TypeMismatch :
234257 if (args .length > 1 ) {
235258 result = Language .interpolate ("editor.status.type_mismatch" , args [0 ], args [1 ]);
@@ -261,16 +284,17 @@ public static String getSimplifiedErrorMessage(IProblem iprob) {
261284 result = Language .interpolate ("editor.status.hiding_enclosing_type" , args [0 ]);
262285 }
263286 break ;
287+ }
264288
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- }
289+ if ( result == null ) {
290+ String message = iprob .getMessage ();
291+ if (message != null ) {
292+ // Remove all instances of token
293+ // "Syntax error on token 'blah', delete this token"
294+ Matcher matcher = tokenRegExp .matcher (message );
295+ message = matcher .replaceAll ("" );
296+ result = message ;
297+ }
274298 }
275299
276300 if (DEBUG ) {
@@ -323,6 +347,20 @@ static private String getErrorMessageForBracket(char c) {
323347 }
324348
325349
350+ /**
351+ * @param badCode The code which may contain curly quotes
352+ * @return Friendly error message if there is a curly quote in badCode,
353+ * null otherwise.
354+ */
355+ static private String getErrorMessageForCurlyQuote (String badCode ) {
356+ if (badCode .contains ("‘" ) || badCode .contains ("’" ) ||
357+ badCode .contains ("“" ) || badCode .contains ("”" )) {
358+ return Language .interpolate ("editor.status.bad_curly_quote" ,
359+ badCode .replaceAll ("[^‘’“”]" , "" ));
360+ } else return null ;
361+ }
362+
363+
326364// static private final String q(Object quotable) {
327365// return "\"" + quotable + "\"";
328366// }
0 commit comments