Skip to content

Commit 66226e6

Browse files
author
Chris
committed
More updates to fix switching between files and fixed a bug in down search when method is invoked in the same class.
1 parent ce919d0 commit 66226e6

2 files changed

Lines changed: 21 additions & 10 deletions

File tree

dataTool/src/dataTool/AnnotationManager.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ public class AnnotationManager implements ISelectionChangedListener {
6161
* @param anEditor
6262
*/
6363
public AnnotationManager(AbstractDecoratedTextEditor anEditor) {
64-
isActive = false;
6564
parseCU(anEditor);
6665
sourceViewer = EclipseHacks.getSourceViewer(anEditor);
6766
painter = new ProgramNavigationPainter(sourceViewer);
@@ -90,8 +89,6 @@ public void selectionChanged(ITextSelection selection) {
9089
ShowDataInBreadcrumbAction crumbs = new ShowDataInBreadcrumbAction(j, activePage);
9190
crumbs.run();
9291
}
93-
upBreadcrumb.setText(null);
94-
downBreadcrumb.setText(null);
9592
DataCallHierarchy call = new DataCallHierarchy();
9693
Set<IMethod> searchUp = null;
9794
Set<IMethod> searchDown = null;
@@ -105,8 +102,7 @@ public void selectionChanged(ITextSelection selection) {
105102
addLinkAnnotation(one);
106103
}
107104
}
108-
Set<String> test = new HashSet<String>();
109-
test.add(one.getValue());
105+
110106
//Adds all occurrences of data node off screen
111107
ArrayList<Object> textUp = new ArrayList<Object>();
112108
ArrayList<Object> textDown = new ArrayList<Object>();
@@ -242,6 +238,12 @@ public void dispose() {
242238
painter.dispose();
243239
currentSearch = null;
244240
}
241+
242+
public void deactivate() {
243+
isActive = false;
244+
upBreadcrumb.dispose();
245+
downBreadcrumb.dispose();
246+
}
245247

246248
public void selectionChanged(SelectionChangedEvent event) {
247249
selectionChanged((ITextSelection) event.getSelection());

dataTool/src/dataTool/DataCallHierarchy.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public class DataCallHierarchy {
6464
private String className;
6565
private String location;
6666
private ICompilationUnit cUnit;
67+
private boolean inClass = false;
6768

6869
public DataCallHierarchy() {
6970

@@ -95,7 +96,9 @@ else if (direction.equals(Finder.DOWN)) {
9596
if( node.getInvocationMethod() != null ) {
9697
Set<IMethod> searchDown = new HashSet<IMethod>();
9798
Set<IMethod> temp = search(node, node.getInvocationMethod(), Finder.DOWN);
99+
System.out.println(down);
98100
for(IMethod i: temp) {
101+
System.out.println(" "+i.getElementName());
99102
if(down.contains(i.getElementName())) {
100103
searchDown.add(i);
101104
}
@@ -150,10 +153,15 @@ public Set<IMethod> search(DataNode node, Method methodName, String direction) t
150153
methods = callGen.getCallersOf(m);
151154
}
152155
else {
153-
Set<IMethod> temp = callGen.getCalleesOf(m);
154-
for(IMethod i: temp) {
155-
methods.add(i);
156-
}
156+
if(!inClass) {
157+
Set<IMethod> temp = callGen.getCalleesOf(m);
158+
for(IMethod i: temp) {
159+
methods.add(i);
160+
}
161+
}
162+
else {
163+
methods.add(m);
164+
}
157165
}
158166
return methods;
159167
}
@@ -174,6 +182,7 @@ private IMethod findMethod(IType type, String methodName) throws JavaModelExcept
174182
{
175183
IMethod imethod = methods[i];
176184
if (imethod.getElementName().equals(methodName)) {
185+
inClass = true;
177186
theMethod = imethod;
178187
}
179188
}
@@ -200,7 +209,7 @@ public IMethod getCurrentMethod(int offset) {
200209
try {
201210
selected = ((ICompilationUnit) elem).getElementAt(offset);
202211
} catch (JavaModelException e) {
203-
// TODO Auto-generated catch block
212+
// Auto-generated catch block
204213
e.printStackTrace();
205214
}
206215
if (selected != null && selected.getElementType() == IJavaElement.METHOD) {

0 commit comments

Comments
 (0)