Skip to content

Commit 7ecf81c

Browse files
committed
Resolved issue #18 again. Switching over to a key-based system.
1 parent 333d750 commit 7ecf81c

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

dataTool/src/dataTool/DataNode.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class DataNode implements Comparable {
2323
final public static String VAR = "variable";
2424

2525
private String binding;
26+
private String key;
2627
private String value;
2728
private int index;
2829
private int length;
@@ -61,6 +62,7 @@ public DataNode( SimpleName sn ) {
6162
length = value.length();
6263
isHighlighted = false;
6364
parameterIndex = -1;
65+
this.key = sn.resolveBinding().getKey();
6466
this.binding = sn.resolveBinding().toString();
6567
}
6668
public void setStartPosition( int i ) {
@@ -127,7 +129,9 @@ public boolean isParameterSelected(int pos) {
127129
}
128130
return true;
129131
}
130-
132+
public String getKey() {
133+
return key;
134+
}
131135
@Override
132136
public int compareTo(Object o) {
133137
if( o == null || !( o instanceof DataNode ) ) {

dataTool/src/dataTool/Finder.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ private boolean isComment(String var, int index, String sourceCode) {
179179
public TreeSet<DataNode> getOccurrences(String s, Position p) {
180180
TreeSet<DataNode> returnList = new TreeSet<DataNode>();
181181
String binding = null;
182+
String bindingKey = null;
182183
String key = null;
183184

184185
for (Entry<String, TreeSet<DataNode>> entry : map.entrySet()) {
@@ -193,14 +194,15 @@ public TreeSet<DataNode> getOccurrences(String s, Position p) {
193194
if (dn.getStartPosition() == p.offset) {
194195
foundNode = dn;
195196
binding = dn.getBinding();
197+
bindingKey = dn.getKey();
196198
break;
197199
}
198200
}
199201
list = entry.getValue();
200202
for (DataNode dn : list) {
201203
// TODO distinguish between class and local variables of
202204
// same name
203-
if (dn.getBinding().equals(binding)) {
205+
if (dn.getKey().equals(bindingKey)) {
204206
returnList.add(dn);
205207
}
206208
}
@@ -210,14 +212,15 @@ public TreeSet<DataNode> getOccurrences(String s, Position p) {
210212
for (DataNode dn : list) {
211213
if (dn.getStartPosition() == p.offset) {
212214
binding = dn.getBinding();
215+
bindingKey = dn.getKey();
213216
break;
214217
}
215218
}
216219
list = entry.getValue();
217220
for (DataNode dn : list) {
218221
// TODO distinguish between class and local variables of
219222
// same name
220-
if (dn.getBinding().equals(binding)) {
223+
if (dn.getKey().equals(bindingKey)) {
221224
returnList.add(dn);
222225
}
223226
}

dataTool/src/dataTool/Visitor.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,10 @@ public void parseData() {
143143
public boolean visit( SimpleName sn ) {
144144
if( sn.resolveTypeBinding() != null ) {
145145
// Add the node to the list
146-
getNodeFromName( sn );
146+
String binding = sn.resolveBinding().toString();
147+
if( !binding.contains("(") && !binding.contains("class") && !binding.contains("interface")){
148+
getNodeFromName( sn );
149+
}
147150
}
148151
return true;
149152
}

0 commit comments

Comments
 (0)