net.sourceforge.pmd.lang.java.symboltable
Class SourceFileScope

java.lang.Object
  extended by net.sourceforge.pmd.lang.symboltable.AbstractScope
      extended by net.sourceforge.pmd.lang.java.symboltable.AbstractJavaScope
          extended by net.sourceforge.pmd.lang.java.symboltable.SourceFileScope
All Implemented Interfaces:
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
SourceFileScope()
           
SourceFileScope(String packageImage)
           
 
Method Summary
 void addDeclaration(NameDeclaration declaration)
          
 void configureImports(ClassLoader classLoader, List<ASTImportDeclaration> imports)
          Configures the type resolution for the symbol table.
 ClassNameDeclaration findClassNameDeclaration(String name)
           
protected  NameDeclaration findVariableHere(JavaNameOccurrence occ)
           
 Map<ClassNameDeclaration,List<NameOccurrence>> getClassDeclarations()
          Convenience method that casts the declarations to ClassNameDeclarations.
 Set<String> getExplicitImports()
           
 String getPackageName()
           
 Map<String,Node> getQualifiedTypeNames()
          Returns a set of all types defined within this source file.
 boolean hasAuxclasspath()
          Whether an auxclasspath has been configured or not.
 Class<?> resolveType(String name)
          Tries to resolve a class by name.
 String toString()
           
 
Methods inherited from class net.sourceforge.pmd.lang.java.symboltable.AbstractJavaScope
checkForDuplicatedNameDeclaration, contains, glomNames
 
Methods inherited from class net.sourceforge.pmd.lang.symboltable.AbstractScope
addNameOccurrence, getDeclarations, getDeclarations, getEnclosingScope, getParent, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SourceFileScope

public SourceFileScope()

SourceFileScope

public SourceFileScope(String packageImage)
Method Detail

configureImports

public void configureImports(ClassLoader classLoader,
                             List<ASTImportDeclaration> imports)
Configures the type resolution for the symbol table.

Parameters:
classLoader - the class loader to use to find additional classes
imports - the import declarations

getExplicitImports

public Set<String> getExplicitImports()

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:
true if 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 null if no class could be found

getPackageName

public String getPackageName()

addDeclaration

public void addDeclaration(NameDeclaration declaration)

Specified by:
addDeclaration in interface Scope
Overrides:
addDeclaration in class AbstractJavaScope
Throws:
IllegalArgumentException - if declaration is not a ClassNameDeclaration

getClassDeclarations

public Map<ClassNameDeclaration,List<NameOccurrence>> getClassDeclarations()
Convenience method that casts the declarations to ClassNameDeclarations.

Returns:
all class name declarations
See Also:
AbstractScope.getDeclarations()

toString

public String toString()
Overrides:
toString in class Object

findClassNameDeclaration

public ClassNameDeclaration findClassNameDeclaration(String name)

findVariableHere

protected NameDeclaration findVariableHere(JavaNameOccurrence occ)
Specified by:
findVariableHere in class AbstractJavaScope

getQualifiedTypeNames

public Map<String,Node> getQualifiedTypeNames()
Returns a set of all types defined within this source file. This includes all top-level types and nested types.

Returns:
set of all types in this source file.


Copyright © 2002-2016 InfoEther. All Rights Reserved.