### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java,v retrieving revision 1.72 diff -u -r1.72 LookupEnvironment.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java 11 May 2006 10:14:34 -0000 1.72 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java 20 Oct 2006 10:11:58 -0000 @@ -83,7 +83,6 @@ this.uniqueWildcardBindings = new SimpleLookupTable(3); this.uniqueParameterizedGenericMethodBindings = new SimpleLookupTable(3); this.accessRestrictions = new HashMap(3); - this.classFilePool = ClassFilePool.newInstance(); } Index: compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java,v retrieving revision 1.286 diff -u -r1.286 Scope.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 9 Oct 2006 17:28:54 -0000 1.286 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 20 Oct 2006 10:12:02 -0000 @@ -992,7 +992,7 @@ if (visibleMemberType == null) visibleMemberType = memberType; else - return new ProblemReferenceBinding(typeName, null, ProblemReasons.Ambiguous); + return new ProblemReferenceBinding(typeName, visibleMemberType, ProblemReasons.Ambiguous); } else { notVisible = memberType; } @@ -1009,7 +1009,7 @@ if (visibleMemberType == null) { visibleMemberType = memberType; } else { - ambiguous = new ProblemReferenceBinding(typeName, null, ProblemReasons.Ambiguous); + ambiguous = new ProblemReferenceBinding(typeName, visibleMemberType, ProblemReasons.Ambiguous); break done; } } else { @@ -2036,7 +2036,7 @@ if (!binding.isValidBinding()) return new ProblemReferenceBinding( CharOperation.subarray(compoundName, 0, currentIndex), - null, // TODO should improve + binding instanceof ReferenceBinding ? ((ReferenceBinding)binding).closestMatch() : null, binding.problemId()); if (!(binding instanceof PackageBinding)) return packageBinding; @@ -2075,7 +2075,7 @@ if (!binding.isValidBinding()) return new ProblemReferenceBinding( CharOperation.arrayConcat(packageBinding.compoundName, name), - null, // TODO should improve + binding instanceof ReferenceBinding ? ((ReferenceBinding)binding).closestMatch() : null, binding.problemId()); ReferenceBinding typeBinding = (ReferenceBinding) binding; @@ -2122,7 +2122,7 @@ if (!binding.isValidBinding()) return new ProblemReferenceBinding( CharOperation.subarray(compoundName, 0, currentIndex), - null, // TODO should improve + binding instanceof ReferenceBinding ? ((ReferenceBinding)binding).closestMatch() : null, binding.problemId()); if (!(binding instanceof PackageBinding)) break; @@ -2153,12 +2153,12 @@ ProblemReferenceBinding problemBinding = (ProblemReferenceBinding) typeBinding; return new ProblemReferenceBinding( CharOperation.subarray(compoundName, 0, currentIndex), - problemBinding.closestMatch, + problemBinding.closestMatch(), typeBinding.problemId()); } return new ProblemReferenceBinding( CharOperation.subarray(compoundName, 0, currentIndex), - null, // TODO should improve + ((ReferenceBinding)binding).closestMatch(), typeBinding.problemId()); } } @@ -2346,7 +2346,7 @@ if (importReference != null) importReference.used = true; if (foundInImport) { // Answer error binding -- import on demand conflict; name found in two import on demand packages. - temp = new ProblemReferenceBinding(name, null, ProblemReasons.Ambiguous); + temp = new ProblemReferenceBinding(name, type, ProblemReasons.Ambiguous); if (typeOrPackageCache != null) typeOrPackageCache.put(name, temp); return temp; @@ -2414,7 +2414,7 @@ if (!binding.isValidBinding()) return new ProblemReferenceBinding( CharOperation.subarray(compoundName, 0, currentIndex), - null, // TODO should improve + binding instanceof ReferenceBinding ? ((ReferenceBinding)binding).closestMatch() : null, binding.problemId()); if (!(binding instanceof PackageBinding)) break; @@ -2440,7 +2440,7 @@ if (!typeBinding.isValidBinding()) return new ProblemReferenceBinding( CharOperation.subarray(compoundName, 0, currentIndex), - null, // TODO should improve + ((ReferenceBinding)binding).closestMatch(), typeBinding.problemId()); if (typeBinding.isGenericType()) { Index: compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java,v retrieving revision 1.102 diff -u -r1.102 BlockScope.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java 8 Jun 2006 13:08:57 -0000 1.102 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java 20 Oct 2006 10:11:57 -0000 @@ -454,7 +454,7 @@ if (!binding.isValidBinding()) return new ProblemReferenceBinding( CharOperation.subarray(compoundName, 0, currentIndex), - null, // TODO should improve + ((ReferenceBinding)binding).closestMatch(), binding.problemId()); if (!((ReferenceBinding) binding).canBeSeenBy(this)) return new ProblemReferenceBinding( @@ -476,11 +476,11 @@ // know binding is now a ReferenceBinding binding = environment().convertToRawType((ReferenceBinding) binding); while (currentIndex < length) { - ReferenceBinding typeBinding = (ReferenceBinding) binding; + ReferenceBinding referenceBinding = (ReferenceBinding) binding; char[] nextName = compoundName[currentIndex++]; invocationSite.setFieldIndex(currentIndex); - invocationSite.setActualReceiverType(typeBinding); - if ((mask & Binding.FIELD) != 0 && (binding = findField(typeBinding, nextName, invocationSite, true /*resolve*/)) != null) { + invocationSite.setActualReceiverType(referenceBinding); + if ((mask & Binding.FIELD) != 0 && (binding = findField(referenceBinding, nextName, invocationSite, true /*resolve*/)) != null) { if (!binding.isValidBinding()) { return new ProblemFieldBinding( ((ProblemFieldBinding)binding).closestMatch, @@ -490,22 +490,23 @@ } break; // binding is now a field } - if ((binding = findMemberType(nextName, typeBinding)) == null) { + if ((binding = findMemberType(nextName, referenceBinding)) == null) { if ((mask & Binding.FIELD) != 0) { return new ProblemBinding( CharOperation.subarray(compoundName, 0, currentIndex), - typeBinding, + referenceBinding, ProblemReasons.NotFound); } return new ProblemReferenceBinding( CharOperation.subarray(compoundName, 0, currentIndex), - typeBinding, + referenceBinding, ProblemReasons.NotFound); } + // binding is a ReferenceBinding if (!binding.isValidBinding()) return new ProblemReferenceBinding( CharOperation.subarray(compoundName, 0, currentIndex), - null, // TODO should improve + ((ReferenceBinding)binding).closestMatch(), binding.problemId()); } if ((mask & Binding.FIELD) != 0 && (binding instanceof FieldBinding)) { @@ -563,7 +564,7 @@ if (!binding.isValidBinding()) return new ProblemReferenceBinding( CharOperation.subarray(compoundName, 0, currentIndex), - null, // TODO should improve + ((ReferenceBinding)binding).closestMatch(), binding.problemId()); if (!((ReferenceBinding) binding).canBeSeenBy(this)) return new ProblemReferenceBinding( @@ -596,16 +597,18 @@ ProblemReasons.NonStaticReferenceInStaticContext); break foundField; // binding is now a field } - if ((binding = findMemberType(nextName, typeBinding)) == null) + if ((binding = findMemberType(nextName, typeBinding)) == null) { return new ProblemBinding( CharOperation.subarray(compoundName, 0, currentIndex), typeBinding, ProblemReasons.NotFound); - if (!binding.isValidBinding()) + } + if (!binding.isValidBinding()) { return new ProblemReferenceBinding( CharOperation.subarray(compoundName, 0, currentIndex), - null, // TODO should improve + ((ReferenceBinding)binding).closestMatch(), binding.problemId()); + } } return binding; } Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java,v retrieving revision 1.103 diff -u -r1.103 ReferenceBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java 9 Jun 2006 10:20:47 -0000 1.103 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java 20 Oct 2006 10:11:58 -0000 @@ -311,6 +311,15 @@ // isDefault() return invocationType.fPackage == this.fPackage; } + +/** + * In case of problems, returns the closest match found. It may not be perfect match, but the + * result of a best effort to improve fault-tolerance. +*/ +public ReferenceBinding closestMatch() { + return this; // by default, the closest match is the binding itself +} + public char[] computeGenericTypeSignature(TypeVariableBinding[] typeVariables) { boolean isMemberOfGeneric = isMemberType() && (enclosingType().modifiers & ExtraCompilerModifiers.AccGenericSignature) != 0; Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemReferenceBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemReferenceBinding.java,v retrieving revision 1.17 diff -u -r1.17 ProblemReferenceBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemReferenceBinding.java 10 May 2006 18:03:50 -0000 1.17 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemReferenceBinding.java 20 Oct 2006 10:11:58 -0000 @@ -11,7 +11,7 @@ package org.eclipse.jdt.internal.compiler.lookup; public class ProblemReferenceBinding extends ReferenceBinding { - public ReferenceBinding closestMatch; + private ReferenceBinding closestMatch; private int problemReason; // NOTE: must only answer the subset of the name related to the problem @@ -24,6 +24,14 @@ public ProblemReferenceBinding(char[] name, ReferenceBinding closestMatch, int problemReason) { this(new char[][] {name}, closestMatch, problemReason); } + +/** + * @see org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding#closestMatch() + */ +public ReferenceBinding closestMatch() { + return this.closestMatch; +} + /* API * Answer the problem id associated with the receiver. * NoError if the receiver is a valid binding. Index: search/org/eclipse/jdt/internal/core/search/matching/PackageReferenceLocator.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PackageReferenceLocator.java,v retrieving revision 1.35 diff -u -r1.35 PackageReferenceLocator.java --- search/org/eclipse/jdt/internal/core/search/matching/PackageReferenceLocator.java 14 Sep 2006 17:10:33 -0000 1.35 +++ search/org/eclipse/jdt/internal/core/search/matching/PackageReferenceLocator.java 20 Oct 2006 10:12:05 -0000 @@ -156,7 +156,7 @@ long[] positions = importRef.sourcePositions; int last = positions.length - 1; if (binding instanceof ProblemReferenceBinding) - binding = ((ProblemReferenceBinding) binding).closestMatch; + binding = ((ProblemReferenceBinding) binding).closestMatch(); if (binding instanceof ReferenceBinding) { PackageBinding pkgBinding = ((ReferenceBinding) binding).fPackage; if (pkgBinding != null) @@ -220,7 +220,7 @@ if (typeBinding instanceof ArrayBinding) typeBinding = ((ArrayBinding) typeBinding).leafComponentType; if (typeBinding instanceof ProblemReferenceBinding) - typeBinding = ((ProblemReferenceBinding) typeBinding).closestMatch; + typeBinding = ((ProblemReferenceBinding) typeBinding).closestMatch(); if (typeBinding instanceof ReferenceBinding) { PackageBinding pkgBinding = ((ReferenceBinding) typeBinding).fPackage; if (pkgBinding != null) @@ -283,7 +283,7 @@ if (binding instanceof ArrayBinding) binding = ((ArrayBinding) binding).leafComponentType; if (binding instanceof ProblemReferenceBinding) - binding = ((ProblemReferenceBinding) binding).closestMatch; + binding = ((ProblemReferenceBinding) binding).closestMatch(); if (binding == null) return INACCURATE_MATCH; if (binding instanceof ReferenceBinding) { Index: search/org/eclipse/jdt/internal/core/search/matching/TypeReferenceLocator.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeReferenceLocator.java,v retrieving revision 1.52 diff -u -r1.52 TypeReferenceLocator.java --- search/org/eclipse/jdt/internal/core/search/matching/TypeReferenceLocator.java 14 Sep 2006 17:10:33 -0000 1.52 +++ search/org/eclipse/jdt/internal/core/search/matching/TypeReferenceLocator.java 20 Oct 2006 10:12:05 -0000 @@ -220,7 +220,7 @@ } if (typeBinding instanceof ProblemReferenceBinding) { ProblemReferenceBinding pbBinding = (ProblemReferenceBinding) typeBinding; - typeBinding = pbBinding.closestMatch; + typeBinding = pbBinding.closestMatch(); lastIndex = pbBinding.compoundName.length - 1; } // try to match all enclosing types for which the token matches as well. @@ -394,7 +394,7 @@ } if (typeBinding instanceof ProblemReferenceBinding) { ProblemReferenceBinding pbBinding = (ProblemReferenceBinding) typeBinding; - typeBinding = pbBinding.closestMatch; + typeBinding = pbBinding.closestMatch(); lastIndex = pbBinding.compoundName.length - 1; } @@ -439,7 +439,7 @@ typeBinding = ((ArrayBinding) typeBinding).leafComponentType; if (typeBinding instanceof ProblemReferenceBinding) { ProblemReferenceBinding pbBinding = (ProblemReferenceBinding) typeBinding; - typeBinding = pbBinding.closestMatch; + typeBinding = pbBinding.closestMatch(); lastIndex = pbBinding.compoundName.length - 1; } @@ -575,7 +575,7 @@ typeBinding = ((ArrayBinding) typeBinding).leafComponentType; if (typeBinding == null || typeBinding instanceof BaseTypeBinding) return; if (typeBinding instanceof ProblemReferenceBinding) { - ReferenceBinding original = ((ProblemReferenceBinding) typeBinding).closestMatch; + ReferenceBinding original = ((ProblemReferenceBinding) typeBinding).closestMatch(); if (original == null) return; // original may not be set (bug 71279) typeBinding = original; } @@ -637,7 +637,7 @@ if (typeBinding instanceof ArrayBinding) typeBinding = ((ArrayBinding) typeBinding).leafComponentType; if (typeBinding instanceof ProblemReferenceBinding) - typeBinding = ((ProblemReferenceBinding) typeBinding).closestMatch; + typeBinding = ((ProblemReferenceBinding) typeBinding).closestMatch(); if (((InternalSearchPattern) this.pattern).focus instanceof IType && typeBinding instanceof ReferenceBinding) { IPackageFragment pkg = ((IType) ((InternalSearchPattern) this.pattern).focus).getPackageFragment(); @@ -653,7 +653,7 @@ if (nameRef instanceof SingleNameReference) { if (binding instanceof ProblemReferenceBinding) - binding = ((ProblemReferenceBinding) binding).closestMatch; + binding = ((ProblemReferenceBinding) binding).closestMatch(); if (binding instanceof ReferenceBinding) return resolveLevelForType((ReferenceBinding) binding); return binding == null || binding instanceof ProblemBinding ? INACCURATE_MATCH : IMPOSSIBLE_MATCH; @@ -700,7 +700,7 @@ if (typeBinding instanceof ArrayBinding) typeBinding = ((ArrayBinding) typeBinding).leafComponentType; if (typeBinding instanceof ProblemReferenceBinding) - typeBinding = ((ProblemReferenceBinding) typeBinding).closestMatch; + typeBinding = ((ProblemReferenceBinding) typeBinding).closestMatch(); if (typeRef instanceof SingleTypeReference) { return resolveLevelForType(typeBinding); Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetScope.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetScope.java,v retrieving revision 1.43 diff -u -r1.43 CodeSnippetScope.java --- eval/org/eclipse/jdt/internal/eval/CodeSnippetScope.java 25 Apr 2006 20:39:50 -0000 1.43 +++ eval/org/eclipse/jdt/internal/eval/CodeSnippetScope.java 20 Oct 2006 10:12:04 -0000 @@ -448,7 +448,7 @@ if (!binding.isValidBinding()) return new ProblemReferenceBinding( CharOperation.subarray(compoundName, 0, currentIndex), - null, // TODO should improve + ((ReferenceBinding)binding).closestMatch(), binding.problemId()); if (!this.canBeSeenByForCodeSnippet((ReferenceBinding) binding, receiverType)) return new ProblemReferenceBinding(CharOperation.subarray(compoundName, 0, currentIndex), (ReferenceBinding) binding, ProblemReasons.NotVisible); @@ -481,7 +481,7 @@ if (!binding.isValidBinding()) return new ProblemReferenceBinding( CharOperation.subarray(compoundName, 0, currentIndex), - null, // TODO should improve + ((ReferenceBinding)binding).closestMatch(), binding.problemId()); } Index: compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java,v retrieving revision 1.36 diff -u -r1.36 QualifiedTypeReference.java --- compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java 8 Jun 2006 13:08:57 -0000 1.36 +++ compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java 20 Oct 2006 10:11:57 -0000 @@ -43,7 +43,7 @@ ProblemReferenceBinding problemBinding = (ProblemReferenceBinding) this.resolvedType; this.resolvedType = new ProblemReferenceBinding( org.eclipse.jdt.core.compiler.CharOperation.subarray(this.tokens, 0, tokenIndex + 1), - problemBinding.closestMatch, + problemBinding.closestMatch(), this.resolvedType.problemId()); } } Index: compiler/org/eclipse/jdt/internal/compiler/ast/JavadocSingleTypeReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocSingleTypeReference.java,v retrieving revision 1.17 diff -u -r1.17 JavadocSingleTypeReference.java --- compiler/org/eclipse/jdt/internal/compiler/ast/JavadocSingleTypeReference.java 18 Nov 2005 16:46:22 -0000 1.17 +++ compiler/org/eclipse/jdt/internal/compiler/ast/JavadocSingleTypeReference.java 20 Oct 2006 10:11:57 -0000 @@ -65,7 +65,7 @@ this.packageBinding = (PackageBinding) binding; } else { if (this.resolvedType.problemId() == ProblemReasons.NonStaticReferenceInStaticContext) { - ReferenceBinding closestMatch = ((ProblemReferenceBinding)this.resolvedType).closestMatch; + ReferenceBinding closestMatch = ((ProblemReferenceBinding)this.resolvedType).closestMatch(); if (closestMatch != null && closestMatch.isTypeVariable()) { this.resolvedType = closestMatch; // ignore problem as we want report specific javadoc one instead return resolvedType; Index: dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java,v retrieving revision 1.145 diff -u -r1.145 DefaultBindingResolver.java --- dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java 15 Aug 2006 00:12:42 -0000 1.145 +++ dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java 20 Oct 2006 10:12:04 -0000 @@ -275,7 +275,7 @@ case ProblemReasons.NonStaticReferenceInStaticContext : if (referenceBinding instanceof ProblemReferenceBinding) { ProblemReferenceBinding problemReferenceBinding = (ProblemReferenceBinding) referenceBinding; - Binding binding2 = problemReferenceBinding.closestMatch; + Binding binding2 = problemReferenceBinding.closestMatch(); if (binding2 != null && binding2 instanceof org.eclipse.jdt.internal.compiler.lookup.TypeBinding) { TypeBinding binding = (TypeBinding) this.bindingTables.compilerBindingsToASTBindings.get(binding2); if (binding != null) { Index: model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java,v retrieving revision 1.70 diff -u -r1.70 HierarchyResolver.java --- model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java 27 Jun 2006 13:50:23 -0000 1.70 +++ model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java 20 Oct 2006 10:12:05 -0000 @@ -295,7 +295,7 @@ TypeReference superclassRef = typeDeclaration == null ? null : typeDeclaration.superclass; TypeBinding superclass = superclassRef == null ? null : superclassRef.resolvedType; if (superclass instanceof ProblemReferenceBinding) { - superclass = ((ProblemReferenceBinding) superclass).closestMatch; + superclass = ((ProblemReferenceBinding) superclass).closestMatch(); } if (superclass != null) ((SourceTypeBinding) typeBinding).superclass = (ReferenceBinding) superclass; @@ -309,7 +309,7 @@ for (int i = 0; i < length; i++) { ReferenceBinding superInterface = (ReferenceBinding) superInterfaces[i].resolvedType; if (superInterface instanceof ProblemReferenceBinding) - superInterface = ((ProblemReferenceBinding) superInterface).closestMatch; + superInterface = superInterface.closestMatch(); if (superInterface != null) interfaceBindings[index++] = superInterface; } Index: codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java,v retrieving revision 1.130 diff -u -r1.130 SelectionEngine.java --- codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java 28 Sep 2006 14:14:29 -0000 1.130 +++ codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java 20 Oct 2006 10:11:57 -0000 @@ -821,9 +821,8 @@ this.acceptedAnswer = true; } else if (binding instanceof ReferenceBinding) { ReferenceBinding typeBinding = (ReferenceBinding) binding; - if(typeBinding instanceof ProblemReferenceBinding) { - typeBinding = ((ProblemReferenceBinding) typeBinding).closestMatch; + typeBinding = typeBinding.closestMatch(); } if (typeBinding == null) return; if (isLocal(typeBinding) && this.requestor instanceof SelectionRequestor) {