net.sourceforge.pmd.lang.java.symboltable

## Class MethodScope

- java.lang.Object
- - net.sourceforge.pmd.lang.java.symboltable.AbstractScope
  - - net.sourceforge.pmd.lang.java.symboltable.MethodScope

All Implemented Interfaces:
  Scope

    public class MethodScope
    extends AbstractScope

### Field Summary

Fields
`protected Map<VariableNameDeclaration,List<NameOccurrence>>` `variableNames`

### Constructor Summary

Constructors
Constructor and Description
`MethodScope(Node node)`

### Method Summary

Methods
`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()
`NameDeclaration` `findVariableHere(NameOccurrence occurrence)`
`MethodScope` `getEnclosingMethodScope()` Goes searching up the tree for this scope's enclosing MethodScope This is handy if you're buried down in a LocalScope and need to hop up to the MethodScope to find a method parameter.
`String` `getName()`
`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

`addDeclaration, addDeclaration, contains, getClassDeclarations, getEnclosingClassScope, getEnclosingSourceFileScope, getParent, glomNames, setParent`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### variableNames

    protected Map<VariableNameDeclaration,List<NameOccurrence>> variableNames

### Constructor Detail

#### MethodScope

    public MethodScope(Node node)

### Method Detail

#### getEnclosingMethodScope

    public MethodScope getEnclosingMethodScope()

Description copied from interface: `Scope`
Goes searching up the tree for this scope's enclosing MethodScope This is handy if you're buried down in a LocalScope and need to hop up to the MethodScope to find a method parameter.

Specified by:
  `getEnclosingMethodScope` in interface `Scope`
Overrides:
  `getEnclosingMethodScope` in class `AbstractScope`

#### 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

#### 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()

#### addDeclaration

    public void addDeclaration(VariableNameDeclaration variableDecl)

Description copied from interface: `Scope`
Add a variable declaration to this scope

#### findVariableHere

    public NameDeclaration findVariableHere(NameOccurrence occurrence)

Specified by:
  `findVariableHere` in class `AbstractScope`

#### getName

    public String getName()

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`