Class AbstractScope

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

@Deprecated public abstract class AbstractScope extends Object implements Scope
Deprecated.
Since 7.19.0. For more info, see net.sourceforge.pmd.lang.symboltable.
Base class for any Scope. Provides useful default implementations.
  • Constructor Details

    • AbstractScope

      public AbstractScope()
      Deprecated.
  • Method Details

    • getParent

      public Scope getParent()
      Deprecated.
      Description copied from interface: Scope
      Retrieves this scope's parent
      Specified by:
      getParent in interface Scope
    • setParent

      public void setParent(Scope parent)
      Deprecated.
      Description copied from interface: Scope
      Points this scope to its parent
      Specified by:
      setParent in interface Scope
    • getDeclarations

      public Map<NameDeclaration,List<NameOccurrence>> getDeclarations()
      Deprecated.
      Description copied from interface: Scope
      Gets all the declaration with the occurrences in this scope.
      Specified by:
      getDeclarations in interface Scope
      Returns:
      map of declarations with occurrences.
    • getDeclarations

      public <T extends NameDeclaration> Map<T,List<NameOccurrence>> getDeclarations(Class<T> clazz)
      Deprecated.
      Description copied from interface: Scope
      Helper method to get only a specific type of name declarations. The return map elements have already been casted to the correct type. This method usually returns a subset of Scope.getDeclarations().
      Specified by:
      getDeclarations in interface Scope
      Parameters:
      clazz - the type of name declarations to use
      Returns:
      map of declarations with occurrences.
    • contains

      public boolean contains(NameOccurrence occ)
      Deprecated.
      Description copied from interface: Scope
      Tests whether or not a NameOccurrence is directly contained in the scope. This means, whether the given NameOccurrence references a declaration, that has been declared within this scope. Note that this search is just for this scope - it doesn't go diving into any parent scopes.
      Specified by:
      contains in interface Scope
    • addDeclaration

      public void addDeclaration(NameDeclaration declaration)
      Deprecated.
      Description copied from interface: Scope
      Adds a new declaration to this scope. Only after the declaration has been added, Scope.contains(NameOccurrence) and Scope.addNameOccurrence(NameOccurrence) can be used correctly.
      Specified by:
      addDeclaration in interface Scope
      Parameters:
      declaration - the declaration to add
    • getEnclosingScope

      public <T extends Scope> T getEnclosingScope(Class<T> clazz)
      Deprecated.
      Description copied from interface: Scope
      Helper method that goes up the parent scopes to find a scope of the specified type
      Specified by:
      getEnclosingScope in interface Scope
      Parameters:
      clazz - the type of the Scope to search for
      Returns:
      the found scope of the specified type or null if no such scope was found.
    • addNameOccurrence

      public Set<NameDeclaration> addNameOccurrence(NameOccurrence occurrence)
      Deprecated.
      Description copied from interface: Scope
      Adds a NameOccurrence to this scope - only call this after getting a true back from Scope.contains(NameOccurrence).
      Specified by:
      addNameOccurrence in interface Scope
      Returns:
      the NameDeclarations that are referenced by the given NameOccurrence, if the NameOccurrence could be added. Otherwise an empty set is returned.