View Javadoc

    1   /**
    2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
    3    */
    4   package net.sourceforge.pmd.lang.java.symboltable;
    5
    6   import java.util.HashMap;
    7   import java.util.List;
    8   import java.util.Map;
    9
    10  import net.sourceforge.pmd.util.UnaryFunction;
    11
    12  public class VariableUsageFinderFunction implements UnaryFunction<VariableNameDeclaration> {
    13
    14      private Map<VariableNameDeclaration, List<NameOccurrence>> results = new HashMap<VariableNameDeclaration, List<NameOccurrence>>();
    15
    16      private Map<VariableNameDeclaration, List<NameOccurrence>> decls;
    17
    18      public VariableUsageFinderFunction(Map<VariableNameDeclaration, List<NameOccurrence>> decls) {
    19          this.decls = decls;
    20      }
    21
    22      public void applyTo(VariableNameDeclaration o) {
    23          results.put(o, decls.get(o));
    24      }
    25
    26      public Map<VariableNameDeclaration, List<NameOccurrence>> getUsed() {
    27          return results;
    28      }
    29  }