Klasse NameLookup
- Alle implementierten Schnittstellen:
SuffixConstants
NameLookup provides name resolution within a Java project.
The name lookup facility uses the project's classpath to prioritize the
order in which package fragments are searched when resolving a name.
Name lookup only returns a handle when the named element actually
exists in the model; otherwise null is returned.
There are two logical sets of methods within this interface. Methods
which start with find* are intended to be convenience methods for quickly
finding an element within another element; for instance, for finding a class within a
package. The other set of methods all begin with seek*. These methods
do comprehensive searches of the IJavaProject returning hits
in real time through an IJavaElementRequestor.
-
Verschachtelte Klassen - Übersicht
Verschachtelte Klassen -
Feldübersicht
FelderModifizierer und TypFeldBeschreibungstatic final intstatic final intAccept flag for specifying annotations.static final intAccept flag for specifying classes.static final intAccept flag for specifying enums.static final intAccept flag for specifying interfaces.static final intAccept flag for specifying records.protected IPackageFragmentRoot[]TheIPackageFragmentRoot's associated with the classpath of this NameLookup facility's project.protected HashtableOfArrayToObjectTable that maps package names to lists of package fragment roots that contain such a package known by this name lookup facility.protected Map<IPackageFragmentRoot,IModuleDescription> protected Map<IPackageFragmentRoot,IClasspathEntry> Reverse map from root path to corresponding resolved CP entry (so as to be able to figure inclusion/exclusion rules)longlonglonglonglonglonglonglongprotected HashMapA map from package handles to a map from type name to an IType or an IType[].static booleanVon Schnittstelle geerbte Felder org.aspectj.org.eclipse.jdt.internal.compiler.util.SuffixConstants
EXTENSION_aj, EXTENSION_AJ, EXTENSION_class, EXTENSION_CLASS, EXTENSION_java, EXTENSION_JAVA, EXTENSION_jmod, EXTENSION_JMOD, SUFFIX_aj, SUFFIX_AJ, SUFFIX_class, SUFFIX_CLASS, SUFFIX_java, SUFFIX_JAVA, SUFFIX_STRING_aj, SUFFIX_STRING_AJ, SUFFIX_STRING_class, SUFFIX_STRING_CLASS, SUFFIX_STRING_java, SUFFIX_STRING_JAVA -
Konstruktorübersicht
KonstruktorenKonstruktorBeschreibungNameLookup(JavaProject rootProject, IPackageFragmentRoot[] packageFragmentRoots, HashtableOfArrayToObject packageFragments, ICompilationUnit[] workingCopies, Map rootToResolvedEntries) -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungprotected booleanacceptType(IType type, int acceptFlags, boolean isSourceType) Returns true if: the given type is an existing class and the flag'sACCEPT_CLASSESbit is on the given type is an existing interface and theACCEPT_INTERFACESbit is on neither theACCEPT_CLASSESorACCEPT_INTERFACESbit is on Otherwise, false is returned.findCompilationUnit(String qualifiedTypeName) Returns theICompilationUnitwhich defines the type namedqualifiedTypeName, ornullif none exists.findModule(char[] moduleName) findPackageFragementRoots(String[] splittedName) Returns the package fragment roots who contain a package fragment with the given qualified name.findPackageFragment(org.eclipse.core.runtime.IPath path) Returns the package fragment whose path matches the given (absolute) path, ornullif none exist.findPackageFragments(String name, boolean partialMatch) Returns the package fragments whose name matches the given (qualified) name, ornullif none exist.findPackageFragments(String name, boolean partialMatch, boolean patternMatch) Returns the package fragments whose name matches the given (qualified) name or pattern, ornullif none exist.Returns the type specified by the qualified name, ornullif none exist.findType(String name, boolean partialMatch, int acceptFlags, boolean considerSecondaryTypes, boolean waitForIndexes, boolean checkRestrictions, org.eclipse.core.runtime.IProgressMonitor monitor) findType(String typeName, String packageName, boolean partialMatch, int acceptFlags, boolean checkRestrictions) Find type considering secondary types but without waiting for indexes.findType(String typeName, String packageName, boolean partialMatch, int acceptFlags, boolean considerSecondaryTypes, boolean waitForIndexes, boolean checkRestrictions, org.eclipse.core.runtime.IProgressMonitor monitor) Find type.findType(String typeName, String packageName, boolean partialMatch, int acceptFlags, boolean considerSecondaryTypes, boolean waitForIndexes, boolean checkRestrictions, org.eclipse.core.runtime.IProgressMonitor monitor, IPackageFragmentRoot[] moduleContext) Find type.findType(String typeName, String packageName, boolean partialMatch, int acceptFlags, boolean checkRestrictions, IPackageFragmentRoot[] moduleContext) Find type in the given modules considering secondary types but without waiting for indexes.findType(String name, IPackageFragment pkg, boolean partialMatch, int acceptFlags) Returns the first type in the given package whose name matches the given (unqualified) name, ornullif none exist.findType(String name, IPackageFragment pkg, boolean partialMatch, int acceptFlags, boolean waitForIndices, boolean considerSecondaryTypes) Returns the first type in the given package whose name matches the given (unqualified) name, ornullif none exist.static IModulegetModuleDescriptionInfo(IModuleDescription moduleDesc) booleanhasCompilationUnit(char[][] pkgName, IPackageFragmentRoot[] moduleContext) booleanbooleanisPackage(String[] pkgName, IPackageFragmentRoot[] moduleContext) protected booleannameMatches(String searchName, ICompilationUnit cu, boolean partialMatch) Returns true if the given cu's name matches the specifiedsearchName, otherwise false.protected booleannameMatches(String searchName, IJavaElement element, boolean partialMatch) Returns true if the given element's name matches the specifiedsearchName, otherwise false.voidvoidseekModule(char[] name, boolean prefixMatch, IJavaElementRequestor requestor) voidseekModuleReferences(String name, IJavaElementRequestor requestor, IJavaProject javaProject) voidseekPackageFragments(String name, boolean partialMatch, IJavaElementRequestor requestor) Notifies the given requestor of all package fragments with the given name.voidseekPackageFragments(String name, boolean partialMatch, IJavaElementRequestor requestor, IPackageFragmentRoot[] moduleContext) Notifies the given requestor of all package fragments with the given name.voidseekTypes(String pkgName, String name, boolean partialMatch, IJavaElementRequestor requestor, int acceptFlags, IPackageFragmentRoot[] moduleContext, String moduleName) Notifies the given requestor of all package fragments with the given name.voidseekTypes(String name, IPackageFragment pkg, boolean partialMatch, int acceptFlags, IJavaElementRequestor requestor) voidseekTypes(String name, IPackageFragment pkg, boolean partialMatch, int acceptFlags, IJavaElementRequestor requestor, boolean considerSecondaryTypes) Notifies the given requestor of all types (classes and interfaces) in the given package fragment with the given (unqualified) name.protected voidseekTypesInBinaryPackage(String name, IPackageFragment pkg, boolean partialMatch, int acceptFlags, IJavaElementRequestor requestor) Performs type search in a binary package.protected voidseekTypesInSourcePackage(String name, IPackageFragment pkg, int firstDot, boolean partialMatch, String topLevelTypeName, int acceptFlags, IJavaElementRequestor requestor) Performs type search in a source package.protected booleanseekTypesInTopLevelType(String prefix, int firstDot, IType topLevelType, IJavaElementRequestor requestor, int acceptFlags) protected booleanseekTypesInType(String prefix, int firstDot, IType type, IJavaElementRequestor requestor, int acceptFlags) Notifies the given requestor of all types (classes and interfaces) in the given type with the given (possibly qualified) name.protected booleanseekTypesInWorkingCopies(String name, IPackageFragment pkg, int firstDot, boolean partialMatch, String topLevelTypeName, int acceptFlags, IJavaElementRequestor requestor, boolean considerSecondaryTypes)
-
Felddetails
-
ACCEPT_CLASSES
public static final int ACCEPT_CLASSESAccept flag for specifying classes.- Siehe auch:
-
ACCEPT_INTERFACES
public static final int ACCEPT_INTERFACESAccept flag for specifying interfaces.- Siehe auch:
-
ACCEPT_ENUMS
public static final int ACCEPT_ENUMSAccept flag for specifying enums.- Siehe auch:
-
ACCEPT_RECORDS
public static final int ACCEPT_RECORDSAccept flag for specifying records.- Siehe auch:
-
ACCEPT_ANNOTATIONS
public static final int ACCEPT_ANNOTATIONSAccept flag for specifying annotations.- Siehe auch:
-
ACCEPT_ALL
public static final int ACCEPT_ALL- Siehe auch:
-
VERBOSE
public static boolean VERBOSE -
packageFragmentRoots
TheIPackageFragmentRoot's associated with the classpath of this NameLookup facility's project. -
packageFragments
Table that maps package names to lists of package fragment roots that contain such a package known by this name lookup facility. To allow > 1 package fragment with the same name, values are arrays of package fragment roots ordered as they appear on the classpath. Note if the list is of size 1, then the IPackageFragmentRoot object replaces the array. -
rootToResolvedEntries
Reverse map from root path to corresponding resolved CP entry (so as to be able to figure inclusion/exclusion rules) -
rootToModule
-
typesInWorkingCopies
A map from package handles to a map from type name to an IType or an IType[]. Allows working copies to take precedence over compilation units. -
timeSpentInSeekTypesInSourcePackage
public long timeSpentInSeekTypesInSourcePackage -
timeSpentInSeekTypesInBinaryPackage
public long timeSpentInSeekTypesInBinaryPackage -
timeSpentInSeekPackageFragmentsWithModuleContext
public long timeSpentInSeekPackageFragmentsWithModuleContext -
timeSpentInSeekModuleAwarePartialPackageFragments
public long timeSpentInSeekModuleAwarePartialPackageFragments -
timeSpentInSeekPackageFragments
public long timeSpentInSeekPackageFragments -
timeSpentInSeekModule
public long timeSpentInSeekModule -
timeSpentInIsPackageWithModuleContext
public long timeSpentInIsPackageWithModuleContext -
timeSpentInSeekTypesInType
public long timeSpentInSeekTypesInType
-
-
Konstruktordetails
-
NameLookup
public NameLookup(JavaProject rootProject, IPackageFragmentRoot[] packageFragmentRoots, HashtableOfArrayToObject packageFragments, ICompilationUnit[] workingCopies, Map rootToResolvedEntries)
-
-
Methodendetails
-
acceptType
Returns true if:- the given type is an existing class and the flag's
ACCEPT_CLASSESbit is on - the given type is an existing interface and the
ACCEPT_INTERFACESbit is on - neither the
ACCEPT_CLASSESorACCEPT_INTERFACESbit is on
- the given type is an existing class and the flag's
-
findCompilationUnit
Returns theICompilationUnitwhich defines the type namedqualifiedTypeName, ornullif none exists. The domain of the search is bounded by the classpath of theIJavaProjectthisNameLookupwas obtained from.The name must be fully qualified (eg "java.lang.Object", "java.util.Hashtable$Entry")
-
findPackageFragment
Returns the package fragment whose path matches the given (absolute) path, ornullif none exist. The domain of the search is bounded by the classpath of theIJavaProjectthisNameLookupwas obtained from. The path can be: - internal to the workbench: "/Project/src" - external to the workbench: "c:/jdk/classes.zip/java/lang" -
findPackageFragments
Returns the package fragments whose name matches the given (qualified) name, ornullif none exist. The name can be:- empty: ""
- qualified: "pack.pack1.pack2"
- Parameter:
partialMatch- partial name matches qualify whentrue, only exact name matches qualify whenfalse
-
findPackageFragments
public IPackageFragment[] findPackageFragments(String name, boolean partialMatch, boolean patternMatch) Returns the package fragments whose name matches the given (qualified) name or pattern, ornullif none exist. The name can be:- empty: ""
- qualified: "pack.pack1.pack2"
- a pattern: "pack.*.util"
- Parameter:
partialMatch- partial name matches qualify whentrue,patternMatch-truewhen the given name might be a pattern,falseotherwise.
-
findPackageFragementRoots
Returns the package fragment roots who contain a package fragment with the given qualified name. No partial matching or pattern matching will be performed on the package name.- Parameter:
splittedName- qualified name of package splitted into parts (eg.,["java", "lang"])- Gibt zurück:
- array of package fragment roots or
null
-
findType
public NameLookup.Answer findType(String typeName, String packageName, boolean partialMatch, int acceptFlags, boolean checkRestrictions, IPackageFragmentRoot[] moduleContext) Find type in the given modules considering secondary types but without waiting for indexes. It means that secondary types may be not found under certain circumstances...- Siehe auch:
-
findType
public NameLookup.Answer findType(String typeName, String packageName, boolean partialMatch, int acceptFlags, boolean checkRestrictions) Find type considering secondary types but without waiting for indexes. It means that secondary types may be not found under certain circumstances...- Siehe auch:
-
findType
public NameLookup.Answer findType(String typeName, String packageName, boolean partialMatch, int acceptFlags, boolean considerSecondaryTypes, boolean waitForIndexes, boolean checkRestrictions, org.eclipse.core.runtime.IProgressMonitor monitor) Find type. Considering secondary types and waiting for indexes depends on given corresponding parameters. -
findType
public NameLookup.Answer findType(String typeName, String packageName, boolean partialMatch, int acceptFlags, boolean considerSecondaryTypes, boolean waitForIndexes, boolean checkRestrictions, org.eclipse.core.runtime.IProgressMonitor monitor, IPackageFragmentRoot[] moduleContext) Find type. Considering secondary types and waiting for indexes depends on given corresponding parameters. -
getModuleDescriptionInfo
-
getModuleDescriptionInfo
-
findType
public IType findType(String name, IPackageFragment pkg, boolean partialMatch, int acceptFlags, boolean waitForIndices, boolean considerSecondaryTypes) Returns the first type in the given package whose name matches the given (unqualified) name, ornullif none exist. Specifying anullpackage will result in no matches. The domain of the search is bounded by the Java project from which this name lookup was obtained.- Parameter:
name- the name of the type to findpkg- the package to searchpartialMatch- partial name matches qualify whentrue, only exact name matches qualify whenfalseacceptFlags- a bit mask describing if classes, interfaces or both classes and interfaces are desired results. If no flags are specified, all types are returned.considerSecondaryTypes- flag to know whether secondary types has to be considered during the search- Siehe auch:
-
findType
Returns the first type in the given package whose name matches the given (unqualified) name, ornullif none exist. Specifying anullpackage will result in no matches. The domain of the search is bounded by the Java project from which this name lookup was obtained.
Note that this method does not find secondary types.- Parameter:
name- the name of the type to findpkg- the package to searchpartialMatch- partial name matches qualify whentrue, only exact name matches qualify whenfalseacceptFlags- a bit mask describing if classes, interfaces or both classes and interfaces are desired results. If no flags are specified, all types are returned.- Siehe auch:
-
findType
Returns the type specified by the qualified name, ornullif none exist. The domain of the search is bounded by the Java project from which this name lookup was obtained.- Parameter:
name- the name of the type to findpartialMatch- partial name matches qualify whentrue, only exact name matches qualify whenfalseacceptFlags- a bit mask describing if classes, interfaces or both classes and interfaces are desired results. If no flags are specified, all types are returned.- Siehe auch:
-
findType
public NameLookup.Answer findType(String name, boolean partialMatch, int acceptFlags, boolean checkRestrictions) -
findType
public NameLookup.Answer findType(String name, boolean partialMatch, int acceptFlags, boolean considerSecondaryTypes, boolean waitForIndexes, boolean checkRestrictions, org.eclipse.core.runtime.IProgressMonitor monitor) -
findModule
-
isPackage
-
isPackage
-
nameMatches
Returns true if the given element's name matches the specifiedsearchName, otherwise false.The
partialMatchargument indicates partial matches should be considered. NOTE: in partialMatch mode, the case will be ignored, and the searchName must already have been lowercased. -
nameMatches
Returns true if the given cu's name matches the specifiedsearchName, otherwise false.The
partialMatchargument indicates partial matches should be considered. NOTE: in partialMatch mode, the case will be ignored, and the searchName must already have been lowercased. -
seekPackageFragments
public void seekPackageFragments(String name, boolean partialMatch, IJavaElementRequestor requestor, IPackageFragmentRoot[] moduleContext) Notifies the given requestor of all package fragments with the given name. Checks the requestor at regular intervals to see if the requestor has canceled. The domain of the search is bounded by theIJavaProjectthisNameLookupwas obtained from.- Parameter:
partialMatch- partial name matches qualify whentrue; only exact name matches qualify whenfalse
-
seekTypes
public void seekTypes(String pkgName, String name, boolean partialMatch, IJavaElementRequestor requestor, int acceptFlags, IPackageFragmentRoot[] moduleContext, String moduleName) Notifies the given requestor of all package fragments with the given name. Checks the requestor at regular intervals to see if the requestor has canceled. The domain of the search is bounded by theIJavaProjectthisNameLookupwas obtained from.- Parameter:
partialMatch- partial name matches qualify whentrue; only exact name matches qualify whenfalse
-
seekPackageFragments
public void seekPackageFragments(String name, boolean partialMatch, IJavaElementRequestor requestor) Notifies the given requestor of all package fragments with the given name. Checks the requestor at regular intervals to see if the requestor has canceled. The domain of the search is bounded by theIJavaProjectthisNameLookupwas obtained from.- Parameter:
partialMatch- partial name matches qualify whentrue; only exact name matches qualify whenfalse
-
seekTypes
public void seekTypes(String name, IPackageFragment pkg, boolean partialMatch, int acceptFlags, IJavaElementRequestor requestor) -
seekModuleReferences
public void seekModuleReferences(String name, IJavaElementRequestor requestor, IJavaProject javaProject) -
seekModule
-
seekTypes
public void seekTypes(String name, IPackageFragment pkg, boolean partialMatch, int acceptFlags, IJavaElementRequestor requestor, boolean considerSecondaryTypes) Notifies the given requestor of all types (classes and interfaces) in the given package fragment with the given (unqualified) name. Checks the requestor at regular intervals to see if the requestor has canceled. If the given package fragment isnull, all types in the project whose simple name matches the given name are found.- Parameter:
name- The name to searchpkg- The corresponding package fragmentpartialMatch- partial name matches qualify whentrue; only exact name matches qualify whenfalseacceptFlags- a bit mask describing if classes, interfaces or both classes and interfaces are desired results. If no flags are specified, all types are returned.requestor- The requestor that collects the result- Siehe auch:
-
seekTypesInBinaryPackage
protected void seekTypesInBinaryPackage(String name, IPackageFragment pkg, boolean partialMatch, int acceptFlags, IJavaElementRequestor requestor) Performs type search in a binary package. -
seekTypesInSourcePackage
protected void seekTypesInSourcePackage(String name, IPackageFragment pkg, int firstDot, boolean partialMatch, String topLevelTypeName, int acceptFlags, IJavaElementRequestor requestor) Performs type search in a source package. -
seekTypesInType
protected boolean seekTypesInType(String prefix, int firstDot, IType type, IJavaElementRequestor requestor, int acceptFlags) Notifies the given requestor of all types (classes and interfaces) in the given type with the given (possibly qualified) name. Checks the requestor at regular intervals to see if the requestor has canceled. -
seekTypesInTopLevelType
protected boolean seekTypesInTopLevelType(String prefix, int firstDot, IType topLevelType, IJavaElementRequestor requestor, int acceptFlags) -
seekTypesInWorkingCopies
protected boolean seekTypesInWorkingCopies(String name, IPackageFragment pkg, int firstDot, boolean partialMatch, String topLevelTypeName, int acceptFlags, IJavaElementRequestor requestor, boolean considerSecondaryTypes) -
hasCompilationUnit
-
printTimeSpent
public void printTimeSpent()
-