View Javadoc

1   /***
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3   */
4   package net.sourceforge.pmd.symboltable;
5   
6   import net.sourceforge.pmd.util.Applier;
7   
8   public class LocalScope extends AbstractScope {
9   
10      public void addDeclaration(VariableNameDeclaration nameDecl) {
11          if (nameDecl.isExceptionBlockParameter()) {
12              // this declaration needs to go somewhere... should this be delegated to the next
13              // highest LocalScope?
14              return;
15          }
16          super.addDeclaration(nameDecl);
17      }
18  
19      public NameDeclaration findVariableHere(NameOccurrence occurrence) {
20          if (occurrence.isThisOrSuper()) {
21              return null;
22          }
23          ImageFinderFunction finder = new ImageFinderFunction(occurrence.getImage());
24          Applier.apply(finder, variableNames.keySet().iterator());
25          return finder.getDecl();
26      }
27  
28      public String toString() {
29          return "LocalScope:" + super.glomNames();
30      }
31  }