Lines 131-158
Link Here
|
131 |
return getLocalizedMessage(id, 0, problemArguments); |
131 |
return getLocalizedMessage(id, 0, problemArguments); |
132 |
} |
132 |
} |
133 |
public final String getLocalizedMessage(int id, int elaborationId, String[] problemArguments) { |
133 |
public final String getLocalizedMessage(int id, int elaborationId, String[] problemArguments) { |
134 |
String message = (String) this.messageTemplates.get(keyFromID(id & IProblem.IgnoreCategoriesMask)); |
134 |
char[] message = ((String) this.messageTemplates.get(keyFromID(id & IProblem.IgnoreCategoriesMask))).toCharArray(); |
135 |
if (message == null) { |
135 |
if (message == null) { |
136 |
return "Unable to retrieve the error message for problem id: " //$NON-NLS-1$ |
136 |
return "Unable to retrieve the error message for problem id: " //$NON-NLS-1$ |
137 |
+ (id & IProblem.IgnoreCategoriesMask) + ". Check compiler resources."; //$NON-NLS-1$ |
137 |
+ (id & IProblem.IgnoreCategoriesMask) + ". Check compiler resources."; //$NON-NLS-1$ |
138 |
} |
138 |
} |
139 |
if (elaborationId != 0) { |
139 |
if (elaborationId != 0) { |
140 |
String elaboration = (String) this.messageTemplates.get(keyFromID(elaborationId)); |
140 |
char[] elaboration = ((String) this.messageTemplates.get(keyFromID(elaborationId))).toCharArray(); |
141 |
if (elaboration == null) { |
141 |
if (elaboration == null) { |
142 |
return "Unable to retrieve the error message elaboration for elaboration id: " //$NON-NLS-1$ |
142 |
return "Unable to retrieve the error message elaboration for elaboration id: " //$NON-NLS-1$ |
143 |
+ elaborationId + ". Check compiler resources."; //$NON-NLS-1$ |
143 |
+ elaborationId + ". Check compiler resources."; //$NON-NLS-1$ |
144 |
} |
144 |
} |
145 |
// make the substitution. String.replaceAll(String,String) cannot be used since it is |
145 |
message = CharOperation.replace(message, FIRST_ARGUMENT, elaboration); |
146 |
// defined only in 1.4 |
|
|
147 |
message = new String(CharOperation.replace( |
148 |
message.toCharArray(), |
149 |
FIRST_ARGUMENT, |
150 |
elaboration.toCharArray())); |
151 |
} |
146 |
} |
152 |
|
147 |
|
153 |
// for compatibility with MessageFormat which eliminates double quotes in original message |
148 |
// for compatibility with MessageFormat which eliminates double quotes in original message |
154 |
char[] messageWithNoDoubleQuotes = |
149 |
char[] messageWithNoDoubleQuotes = |
155 |
CharOperation.replace(message.toCharArray(), DOUBLE_QUOTES, SINGLE_QUOTE); |
150 |
CharOperation.replace(message, DOUBLE_QUOTES, SINGLE_QUOTE); |
156 |
|
151 |
|
157 |
if (problemArguments == null) return new String(messageWithNoDoubleQuotes); |
152 |
if (problemArguments == null) return new String(messageWithNoDoubleQuotes); |
158 |
|
153 |
|
Lines 169-186
Link Here
|
169 |
if (output == null) output = new StringBuffer(length+problemArguments.length*20); |
164 |
if (output == null) output = new StringBuffer(length+problemArguments.length*20); |
170 |
output.append(messageWithNoDoubleQuotes, start, end - start); |
165 |
output.append(messageWithNoDoubleQuotes, start, end - start); |
171 |
if ((start = CharOperation.indexOf('}', messageWithNoDoubleQuotes, end + 1)) > -1) { |
166 |
if ((start = CharOperation.indexOf('}', messageWithNoDoubleQuotes, end + 1)) > -1) { |
172 |
int index = -1; |
|
|
173 |
String argId = new String(messageWithNoDoubleQuotes, end + 1, start - end - 1); |
174 |
try { |
167 |
try { |
175 |
index = Integer.parseInt(argId); |
168 |
output.append(problemArguments[CharOperation.parseInt(messageWithNoDoubleQuotes, end + 1, start - end - 1)]); |
176 |
output.append(problemArguments[index]); |
|
|
177 |
} catch (NumberFormatException nfe) { |
169 |
} catch (NumberFormatException nfe) { |
178 |
output.append(messageWithNoDoubleQuotes, end + 1, start - end); |
170 |
output.append(messageWithNoDoubleQuotes, end + 1, start - end); |
179 |
} catch (ArrayIndexOutOfBoundsException e) { |
171 |
} catch (ArrayIndexOutOfBoundsException e) { |
180 |
return "Cannot bind message for problem (id: " //$NON-NLS-1$ |
172 |
return "Cannot bind message for problem (id: " //$NON-NLS-1$ |
181 |
+ (id & IProblem.IgnoreCategoriesMask) |
173 |
+ (id & IProblem.IgnoreCategoriesMask) |
182 |
+ ") \"" //$NON-NLS-1$ |
174 |
+ ") \"" //$NON-NLS-1$ |
183 |
+ message |
175 |
+ new String(message) |
184 |
+ "\" with arguments: {" //$NON-NLS-1$ |
176 |
+ "\" with arguments: {" //$NON-NLS-1$ |
185 |
+ Util.toString(problemArguments) |
177 |
+ Util.toString(problemArguments) |
186 |
+"}"; //$NON-NLS-1$ |
178 |
+"}"; //$NON-NLS-1$ |