Klasse NameLookup

java.lang.Object
org.aspectj.org.eclipse.jdt.internal.core.NameLookup
Alle implementierten Schnittstellen:
SuffixConstants

public class NameLookup extends Object implements SuffixConstants
A 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.

  • Felddetails

    • ACCEPT_CLASSES

      public static final int ACCEPT_CLASSES
      Accept flag for specifying classes.
      Siehe auch:
    • ACCEPT_INTERFACES

      public static final int ACCEPT_INTERFACES
      Accept flag for specifying interfaces.
      Siehe auch:
    • ACCEPT_ENUMS

      public static final int ACCEPT_ENUMS
      Accept flag for specifying enums.
      Siehe auch:
    • ACCEPT_RECORDS

      public static final int ACCEPT_RECORDS
      Accept flag for specifying records.
      Siehe auch:
    • ACCEPT_ANNOTATIONS

      public static final int ACCEPT_ANNOTATIONS
      Accept flag for specifying annotations.
      Siehe auch:
    • ACCEPT_ALL

      public static final int ACCEPT_ALL
      Siehe auch:
    • VERBOSE

      public static boolean VERBOSE
    • packageFragmentRoots

      protected IPackageFragmentRoot[] packageFragmentRoots
      The IPackageFragmentRoot's associated with the classpath of this NameLookup facility's project.
    • packageFragments

      protected HashtableOfArrayToObject 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

      protected Map<IPackageFragmentRoot,IClasspathEntry> rootToResolvedEntries
      Reverse map from root path to corresponding resolved CP entry (so as to be able to figure inclusion/exclusion rules)
    • rootToModule

      protected Map<IPackageFragmentRoot,IModuleDescription> rootToModule
    • typesInWorkingCopies

      protected HashMap 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

  • Methodendetails

    • acceptType

      protected boolean acceptType(IType type, int acceptFlags, boolean isSourceType)
      Returns true if:
      • the given type is an existing class and the flag's ACCEPT_CLASSES bit is on
      • the given type is an existing interface and the ACCEPT_INTERFACES bit is on
      • neither the ACCEPT_CLASSES or ACCEPT_INTERFACES bit is on
      Otherwise, false is returned.
    • findCompilationUnit

      public ICompilationUnit findCompilationUnit(String qualifiedTypeName)
      Returns the ICompilationUnit which defines the type named qualifiedTypeName, or null if none exists. The domain of the search is bounded by the classpath of the IJavaProject this NameLookup was obtained from.

      The name must be fully qualified (eg "java.lang.Object", "java.util.Hashtable$Entry")

    • findPackageFragment

      public IPackageFragment findPackageFragment(org.eclipse.core.runtime.IPath path)
      Returns the package fragment whose path matches the given (absolute) path, or null if none exist. The domain of the search is bounded by the classpath of the IJavaProject this NameLookup was obtained from. The path can be: - internal to the workbench: "/Project/src" - external to the workbench: "c:/jdk/classes.zip/java/lang"
    • findPackageFragments

      public IPackageFragment[] findPackageFragments(String name, boolean partialMatch)
      Returns the package fragments whose name matches the given (qualified) name, or null if none exist. The name can be:
      • empty: ""
      • qualified: "pack.pack1.pack2"
      Parameter:
      partialMatch - partial name matches qualify when true, only exact name matches qualify when false
    • findPackageFragments

      public IPackageFragment[] findPackageFragments(String name, boolean partialMatch, boolean patternMatch)
      Returns the package fragments whose name matches the given (qualified) name or pattern, or null if none exist. The name can be:
      • empty: ""
      • qualified: "pack.pack1.pack2"
      • a pattern: "pack.*.util"
      Parameter:
      partialMatch - partial name matches qualify when true,
      patternMatch - true when the given name might be a pattern, false otherwise.
    • findPackageFragementRoots

      public IPackageFragmentRoot[] findPackageFragementRoots(String[] splittedName)
      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:
      • "https://bugs.eclipse.org/bugs/show_bug.cgi?id=118789"
    • 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:
      • "https://bugs.eclipse.org/bugs/show_bug.cgi?id=118789"
    • 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

      public static IModule getModuleDescriptionInfo(IModuleDescription moduleDesc)
    • getModuleDescriptionInfo

      public IModule getModuleDescriptionInfo(PackageFragmentRoot root)
    • 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, or null if none exist. Specifying a null package 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 find
      pkg - the package to search
      partialMatch - partial name matches qualify when true, only exact name matches qualify when false
      acceptFlags - 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

      public IType findType(String name, IPackageFragment pkg, boolean partialMatch, int acceptFlags)
      Returns the first type in the given package whose name matches the given (unqualified) name, or null if none exist. Specifying a null package 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 find
      pkg - the package to search
      partialMatch - partial name matches qualify when true, only exact name matches qualify when false
      acceptFlags - 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 IType findType(String name, boolean partialMatch, int acceptFlags)
      Returns the type specified by the qualified name, or null if 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 find
      partialMatch - partial name matches qualify when true, only exact name matches qualify when false
      acceptFlags - 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

      public NameLookup.Answer findModule(char[] moduleName)
    • isPackage

      public boolean isPackage(String[] pkgName)
    • isPackage

      public boolean isPackage(String[] pkgName, IPackageFragmentRoot[] moduleContext)
    • nameMatches

      protected boolean nameMatches(String searchName, IJavaElement element, boolean partialMatch)
      Returns true if the given element's name matches the specified searchName, otherwise false.

      The partialMatch argument indicates partial matches should be considered. NOTE: in partialMatch mode, the case will be ignored, and the searchName must already have been lowercased.

    • nameMatches

      protected boolean nameMatches(String searchName, ICompilationUnit cu, boolean partialMatch)
      Returns true if the given cu's name matches the specified searchName, otherwise false.

      The partialMatch argument 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 the IJavaProject this NameLookup was obtained from.
      Parameter:
      partialMatch - partial name matches qualify when true; only exact name matches qualify when false
    • 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 the IJavaProject this NameLookup was obtained from.
      Parameter:
      partialMatch - partial name matches qualify when true; only exact name matches qualify when false
    • 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 the IJavaProject this NameLookup was obtained from.
      Parameter:
      partialMatch - partial name matches qualify when true; only exact name matches qualify when false
    • 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

      public void seekModule(char[] name, boolean prefixMatch, IJavaElementRequestor requestor)
    • 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 is null, all types in the project whose simple name matches the given name are found.
      Parameter:
      name - The name to search
      pkg - The corresponding package fragment
      partialMatch - partial name matches qualify when true; only exact name matches qualify when false
      acceptFlags - 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

      public boolean hasCompilationUnit(char[][] pkgName, IPackageFragmentRoot[] moduleContext)
    • printTimeSpent

      public void printTimeSpent()