Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipe Mulet2004-05-11 16:46:53 +0000
committerPhilipe Mulet2004-05-11 16:46:53 +0000
commit93b70485a331557e06c4f378f7086f6e4f12616a (patch)
tree2972e36d295c5b9016ea9b83fca1a5f8c0bcf9fc /org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal
parent368e7b2744bb4a520a4dfc9ab8183508aa7c626d (diff)
downloadeclipse.jdt.core-93b70485a331557e06c4f378f7086f6e4f12616a.tar.gz
eclipse.jdt.core-93b70485a331557e06c4f378f7086f6e4f12616a.tar.xz
eclipse.jdt.core-93b70485a331557e06c4f378f7086f6e4f12616a.zip
61706
Diffstat (limited to 'org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal')
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java50
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java7
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java12
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java8
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java12
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/Label.java6
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ReferenceContext.java3
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java126
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InvocationSite.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java449
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortCompilation.java46
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortCompilationUnit.java5
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortMethod.java5
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortType.java5
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblem.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java13
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java4
20 files changed, 401 insertions, 362 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 77a398a1e2..1b2745f4c5 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
@@ -721,7 +721,7 @@ public class ClassFile
MethodBinding methodBinding,
IProblem[] problems) {
if (methodBinding.isAbstract() && methodBinding.declaringClass.isInterface()) {
- method.abort(ProblemSeverities.AbortType);
+ method.abort(ProblemSeverities.AbortType, null);
}
// always clear the strictfp/native/abstract bit for a problem method
generateMethodInfoHeader(methodBinding, methodBinding.modifiers & ~(AccStrictfp | AccNative | AccAbstract));
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 9f49861a80..e3351041ce 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
@@ -405,9 +405,7 @@ public class Compiler implements ITypeRequestor, ProblemSeverities {
Error, // severity
0, // source start
0, // source end
- 0, // line number
- unit,
- result),
+ 0), // line number
unit);
/* hand back the compilation result */
@@ -453,23 +451,21 @@ public class Compiler implements ITypeRequestor, ProblemSeverities {
result = unitsToProcess[totalUnits - 1].compilationResult;
// last unit in beginToCompile ?
if (result != null && !result.hasBeenAccepted) {
- /* distant problem which could not be reported back there */
- if (abortException.problemId != 0) {
- result
- .record(
- problemReporter
- .createProblem(
- result.getFileName(),
- abortException.problemId,
- abortException.problemArguments,
- abortException.messageArguments,
- Error, // severity
- 0, // source start
- 0, // source end
- 0, // line number
- unit,
- result),
- unit);
+ /* distant problem which could not be reported back there? */
+ if (abortException.problem != null) {
+ recordDistantProblem: {
+ IProblem distantProblem = abortException.problem;
+ IProblem[] knownProblems = result.problems;
+ for (int i = 0; i < result.problemCount; i++) {
+ if (knownProblems[i] == distantProblem) { // already recorded
+ break recordDistantProblem;
+ }
+ }
+ if (distantProblem instanceof DefaultProblem) { // fixup filename TODO (philippe) should improve API to make this official
+ ((DefaultProblem) distantProblem).setOriginatingFileName(result.getFileName());
+ }
+ result .record(distantProblem, unit);
+ }
} else {
/* distant internal exception which could not be reported back there */
if (abortException.exception != null) {
@@ -482,20 +478,6 @@ public class Compiler implements ITypeRequestor, ProblemSeverities {
requestor.acceptResult(result.tagAsAccepted());
}
} else {
- /*
- if (abortException.problemId != 0){
- IProblem problem =
- problemReporter.createProblem(
- "???".toCharArray(),
- abortException.problemId,
- abortException.problemArguments,
- Error, // severity
- 0, // source start
- 0, // source end
- 0); // line number
- System.out.println(problem.getMessage());
- }
- */
abortException.printStackTrace();
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
index b3081c0ca2..74ba90b968 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
@@ -255,7 +255,12 @@ public abstract class ASTNode implements BaseTypes, CompilerModifiers, TypeConst
output.append("abstract "); //$NON-NLS-1$
return output;
}
-
+ public int sourceStart() {
+ return this.sourceStart;
+ }
+ public int sourceEnd() {
+ return this.sourceEnd;
+ }
public String toString() {
return print(0, new StringBuffer(30)).toString();
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java
index 673d28cf6f..04c2ca7d01 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java
@@ -55,17 +55,17 @@ public abstract class AbstractMethodDeclaration
/*
* We cause the compilation task to abort to a given extent.
*/
- public void abort(int abortLevel) {
+ public void abort(int abortLevel, IProblem problem) {
switch (abortLevel) {
case AbortCompilation :
- throw new AbortCompilation(this.compilationResult);
+ throw new AbortCompilation(this.compilationResult, problem);
case AbortCompilationUnit :
- throw new AbortCompilationUnit(this.compilationResult);
+ throw new AbortCompilationUnit(this.compilationResult, problem);
case AbortType :
- throw new AbortType(this.compilationResult);
+ throw new AbortType(this.compilationResult, problem);
default :
- throw new AbortMethod(this.compilationResult);
+ throw new AbortMethod(this.compilationResult, problem);
}
}
@@ -227,7 +227,7 @@ public abstract class AbstractMethodDeclaration
// if a problem got reported during code gen, then trigger problem method creation
if (this.ignoreFurtherInvestigation) {
- throw new AbortMethod(this.scope.referenceCompilationUnit().compilationResult);
+ throw new AbortMethod(this.scope.referenceCompilationUnit().compilationResult, null);
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java
index 396ba58a6a..ecfe767b9e 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java
@@ -391,6 +391,8 @@ public class CastExpression extends Expression {
public void setActualReceiverType(ReferenceBinding actualReceiverType) { /* ignore */}
public void setDepth(int depth) { /* ignore */}
public void setFieldIndex(int depth){ /* ignore */}
+ public int sourceStart() { return 0; }
+ public int sourceEnd() { return 0; }
};
MethodBinding bindingIfNoCast;
if (binding.isConstructor()) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java
index 80f2e49163..d736614978 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java
@@ -53,15 +53,15 @@ public class CompilationUnitDeclaration
/*
* We cause the compilation task to abort to a given extent.
*/
- public void abort(int abortLevel) {
+ public void abort(int abortLevel, IProblem problem) {
switch (abortLevel) {
case AbortType :
- throw new AbortType(this.compilationResult);
+ throw new AbortType(this.compilationResult, problem);
case AbortMethod :
- throw new AbortMethod(this.compilationResult);
+ throw new AbortMethod(this.compilationResult, problem);
default :
- throw new AbortCompilationUnit(this.compilationResult);
+ throw new AbortCompilationUnit(this.compilationResult, problem);
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java
index 84425fdcb7..7170bbf40d 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java
@@ -302,7 +302,7 @@ public class ConstructorDeclaration extends AbstractMethodDeclaration {
// if a problem got reported during code gen, then trigger problem method creation
if (ignoreFurtherInvestigation) {
- throw new AbortMethod(scope.referenceCompilationUnit().compilationResult);
+ throw new AbortMethod(scope.referenceCompilationUnit().compilationResult, null);
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java
index 164379b2cd..e8298207ba 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java
@@ -59,17 +59,17 @@ public class TypeDeclaration
/*
* We cause the compilation task to abort to a given extent.
*/
- public void abort(int abortLevel) {
+ public void abort(int abortLevel, IProblem problem) {
switch (abortLevel) {
case AbortCompilation :
- throw new AbortCompilation(this.compilationResult);
+ throw new AbortCompilation(this.compilationResult, problem);
case AbortCompilationUnit :
- throw new AbortCompilationUnit(this.compilationResult);
+ throw new AbortCompilationUnit(this.compilationResult, problem);
case AbortMethod :
- throw new AbortMethod(this.compilationResult);
+ throw new AbortMethod(this.compilationResult, problem);
default :
- throw new AbortType(this.compilationResult);
+ throw new AbortType(this.compilationResult, problem);
}
}
/**
@@ -557,7 +557,7 @@ public class TypeDeclaration
classFile.addSpecialMethods();
if (ignoreFurtherInvestigation) { // trigger problem type generation for code gen errors
- throw new AbortType(scope.referenceCompilationUnit().compilationResult);
+ throw new AbortType(scope.referenceCompilationUnit().compilationResult, null);
}
// finalize the compiled type result
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/Label.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/Label.java
index dfeda75554..8c29bcef2b 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/Label.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/Label.java
@@ -72,7 +72,7 @@ void branch() {
*/
int offset = position - codeStream.position + 1;
if (Math.abs(offset) > 0x7FFF && !this.codeStream.wideMode) {
- throw new AbortMethod(CodeStream.RESTART_IN_WIDE_MODE);
+ throw new AbortMethod(CodeStream.RESTART_IN_WIDE_MODE, null);
}
codeStream.writeSignedShort(offset);
}
@@ -193,7 +193,7 @@ public void place() { // Currently lacking wide support.
for (int i = 0; i < forwardReferenceCount; i++) {
int offset = position - forwardReferences[i] + 1;
if (Math.abs(offset) > 0x7FFF && !this.codeStream.wideMode) {
- throw new AbortMethod(CodeStream.RESTART_IN_WIDE_MODE);
+ throw new AbortMethod(CodeStream.RESTART_IN_WIDE_MODE, null);
}
if (this.codeStream.wideMode) {
if (this.isWide) {
@@ -224,7 +224,7 @@ public void place() { // Currently lacking wide support.
int forwardPosition = label.forwardReferences[j];
int offset = position - forwardPosition + 1;
if (Math.abs(offset) > 0x7FFF && !this.codeStream.wideMode) {
- throw new AbortMethod(CodeStream.RESTART_IN_WIDE_MODE);
+ throw new AbortMethod(CodeStream.RESTART_IN_WIDE_MODE, null);
}
if (this.codeStream.wideMode) {
if (this.isWide) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ReferenceContext.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ReferenceContext.java
index 3727698389..f645b0acf5 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ReferenceContext.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ReferenceContext.java
@@ -15,10 +15,11 @@ package org.eclipse.jdt.internal.compiler.impl;
* For example: method, type or compilation unit.
*/
+import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.compiler.CompilationResult;
public interface ReferenceContext {
- void abort(int abortLevel);
+ void abort(int abortLevel, IProblem problem);
CompilationResult compilationResult();
void tagAsHavingErrors();
boolean hasErrors();
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
index a9c72bce2c..ec38ec629a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
@@ -16,6 +16,7 @@ import org.eclipse.jdt.internal.compiler.ast.Clinit;
import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
+import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
@@ -797,72 +798,77 @@ public class ClassScope extends Scope {
}
private ReferenceBinding findSupertype(TypeReference typeReference) {
- typeReference.aboutToResolve(this); // allows us to trap completion & selection nodes
- char[][] compoundName = typeReference.getTypeName();
- compilationUnitScope().recordQualifiedReference(compoundName);
- SourceTypeBinding sourceType = referenceContext.binding;
- int size = compoundName.length;
- int n = 1;
- ReferenceBinding superType;
-
- // resolve the first name of the compoundName
- if (CharOperation.equals(compoundName[0], sourceType.sourceName)) {
- superType = sourceType;
- // match against the sourceType even though nested members cannot be supertypes
- } else {
- Binding typeOrPackage = parent.getTypeOrPackage(compoundName[0], TYPE | PACKAGE);
- if (typeOrPackage == null || !typeOrPackage.isValidBinding())
- return new ProblemReferenceBinding(
- compoundName[0],
- typeOrPackage == null ? NotFound : typeOrPackage.problemId());
-
- boolean checkVisibility = false;
- for (; n < size; n++) {
- if (!(typeOrPackage instanceof PackageBinding))
- break;
- PackageBinding packageBinding = (PackageBinding) typeOrPackage;
- typeOrPackage = packageBinding.getTypeOrPackage(compoundName[n]);
+ try {
+ typeReference.aboutToResolve(this); // allows us to trap completion & selection nodes
+ char[][] compoundName = typeReference.getTypeName();
+ compilationUnitScope().recordQualifiedReference(compoundName);
+ SourceTypeBinding sourceType = referenceContext.binding;
+ int size = compoundName.length;
+ int n = 1;
+ ReferenceBinding superType;
+
+ // resolve the first name of the compoundName
+ if (CharOperation.equals(compoundName[0], sourceType.sourceName)) {
+ superType = sourceType;
+ // match against the sourceType even though nested members cannot be supertypes
+ } else {
+ Binding typeOrPackage = parent.getTypeOrPackage(compoundName[0], TYPE | PACKAGE);
if (typeOrPackage == null || !typeOrPackage.isValidBinding())
return new ProblemReferenceBinding(
- CharOperation.subarray(compoundName, 0, n + 1),
+ compoundName[0],
typeOrPackage == null ? NotFound : typeOrPackage.problemId());
- checkVisibility = true;
- }
-
- // convert to a ReferenceBinding
- if (typeOrPackage instanceof PackageBinding) // error, the compoundName is a packageName
- return new ProblemReferenceBinding(CharOperation.subarray(compoundName, 0, n), NotFound);
- superType = (ReferenceBinding) typeOrPackage;
- compilationUnitScope().recordTypeReference(superType); // to record supertypes
-
- if (checkVisibility
- && n == size) { // if we're finished and know the final supertype then check visibility
- if (!superType.canBeSeenBy(sourceType.fPackage))
- // its a toplevel type so just check package access
- return new ProblemReferenceBinding(CharOperation.subarray(compoundName, 0, n), superType, NotVisible);
+
+ boolean checkVisibility = false;
+ for (; n < size; n++) {
+ if (!(typeOrPackage instanceof PackageBinding))
+ break;
+ PackageBinding packageBinding = (PackageBinding) typeOrPackage;
+ typeOrPackage = packageBinding.getTypeOrPackage(compoundName[n]);
+ if (typeOrPackage == null || !typeOrPackage.isValidBinding())
+ return new ProblemReferenceBinding(
+ CharOperation.subarray(compoundName, 0, n + 1),
+ typeOrPackage == null ? NotFound : typeOrPackage.problemId());
+ checkVisibility = true;
+ }
+
+ // convert to a ReferenceBinding
+ if (typeOrPackage instanceof PackageBinding) // error, the compoundName is a packageName
+ return new ProblemReferenceBinding(CharOperation.subarray(compoundName, 0, n), NotFound);
+ superType = (ReferenceBinding) typeOrPackage;
+ compilationUnitScope().recordTypeReference(superType); // to record supertypes
+
+ if (checkVisibility
+ && n == size) { // if we're finished and know the final supertype then check visibility
+ if (!superType.canBeSeenBy(sourceType.fPackage))
+ // its a toplevel type so just check package access
+ return new ProblemReferenceBinding(CharOperation.subarray(compoundName, 0, n), superType, NotVisible);
+ }
}
- }
- // at this point we know we have a type but we have to look for cycles
- while (true) {
- // must detect cycles & force connection up the hierarchy... also handle cycles with binary types.
- // must be guaranteed that the superType knows its entire hierarchy
- if (detectCycle(sourceType, superType, typeReference))
- return null; // cycle error was already reported
-
- if (n >= size)
- break;
-
- // retrieve the next member type
- char[] typeName = compoundName[n++];
- superType = findMemberType(typeName, superType);
- if (superType == null)
- return new ProblemReferenceBinding(CharOperation.subarray(compoundName, 0, n), NotFound);
- if (!superType.isValidBinding()) {
- superType.compoundName = CharOperation.subarray(compoundName, 0, n);
- return superType;
+ // at this point we know we have a type but we have to look for cycles
+ while (true) {
+ // must detect cycles & force connection up the hierarchy... also handle cycles with binary types.
+ // must be guaranteed that the superType knows its entire hierarchy
+ if (detectCycle(sourceType, superType, typeReference))
+ return null; // cycle error was already reported
+
+ if (n >= size)
+ break;
+
+ // retrieve the next member type
+ char[] typeName = compoundName[n++];
+ superType = findMemberType(typeName, superType);
+ if (superType == null)
+ return new ProblemReferenceBinding(CharOperation.subarray(compoundName, 0, n), NotFound);
+ if (!superType.isValidBinding()) {
+ superType.compoundName = CharOperation.subarray(compoundName, 0, n);
+ return superType;
+ }
}
+ return superType;
+ } catch (AbortCompilation e) {
+ e.updateContext(typeReference, referenceCompilationUnit().compilationResult);
+ throw e;
}
- return superType;
}
/* Answer the problem reporter to use for raising new problems.
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InvocationSite.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InvocationSite.java
index 777c3640eb..e9703baa93 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InvocationSite.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InvocationSite.java
@@ -21,4 +21,6 @@ public interface InvocationSite {
// but actual receiver type is pkg.Type)
// e.g2. in presence of implicit access to enclosing type
void setActualReceiverType(ReferenceBinding receiverType);
+ int sourceStart();
+ int sourceEnd();
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java
index bf4e425da3..11187e6bf4 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java
@@ -14,6 +14,7 @@ import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
+import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
import org.eclipse.jdt.internal.compiler.util.ObjectVector;
@@ -841,197 +842,208 @@ public abstract class Scope
* Limitations: cannot request FIELD independently of LOCAL, or vice versa
*/
public Binding getBinding(char[] name, int mask, InvocationSite invocationSite, boolean needResolve) {
-
- Binding binding = null;
- FieldBinding problemField = null;
- if ((mask & VARIABLE) != 0) {
- boolean insideStaticContext = false;
- boolean insideConstructorCall = false;
-
- FieldBinding foundField = null;
- // can be a problem field which is answered if a valid field is not found
- ProblemFieldBinding foundInsideProblem = null;
- // inside Constructor call or inside static context
- Scope scope = this;
- int depth = 0;
- int foundDepth = 0;
- ReferenceBinding foundActualReceiverType = null;
- done : while (true) { // done when a COMPILATION_UNIT_SCOPE is found
- switch (scope.kind) {
- case METHOD_SCOPE :
- MethodScope methodScope = (MethodScope) scope;
- insideStaticContext |= methodScope.isStatic;
- insideConstructorCall |= methodScope.isConstructorCall;
- // Fall through... could duplicate the code below to save a cast - questionable optimization
- case BLOCK_SCOPE :
- LocalVariableBinding variableBinding = scope.findVariable(name);
- // looks in this scope only
- if (variableBinding != null) {
- if (foundField != null && foundField.isValidBinding())
- return new ProblemFieldBinding(
- foundField.declaringClass,
- name,
- InheritedNameHidesEnclosingName);
- if (depth > 0)
- invocationSite.setDepth(depth);
- return variableBinding;
- }
- break;
- case CLASS_SCOPE :
- ClassScope classScope = (ClassScope) scope;
- SourceTypeBinding enclosingType = classScope.referenceContext.binding;
- FieldBinding fieldBinding =
- classScope.findField(enclosingType, name, invocationSite, needResolve);
- // Use next line instead if willing to enable protected access accross inner types
- // FieldBinding fieldBinding = findField(enclosingType, name, invocationSite);
- if (fieldBinding != null) { // skip it if we did not find anything
- if (fieldBinding.problemId() == Ambiguous) {
- if (foundField == null || foundField.problemId() == NotVisible)
- // supercedes any potential InheritedNameHidesEnclosingName problem
- return fieldBinding;
- // make the user qualify the field, likely wants the first inherited field (javac generates an ambiguous error instead)
- return new ProblemFieldBinding(
- fieldBinding.declaringClass,
- name,
- InheritedNameHidesEnclosingName);
- }
- ProblemFieldBinding insideProblem = null;
- if (fieldBinding.isValidBinding()) {
- if (!fieldBinding.isStatic()) {
- if (insideConstructorCall) {
- insideProblem =
- new ProblemFieldBinding(
- fieldBinding.declaringClass,
- name,
- NonStaticReferenceInConstructorInvocation);
- } else if (insideStaticContext) {
- insideProblem =
- new ProblemFieldBinding(
- fieldBinding.declaringClass,
- name,
- NonStaticReferenceInStaticContext);
- }
+ try {
+ Binding binding = null;
+ FieldBinding problemField = null;
+ if ((mask & VARIABLE) != 0) {
+ boolean insideStaticContext = false;
+ boolean insideConstructorCall = false;
+
+ FieldBinding foundField = null;
+ // can be a problem field which is answered if a valid field is not found
+ ProblemFieldBinding foundInsideProblem = null;
+ // inside Constructor call or inside static context
+ Scope scope = this;
+ int depth = 0;
+ int foundDepth = 0;
+ ReferenceBinding foundActualReceiverType = null;
+ done : while (true) { // done when a COMPILATION_UNIT_SCOPE is found
+ switch (scope.kind) {
+ case METHOD_SCOPE :
+ MethodScope methodScope = (MethodScope) scope;
+ insideStaticContext |= methodScope.isStatic;
+ insideConstructorCall |= methodScope.isConstructorCall;
+ // Fall through... could duplicate the code below to save a cast - questionable optimization
+ case BLOCK_SCOPE :
+ LocalVariableBinding variableBinding = scope.findVariable(name);
+ // looks in this scope only
+ if (variableBinding != null) {
+ if (foundField != null && foundField.isValidBinding())
+ return new ProblemFieldBinding(
+ foundField.declaringClass,
+ name,
+ InheritedNameHidesEnclosingName);
+ if (depth > 0)
+ invocationSite.setDepth(depth);
+ return variableBinding;
+ }
+ break;
+ case CLASS_SCOPE :
+ ClassScope classScope = (ClassScope) scope;
+ SourceTypeBinding enclosingType = classScope.referenceContext.binding;
+ FieldBinding fieldBinding =
+ classScope.findField(enclosingType, name, invocationSite, needResolve);
+ // Use next line instead if willing to enable protected access accross inner types
+ // FieldBinding fieldBinding = findField(enclosingType, name, invocationSite);
+ if (fieldBinding != null) { // skip it if we did not find anything
+ if (fieldBinding.problemId() == Ambiguous) {
+ if (foundField == null || foundField.problemId() == NotVisible)
+ // supercedes any potential InheritedNameHidesEnclosingName problem
+ return fieldBinding;
+ // make the user qualify the field, likely wants the first inherited field (javac generates an ambiguous error instead)
+ return new ProblemFieldBinding(
+ fieldBinding.declaringClass,
+ name,
+ InheritedNameHidesEnclosingName);
}
- if (enclosingType == fieldBinding.declaringClass
- || environment().options.complianceLevel >= ClassFileConstants.JDK1_4){
- // found a valid field in the 'immediate' scope (ie. not inherited)
- // OR in 1.4 mode (inherited shadows enclosing)
- if (foundField == null) {
- if (depth > 0){
- invocationSite.setDepth(depth);
- invocationSite.setActualReceiverType(enclosingType);
+
+ ProblemFieldBinding insideProblem = null;
+ if (fieldBinding.isValidBinding()) {
+ if (!fieldBinding.isStatic()) {
+ if (insideConstructorCall) {
+ insideProblem =
+ new ProblemFieldBinding(
+ fieldBinding.declaringClass,
+ name,
+ NonStaticReferenceInConstructorInvocation);
+ } else if (insideStaticContext) {
+ insideProblem =
+ new ProblemFieldBinding(
+ fieldBinding.declaringClass,
+ name,
+ NonStaticReferenceInStaticContext);
}
- // return the fieldBinding if it is not declared in a superclass of the scope's binding (that is, inherited)
- return insideProblem == null ? fieldBinding : insideProblem;
}
- if (foundField.isValidBinding())
- // if a valid field was found, complain when another is found in an 'immediate' enclosing type (that is, not inherited)
- if (foundField.declaringClass != fieldBinding.declaringClass)
- // ie. have we found the same field - do not trust field identity yet
- return new ProblemFieldBinding(
- fieldBinding.declaringClass,
- name,
- InheritedNameHidesEnclosingName);
+ if (enclosingType == fieldBinding.declaringClass
+ || environment().options.complianceLevel >= ClassFileConstants.JDK1_4){
+ // found a valid field in the 'immediate' scope (ie. not inherited)
+ // OR in 1.4 mode (inherited shadows enclosing)
+ if (foundField == null) {
+ if (depth > 0){
+ invocationSite.setDepth(depth);
+ invocationSite.setActualReceiverType(enclosingType);
+ }
+ // return the fieldBinding if it is not declared in a superclass of the scope's binding (that is, inherited)
+ return insideProblem == null ? fieldBinding : insideProblem;
+ }
+ if (foundField.isValidBinding())
+ // if a valid field was found, complain when another is found in an 'immediate' enclosing type (that is, not inherited)
+ if (foundField.declaringClass != fieldBinding.declaringClass)
+ // ie. have we found the same field - do not trust field identity yet
+ return new ProblemFieldBinding(
+ fieldBinding.declaringClass,
+ name,
+ InheritedNameHidesEnclosingName);
+ }
+ }
+
+ if (foundField == null
+ || (foundField.problemId() == NotVisible
+ && fieldBinding.problemId() != NotVisible)) {
+ // only remember the fieldBinding if its the first one found or the previous one was not visible & fieldBinding is...
+ foundDepth = depth;
+ foundActualReceiverType = enclosingType;
+ foundInsideProblem = insideProblem;
+ foundField = fieldBinding;
}
}
-
- if (foundField == null
- || (foundField.problemId() == NotVisible
- && fieldBinding.problemId() != NotVisible)) {
- // only remember the fieldBinding if its the first one found or the previous one was not visible & fieldBinding is...
- foundDepth = depth;
- foundActualReceiverType = enclosingType;
- foundInsideProblem = insideProblem;
- foundField = fieldBinding;
- }
- }
- depth++;
- insideStaticContext |= enclosingType.isStatic();
- // 1EX5I8Z - accessing outer fields within a constructor call is permitted
- // in order to do so, we change the flag as we exit from the type, not the method
- // itself, because the class scope is used to retrieve the fields.
- MethodScope enclosingMethodScope = scope.methodScope();
- insideConstructorCall =
- enclosingMethodScope == null ? false : enclosingMethodScope.isConstructorCall;
- break;
- case COMPILATION_UNIT_SCOPE :
- break done;
+ depth++;
+ insideStaticContext |= enclosingType.isStatic();
+ // 1EX5I8Z - accessing outer fields within a constructor call is permitted
+ // in order to do so, we change the flag as we exit from the type, not the method
+ // itself, because the class scope is used to retrieve the fields.
+ MethodScope enclosingMethodScope = scope.methodScope();
+ insideConstructorCall =
+ enclosingMethodScope == null ? false : enclosingMethodScope.isConstructorCall;
+ break;
+ case COMPILATION_UNIT_SCOPE :
+ break done;
+ }
+ scope = scope.parent;
}
- scope = scope.parent;
- }
-
- if (foundInsideProblem != null)
- return foundInsideProblem;
- if (foundField != null) {
- if (foundField.isValidBinding()){
- if (foundDepth > 0){
- invocationSite.setDepth(foundDepth);
- invocationSite.setActualReceiverType(foundActualReceiverType);
+
+ if (foundInsideProblem != null)
+ return foundInsideProblem;
+ if (foundField != null) {
+ if (foundField.isValidBinding()){
+ if (foundDepth > 0){
+ invocationSite.setDepth(foundDepth);
+ invocationSite.setActualReceiverType(foundActualReceiverType);
+ }
+ return foundField;
}
- return foundField;
+ problemField = foundField;
}
- problemField = foundField;
}
- }
+
+ // We did not find a local or instance variable.
+ if ((mask & TYPE) != 0) {
+ if ((binding = getBaseType(name)) != null)
+ return binding;
+ binding = getTypeOrPackage(name, (mask & PACKAGE) == 0 ? TYPE : TYPE | PACKAGE);
+ if (binding.isValidBinding() || mask == TYPE)
+ return binding;
+ // answer the problem type binding if we are only looking for a type
+ } else if ((mask & PACKAGE) != 0) {
+ compilationUnitScope().recordSimpleReference(name);
+ if ((binding = environment().getTopLevelPackage(name)) != null)
+ return binding;
+ }
+ if (problemField != null) return problemField;
+ return new ProblemBinding(name, enclosingSourceType(), NotFound);
- // We did not find a local or instance variable.
- if ((mask & TYPE) != 0) {
- if ((binding = getBaseType(name)) != null)
- return binding;
- binding = getTypeOrPackage(name, (mask & PACKAGE) == 0 ? TYPE : TYPE | PACKAGE);
- if (binding.isValidBinding() || mask == TYPE)
- return binding;
- // answer the problem type binding if we are only looking for a type
- } else if ((mask & PACKAGE) != 0) {
- compilationUnitScope().recordSimpleReference(name);
- if ((binding = environment().getTopLevelPackage(name)) != null)
- return binding;
+ } catch (AbortCompilation e) {
+ e.updateContext(invocationSite, referenceCompilationUnit().compilationResult);
+ throw e;
}
- if (problemField != null) return problemField;
- return new ProblemBinding(name, enclosingSourceType(), NotFound);
}
public MethodBinding getConstructor(ReferenceBinding receiverType, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
- compilationUnitScope().recordTypeReference(receiverType);
- compilationUnitScope().recordTypeReferences(argumentTypes);
- MethodBinding methodBinding = receiverType.getExactConstructor(argumentTypes);
- if (methodBinding != null && methodBinding.canBeSeenBy(invocationSite, this))
- return methodBinding;
- MethodBinding[] methods = receiverType.getMethods(ConstructorDeclaration.ConstantPoolName);
- if (methods == NoMethods)
- return new ProblemMethodBinding(
- ConstructorDeclaration.ConstantPoolName,
- argumentTypes,
- NotFound);
-
- MethodBinding[] compatible = new MethodBinding[methods.length];
- int compatibleIndex = 0;
- for (int i = 0, length = methods.length; i < length; i++)
- if (areParametersAssignable(methods[i].parameters, argumentTypes))
- compatible[compatibleIndex++] = methods[i];
- if (compatibleIndex == 0)
- return new ProblemMethodBinding(
- ConstructorDeclaration.ConstantPoolName,
- argumentTypes,
- NotFound);
- // need a more descriptive error... cannot convert from X to Y
-
- MethodBinding[] visible = new MethodBinding[compatibleIndex];
- int visibleIndex = 0;
- for (int i = 0; i < compatibleIndex; i++) {
- MethodBinding method = compatible[i];
- if (method.canBeSeenBy(invocationSite, this))
- visible[visibleIndex++] = method;
+ try {
+ compilationUnitScope().recordTypeReference(receiverType);
+ compilationUnitScope().recordTypeReferences(argumentTypes);
+ MethodBinding methodBinding = receiverType.getExactConstructor(argumentTypes);
+ if (methodBinding != null && methodBinding.canBeSeenBy(invocationSite, this))
+ return methodBinding;
+ MethodBinding[] methods = receiverType.getMethods(ConstructorDeclaration.ConstantPoolName);
+ if (methods == NoMethods)
+ return new ProblemMethodBinding(
+ ConstructorDeclaration.ConstantPoolName,
+ argumentTypes,
+ NotFound);
+
+ MethodBinding[] compatible = new MethodBinding[methods.length];
+ int compatibleIndex = 0;
+ for (int i = 0, length = methods.length; i < length; i++)
+ if (areParametersAssignable(methods[i].parameters, argumentTypes))
+ compatible[compatibleIndex++] = methods[i];
+ if (compatibleIndex == 0)
+ return new ProblemMethodBinding(
+ ConstructorDeclaration.ConstantPoolName,
+ argumentTypes,
+ NotFound);
+ // need a more descriptive error... cannot convert from X to Y
+
+ MethodBinding[] visible = new MethodBinding[compatibleIndex];
+ int visibleIndex = 0;
+ for (int i = 0; i < compatibleIndex; i++) {
+ MethodBinding method = compatible[i];
+ if (method.canBeSeenBy(invocationSite, this))
+ visible[visibleIndex++] = method;
+ }
+ if (visibleIndex == 1) return visible[0];
+ if (visibleIndex == 0)
+ return new ProblemMethodBinding(
+ compatible[0],
+ ConstructorDeclaration.ConstantPoolName,
+ compatible[0].parameters,
+ NotVisible);
+ return mostSpecificClassMethodBinding(visible, visibleIndex);
+ } catch (AbortCompilation e) {
+ e.updateContext(invocationSite, referenceCompilationUnit().compilationResult);
+ throw e;
}
- if (visibleIndex == 1) return visible[0];
- if (visibleIndex == 0)
- return new ProblemMethodBinding(
- compatible[0],
- ConstructorDeclaration.ConstantPoolName,
- compatible[0].parameters,
- NotVisible);
- return mostSpecificClassMethodBinding(visible, visibleIndex);
}
public final PackageBinding getCurrentPackage() {
@@ -1079,13 +1091,18 @@ public abstract class Scope
}
public FieldBinding getField(TypeBinding receiverType, char[] fieldName, InvocationSite invocationSite) {
- FieldBinding field = findField(receiverType, fieldName, invocationSite, true /*resolve*/);
- if (field != null) return field;
-
- return new ProblemFieldBinding(
- receiverType instanceof ReferenceBinding ? (ReferenceBinding) receiverType : null,
- fieldName,
- NotFound);
+ try {
+ FieldBinding field = findField(receiverType, fieldName, invocationSite, true /*resolve*/);
+ if (field != null) return field;
+
+ return new ProblemFieldBinding(
+ receiverType instanceof ReferenceBinding ? (ReferenceBinding) receiverType : null,
+ fieldName,
+ NotFound);
+ } catch (AbortCompilation e) {
+ e.updateContext(invocationSite, referenceCompilationUnit().compilationResult);
+ throw e;
+ }
}
public final ReferenceBinding getJavaIoSerializable() {
@@ -1177,38 +1194,44 @@ public abstract class Scope
}
public MethodBinding getMethod(TypeBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
- if (receiverType.isArrayType())
- return findMethodForArray((ArrayBinding) receiverType, selector, argumentTypes, invocationSite);
- if (receiverType.isBaseType())
- return new ProblemMethodBinding(selector, argumentTypes, NotFound);
-
- ReferenceBinding currentType = (ReferenceBinding) receiverType;
- if (!currentType.canBeSeenBy(this))
- return new ProblemMethodBinding(selector, argumentTypes, ReceiverTypeNotVisible);
-
- // retrieve an exact visible match (if possible)
- MethodBinding methodBinding = findExactMethod(currentType, selector, argumentTypes, invocationSite);
- if (methodBinding != null) return methodBinding;
-
- // answers closest approximation, may not check argumentTypes or visibility
- methodBinding = findMethod(currentType, selector, argumentTypes, invocationSite);
- if (methodBinding == null)
- return new ProblemMethodBinding(selector, argumentTypes, NotFound);
- if (methodBinding.isValidBinding()) {
- if (!areParametersAssignable(methodBinding.parameters, argumentTypes))
- return new ProblemMethodBinding(
- methodBinding,
- selector,
- argumentTypes,
- NotFound);
- if (!methodBinding.canBeSeenBy(currentType, invocationSite, this))
- return new ProblemMethodBinding(
- methodBinding,
- selector,
- methodBinding.parameters,
- NotVisible);
+ try {
+ if (receiverType.isArrayType())
+ return findMethodForArray((ArrayBinding) receiverType, selector, argumentTypes, invocationSite);
+ if (receiverType.isBaseType())
+ return new ProblemMethodBinding(selector, argumentTypes, NotFound);
+
+ ReferenceBinding currentType = (ReferenceBinding) receiverType;
+ if (!currentType.canBeSeenBy(this))
+ return new ProblemMethodBinding(selector, argumentTypes, ReceiverTypeNotVisible);
+
+ // retrieve an exact visible match (if possible)
+ MethodBinding methodBinding = findExactMethod(currentType, selector, argumentTypes, invocationSite);
+ if (methodBinding != null) return methodBinding;
+
+ // answers closest approximation, may not check argumentTypes or visibility
+ methodBinding = findMethod(currentType, selector, argumentTypes, invocationSite);
+ if (methodBinding == null)
+ return new ProblemMethodBinding(selector, argumentTypes, NotFound);
+ if (methodBinding.isValidBinding()) {
+ if (!areParametersAssignable(methodBinding.parameters, argumentTypes))
+ return new ProblemMethodBinding(
+ methodBinding,
+ selector,
+ argumentTypes,
+ NotFound);
+ if (!methodBinding.canBeSeenBy(currentType, invocationSite, this))
+ return new ProblemMethodBinding(
+ methodBinding,
+ selector,
+ methodBinding.parameters,
+ NotVisible);
+ }
+ return methodBinding;
+
+ } catch (AbortCompilation e) {
+ e.updateContext(invocationSite, referenceCompilationUnit().compilationResult);
+ throw e;
}
- return methodBinding;
}
/* Answer the type binding that corresponds the given name, starting the lookup in the receiver.
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortCompilation.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortCompilation.java
index cc1525bac4..a462f2346c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortCompilation.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortCompilation.java
@@ -10,7 +10,10 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.problem;
+import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.compiler.CompilationResult;
+import org.eclipse.jdt.internal.compiler.ast.ASTNode;
+import org.eclipse.jdt.internal.compiler.lookup.InvocationSite;
/*
* Special unchecked exception type used
@@ -22,38 +25,49 @@ public class AbortCompilation extends RuntimeException {
public CompilationResult compilationResult;
public Throwable exception;
- public int problemId;
- public String[] problemArguments, messageArguments;
+ public IProblem problem;
+
/* special fields used to abort silently (e.g. when cancelling build process) */
public boolean isSilent;
public RuntimeException silentException;
public AbortCompilation() {
-
- this(null);
+ // empty
}
- public AbortCompilation(int problemId, String[] problemArguments, String[] messageArguments) {
-
- this.problemId = problemId;
- this.problemArguments = problemArguments;
- this.messageArguments = messageArguments;
- }
-
- public AbortCompilation(CompilationResult compilationResult) {
-
- this(compilationResult, null);
+ public AbortCompilation(CompilationResult compilationResult, IProblem problem) {
+ this();
+ this.compilationResult = compilationResult;
+ this.problem = problem;
}
public AbortCompilation(CompilationResult compilationResult, Throwable exception) {
-
+ this();
this.compilationResult = compilationResult;
this.exception = exception;
}
public AbortCompilation(boolean isSilent, RuntimeException silentException) {
-
+ this();
this.isSilent = isSilent;
this.silentException = silentException;
}
+
+ public void updateContext(InvocationSite invocationSite, CompilationResult unitResult) {
+ if (this.problem == null) return;
+ if (this.problem.getSourceStart() != 0 || this.problem.getSourceEnd() != 0) return;
+ this.problem.setSourceStart(invocationSite.sourceStart());
+ this.problem.setSourceEnd(invocationSite.sourceEnd());
+ this.problem.setSourceLineNumber(ProblemHandler.searchLineNumber(unitResult.lineSeparatorPositions, invocationSite.sourceStart()));
+ this.compilationResult = unitResult;
+ }
+
+ public void updateContext(ASTNode astNode, CompilationResult unitResult) {
+ if (this.problem == null) return;
+ if (this.problem.getSourceStart() != 0 || this.problem.getSourceEnd() != 0) return;
+ this.problem.setSourceStart(astNode.sourceStart());
+ this.problem.setSourceEnd(astNode.sourceEnd());
+ this.problem.setSourceLineNumber(ProblemHandler.searchLineNumber(unitResult.lineSeparatorPositions, astNode.sourceStart()));
+ this.compilationResult = unitResult;
+ }
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortCompilationUnit.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortCompilationUnit.java
index 5e29b916dd..203807a1ff 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortCompilationUnit.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortCompilationUnit.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.problem;
+import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.compiler.CompilationResult;
/*
@@ -19,7 +20,7 @@ import org.eclipse.jdt.internal.compiler.CompilationResult;
* should only be thrown from within problem handlers.
*/
public class AbortCompilationUnit extends AbortCompilation {
-public AbortCompilationUnit(CompilationResult compilationResult) {
- super(compilationResult);
+public AbortCompilationUnit(CompilationResult compilationResult, IProblem problem) {
+ super(compilationResult, problem);
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortMethod.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortMethod.java
index dd9d11fefc..6728056dd7 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortMethod.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortMethod.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.problem;
+import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.compiler.CompilationResult;
/*
@@ -19,7 +20,7 @@ import org.eclipse.jdt.internal.compiler.CompilationResult;
* should only be thrown from within problem handlers.
*/
public class AbortMethod extends AbortType {
-public AbortMethod(CompilationResult compilationResult) {
- super(compilationResult);
+public AbortMethod(CompilationResult compilationResult, IProblem problem) {
+ super(compilationResult, problem);
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortType.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortType.java
index 78531d7123..99546e6197 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortType.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortType.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.problem;
+import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.compiler.CompilationResult;
/*
@@ -19,7 +20,7 @@ import org.eclipse.jdt.internal.compiler.CompilationResult;
* should only be thrown from within problem handlers.
*/
public class AbortType extends AbortCompilationUnit {
-public AbortType(CompilationResult compilationResult) {
- super(compilationResult);
+public AbortType(CompilationResult compilationResult, IProblem problem) {
+ super(compilationResult, problem);
}
}
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 b20a855391..8ec86190ec 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
@@ -177,6 +177,10 @@ public class DefaultProblem implements ProblemSeverities, IProblem {
return (this.severity & ProblemSeverities.Error) == 0;
}
+ public void setOriginatingFileName(char[] fileName) {
+ this.fileName = fileName;
+ }
+
/**
* Set the end position of the problem (inclusive), or -1 if unknown.
*
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java
index bf65671abe..5b334d2e66 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java
@@ -61,9 +61,7 @@ public IProblem createProblem(
int severity,
int problemStartPosition,
int problemEndPosition,
- int lineNumber,
- ReferenceContext referenceContext,
- CompilationResult unitResult) {
+ int lineNumber) {
return this.problemFactory.createProblem(
fileName,
@@ -91,7 +89,8 @@ public void handle(
// if no reference context, we need to abort from the current compilation process
if (referenceContext == null) {
if ((severity & Error) != 0) { // non reportable error is fatal
- throw new AbortCompilation(problemId, problemArguments, messageArguments);
+ IProblem problem = this.createProblem(null, problemId, problemArguments, messageArguments, severity, 0, 0, 0);
+ throw new AbortCompilation(null, problem);
} else {
return; // ignore non reportable warning
}
@@ -108,9 +107,7 @@ public void handle(
problemEndPosition,
problemStartPosition >= 0
? searchLineNumber(unitResult.lineSeparatorPositions, problemStartPosition)
- : 0,
- referenceContext,
- unitResult);
+ : 0);
if (problem == null) return; // problem couldn't be created, ignore
switch (severity & Error) {
@@ -123,7 +120,7 @@ public void handle(
if ((abortLevel =
(this.policy.stopOnFirstError() ? AbortCompilation : severity & Abort)) != 0) {
- referenceContext.abort(abortLevel);
+ referenceContext.abort(abortLevel, problem);
}
break;
case Warning :
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 5e685b9a5c..4d02e2c59a 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
@@ -2156,8 +2156,8 @@ public void isClassPathCorrect(char[][] wellKnownTypeName, CompilationUnitDeclar
arguments,
arguments,
AbortCompilation | Error,
- compUnitDecl == null ? 0 : compUnitDecl.sourceStart,
- compUnitDecl == null ? 1 : compUnitDecl.sourceEnd);
+ 0,
+ 0);
}
public void javadocDuplicatedReturnTag(int sourceStart, int sourceEnd){
this.handle(IProblem.JavadocDuplicateReturnTag, NoArgument, NoArgument, sourceStart, sourceEnd);

Back to the top