Class SourceFileScope
- java.lang.Object
-
- net.sourceforge.pmd.lang.symboltable.AbstractScope
-
- net.sourceforge.pmd.lang.java.symboltable.AbstractJavaScope
-
- net.sourceforge.pmd.lang.java.symboltable.SourceFileScope
-
- All Implemented Interfaces:
net.sourceforge.pmd.lang.symboltable.Scope
public class SourceFileScope extends AbstractJavaScope
This scope is the outer most scope of a Java file. A Source File can contain one ore more classes.
-
-
Constructor Summary
Constructors Constructor Description SourceFileScope(ClassLoader classLoader)SourceFileScope(ClassLoader classLoader, String packageImage)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDeclaration(net.sourceforge.pmd.lang.symboltable.NameDeclaration declaration)voidconfigureImports(List<ASTImportDeclaration> imports)Configures the type resolution for the symbol table.ClassNameDeclarationfindClassNameDeclaration(String name)protected Set<net.sourceforge.pmd.lang.symboltable.NameDeclaration>findVariableHere(JavaNameOccurrence occ)Map<ClassNameDeclaration,List<net.sourceforge.pmd.lang.symboltable.NameOccurrence>>getClassDeclarations()Convenience method that casts the declarations toClassNameDeclarations.Set<String>getExplicitImports()StringgetPackageName()Map<String,net.sourceforge.pmd.lang.ast.Node>getQualifiedTypeNames()Returns a set of all types defined within this source file.booleanhasAuxclasspath()Whether an auxclasspath has been configured or not.Class<?>resolveType(String name)Tries to resolve a class by name.StringtoString()-
Methods inherited from class net.sourceforge.pmd.lang.java.symboltable.AbstractJavaScope
checkForDuplicatedNameDeclaration, contains, glomNames
-
-
-
-
Constructor Detail
-
SourceFileScope
public SourceFileScope(ClassLoader classLoader)
-
SourceFileScope
public SourceFileScope(ClassLoader classLoader, String packageImage)
-
-
Method Detail
-
configureImports
public void configureImports(List<ASTImportDeclaration> imports)
Configures the type resolution for the symbol table.- Parameters:
imports- the import declarations
-
hasAuxclasspath
public boolean hasAuxclasspath()
Whether an auxclasspath has been configured or not. This can be used to enable/disable more detailed symbol table analysis and type resolution can be used - or to fall back to more simple implementation.- Returns:
trueif the auxclasspath is configured and types can be resolved reliably.- See Also:
resolveType(String)
-
resolveType
public Class<?> resolveType(String name)
Tries to resolve a class by name.- Parameters:
name- the name of the class- Returns:
- the class or
nullif no class could be found
-
getPackageName
public String getPackageName()
-
addDeclaration
public void addDeclaration(net.sourceforge.pmd.lang.symboltable.NameDeclaration declaration)
- Specified by:
addDeclarationin interfacenet.sourceforge.pmd.lang.symboltable.Scope- Overrides:
addDeclarationin classAbstractJavaScope- Throws:
IllegalArgumentException- if declaration is not aClassNameDeclaration
-
getClassDeclarations
public Map<ClassNameDeclaration,List<net.sourceforge.pmd.lang.symboltable.NameOccurrence>> getClassDeclarations()
Convenience method that casts the declarations toClassNameDeclarations.- Returns:
- all class name declarations
- See Also:
AbstractScope.getDeclarations()
-
findClassNameDeclaration
public ClassNameDeclaration findClassNameDeclaration(String name)
-
findVariableHere
protected Set<net.sourceforge.pmd.lang.symboltable.NameDeclaration> findVariableHere(JavaNameOccurrence occ)
- Specified by:
findVariableHerein classAbstractJavaScope
-
-