|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
Scope.java | - | - | - | - |
|
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 java.util.Map; | |
7 | ||
8 | /** | |
9 | * Provides methods which all scopes must implement | |
10 | * <p/> | |
11 | * See JLS 6.3 for a description of scopes | |
12 | */ | |
13 | public interface Scope { | |
14 | ||
15 | /** | |
16 | * Returns a Map (VariableNameDeclaration->List(NameOccurrence,NameOccurrence)) of declarations that | |
17 | * exist at this scope | |
18 | */ | |
19 | Map getVariableDeclarations(); | |
20 | ||
21 | /** | |
22 | * Returns a Map (VariableNameDeclaration->List(NameOccurrence,NameOccurrence)) of declarations that | |
23 | * exist at this scope | |
24 | */ | |
25 | Map getClassDeclarations(); | |
26 | ||
27 | /** | |
28 | * Add a class declaration to this scope | |
29 | */ | |
30 | void addDeclaration(ClassNameDeclaration decl); | |
31 | ||
32 | /** | |
33 | * Add a variable declaration to this scope | |
34 | */ | |
35 | void addDeclaration(VariableNameDeclaration decl); | |
36 | ||
37 | /** | |
38 | * Add a method declaration to this scope | |
39 | */ | |
40 | void addDeclaration(MethodNameDeclaration decl); | |
41 | ||
42 | /** | |
43 | * Tests whether or not a NameOccurrence is directly contained in the scope | |
44 | * Note that this search is just for this scope - it doesn't go diving into any | |
45 | * child scopes. | |
46 | */ | |
47 | boolean contains(NameOccurrence occ); | |
48 | ||
49 | /** | |
50 | * Adds a NameOccurrence to this scope - only call this after getting | |
51 | * a true back from contains() | |
52 | */ | |
53 | NameDeclaration addVariableNameOccurrence(NameOccurrence occ); | |
54 | ||
55 | /** | |
56 | * Points this scope to its parent | |
57 | */ | |
58 | void setParent(Scope parent); | |
59 | ||
60 | /** | |
61 | * Retrieves this scope's parent | |
62 | */ | |
63 | Scope getParent(); | |
64 | ||
65 | /** | |
66 | * Goes searching up the tree for this scope's enclosing ClassScope | |
67 | * This is handy if you're buried down in a LocalScope and need to | |
68 | * hop up to the ClassScope to find a method name. | |
69 | */ | |
70 | ClassScope getEnclosingClassScope(); | |
71 | ||
72 | /** | |
73 | * Goes searching up the tree for this scope's enclosing SourceFileScope | |
74 | * This is handy if you're buried down in a LocalScope and need to | |
75 | * hop up to the SourceFileScope to find a class name. | |
76 | */ | |
77 | SourceFileScope getEnclosingSourceFileScope(); | |
78 | ||
79 | /** | |
80 | * Goes searching up the tree for this scope's enclosing SourceFileScope | |
81 | * This is handy if you're buried down in a LocalScope and need to | |
82 | * hop up to the MethodScope to find a method parameter. | |
83 | */ | |
84 | MethodScope getEnclosingMethodScope(); | |
85 | } |
|