Skip to content

Commit f7cfa7b

Browse files
author
Chris
committed
.gitignore merge conflict resolution
2 parents fcd6c98 + 2dc71a2 commit f7cfa7b

31 files changed

+1381
-1268
lines changed

.classpath

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="ui"/>
4+
<classpathentry kind="src" path="ui refactoring"/>
5+
<classpathentry kind="src" path="core refactoring"/>
6+
<classpathentry kind="src" path="core extension"/>
7+
<classpathentry kind="src" output="bin-jar-in-jar-loader" path="jar in jar loader"/>
8+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
9+
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
10+
<classpathentry kind="output" path="bin"/>
11+
</classpath>

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ progNav Paper/progNav Paper.synctex.gz
77

88
#Eclipse
99
.project
10+

.project

Lines changed: 0 additions & 11 deletions
This file was deleted.

dataTool/.classpath

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
<classpath>
3-
<classpathentry kind="src" path="src">
4-
<attributes>
5-
<attribute name="ignore_optional_problems" value="true"/>
6-
</attributes>
7-
</classpathentry>
8-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
9-
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
10-
<classpathentry kind="src" path="src_tests"/>
11-
<classpathentry kind="output" path="bin"/>
12-
</classpath>
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
4+
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5+
<classpathentry kind="src" path="src">
6+
<attributes>
7+
<attribute name="ignore_optional_problems" value="true"/>
8+
</attributes>
9+
</classpathentry>
10+
<classpathentry kind="src" path="src_tests"/>
11+
<classpathentry kind="output" path="bin"/>
12+
</classpath>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
eclipse.preferences.version=1
2+
resolve.requirebundle=false

dataTool/META-INF/MANIFEST.MF

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ Require-Bundle: org.eclipse.ui,
2020
org.eclipse.jdt.ui,
2121
org.eclipse.ui.ide;bundle-version="3.11.0",
2222
org.eclipse.ui.ide.application;bundle-version="1.1.0",
23-
org.eclipse.text
23+
org.eclipse.text,
24+
org.eclipse.ui.forms,
25+
org.eclipse.jdt;bundle-version="3.11.1"
2426
Eclipse-LazyStart: true
2527
Import-Package: org.eclipse.jdt.internal.ui.search
28+
Export-Package: dataTool,
29+
dataTool.annotations,
30+
dataTool.ui
717 KB
Binary file not shown.
Lines changed: 160 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,166 +1,251 @@
11
package dataTool;
22

3+
import java.util.ArrayList;
4+
import java.util.HashSet;
5+
import java.util.Set;
6+
import java.util.TreeSet;
37

8+
import org.eclipse.jdt.core.IMethod;
49
import org.eclipse.jdt.core.JavaModelException;
510
import org.eclipse.jdt.core.dom.AST;
611
import org.eclipse.jdt.core.dom.ASTNode;
712
import org.eclipse.jdt.core.dom.ASTParser;
813
import org.eclipse.jdt.core.dom.CompilationUnit;
14+
import org.eclipse.jdt.core.dom.MethodDeclaration;
15+
import org.eclipse.jdt.core.dom.SimpleName;
16+
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
17+
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditorBreadcrumb;
18+
import org.eclipse.jdt.internal.ui.javaeditor.breadcrumb.EditorBreadcrumb;
19+
import org.eclipse.jdt.internal.ui.javaeditor.breadcrumb.IBreadcrumb;
20+
import org.eclipse.jface.action.Action;
921
import org.eclipse.jface.text.ITextSelection;
1022
import org.eclipse.jface.text.Position;
1123
import org.eclipse.jface.text.source.SourceViewer;
1224
import org.eclipse.jface.viewers.ISelectionChangedListener;
1325
import org.eclipse.jface.viewers.SelectionChangedEvent;
26+
import org.eclipse.ui.IEditorPart;
27+
import org.eclipse.ui.IWorkbenchPage;
28+
import org.eclipse.ui.PlatformUI;
1429
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditor;
1530
import org.eclipse.ui.texteditor.AbstractTextEditor;
1631

32+
import dataTool.annotations.LinkAnnotation;
1733
import dataTool.annotations.ProgramNavigationPainter;
1834
import dataTool.annotations.SuggestedSelectionAnnotation;
35+
import dataTool.ui.ShowDataInBreadcrumbAction;
1936
import edu.pdx.cs.multiview.jdt.util.JDTUtils;
2037
import edu.pdx.cs.multiview.jface.annotation.AnnTransaction;
2138
import edu.pdx.cs.multiview.jface.annotation.AnnotationPainter;
39+
import edu.pdx.cs.multiview.jface.annotation.ISelfDrawingAnnotation;
2240
import edu.pdx.cs.multiview.util.eclipse.EclipseHacks;
2341

2442
public class AnnotationManager implements ISelectionChangedListener {
25-
26-
private SuggestedSelectionAnnotation currentAnnotation = new SuggestedSelectionAnnotation();
27-
28-
private AnnotationPainter painter;
29-
30-
//the visitor for the editor
43+
44+
private SuggestedSelectionAnnotation highlightAnnotation = new SuggestedSelectionAnnotation();
45+
private LinkAnnotation linkAnnotation = new LinkAnnotation();
46+
private SourceViewer sourceViewer;
47+
private ProgramNavigationPainter painter;
48+
private static boolean isActive = false;
49+
private IBreadcrumb upBreadcrumb;
50+
private IBreadcrumb downBreadcrumb;
51+
52+
// the visitor for the editor
3153
private Visitor visitor;
3254

55+
public static String currentSearch = null;
56+
3357
/**
34-
* Creates an annotation manager given an editor, containing a
35-
* compilation unit, assumedly
58+
* Creates an annotation manager given an editor, containing a compilation
59+
* unit, assumedly
3660
*
3761
* @param anEditor
3862
*/
3963
public AnnotationManager(AbstractDecoratedTextEditor anEditor) {
40-
4164
parseCU(anEditor);
42-
43-
SourceViewer sourceViewer = EclipseHacks.getSourceViewer(anEditor);
65+
sourceViewer = EclipseHacks.getSourceViewer(anEditor);
4466
painter = new ProgramNavigationPainter(sourceViewer);
4567
painter.addSelectionChangedListener(this);
4668
sourceViewer.addPainter(painter);
47-
48-
selectionChanged((ITextSelection)painter.getSelection());
69+
selectionChanged((ITextSelection) painter.getSelection());
4970
}
5071

5172
public void selectionChanged(ITextSelection selection) {
5273
painter.removeAllAnnotations();
53-
try {
54-
55-
ASTNode one = getNode(selection.getOffset());
56-
57-
if(selection.getLength()==0){
58-
addAnnotation(one, one);
59-
return;
74+
try {
75+
DataNode one = getNode(selection.getOffset());
76+
Finder finder = Finder.getInstance();
77+
if(one != null) {
78+
addAnnotation(one);
79+
currentSearch = one.getBinding();
80+
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
81+
IEditorPart activeEditor = activePage.getActiveEditor();
82+
JavaEditor j = (JavaEditor) activeEditor;
83+
upBreadcrumb = j.getBreadcrumb();
84+
downBreadcrumb = j.getBreadcrumb2();
85+
if(!isActive) {
86+
isActive = true;
87+
upBreadcrumb.setText(null);
88+
downBreadcrumb.setText(null);
89+
ShowDataInBreadcrumbAction crumbs = new ShowDataInBreadcrumbAction(j, activePage);
90+
crumbs.run();
91+
}
92+
DataCallHierarchy call = new DataCallHierarchy();
93+
Set<IMethod> searchUp = null;
94+
Set<IMethod> searchDown = null;
95+
if((finder.upSearch(one) != null || finder.downSearch(one) != null || one.getInvocationMethod() != null) && currentSearch != null) {
96+
searchUp = call.searchProject(one, Finder.UP);
97+
searchDown = call.searchProject(one, Finder.DOWN);
98+
if(one.isParameterSelected(selection.getOffset())) {
99+
linkAnnotation.searchResultsDown = searchDown;
100+
linkAnnotation.searchResultsUp = searchUp;
101+
linkAnnotation.setDataNode(one);
102+
addLinkAnnotation(one);
103+
}
104+
}
105+
106+
//Adds all occurrences of data node off screen
107+
ArrayList<Object> textUp = new ArrayList<Object>();
108+
ArrayList<Object> textDown = new ArrayList<Object>();
109+
for(DataNode dn: finder.getOccurrences(one.getValue(), new Position(one.getStartPosition(), one.getLength()))) {
110+
int[] offScreen = new int[3];
111+
int line = sourceViewer.widgetLineOfWidgetOffset(dn.getStartPosition())+1;
112+
offScreen[0] = line;
113+
offScreen[1] = dn.getStartPosition();
114+
offScreen[2] = dn.getLength();
115+
if(dn.getStartPosition() < sourceViewer.getTopIndexStartOffset()) {
116+
textUp.add(offScreen);
117+
}
118+
else if(dn.getStartPosition() > sourceViewer.getBottomIndexEndOffset()) {
119+
textDown.add(offScreen);
120+
}
121+
}
122+
if(searchUp != null) {
123+
textUp.addAll(searchUp);
124+
((EditorBreadcrumb)upBreadcrumb).setSearchMethod(call.getCurrentMethod(one.getStartPosition()));
125+
}
126+
if(searchDown != null) {
127+
textDown.addAll(searchDown);
128+
}
129+
upBreadcrumb.setText(textUp);
130+
downBreadcrumb.setText(textDown);
60131
}
61-
62-
ASTNode two = getNode(selection.getOffset()+selection.getLength());
63-
64-
if(one!=null){
65-
if(!areSiblings(one,two))
66-
two = meet(one,two);
67-
68-
if(two!=null)
69-
addAnnotation(one, two);
70-
71-
}else{
132+
else {
72133
removeAnnotations();
73134
}
74-
75135
} catch (Exception e) {
76136
Activator.logError(e);
77137
removeAnnotations();
78-
}
138+
}
79139
}
140+
141+
private void addAnnotation(DataNode node) {
142+
int start = node.getStartPosition();
143+
int end = node.getStartPosition() + node.getLength();
80144

81-
private void addAnnotation(ASTNode one, ASTNode two) {
82-
int start = one.getStartPosition();
83-
int end = two.getStartPosition()+two.getLength();
84-
85-
if(!isAlreadyAnnotated(start, end))
86-
addAnnotationsAt(start, end-start);
145+
if (!isAlreadyAnnotated(start, end))
146+
addAnnotationsAt(start, end - start, true);
147+
}
148+
149+
private void addLinkAnnotation(DataNode node) {
150+
SimpleName method;
151+
if(node.getInvocationMethod() != null) {
152+
method = node.getInvocationMethod().getName();
153+
}
154+
else {
155+
method = node.getDeclarationMethod().getName();
156+
}
157+
int start = method.getStartPosition();
158+
int end = method.getStartPosition() + method.getLength();
159+
if(!isAlreadyAnnotated(start, end)) {
160+
addAnnotationsAt(start, end - start, false);
161+
}
87162
}
88163

89164
private boolean areSiblings(ASTNode one, ASTNode two) {
90-
165+
91166
return one.getParent().equals(two.getParent());
92167
}
93168

94169
private ASTNode meet(ASTNode from, ASTNode to) {
95170

96-
if(areSiblings(from,to))
171+
if (areSiblings(from, to))
97172
return to;
98-
99-
if(to.getParent()==null)
173+
174+
if (to.getParent() == null)
100175
return null;
101-
102-
return meet(from,to.getParent());
176+
177+
return meet(from, to.getParent());
103178
}
104179

105180
private boolean isAlreadyAnnotated(int start, int end) {
106-
107-
Position headPosition = painter.getPosition(currentAnnotation);
108-
109-
if(headPosition!=null)
110-
return headPosition.getOffset()==start &&
111-
headPosition.getOffset()+headPosition.getLength()==end;
112-
181+
182+
Position headPosition = painter.getPosition(highlightAnnotation);
183+
184+
if (headPosition != null)
185+
return headPosition.getOffset() == start && headPosition.getOffset() + headPosition.getLength() == end;
186+
113187
return false;
114188
}
115189

116-
private ASTNode getNode(int position) {
190+
private DataNode getNode(int position) {
117191
return visitor.statementAt(position);
118192
}
119-
120-
private void parseCU(AbstractTextEditor editor){
193+
194+
private void parseCU(AbstractTextEditor editor) {
121195
try {
122196
visitor = parse(JDTUtils.getCUSource(editor));
123197
} catch (JavaModelException e) {
124198
Activator.logError(e);
125199
}
126200
}
127-
128-
private static Visitor parse(String source) throws JavaModelException{
129-
201+
202+
private static Visitor parse(String source) throws JavaModelException {
203+
130204
ASTParser parser = ASTParser.newParser(AST.JLS3);
131205
parser.setSource(source.toCharArray());
132206
CompilationUnit astRoot = (CompilationUnit) parser.createAST(null);
133-
134-
Visitor visitor = new Visitor(source);
207+
208+
Visitor visitor = new Visitor(source);
135209
astRoot.accept(visitor);
136-
210+
137211
return visitor;
138212
}
139213

140-
private void addAnnotationsAt(int statementStart, int length) {
141-
214+
private void addAnnotationsAt(int statementStart, int length, boolean isHighlight) {
215+
142216
AnnTransaction anns = new AnnTransaction();
143-
anns.remove(currentAnnotation);
144-
anns.add(currentAnnotation, new Position(statementStart,length));
145-
217+
if(isHighlight) {
218+
anns.remove(highlightAnnotation);
219+
anns.add(highlightAnnotation, new Position(statementStart, length));
220+
}
221+
else {
222+
anns.remove(linkAnnotation);
223+
anns.add(linkAnnotation, new Position(statementStart, length));
224+
}
146225
painter.replaceAnnotations(anns);
147226
}
148-
149-
public void removeAnnotations(){
150-
try{
151-
if(currentAnnotation!=null){
152-
//painter.removeAnnotation(currentAnnotation);
227+
228+
public void removeAnnotations() {
229+
try {
230+
if (highlightAnnotation != null) {
153231
painter.removeAllAnnotations();
154232
}
155-
}catch(Exception ignore){}
233+
} catch (Exception ignore) {
234+
}
156235
}
157-
236+
158237
public void dispose() {
159238
painter.dispose();
239+
currentSearch = null;
240+
}
241+
242+
public void deactivate() {
243+
isActive = false;
244+
upBreadcrumb.dispose();
245+
downBreadcrumb.dispose();
160246
}
161247

162248
public void selectionChanged(SelectionChangedEvent event) {
163-
painter.removeAllAnnotations();
164-
selectionChanged((ITextSelection)event.getSelection());
249+
selectionChanged((ITextSelection) event.getSelection());
165250
}
166251
}

0 commit comments

Comments
 (0)