diff options
Diffstat (limited to 'org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core')
5 files changed, 51 insertions, 7 deletions
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/AndLocator.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/AndLocator.java index e026c7f592..9e9b2aa857 100644 --- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/AndLocator.java +++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/AndLocator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 IBM Corporation and others. + * Copyright (c) 2000, 2012 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 @@ -23,11 +23,13 @@ import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration; import org.eclipse.jdt.internal.compiler.ast.MemberValuePair; import org.eclipse.jdt.internal.compiler.ast.MessageSend; import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration; +import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference; import org.eclipse.jdt.internal.compiler.ast.Reference; import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; import org.eclipse.jdt.internal.compiler.ast.TypeParameter; import org.eclipse.jdt.internal.compiler.ast.TypeReference; import org.eclipse.jdt.internal.compiler.lookup.Binding; +import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; public class AndLocator extends PatternLocator { @@ -263,5 +265,9 @@ void setFlavors(int flavors) { this.patternLocators[i].setFlavors(flavors); } } - +public void recordResolution(QualifiedTypeReference typeReference, TypeBinding resolution) { + for (int i = 0, length = this.patternLocators.length; i < length; i++) { + this.patternLocators[i].recordResolution(typeReference, resolution); + } +} } diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java index ccd1838629..5585ae9fa4 100644 --- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java +++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java @@ -1061,6 +1061,8 @@ public void initialize(JavaProject project, int possibleMatchSize) throws JavaMo // initialize queue of units this.numberOfMatches = 0; this.matchesToProcess = new PossibleMatch[possibleMatchSize]; + + this.lookupEnvironment.addResolutionListener(this.patternLocator); } protected void locateMatches(JavaProject javaProject, PossibleMatch[] possibleMatches, int start, int length) throws CoreException { initialize(javaProject, length); diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/OrLocator.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/OrLocator.java index 9876b7ce60..f435ac755d 100644 --- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/OrLocator.java +++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/OrLocator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 IBM Corporation and others. + * Copyright (c) 2000, 2012 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 @@ -24,6 +24,7 @@ import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration; import org.eclipse.jdt.internal.compiler.ast.MemberValuePair; import org.eclipse.jdt.internal.compiler.ast.MessageSend; import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration; +import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference; import org.eclipse.jdt.internal.compiler.ast.Reference; import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; import org.eclipse.jdt.internal.compiler.ast.TypeParameter; @@ -32,6 +33,7 @@ import org.eclipse.jdt.internal.compiler.lookup.Binding; import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; import org.eclipse.jdt.internal.compiler.lookup.MemberTypeBinding; import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; +import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; public class OrLocator extends PatternLocator { @@ -315,5 +317,9 @@ void setFlavors(int flavors) { this.patternLocators[i].setFlavors(flavors); } } - +public void recordResolution(QualifiedTypeReference typeReference, TypeBinding resolution) { + for (int i = 0, length = this.patternLocators.length; i < length; i++) { + this.patternLocators[i].recordResolution(typeReference, resolution); + } +} } diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PatternLocator.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PatternLocator.java index 6cb561f44d..7992580ac5 100644 --- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PatternLocator.java +++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PatternLocator.java @@ -18,7 +18,7 @@ import org.eclipse.jdt.internal.compiler.ast.*; import org.eclipse.jdt.internal.compiler.lookup.*; import org.eclipse.jdt.internal.core.search.indexing.IIndexConstants; -public abstract class PatternLocator implements IIndexConstants { +public abstract class PatternLocator implements IIndexConstants, IQualifiedTypeResolutionListener { // store pattern info protected int matchMode; @@ -970,4 +970,7 @@ protected int resolveLevelForType (char[] simpleNamePattern, public String toString(){ return "SearchPattern"; //$NON-NLS-1$ } +public void recordResolution(QualifiedTypeReference typeReference, TypeBinding resolution) { + // noop by default +} } diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeReferenceLocator.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeReferenceLocator.java index 137c9c85fa..ddea928667 100644 --- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeReferenceLocator.java +++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeReferenceLocator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2012 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 @@ -10,6 +10,12 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core.search.matching; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.*; import org.eclipse.jdt.core.*; @@ -680,7 +686,7 @@ protected int resolveLevel(TypeReference typeRef) { if (typeRef instanceof SingleTypeReference) { return resolveLevelForType(typeBinding); } else - return resolveLevelForTypeOrEnclosingTypes(this.pattern.simpleName, this.pattern.qualification, typeBinding); + return resolveLevelForTypeOrQualifyingTypes(typeRef, typeBinding); } /* (non-Javadoc) * Resolve level for type with a given binding. @@ -742,6 +748,27 @@ protected int resolveLevelForTypeOrEnclosingTypes(char[] simpleNamePattern, char } return IMPOSSIBLE_MATCH; } +private Map/*<QualifiedTypeReference, List<TypeBinding>>*/ recordedResolutions = new HashMap(); +int resolveLevelForTypeOrQualifyingTypes(TypeReference typeRef, TypeBinding typeBinding) { + if (typeBinding == null || !typeBinding.isValidBinding()) return INACCURATE_MATCH; + List resolutionsList = (List) this.recordedResolutions.get(typeRef); + if (resolutionsList != null) { + for (Iterator i = resolutionsList.iterator(); i.hasNext();) { + TypeBinding resolution = (TypeBinding) i.next(); + int level = resolveLevelForType(resolution); + if (level != IMPOSSIBLE_MATCH) return level; + } + } + return IMPOSSIBLE_MATCH; +} +public void recordResolution(QualifiedTypeReference typeReference, TypeBinding resolution) { + List/*<TypeBinding>*/ resolutionsForTypeReference = (List) this.recordedResolutions.get(typeReference); + if (resolutionsForTypeReference == null) { + resolutionsForTypeReference = new ArrayList(); + } + resolutionsForTypeReference.add(resolution); + this.recordedResolutions.put(typeReference, resolutionsForTypeReference); +} public String toString() { return "Locator for " + this.pattern.toString(); //$NON-NLS-1$ } |