1 |
| |
2 |
| |
3 |
| |
4 |
| package net.sourceforge.pmd.symboltable; |
5 |
| |
6 |
| import java.util.Iterator; |
7 |
| import java.util.Map; |
8 |
| |
9 |
| public abstract class AbstractScope implements Scope { |
10 |
| |
11 |
| private Scope parent; |
12 |
| |
13 |
0
| public Map getClassDeclarations() {
|
14 |
0
| throw new RuntimeException("AbstractScope.getClassDeclarations() was invoked. That shouldn't happen... bug.");
|
15 |
| } |
16 |
| |
17 |
408
| public MethodScope getEnclosingMethodScope() {
|
18 |
408
| return parent.getEnclosingMethodScope();
|
19 |
| } |
20 |
| |
21 |
3182
| public ClassScope getEnclosingClassScope() {
|
22 |
3182
| return parent.getEnclosingClassScope();
|
23 |
| } |
24 |
| |
25 |
2574
| public SourceFileScope getEnclosingSourceFileScope() {
|
26 |
2574
| return parent.getEnclosingSourceFileScope();
|
27 |
| } |
28 |
| |
29 |
4023
| public void setParent(Scope parent) {
|
30 |
4023
| this.parent = parent;
|
31 |
| } |
32 |
| |
33 |
7229
| public Scope getParent() {
|
34 |
7229
| return parent;
|
35 |
| } |
36 |
| |
37 |
0
| public void addDeclaration(MethodNameDeclaration methodDecl) {
|
38 |
0
| parent.addDeclaration(methodDecl);
|
39 |
| } |
40 |
| |
41 |
6
| public void addDeclaration(ClassNameDeclaration classDecl) {
|
42 |
6
| parent.addDeclaration(classDecl);
|
43 |
| } |
44 |
| |
45 |
7035
| public boolean contains(NameOccurrence occurrence) {
|
46 |
7035
| return findVariableHere(occurrence) != null;
|
47 |
| } |
48 |
| |
49 |
| protected abstract NameDeclaration findVariableHere(NameOccurrence occurrence); |
50 |
| |
51 |
0
| protected String glomNames(Iterator i) {
|
52 |
0
| StringBuffer result = new StringBuffer();
|
53 |
0
| while (i.hasNext()) {
|
54 |
0
| result.append(i.next().toString());
|
55 |
0
| result.append(",");
|
56 |
| } |
57 |
0
| return result.length() == 0 ? "" : result.toString().substring(0, result.length() - 1);
|
58 |
| } |
59 |
| |
60 |
| } |