@@ -36,7 +36,7 @@ public class VariableVisitor extends ASTVisitor {
36
36
private final Set <Method > targetMethods ;
37
37
38
38
private Set <Variable > variableSet = new HashSet <>(); // all element defined in this project file
39
- private Map <Integer , Statement > variableInFile = new TreeMap <>();
39
+ private Map <Integer , Statement > varStatMap = new TreeMap <>();
40
40
41
41
public VariableVisitor (String file ,
42
42
String packageName ,
@@ -97,11 +97,14 @@ public boolean visit(MethodDeclaration node) {
97
97
98
98
@ Override
99
99
public boolean visit (SimpleName node ) {
100
+ // TODO xyz the statement of "return this;" and "return null" can not be visited
101
+ // return statement directly control dependence on the method it belongs.
102
+
100
103
IBinding binding = node .resolveBinding ();
101
104
if (binding instanceof IVariableBinding ) {
102
105
IVariableBinding iVariableBinding = (IVariableBinding ) binding ;
103
106
Variable variable = genVariable (node , iVariableBinding );
104
- addVariable (AstUtils .getStartLine (node ), variable , node );
107
+ addVariable (AstUtils .getStartLine (node ), variable );
105
108
106
109
variableSet .add (variable );
107
110
}
@@ -111,20 +114,24 @@ public boolean visit(SimpleName node) {
111
114
112
115
// private methods
113
116
private void addVariable (Integer lineNum ,
114
- Variable variable ,
115
- SimpleName node ) {
117
+ Variable variable ) {
118
+
119
+ if ("/home/piggy/work/mirror/mirror-common/src/main/java/cn/com/mirror/project/unit/element/Method.java"
120
+ .equals (variable .getFile ()) && (lineNum == 49 || lineNum == 51 )) {
121
+ log .debug ("a;lsjd;lfjsajdlfjalsjd;lf" );
122
+ }
116
123
117
- if (!variableInFile .containsKey (lineNum )) {
124
+ if (!varStatMap .containsKey (lineNum )) {
118
125
Statement statement = new Statement (this .file ,
119
126
lineNum ,
120
127
lineNum ,
121
128
FileUtils .listCodeLines (this .file ).get (lineNum - 1 ),
122
129
this .packageName );
123
130
124
131
statement .addVariable (variable );
125
- variableInFile .put (lineNum , statement );
132
+ varStatMap .put (lineNum , statement );
126
133
} else {
127
- variableInFile .get (lineNum ).addVariable (variable );
134
+ varStatMap .get (lineNum ).addVariable (variable );
128
135
}
129
136
}
130
137
0 commit comments