net.sourceforge.pmd.symboltable
Class ClassScope

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

public class ClassScope
extends AbstractScope


Field Summary
protected  java.util.Map<ClassNameDeclaration,java.util.List<NameOccurrence>> classNames
           
protected  java.util.Map<MethodNameDeclaration,java.util.List<NameOccurrence>> methodNames
           
protected  java.util.Map<VariableNameDeclaration,java.util.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(java.lang.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)
           
 java.util.Map<ClassNameDeclaration,java.util.List<NameOccurrence>> getClassDeclarations()
          Returns a Map (VariableNameDeclaration->List(NameOccurrence,NameOccurrence)) of declarations that exist at this scope
 java.lang.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.
 java.util.Map<MethodNameDeclaration,java.util.List<NameOccurrence>> getMethodDeclarations()
           
 java.util.Map<VariableNameDeclaration,java.util.List<NameOccurrence>> getVariableDeclarations()
          Returns a Map (VariableNameDeclaration->List(NameOccurrence,NameOccurrence)) of declarations that exist at this scope
 java.lang.String toString()
           
 
Methods inherited from class net.sourceforge.pmd.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 java.util.Map<ClassNameDeclaration,java.util.List<NameOccurrence>> classNames

methodNames

protected java.util.Map<MethodNameDeclaration,java.util.List<NameOccurrence>> methodNames

variableNames

protected java.util.Map<VariableNameDeclaration,java.util.List<NameOccurrence>> variableNames
Constructor Detail

ClassScope

public ClassScope(java.lang.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 java.util.Map<VariableNameDeclaration,java.util.List<NameOccurrence>> getVariableDeclarations()
Description copied from interface: Scope
Returns a Map (VariableNameDeclaration->List(NameOccurrence,NameOccurrence)) of declarations that exist at this scope


getMethodDeclarations

public java.util.Map<MethodNameDeclaration,java.util.List<NameOccurrence>> getMethodDeclarations()

getClassDeclarations

public java.util.Map<ClassNameDeclaration,java.util.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 java.lang.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 java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2002-2011 InfoEther. All Rights Reserved.