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

java.lang.Object
  extended by net.sourceforge.pmd.lang.java.symboltable.AbstractScope
      extended by net.sourceforge.pmd.lang.java.symboltable.ClassScope
All Implemented Interfaces:
Scope

public class ClassScope
extends AbstractScope


Field Summary
protected  Map<ClassNameDeclaration,List<NameOccurrence>> classNames
           
protected  Map<MethodNameDeclaration,List<NameOccurrence>> methodNames
           
protected  Map<VariableNameDeclaration,List<NameOccurrence>> variableNames
           
 
Constructor Summary
ClassScope()
          This is only for anonymous inner classes

FIXME - should have name like Foo$1, not Anonymous$1 to get this working right, the parent scope needs to be passed in when instantiating a ClassScope

ClassScope(String className)
           
 
Method Summary
 void addDeclaration(ClassNameDeclaration decl)
          Add a class declaration to this scope
 void addDeclaration(MethodNameDeclaration decl)
          Add a method declaration to this scope
 void addDeclaration(VariableNameDeclaration variableDecl)
          Add a variable declaration to this scope
 NameDeclaration addVariableNameOccurrence(NameOccurrence occurrence)
          Adds a NameOccurrence to this scope - only call this after getting a true back from contains()
protected  NameDeclaration findVariableHere(NameOccurrence occurrence)
           
 Map<ClassNameDeclaration,List<NameOccurrence>> getClassDeclarations()
          Returns a Map (VariableNameDeclaration->List(NameOccurrence,NameOccurrence)) of declarations that exist at this scope
 String getClassName()
           
 ClassScope getEnclosingClassScope()
          Goes searching up the tree for this scope's enclosing ClassScope This is handy if you're buried down in a LocalScope and need to hop up to the ClassScope to find a method name.
 Map<MethodNameDeclaration,List<NameOccurrence>> getMethodDeclarations()
           
 Map<VariableNameDeclaration,List<NameOccurrence>> getVariableDeclarations()
          Returns a Map (VariableNameDeclaration->List(NameOccurrence,NameOccurrence)) of declarations that exist at this scope
 String toString()
           
 
Methods inherited from class net.sourceforge.pmd.lang.java.symboltable.AbstractScope
contains, getEnclosingMethodScope, getEnclosingSourceFileScope, getParent, glomNames, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

classNames

protected Map<ClassNameDeclaration,List<NameOccurrence>> classNames

methodNames

protected Map<MethodNameDeclaration,List<NameOccurrence>> methodNames

variableNames

protected Map<VariableNameDeclaration,List<NameOccurrence>> variableNames
Constructor Detail

ClassScope

public ClassScope(String className)

ClassScope

public ClassScope()
This is only for anonymous inner classes

FIXME - should have name like Foo$1, not Anonymous$1 to get this working right, the parent scope needs to be passed in when instantiating a ClassScope

Method Detail

addDeclaration

public void addDeclaration(VariableNameDeclaration variableDecl)
Description copied from interface: Scope
Add a variable declaration to this scope


addVariableNameOccurrence

public NameDeclaration addVariableNameOccurrence(NameOccurrence occurrence)
Description copied from interface: Scope
Adds a NameOccurrence to this scope - only call this after getting a true back from contains()


getVariableDeclarations

public Map<VariableNameDeclaration,List<NameOccurrence>> getVariableDeclarations()
Description copied from interface: Scope
Returns a Map (VariableNameDeclaration->List(NameOccurrence,NameOccurrence)) of declarations that exist at this scope


getMethodDeclarations

public Map<MethodNameDeclaration,List<NameOccurrence>> getMethodDeclarations()

getClassDeclarations

public Map<ClassNameDeclaration,List<NameOccurrence>> getClassDeclarations()
Description copied from interface: Scope
Returns a Map (VariableNameDeclaration->List(NameOccurrence,NameOccurrence)) of declarations that exist at this scope

Specified by:
getClassDeclarations in interface Scope
Overrides:
getClassDeclarations in class AbstractScope

getEnclosingClassScope

public ClassScope getEnclosingClassScope()
Description copied from interface: Scope
Goes searching up the tree for this scope's enclosing ClassScope This is handy if you're buried down in a LocalScope and need to hop up to the ClassScope to find a method name.

Specified by:
getEnclosingClassScope in interface Scope
Overrides:
getEnclosingClassScope in class AbstractScope

getClassName

public String getClassName()

addDeclaration

public void addDeclaration(MethodNameDeclaration decl)
Description copied from interface: Scope
Add a method declaration to this scope

Specified by:
addDeclaration in interface Scope
Overrides:
addDeclaration in class AbstractScope

addDeclaration

public void addDeclaration(ClassNameDeclaration decl)
Description copied from interface: Scope
Add a class declaration to this scope

Specified by:
addDeclaration in interface Scope
Overrides:
addDeclaration in class AbstractScope

findVariableHere

protected NameDeclaration findVariableHere(NameOccurrence occurrence)
Specified by:
findVariableHere in class AbstractScope

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2002-2012 InfoEther. All Rights Reserved.