Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Schindl2015-01-21 07:47:18 +0000
committerTom Schindl2015-01-21 07:47:18 +0000
commitcbb47e3ca2920685294557f20b5f6bf9a4363b70 (patch)
treec09bf1459d957fabd2e876a165c4bbd88590f6ce
parentae0d1bec58bad6caf361d8554f66abcc5ac3bdae (diff)
downloadorg.eclipse.efxclipse-cbb47e3ca2920685294557f20b5f6bf9a4363b70.tar.gz
org.eclipse.efxclipse-cbb47e3ca2920685294557f20b5f6bf9a4363b70.tar.xz
org.eclipse.efxclipse-cbb47e3ca2920685294557f20b5f6bf9a4363b70.zip
make outline navigateable in both directions
-rw-r--r--experimental/compensator/org.eclipse.fx.code.compensator.editor/src/org/eclipse/fx/code/compensator/editor/Outline.java3
-rw-r--r--experimental/compensator/org.eclipse.fx.code.compensator.jdt/src/org/eclipse/fx/code/compensator/jdt/JDTOutlineFactory.java17
-rw-r--r--experimental/compensator/org.eclipse.fx.code.compensator.nashorn.qx/src/org/eclipse/fx/code/compensator/nashorn/qx/QxOutlineExtension.java22
-rw-r--r--experimental/compensator/org.eclipse.fx.code.compensator.nashorn/src/org/eclipse/fx/code/compensator/nashorn/JSOutline.java8
-rw-r--r--experimental/compensator/org.eclipse.fx.code.compensator.nashorn/src/org/eclipse/fx/code/compensator/nashorn/JSOutlineItem.java9
5 files changed, 36 insertions, 23 deletions
diff --git a/experimental/compensator/org.eclipse.fx.code.compensator.editor/src/org/eclipse/fx/code/compensator/editor/Outline.java b/experimental/compensator/org.eclipse.fx.code.compensator.editor/src/org/eclipse/fx/code/compensator/editor/Outline.java
index 28dadfffe..65883601f 100644
--- a/experimental/compensator/org.eclipse.fx.code.compensator.editor/src/org/eclipse/fx/code/compensator/editor/Outline.java
+++ b/experimental/compensator/org.eclipse.fx.code.compensator.editor/src/org/eclipse/fx/code/compensator/editor/Outline.java
@@ -10,8 +10,6 @@
*******************************************************************************/
package org.eclipse.fx.code.compensator.editor;
-import java.util.List;
-
import javafx.collections.ObservableList;
import javafx.scene.Node;
@@ -21,6 +19,7 @@ public interface Outline {
public interface OutlineItem {
public CharSequence getLabel();
public Node getGraphic();
+ public OutlineItem getParent();
public ObservableList<OutlineItem> getChildren();
}
}
diff --git a/experimental/compensator/org.eclipse.fx.code.compensator.jdt/src/org/eclipse/fx/code/compensator/jdt/JDTOutlineFactory.java b/experimental/compensator/org.eclipse.fx.code.compensator.jdt/src/org/eclipse/fx/code/compensator/jdt/JDTOutlineFactory.java
index 656b01748..acfd22065 100644
--- a/experimental/compensator/org.eclipse.fx.code.compensator.jdt/src/org/eclipse/fx/code/compensator/jdt/JDTOutlineFactory.java
+++ b/experimental/compensator/org.eclipse.fx.code.compensator.jdt/src/org/eclipse/fx/code/compensator/jdt/JDTOutlineFactory.java
@@ -80,7 +80,7 @@ public class JDTOutlineFactory implements OutlineFactory {
ASTNode cu = parser.createAST(null);
Stack<OutlineItem> i = new Stack<>();
- i.push(new JavaOutlineItem(graphicsLoader,"<root>",Type.UNKNOWN,0));
+ i.push(new JavaOutlineItem(null,graphicsLoader,"<root>",Type.UNKNOWN,0));
cu.accept(new ASTVisitor() {
@@ -88,7 +88,7 @@ public class JDTOutlineFactory implements OutlineFactory {
public boolean visit(TypeDeclaration node) {
StyledString s = new StyledString();
s.getSegmentList().add(new StyledStringSegment(node.getName().getFullyQualifiedName(),"java-element-name"));
- OutlineItem o = new JavaOutlineItem(graphicsLoader,s, Type.CLASS, node.getModifiers());
+ OutlineItem o = new JavaOutlineItem(i.peek(),graphicsLoader,s, Type.CLASS, node.getModifiers());
i.peek().getChildren().add(o);
i.push(o);
@@ -112,7 +112,7 @@ public class JDTOutlineFactory implements OutlineFactory {
StyledString s = new StyledString();
s.getSegmentList().add(new StyledStringSegment(vdf.getName().getFullyQualifiedName(),"java-element-name"));
s.getSegmentList().add(new StyledStringSegment(" : " + type, "java-type-info"));
- i.peek().getChildren().add(new JavaOutlineItem(graphicsLoader,s, Type.FIELD,node.getModifiers()));
+ i.peek().getChildren().add(new JavaOutlineItem(i.peek(),graphicsLoader,s, Type.FIELD,node.getModifiers()));
}
}
return super.visit(node);
@@ -139,7 +139,7 @@ public class JDTOutlineFactory implements OutlineFactory {
s.getSegmentList().add(new StyledStringSegment(b.toString(),"java-element-name"));
s.getSegmentList().add(new StyledStringSegment(" : " + type, "java-type-info"));
- i.peek().getChildren().add(new JavaOutlineItem(graphicsLoader,s, Type.METHOD, node.getModifiers()));
+ i.peek().getChildren().add(new JavaOutlineItem(i.peek(),graphicsLoader,s, Type.METHOD, node.getModifiers()));
return super.visit(node);
}
@@ -155,8 +155,10 @@ public class JDTOutlineFactory implements OutlineFactory {
private final int flags;
private final Type type;
private final GraphicsLoader loader;
+ private final OutlineItem parent;
- public JavaOutlineItem(GraphicsLoader loader, CharSequence label, Type type, int flags) {
+ public JavaOutlineItem(OutlineItem parent, GraphicsLoader loader, CharSequence label, Type type, int flags) {
+ this.parent = parent;
this.loader = loader;
this.label = label;
this.type = type;
@@ -169,6 +171,11 @@ public class JDTOutlineFactory implements OutlineFactory {
}
@Override
+ public OutlineItem getParent() {
+ return parent;
+ }
+
+ @Override
public Node getGraphic() {
URI baseImage = null;
diff --git a/experimental/compensator/org.eclipse.fx.code.compensator.nashorn.qx/src/org/eclipse/fx/code/compensator/nashorn/qx/QxOutlineExtension.java b/experimental/compensator/org.eclipse.fx.code.compensator.nashorn.qx/src/org/eclipse/fx/code/compensator/nashorn/qx/QxOutlineExtension.java
index f6e61e337..15f973036 100644
--- a/experimental/compensator/org.eclipse.fx.code.compensator.nashorn.qx/src/org/eclipse/fx/code/compensator/nashorn/qx/QxOutlineExtension.java
+++ b/experimental/compensator/org.eclipse.fx.code.compensator.nashorn.qx/src/org/eclipse/fx/code/compensator/nashorn/qx/QxOutlineExtension.java
@@ -41,7 +41,7 @@ public class QxOutlineExtension implements JSOutlineExtension {
@Override
public OutlineItem createOutline(FunctionNode node, Input<?> input, GraphicsLoader loader) {
- JSOutlineItem root = new JSOutlineItem("<root>",null);
+ JSOutlineItem root = new JSOutlineItem(null,"<root>",null);
node.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) {
private JSOutlineItem classDef;
@@ -51,7 +51,7 @@ public class QxOutlineExtension implements JSOutlineExtension {
if( callNode.getFunction().toString().endsWith("qx.Class.define") ) {
StyledString s = new StyledString();
s.appendSegment(((LiteralNode<?>)callNode.getArgs().get(0)).getString(),"java-element-name");
- classDef = new JSOutlineItem(s, null);
+ classDef = new JSOutlineItem(root,s, null);
root.getChildren().add(classDef);
}
return super.enterCallNode(callNode);
@@ -72,10 +72,10 @@ public class QxOutlineExtension implements JSOutlineExtension {
case "events":
break;
case "properties":
- classDef.getChildren().add(handleProperties(propertyNode,loader));
+ classDef.getChildren().add(handleProperties(classDef,propertyNode,loader));
break;
case "members":
- classDef.getChildren().add(handleMembers(propertyNode,(String) input.getData(),loader));
+ classDef.getChildren().add(handleMembers(classDef,propertyNode,(String) input.getData(),loader));
break;
default:
break;
@@ -87,8 +87,8 @@ public class QxOutlineExtension implements JSOutlineExtension {
return root;
}
- private JSOutlineItem handleProperties(PropertyNode p, GraphicsLoader loader) {
- JSOutlineItem outline = new JSOutlineItem("Properties", null);
+ private JSOutlineItem handleProperties(OutlineItem parent, PropertyNode p, GraphicsLoader loader) {
+ JSOutlineItem outline = new JSOutlineItem(parent, "Properties", null);
p.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) {
@Override
public boolean enterPropertyNode(PropertyNode propertyNode) {
@@ -113,7 +113,7 @@ public class QxOutlineExtension implements JSOutlineExtension {
} else {
uri = PROPERTY_PUBLIC_CLASS;
}
- outline.getChildren().add(new JSOutlineItem(s, () -> loader.getGraphicsNode(uri)));
+ outline.getChildren().add(new JSOutlineItem(outline, s, () -> loader.getGraphicsNode(uri)));
return false;
}
@@ -123,8 +123,8 @@ public class QxOutlineExtension implements JSOutlineExtension {
return outline;
}
- private JSOutlineItem handleMembers(PropertyNode p, String content, GraphicsLoader loader) {
- JSOutlineItem outline = new JSOutlineItem("Members", null);
+ private JSOutlineItem handleMembers(OutlineItem parent, PropertyNode p, String content, GraphicsLoader loader) {
+ JSOutlineItem outline = new JSOutlineItem(parent, "Members", null);
p.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) {
@Override
@@ -139,7 +139,7 @@ public class QxOutlineExtension implements JSOutlineExtension {
} else {
uri = METHOD_PUBLIC_CLASS;
}
- outline.getChildren().add(new JSOutlineItem(propertyNode.getKeyName()+"()",() -> loader.getGraphicsNode(uri)));
+ outline.getChildren().add(new JSOutlineItem(outline, propertyNode.getKeyName()+"()",() -> loader.getGraphicsNode(uri)));
} else if( propertyNode.getValue() instanceof ObjectNode || propertyNode.getValue() instanceof LiteralNode<?> ) {
URI uri;
if( propertyNode.getKeyName().startsWith("__") ) {
@@ -150,7 +150,7 @@ public class QxOutlineExtension implements JSOutlineExtension {
uri = FIELD_PUBLIC_CLASS;
}
- outline.getChildren().add(new JSOutlineItem(propertyNode.getKeyName(),() -> loader.getGraphicsNode(uri)));
+ outline.getChildren().add(new JSOutlineItem(outline, propertyNode.getKeyName(),() -> loader.getGraphicsNode(uri)));
} else {
System.err.println("Unknown value type: " + propertyNode.getValue().getClass());
}
diff --git a/experimental/compensator/org.eclipse.fx.code.compensator.nashorn/src/org/eclipse/fx/code/compensator/nashorn/JSOutline.java b/experimental/compensator/org.eclipse.fx.code.compensator.nashorn/src/org/eclipse/fx/code/compensator/nashorn/JSOutline.java
index abcf035bc..555919743 100644
--- a/experimental/compensator/org.eclipse.fx.code.compensator.nashorn/src/org/eclipse/fx/code/compensator/nashorn/JSOutline.java
+++ b/experimental/compensator/org.eclipse.fx.code.compensator.nashorn/src/org/eclipse/fx/code/compensator/nashorn/JSOutline.java
@@ -62,7 +62,7 @@ public class JSOutline implements Outline {
private static OutlineItem defaultOutline(FunctionNode node, GraphicsLoader loader) {
Stack<OutlineItem> i = new Stack<>();
- i.push(new JSOutlineItem("<root>",null));
+ i.push(new JSOutlineItem(null,"<root>",null));
node.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) {
@Override
@@ -72,12 +72,12 @@ public class JSOutline implements Outline {
if( functionNode.isAnonymous() ) {
String name = ((IdentNode)functionNode.getIdent().accept(this)).getName();
if( name.contains(":") ) {
- outlineItem = new JSOutlineItem("<anonymous>",() -> loader.getGraphicsNode(FUNCTION_ICON));
+ outlineItem = new JSOutlineItem(i.peek(),"<anonymous>",() -> loader.getGraphicsNode(FUNCTION_ICON));
} else {
- outlineItem = new JSOutlineItem(name, () -> loader.getGraphicsNode(METHOD_ICON));
+ outlineItem = new JSOutlineItem(i.peek(), name, () -> loader.getGraphicsNode(METHOD_ICON));
}
} else {
- outlineItem = new JSOutlineItem(((IdentNode)functionNode.getIdent().accept(this)).getName(),() -> loader.getGraphicsNode(FUNCTION_ICON));
+ outlineItem = new JSOutlineItem(i.peek(), ((IdentNode)functionNode.getIdent().accept(this)).getName(),() -> loader.getGraphicsNode(FUNCTION_ICON));
}
i.peek().getChildren().add(outlineItem);
diff --git a/experimental/compensator/org.eclipse.fx.code.compensator.nashorn/src/org/eclipse/fx/code/compensator/nashorn/JSOutlineItem.java b/experimental/compensator/org.eclipse.fx.code.compensator.nashorn/src/org/eclipse/fx/code/compensator/nashorn/JSOutlineItem.java
index dc922f6f1..94fab5864 100644
--- a/experimental/compensator/org.eclipse.fx.code.compensator.nashorn/src/org/eclipse/fx/code/compensator/nashorn/JSOutlineItem.java
+++ b/experimental/compensator/org.eclipse.fx.code.compensator.nashorn/src/org/eclipse/fx/code/compensator/nashorn/JSOutlineItem.java
@@ -14,13 +14,20 @@ public class JSOutlineItem implements OutlineItem {
.observableArrayList();
private final Supplier<Node> graphicSupplier;
+ private final OutlineItem parent;
- public JSOutlineItem(CharSequence name, Supplier<Node> graphicSupplier) {
+ public JSOutlineItem(OutlineItem parent, CharSequence name, Supplier<Node> graphicSupplier) {
+ this.parent = parent;
this.name = name;
this.graphicSupplier = graphicSupplier;
}
@Override
+ public OutlineItem getParent() {
+ return parent;
+ }
+
+ @Override
public CharSequence getLabel() {
return name;
}

Back to the top