DummyScope.java
01 package net.sourceforge.pmd.lang.java.symboltable;
02 
03 import java.util.Collections;
04 import java.util.List;
05 import java.util.Map;
06 
07 /**
08  * Implementation of Scope for source types that are simpler than java sources.
09  * It implements the methods only when necessary not to break at runtime
10  * when Violations are handled.
11  *
12  @author pieter_van_raemdonck - Application Engineers NV/SA - www.ae.be
13  */
14 public class DummyScope implements Scope {
15 
16     private Scope parent;
17 
18     public Map<VariableNameDeclaration, List<NameOccurrence>> getVariableDeclarations() {
19         return Collections.emptyMap();
20     }
21 
22     public Map<ClassNameDeclaration, List<NameOccurrence>> getClassDeclarations() {
23         return Collections.emptyMap();
24     }
25 
26     public void addDeclaration(ClassNameDeclaration decl) {
27     }
28 
29     public void addDeclaration(VariableNameDeclaration decl) {
30     }
31 
32     public void addDeclaration(MethodNameDeclaration decl) {
33     }
34 
35     public boolean contains(NameOccurrence occ) {
36         return false;
37     }
38 
39     public NameDeclaration addVariableNameOccurrence(NameOccurrence occ) {
40         return null;
41     }
42 
43     public void setParent(Scope parent) {
44         this.parent = parent;
45     }
46 
47     public Scope getParent() {
48         return parent;
49     }
50 
51     public ClassScope getEnclosingClassScope() {
52         return new ClassScope();
53     }
54 
55     public SourceFileScope getEnclosingSourceFileScope() {
56         return new SourceFileScope();
57     }
58 
59     public MethodScope getEnclosingMethodScope() {
60         return null;
61     }
62 
63 }