Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Thomann2005-04-11 15:37:37 +0000
committerOlivier Thomann2005-04-11 15:37:37 +0000
commit663ec6c2eb68be77ac5a9531885836701530934d (patch)
tree214243367b9bc6b9662561a3f7d368f24a54f9b5 /org.eclipse.jdt.core/compiler/org/eclipse
parent699f26e934e59aeb24a73287942d4b68645611a6 (diff)
downloadeclipse.jdt.core-663ec6c2eb68be77ac5a9531885836701530934d.tar.gz
eclipse.jdt.core-663ec6c2eb68be77ac5a9531885836701530934d.tar.xz
eclipse.jdt.core-663ec6c2eb68be77ac5a9531885836701530934d.zip
HEAD - Fix for 89096
Diffstat (limited to 'org.eclipse.jdt.core/compiler/org/eclipse')
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java34
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java61
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/Constant.java20
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java21
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblem.java5
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java12
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Messages.java244
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Util.java61
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/messages.properties70
10 files changed, 358 insertions, 174 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java
index 7eae099d87..168b33d989 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java
@@ -23,7 +23,7 @@ import org.eclipse.jdt.internal.compiler.impl.Constant;
import org.eclipse.jdt.internal.compiler.impl.StringConstant;
import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
-import org.eclipse.jdt.internal.compiler.util.Util;
+import org.eclipse.jdt.internal.compiler.util.Messages;
/**
* Represents a class file wrapper on bytes, it is aware of its actual
@@ -79,14 +79,14 @@ public class ClassFile
f = new File(outputPath);
if (f.exists()) {
if (!f.isDirectory()) {
- System.out.println(Util.bind("output.isFile", f.getAbsolutePath()));//$NON-NLS-1$
- throw new IOException(Util.bind("output.isFileNotDirectory"));//$NON-NLS-1$
+ System.out.println(Messages.bind(Messages.output_isFile, f.getAbsolutePath()));
+ throw new IOException(Messages.output_isFileNotDirectory);
}
} else {
// we have to create that directory
if (!f.mkdirs()) {
- System.out.println(Util.bind("output.dirName", f.getAbsolutePath()));//$NON-NLS-1$
- throw new IOException(Util.bind("output.notValidAll"));//$NON-NLS-1$
+ System.out.println(Messages.bind(Messages.output_dirName, f.getAbsolutePath()));
+ throw new IOException(Messages.output_notValidAll);
}
}
StringBuffer outDir = new StringBuffer(outputPath);
@@ -102,8 +102,8 @@ public class ClassFile
} else {
// Need to add the outDir
if (!f.mkdir()) {
- System.out.println(Util.bind("output.fileName", f.getName()));//$NON-NLS-1$
- throw new IOException(Util.bind("output.notValid"));//$NON-NLS-1$
+ System.out.println(Messages.bind(Messages.output_fileName, f.getName()));
+ throw new IOException(Messages.output_notValid);
}
}
token = tokenizer.nextToken();
@@ -933,7 +933,7 @@ public class ClassFile
generateCodeAttributeHeader();
StringBuffer buffer = new StringBuffer(25);
buffer.append("\t" + problem.getMessage() + "\n" ); //$NON-NLS-1$ //$NON-NLS-2$
- buffer.insert(0, Util.bind("compilation.unresolvedProblem"));//$NON-NLS-1$
+ buffer.insert(0, Messages.compilation_unresolvedProblem);
String problemString = buffer.toString();
codeStream.init(this);
@@ -987,9 +987,9 @@ public class ClassFile
}
} // insert the top line afterwards, once knowing how many problems we have to consider
if (count > 1) {
- buffer.insert(0, Util.bind("compilation.unresolvedProblems"));//$NON-NLS-1$
+ buffer.insert(0, Messages.compilation_unresolvedProblems);
} else {
- buffer.insert(0, Util.bind("compilation.unresolvedProblem"));//$NON-NLS-1$
+ buffer.insert(0, Messages.compilation_unresolvedProblem);
}
problemString = buffer.toString();
}
@@ -1049,9 +1049,9 @@ public class ClassFile
}
} // insert the top line afterwards, once knowing how many problems we have to consider
if (count > 1) {
- buffer.insert(0, Util.bind("compilation.unresolvedProblems"));//$NON-NLS-1$
+ buffer.insert(0, Messages.compilation_unresolvedProblems);
} else {
- buffer.insert(0, Util.bind("compilation.unresolvedProblem"));//$NON-NLS-1$
+ buffer.insert(0, Messages.compilation_unresolvedProblem);
}
problemString = buffer.toString();
}
@@ -1139,9 +1139,9 @@ public class ClassFile
}
} // insert the top line afterwards, once knowing how many problems we have to consider
if (count > 1) {
- buffer.insert(0, Util.bind("compilation.unresolvedProblems"));//$NON-NLS-1$
+ buffer.insert(0, Messages.compilation_unresolvedProblems);
} else {
- buffer.insert(0, Util.bind("compilation.unresolvedProblem"));//$NON-NLS-1$
+ buffer.insert(0, Messages.compilation_unresolvedProblem);
}
problemString = buffer.toString();
}
@@ -1658,7 +1658,7 @@ public class ClassFile
if (startPC != endPC) { // only entries for non zero length
if (endPC == -1) {
localVariable.declaringScope.problemReporter().abortDueToInternalError(
- Util.bind("abort.invalidAttribute" , new String(localVariable.name)), //$NON-NLS-1$
+ Messages.bind(Messages.abort_invalidAttribute, new String(localVariable.name)),
(ASTNode) localVariable.declaringScope.methodScope().referenceContext);
}
if (isParameterizedType) {
@@ -1950,7 +1950,7 @@ public class ClassFile
if (startPC != endPC) { // only entries for non zero length
if (endPC == -1) {
localVariable.declaringScope.problemReporter().abortDueToInternalError(
- Util.bind("abort.invalidAttribute", new String(localVariable.name)), //$NON-NLS-1$
+ Messages.bind(Messages.abort_invalidAttribute, new String(localVariable.name)),
(ASTNode) localVariable.declaringScope.methodScope().referenceContext);
}
if (localContentsOffset + 10 >= this.contents.length) {
@@ -2669,7 +2669,7 @@ public class ClassFile
if (startPC != endPC) { // only entries for non zero length
if (endPC == -1) {
localVariable.declaringScope.problemReporter().abortDueToInternalError(
- Util.bind("abort.invalidAttribute", new String(localVariable.name)), //$NON-NLS-1$
+ Messages.bind(Messages.abort_invalidAttribute, new String(localVariable.name)),
(ASTNode) localVariable.declaringScope.methodScope().referenceContext);
}
if (localContentsOffset + 10 > this.contents.length) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java
index f9a15fb8e5..6d9a508fbc 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java
@@ -183,10 +183,7 @@ public class Compiler implements ITypeRequestor, ProblemSeverities {
public void accept(IBinaryType binaryType, PackageBinding packageBinding, AccessRestriction accessRestriction) {
if (options.verbose) {
System.out.println(
- Util.bind("compilation.loadBinary", //$NON-NLS-1$
- new String[] {
- new String(binaryType.getName())
- }));
+ Messages.bind(Messages.compilation_loadBinary, new String(binaryType.getName())));
// new Exception("TRACE BINARY").printStackTrace(System.out);
// System.out.println();
}
@@ -205,12 +202,12 @@ public class Compiler implements ITypeRequestor, ProblemSeverities {
if (options.verbose) {
String count = String.valueOf(totalUnits + 1);
System.out.println(
- Util.bind("compilation.request", //$NON-NLS-1$
- new String[] {
- count,
- count,
- new String(sourceUnit.getFileName())
- }));
+ Messages.bind(Messages.compilation_request,
+ new String[] {
+ count,
+ count,
+ new String(sourceUnit.getFileName())
+ }));
}
// diet parsing for large collection of unit
CompilationUnitDeclaration parsedUnit;
@@ -241,7 +238,7 @@ public class Compiler implements ITypeRequestor, ProblemSeverities {
*/
public void accept(ISourceType[] sourceTypes, PackageBinding packageBinding, AccessRestriction accessRestriction) {
problemReporter.abortDueToInternalError(
- Util.bind("abort.againstSourceModel", String.valueOf(sourceTypes[0].getName()), String.valueOf(sourceTypes[0].getFileName()))); //$NON-NLS-1$
+ Messages.bind(Messages.abort_againstSourceModel, new String[] { String.valueOf(sourceTypes[0].getName()), String.valueOf(sourceTypes[0].getFileName()) }));
}
protected void addCompilationUnit(
@@ -278,12 +275,12 @@ public class Compiler implements ITypeRequestor, ProblemSeverities {
try {
if (options.verbose) {
System.out.println(
- Util.bind("compilation.request", //$NON-NLS-1$
- new String[] {
- String.valueOf(i + 1),
- String.valueOf(maxUnits),
- new String(sourceUnits[i].getFileName())
- }));
+ Messages.bind(Messages.compilation_request,
+ new String[] {
+ String.valueOf(i + 1),
+ String.valueOf(maxUnits),
+ new String(sourceUnits[i].getFileName())
+ }));
}
// diet parsing for large collection of units
if (totalUnits < parseThreshold) {
@@ -323,12 +320,12 @@ public class Compiler implements ITypeRequestor, ProblemSeverities {
try {
if (options.verbose)
System.out.println(
- Util.bind("compilation.process", //$NON-NLS-1$
- new String[] {
- String.valueOf(i + 1),
- String.valueOf(totalUnits),
- new String(unitsToProcess[i].getFileName())
- }));
+ Messages.bind(Messages.compilation_process,
+ new String[] {
+ String.valueOf(i + 1),
+ String.valueOf(totalUnits),
+ new String(unitsToProcess[i].getFileName())
+ }));
process(unit, i);
} finally {
// cleanup compilation unit result
@@ -338,12 +335,12 @@ public class Compiler implements ITypeRequestor, ProblemSeverities {
requestor.acceptResult(unit.compilationResult.tagAsAccepted());
if (options.verbose)
System.out.println(
- Util.bind("compilation.done", //$NON-NLS-1$
- new String[] {
- String.valueOf(i + 1),
- String.valueOf(totalUnits),
- new String(unit.getFileName())
- }));
+ Messages.bind(Messages.compilation_done,
+ new String[] {
+ String.valueOf(i + 1),
+ String.valueOf(totalUnits),
+ new String(unit.getFileName())
+ }));
}
} catch (AbortCompilation e) {
this.handleInternalException(e, unit);
@@ -359,10 +356,10 @@ public class Compiler implements ITypeRequestor, ProblemSeverities {
if (options.verbose) {
if (totalUnits > 1) {
System.out.println(
- Util.bind("compilation.units", String.valueOf(totalUnits))); //$NON-NLS-1$
+ Messages.bind(Messages.compilation_units, String.valueOf(totalUnits)));
} else {
System.out.println(
- Util.bind("compilation.unit", String.valueOf(totalUnits))); //$NON-NLS-1$
+ Messages.bind(Messages.compilation_unit, String.valueOf(totalUnits)));
}
}
}
@@ -391,7 +388,7 @@ public class Compiler implements ITypeRequestor, ProblemSeverities {
StringBuffer buffer = stringWriter.getBuffer();
String[] pbArguments = new String[] {
- Util.bind("compilation.internalError") //$NON-NLS-1$
+ Messages.compilation_internalError
+ "\n" //$NON-NLS-1$
+ buffer.toString()};
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java
index 09cf75e7cb..85fb5bc8dd 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java
@@ -19,7 +19,7 @@ import org.eclipse.jdt.internal.compiler.codegen.*;
import org.eclipse.jdt.internal.compiler.flow.*;
import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.problem.*;
-import org.eclipse.jdt.internal.compiler.util.Util;
+import org.eclipse.jdt.internal.compiler.util.Messages;
public abstract class Expression extends Statement {
@@ -577,7 +577,7 @@ public abstract class Expression extends Statement {
codeStream.recordPositionsFrom(pc, this.sourceStart);
} else {
// actual non-constant code generation
- throw new ShouldNotImplement(Util.bind("ast.missingCode")); //$NON-NLS-1$
+ throw new ShouldNotImplement(Messages.ast_missingCode);
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/Constant.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/Constant.java
index 22f4638200..fe5bb5a0b3 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/Constant.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/Constant.java
@@ -13,7 +13,7 @@ package org.eclipse.jdt.internal.compiler.impl;
import org.eclipse.jdt.internal.compiler.ast.OperatorIds;
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
import org.eclipse.jdt.internal.compiler.problem.ShouldNotImplement;
-import org.eclipse.jdt.internal.compiler.util.Util;
+import org.eclipse.jdt.internal.compiler.util.Messages;
public abstract class Constant implements TypeIds, OperatorIds {
@@ -25,12 +25,12 @@ public abstract class Constant implements TypeIds, OperatorIds {
public boolean booleanValue() {
- throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto", typeName(), "boolean")); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotCastedInto, new String[] { typeName(), "boolean" })); //$NON-NLS-1$
}
public byte byteValue() {
- throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto", typeName(), "byte")); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotCastedInto, new String[] { typeName(), "byte" })); //$NON-NLS-1$
}
public final Constant castTo(int conversionToTargetType){
@@ -205,7 +205,7 @@ public abstract class Constant implements TypeIds, OperatorIds {
public char charValue() {
- throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto", typeName(), "char")); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotCastedInto, new String[] { typeName(), "char" })); //$NON-NLS-1$
}
public static final Constant computeConstantOperation(Constant cst, int id, int operator) {
@@ -1514,12 +1514,12 @@ public abstract class Constant implements TypeIds, OperatorIds {
public double doubleValue() {
- throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto", typeName(), "double")); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotCastedInto, new String[] { typeName(), "double" })); //$NON-NLS-1$
}
public float floatValue() {
- throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto", typeName(), "float")); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotCastedInto, new String[] { typeName(), "float" })); //$NON-NLS-1$
}
public static Constant fromValue(byte value) {
@@ -1569,22 +1569,22 @@ public abstract class Constant implements TypeIds, OperatorIds {
public int intValue() {
- throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto", typeName(), "int")); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotCastedInto, new String[] { typeName(), "int" })); //$NON-NLS-1$
}
public long longValue() {
- throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto", typeName(), "long")); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotCastedInto, new String[] { typeName(), "long" })); //$NON-NLS-1$
}
public short shortValue() {
- throw new ShouldNotImplement(Util.bind("constant.cannotConvertedTo", typeName(), "short")); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotConvertedTo, new String[] { typeName(), "short" })); //$NON-NLS-1$
}
public String stringValue() {
- throw new ShouldNotImplement(Util.bind("constant.cannotConvertedTo", typeName(), "String")); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotConvertedTo, new String[] { typeName(), "String" })); //$NON-NLS-1$
}
public String toString(){
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
index 8bfc4da1c5..f98e28cc7a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
@@ -37,6 +37,7 @@ import org.eclipse.jdt.internal.compiler.parser.diagnose.DiagnoseParser;
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
+import org.eclipse.jdt.internal.compiler.util.Messages;
import org.eclipse.jdt.internal.compiler.util.Util;
public class Parser implements ParserBasicInformation, TerminalTokens, CompilerModifiers, OperatorIds, TypeIds {
@@ -429,7 +430,7 @@ public final static void buildFilesFromLPG(String dataFilename, String dataFilen
try {
contents = Util.getFileCharContent(new File(dataFilename), null);
} catch (IOException ex) {
- System.out.println(Util.bind("parser.incorrectPath")); //$NON-NLS-1$
+ System.out.println(Messages.parser_incorrectPath);
return;
}
java.util.StringTokenizer st =
@@ -470,7 +471,7 @@ public final static void buildFilesFromLPG(String dataFilename, String dataFilen
try {
contents = Util.getFileCharContent(new File(dataFilename2), null);
} catch (IOException ex) {
- System.out.println(Util.bind("parser.incorrectPath")); //$NON-NLS-1$
+ System.out.println(Messages.parser_incorrectPath);
return;
}
st = new java.util.StringTokenizer(new String(contents), "\t\n\r=#"); //$NON-NLS-1$
@@ -483,7 +484,7 @@ public final static void buildFilesFromLPG(String dataFilename, String dataFilen
buildFileForCompliance(prefix + (++i) + ".rsc", newRhs.length, tokens);//$NON-NLS-1$
buildFileForReadableName(READABLE_NAMES_FILE+".properties", newLhs, newNonTerminalIndex, newName, tokens);//$NON-NLS-1$
- System.out.println(Util.bind("parser.moveFiles")); //$NON-NLS-1$
+ System.out.println(Messages.parser_moveFiles);
}
public static int in_symbol(int state) {
return in_symb[original_state(state)];
@@ -541,7 +542,7 @@ protected static byte[] readByteTable(String filename) throws java.io.IOExceptio
InputStream stream = Parser.class.getResourceAsStream(filename);
if (stream == null) {
- throw new java.io.IOException(Util.bind("parser.missingFile", filename)); //$NON-NLS-1$
+ throw new java.io.IOException(Messages.bind(Messages.parser_missingFile, filename));
}
byte[] bytes = null;
try {
@@ -602,7 +603,7 @@ protected static char[] readTable(String filename) throws java.io.IOException {
InputStream stream = Parser.class.getResourceAsStream(filename);
if (stream == null) {
- throw new java.io.IOException(Util.bind("parser.missingFile", filename)); //$NON-NLS-1$
+ throw new java.io.IOException(Messages.bind(Messages.parser_missingFile, filename));
}
byte[] bytes = null;
try {
@@ -619,7 +620,7 @@ protected static char[] readTable(String filename) throws java.io.IOException {
//minimal integrity check (even size expected)
int length = bytes.length;
if (length % 2 != 0)
- throw new java.io.IOException(Util.bind("parser.corruptedFile", filename)); //$NON-NLS-1$
+ throw new java.io.IOException(Messages.bind(Messages.parser_corruptedFile, filename));
// convert bytes into chars
char[] chars = new char[length / 2];
@@ -639,7 +640,7 @@ protected static long[] readLongTable(String filename) throws java.io.IOExceptio
InputStream stream = Parser.class.getResourceAsStream(filename);
if (stream == null) {
- throw new java.io.IOException(Util.bind("parser.missingFile", filename)); //$NON-NLS-1$
+ throw new java.io.IOException(Messages.bind(Messages.parser_missingFile, filename));
}
byte[] bytes = null;
try {
@@ -656,7 +657,7 @@ protected static long[] readLongTable(String filename) throws java.io.IOExceptio
//minimal integrity check (even size expected)
int length = bytes.length;
if (length % 8 != 0)
- throw new java.io.IOException(Util.bind("parser.corruptedFile", filename)); //$NON-NLS-1$
+ throw new java.io.IOException(Messages.bind(Messages.parser_corruptedFile, filename));
// convert bytes into longs
long[] longs = new long[length / 8];
@@ -7543,14 +7544,14 @@ protected CompilationUnitDeclaration endParse(int act) {
if (this.currentElement != null){
this.currentElement.topElement().updateParseTree();
if (VERBOSE_RECOVERY){
- System.out.print(Util.bind("parser.syntaxRecovery")); //$NON-NLS-1$
+ System.out.print(Messages.parser_syntaxRecovery);
System.out.println("--------------------------"); //$NON-NLS-1$
System.out.println(this.compilationUnit);
System.out.println("----------------------------------"); //$NON-NLS-1$
}
} else {
if (this.diet & VERBOSE_RECOVERY){
- System.out.print(Util.bind("parser.regularParse")); //$NON-NLS-1$
+ System.out.print(Messages.parser_regularParse);
System.out.println("--------------------------"); //$NON-NLS-1$
System.out.println(this.compilationUnit);
System.out.println("----------------------------------"); //$NON-NLS-1$
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblem.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblem.java
index 75a60bc94b..81efea4258 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblem.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblem.java
@@ -11,6 +11,7 @@
package org.eclipse.jdt.internal.compiler.problem;
import org.eclipse.jdt.core.compiler.IProblem;
+import org.eclipse.jdt.internal.compiler.util.Messages;
import org.eclipse.jdt.internal.compiler.util.Util;
public class DefaultProblem implements ProblemSeverities, IProblem {
@@ -51,10 +52,10 @@ public class DefaultProblem implements ProblemSeverities, IProblem {
//sanity .....
if ((this.startPosition > this.endPosition)
|| ((this.startPosition < 0) && (this.endPosition < 0)))
- return Util.bind("problem.noSourceInformation"); //$NON-NLS-1$
+ return Messages.problem_noSourceInformation;
StringBuffer errorBuffer = new StringBuffer(" "); //$NON-NLS-1$
- errorBuffer.append(Util.bind("problem.atLine", String.valueOf(this.line))); //$NON-NLS-1$
+ errorBuffer.append(Messages.bind(Messages.problem_atLine, String.valueOf(this.line)));
errorBuffer.append(Util.LINE_SEPARATOR).append("\t"); //$NON-NLS-1$
char c;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
index 60cb54dc45..e3129b1040 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
@@ -21,7 +21,7 @@ import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.parser.*;
-import org.eclipse.jdt.internal.compiler.util.Util;
+import org.eclipse.jdt.internal.compiler.util.Messages;
public class ProblemReporter extends ProblemHandler implements ProblemReasons {
@@ -3945,7 +3945,7 @@ public void nativeMethodsCannotBeStrictfp(ReferenceBinding type, AbstractMethodD
methodDecl.sourceEnd);
}
public void needImplementation() {
- this.abortDueToInternalError(Util.bind("abort.missingCode")); //$NON-NLS-1$
+ this.abortDueToInternalError(Messages.abort_missingCode);
}
public void needToEmulateFieldAccess(FieldBinding field, ASTNode location, boolean isReadAccess) {
this.handle(
@@ -4563,13 +4563,13 @@ public void parseErrorUnexpectedEnd(
String[] arguments;
if(this.referenceContext instanceof ConstructorDeclaration) {
- arguments = new String[] {Util.bind("parser.endOfConstructor")}; //$NON-NLS-1$
+ arguments = new String[] {Messages.parser_endOfConstructor};
} else if(this.referenceContext instanceof MethodDeclaration) {
- arguments = new String[] {Util.bind("parser.endOfMethod")}; //$NON-NLS-1$
+ arguments = new String[] {Messages.parser_endOfMethod};
} else if(this.referenceContext instanceof TypeDeclaration) {
- arguments = new String[] {Util.bind("parser.endOfInitializer")}; //$NON-NLS-1$
+ arguments = new String[] {Messages.parser_endOfInitializer};
} else {
- arguments = new String[] {Util.bind("parser.endOfFile")}; //$NON-NLS-1$
+ arguments = new String[] {Messages.parser_endOfFile};
}
this.handle(
IProblem.ParsingErrorUnexpectedEOF,
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Messages.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Messages.java
new file mode 100644
index 0000000000..67c23f7a5c
--- /dev/null
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Messages.java
@@ -0,0 +1,244 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.compiler.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Properties;
+
+public final class Messages {
+ private static class MessagesProperties extends Properties {
+
+ private static final int MOD_EXPECTED = Modifier.PUBLIC | Modifier.STATIC;
+ private static final int MOD_MASK = MOD_EXPECTED | Modifier.FINAL;
+ private static final long serialVersionUID = 1L;
+
+ private final Map fields;
+
+ public MessagesProperties(Field[] fieldArray, String bundleName) {
+ super();
+ final int len = fieldArray.length;
+ fields = new HashMap(len * 2);
+ for (int i = 0; i < len; i++) {
+ fields.put(fieldArray[i].getName(), fieldArray[i]);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Hashtable#put(java.lang.Object, java.lang.Object)
+ */
+ public synchronized Object put(Object key, Object value) {
+ try {
+ Field field = (Field) fields.get(key);
+ if (field == null) {
+ return null;
+ }
+ //can only set value of public static non-final fields
+ if ((field.getModifiers() & MOD_MASK) != MOD_EXPECTED)
+ return null;
+ // Set the value into the field. We should never get an exception here because
+ // we know we have a public static non-final field. If we do get an exception, silently
+ // log it and continue. This means that the field will (most likely) be un-initialized and
+ // will fail later in the code and if so then we will see both the NPE and this error.
+ try {
+ field.set(null, value);
+ } catch (Exception e) {
+ // ignore
+ }
+ } catch (SecurityException e) {
+ // ignore
+ }
+ return null;
+ }
+ }
+
+
+ private static String[] nlSuffixes;
+ private static final String EXTENSION = ".properties"; //$NON-NLS-1$
+
+ private static final String BUNDLE_NAME = "org.eclipse.jdt.internal.compiler.util.messages";//$NON-NLS-1$
+
+ private Messages() {
+ // Do not instantiate
+ }
+
+ public static String compilation_unresolvedProblem;
+ public static String compilation_unresolvedProblems;
+ public static String compilation_request;
+ public static String compilation_loadBinary;
+ public static String compilation_process;
+ public static String compilation_write;
+ public static String compilation_done;
+ public static String compilation_units;
+ public static String compilation_unit;
+ public static String compilation_internalError;
+ public static String output_isFile;
+ public static String output_isFileNotDirectory;
+ public static String output_dirName;
+ public static String output_notValidAll;
+ public static String output_fileName;
+ public static String output_notValid;
+ public static String problem_noSourceInformation;
+ public static String problem_atLine;
+ public static String abort_invalidAttribute;
+ public static String abort_missingCode;
+ public static String abort_againstSourceModel;
+ public static String accept_cannot;
+ public static String parser_incorrectPath;
+ public static String parser_moveFiles;
+ public static String parser_syntaxRecovery;
+ public static String parser_regularParse;
+ public static String parser_missingFile;
+ public static String parser_corruptedFile;
+ public static String parser_endOfFile;
+ public static String parser_endOfConstructor;
+ public static String parser_endOfMethod;
+ public static String parser_endOfInitializer;
+ public static String ast_missingCode;
+ public static String constant_cannotCastedInto;
+ public static String constant_cannotConvertedTo;
+
+ static {
+ initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ /**
+ * Bind the given message's substitution locations with the given string values.
+ *
+ * @param message the message to be manipulated
+ * @return the manipulated String
+ */
+ public static String bind(String message) {
+ return bind(message, null);
+ }
+
+ /**
+ * Bind the given message's substitution locations with the given string values.
+ *
+ * @param message the message to be manipulated
+ * @param binding the object to be inserted into the message
+ * @return the manipulated String
+ */
+ public static String bind(String message, Object binding) {
+ return bind(message, new Object[] {binding});
+ }
+
+ /**
+ * Bind the given message's substitution locations with the given string values.
+ *
+ * @param message the message to be manipulated
+ * @param binding1 An object to be inserted into the message
+ * @param binding2 A second object to be inserted into the message
+ * @return the manipulated String
+ */
+ public static String bind(String message, Object binding1, Object binding2) {
+ return bind(message, new Object[] {binding1, binding2});
+ }
+
+ /**
+ * Bind the given message's substitution locations with the given string values.
+ *
+ * @param message the message to be manipulated
+ * @param bindings An array of objects to be inserted into the message
+ * @return the manipulated String
+ */
+ public static String bind(String message, Object[] bindings) {
+ return MessageFormat.format(message, bindings);
+ }
+
+ /*
+ * Build an array of directories to search
+ */
+ private static String[] buildVariants(String root) {
+ if (nlSuffixes == null) {
+ //build list of suffixes for loading resource bundles
+ String nl = Locale.getDefault().toString();
+ ArrayList result = new ArrayList(4);
+ int lastSeparator;
+ while (true) {
+ result.add('_' + nl + EXTENSION);
+ lastSeparator = nl.lastIndexOf('_');
+ if (lastSeparator == -1)
+ break;
+ nl = nl.substring(0, lastSeparator);
+ }
+ //add the empty suffix last (most general)
+ result.add(EXTENSION);
+ nlSuffixes = (String[]) result.toArray(new String[result.size()]);
+ }
+ root = root.replace('.', '/');
+ String[] variants = new String[nlSuffixes.length];
+ for (int i = 0; i < variants.length; i++)
+ variants[i] = root + nlSuffixes[i];
+ return variants;
+ }
+ public static void initializeMessages(String bundleName, Class clazz) {
+ // load the resource bundle and set the fields
+ final Field[] fields = clazz.getDeclaredFields();
+ load(bundleName, clazz.getClassLoader(), fields);
+
+ // iterate over the fields in the class to make sure that there aren't any empty ones
+ final int MOD_EXPECTED = Modifier.PUBLIC | Modifier.STATIC;
+ final int MOD_MASK = MOD_EXPECTED | Modifier.FINAL;
+ final int numFields = fields.length;
+ for (int i = 0; i < numFields; i++) {
+ Field field = fields[i];
+ if ((field.getModifiers() & MOD_MASK) != MOD_EXPECTED)
+ continue;
+ try {
+ // Set the value into the field if its empty. We should never get an exception here because
+ // we know we have a public static non-final field. If we do get an exception, silently
+ // log it and continue. This means that the field will (most likely) be un-initialized and
+ // will fail later in the code and if so then we will see both the NPE and this error.
+ if (field.get(clazz) == null) {
+ String value = "Missing message: " + field.getName() + " in: " + bundleName; //$NON-NLS-1$ //$NON-NLS-2$
+ field.set(null, value);
+ }
+ } catch (IllegalArgumentException e) {
+ // ignore
+ } catch (IllegalAccessException e) {
+ // ignore
+ }
+ }
+ }
+ /**
+ * Load the given resource bundle using the specified class loader.
+ */
+ public static void load(final String bundleName, final ClassLoader loader, final Field[] fields) {
+ final String[] variants = buildVariants(bundleName);
+ // search the dirs in reverse order so the cascading defaults is set correctly
+ for (int i = variants.length; --i >= 0;) {
+ final InputStream input = loader.getResourceAsStream(variants[i]);
+ if (input == null)
+ continue;
+ try {
+ final MessagesProperties properties = new MessagesProperties(fields, bundleName);
+ properties.load(input);
+ } catch (IOException e) {
+ // ignore
+ } finally {
+ if (input != null)
+ try {
+ input.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Util.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Util.java
index 3feab799f4..63cb886f1c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Util.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Util.java
@@ -17,10 +17,6 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.text.MessageFormat;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import org.eclipse.jdt.core.compiler.CharOperation;
@@ -30,57 +26,12 @@ public class Util implements SuffixConstants {
public interface Displayable {
String displayString(Object o);
}
- static {
- relocalize();
- }
- /* Bundle containing messages */
- protected static ResourceBundle bundle;
- private final static String bundleName =
- "org.eclipse.jdt.internal.compiler.util.messages"; //$NON-NLS-1$
private static final int DEFAULT_READING_SIZE = 8192;
-
public static String LINE_SEPARATOR = System.getProperty("line.separator"); //$NON-NLS-1$
public static char[] LINE_SEPARATOR_CHARS = LINE_SEPARATOR.toCharArray();
/**
- * Lookup the message with the given ID in this catalog
- */
- public static String bind(String id) {
- return bind(id, (String[]) null);
- }
- /**
- * Lookup the message with the given ID in this catalog and bind its
- * substitution locations with the given string.
- */
- public static String bind(String id, String argument) {
- return bind(id, new String[] { argument });
- }
- /**
- * Lookup the message with the given ID in this catalog and bind its
- * substitution locations with the given strings.
- */
- public static String bind(String id, String argument1, String argument2) {
- return bind(id, new String[] { argument1, argument2 });
- }
- /**
- * Lookup the message with the given ID in this catalog and bind its
- * substitution locations with the given string values.
- */
- public static String bind(String id, String[] arguments) {
- if (id == null)
- return "No message available"; //$NON-NLS-1$
- String message = null;
- try {
- message = bundle.getString(id);
- } catch (MissingResourceException e) {
- // If we got an exception looking for the message, fail gracefully by just returning
- // the id we were looking for. In most cases this is semi-informative so is not too bad.
- return "Missing message: " + id + " in: " + bundleName; //$NON-NLS-2$ //$NON-NLS-1$
- }
- return MessageFormat.format(message, arguments);
- }
- /**
* Returns the given bytes as a char array using a given encoding (null means platform default).
*/
public static char[] bytesToChar(byte[] bytes, String encoding) throws IOException {
@@ -333,6 +284,7 @@ public class Util implements SuffixConstants {
}
}
}
+
/**
* Returns true iff str.toLowerCase().endsWith(".jar") || str.toLowerCase().endsWith(".zip")
* implementation is not creating extra strings.
@@ -466,17 +418,6 @@ public class Util implements SuffixConstants {
}
return true;
}
- /**
- * Creates a NLS catalog for the given locale.
- */
- public static void relocalize() {
- try {
- bundle = ResourceBundle.getBundle(bundleName, Locale.getDefault());
- } catch(MissingResourceException e) {
- System.out.println("Missing resource : " + bundleName.replace('.', '/') + ".properties for locale " + Locale.getDefault()); //$NON-NLS-1$//$NON-NLS-2$
- throw e;
- }
- }
/**
* Converts a boolean value into Boolean.
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/messages.properties b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/messages.properties
index 39949afd64..602ec2c00d 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/messages.properties
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/messages.properties
@@ -11,52 +11,52 @@
### Eclipse Java Core Compiler messages.
### compilation
-compilation.unresolvedProblem = Unresolved compilation problem: \n
-compilation.unresolvedProblems = Unresolved compilation problems: \n
-compilation.request = [parsing {2} - #{0}/{1}]
-compilation.loadBinary = [reading {0}.class]
-compilation.process = [analyzing {2} - #{0}/{1}]
-compilation.write = [writing {1} - #{0}]
-compilation.done = [completed {2} - #{0}/{1}]
-compilation.units = [{0} units compiled]
-compilation.unit = [{0} unit compiled]
-compilation.internalError = Internal compiler error
+compilation_unresolvedProblem = Unresolved compilation problem: \n
+compilation_unresolvedProblems = Unresolved compilation problems: \n
+compilation_request = [parsing {2} - #{0}/{1}]
+compilation_loadBinary = [reading {0}.class]
+compilation_process = [analyzing {2} - #{0}/{1}]
+compilation_write = [writing {1} - #{0}]
+compilation_done = [completed {2} - #{0}/{1}]
+compilation_units = [{0} units compiled]
+compilation_unit = [{0} unit compiled]
+compilation_internalError = Internal compiler error
### output
-output.isFile = The outDir is a file : {0}
-output.isFileNotDirectory = The outDir is a file not a directory.
-output.dirName = The output dir name is : {0}
-output.notValidAll = The outDir is not a valid directory name. All the directories cannot be created.
-output.fileName = file name : {0}
-output.notValid = The outDir is not a valid directory name. The directory cannot be created.
+output_isFile = The outDir is a file : {0}
+output_isFileNotDirectory = The outDir is a file not a directory.
+output_dirName = The output dir name is : {0}
+output_notValidAll = The outDir is not a valid directory name. All the directories cannot be created.
+output_fileName = file name : {0}
+output_notValid = The outDir is not a valid directory name. The directory cannot be created.
### problem
-problem.noSourceInformation = \n!! no source information available !!
-problem.atLine = (at line {0})
+problem_noSourceInformation = \n!! no source information available !!
+problem_atLine = (at line {0})
### abort
-abort.invalidAttribute = SANITY CHECK: Invalid attribute for local variable {0}
-abort.missingCode = Missing code implementation in the compiler
-abort.againstSourceModel = Cannot compile against source model {0} issued from {1}
+abort_invalidAttribute = SANITY CHECK: Invalid attribute for local variable {0}
+abort_missingCode = Missing code implementation in the compiler
+abort_againstSourceModel = Cannot compile against source model {0} issued from {1}
### accept
-accept.cannot = Cannot accept the compilation unit:
+accept_cannot = Cannot accept the compilation unit:
### parser
-parser.incorrectPath = The path for the javadcl.java file is incorrect
-parser.moveFiles = MOVE FILES IN THE Runtime DIRECTORY OF Parser.class
-parser.syntaxRecovery = SYNTAX RECOVERY
-parser.regularParse = REGULAR PARSE
-parser.missingFile = missing file {0}
-parser.corruptedFile = corrupted file {0}
-parser.endOfFile = end of file
-parser.endOfConstructor = end of constructor
-parser.endOfMethod = end of method
-parser.endOfInitializer = end of initializer
+parser_incorrectPath = The path for the javadcl.java file is incorrect
+parser_moveFiles = MOVE FILES IN THE Runtime DIRECTORY OF Parser.class
+parser_syntaxRecovery = SYNTAX RECOVERY
+parser_regularParse = REGULAR PARSE
+parser_missingFile = missing file {0}
+parser_corruptedFile = corrupted file {0}
+parser_endOfFile = end of file
+parser_endOfConstructor = end of constructor
+parser_endOfMethod = end of method
+parser_endOfInitializer = end of initializer
### ast
-ast.missingCode = Missing code gen implementation
+ast_missingCode = Missing code gen implementation
### constant
-constant.cannotCastedInto = {0} constant cannot be casted into {1}
-constant.cannotConvertedTo = {0} constant cannot be converted to {1}
+constant_cannotCastedInto = {0} constant cannot be casted into {1}
+constant_cannotConvertedTo = {0} constant cannot be converted to {1}

Back to the top