use of org.eclipse.xtext.ui.editor.outline.IOutlineNode in project xtext-xtend by eclipse.
the class XtendOutlinePage method getInitiallyExpandedNodes.
@Override
protected List<IOutlineNode> getInitiallyExpandedNodes() {
IOutlineNode rootNode = getTreeProvider().createRoot(getXtextDocument());
List<IOutlineNode> result = newArrayList(rootNode);
for (IOutlineNode firstLevelNode : rootNode.getChildren()) if (firstLevelNode instanceof EObjectNode)
result.add(firstLevelNode);
return result;
}
use of org.eclipse.xtext.ui.editor.outline.IOutlineNode in project xtext-xtend by eclipse.
the class XtendOutlineWithEditorLinker method selectInTreeView.
@Override
public void selectInTreeView(final ISelection selection) {
if (((selection instanceof ITextSelection) && (!this.treeViewer.getTree().isDisposed()))) {
final ITextSelection textSelection = ((ITextSelection) selection);
int _offset = textSelection.getOffset();
int _length = textSelection.getLength();
final TextRegion selectedTextRegion = new TextRegion(_offset, _length);
final Object input = this.treeViewer.getInput();
if ((input instanceof IOutlineNode)) {
final List<IOutlineNode> matchingNodes = CollectionLiterals.<IOutlineNode>newArrayList();
this.findNodesInRange(((IOutlineNode) input), selectedTextRegion, matchingNodes);
boolean _isEmpty = matchingNodes.isEmpty();
boolean _not = (!_isEmpty);
if (_not) {
final Function1<IOutlineNode, Integer> _function = (IOutlineNode it) -> {
return Integer.valueOf(it.getFullTextRegion().getLength());
};
final Integer smallestMatch = IterableExtensions.<Integer>min(ListExtensions.<IOutlineNode, Integer>map(matchingNodes, _function));
final Function1<IOutlineNode, Boolean> _function_1 = (IOutlineNode it) -> {
int _length_1 = it.getFullTextRegion().getLength();
return Boolean.valueOf((_length_1 == (smallestMatch).intValue()));
};
final Iterable<IOutlineNode> nodesToBeSelected = IterableExtensions.<IOutlineNode>filter(matchingNodes, _function_1);
boolean _isEmpty_1 = IterableExtensions.isEmpty(nodesToBeSelected);
boolean _not_1 = (!_isEmpty_1);
if (_not_1) {
Object[] _array = IterableExtensions.<IOutlineNode>toList(nodesToBeSelected).toArray();
StructuredSelection _structuredSelection = new StructuredSelection(_array);
this.treeViewer.setSelection(_structuredSelection);
}
}
}
}
}
use of org.eclipse.xtext.ui.editor.outline.IOutlineNode in project xtext-xtend by eclipse.
the class XtendOutlineWithEditorLinker method findNodesInRange.
protected void findNodesInRange(final IOutlineNode input, final ITextRegion selectedTextRegion, final List<IOutlineNode> nodes) {
final ITextRegion textRegion = input.getFullTextRegion();
if (((textRegion == null) || textRegion.contains(selectedTextRegion))) {
nodes.add(input);
}
List<IOutlineNode> _children = input.getChildren();
for (final IOutlineNode child : _children) {
this.findNodesInRange(child, selectedTextRegion, nodes);
}
}
use of org.eclipse.xtext.ui.editor.outline.IOutlineNode in project xtext-xtend by eclipse.
the class OpenEditorTest method testOpenFromOutline.
@Test
public void testOpenFromOutline() throws Exception {
XtextEditor bazXtendEditor = workbenchTestHelper.openEditor("outlinetest/Baz.xtend", "package outlinetest class Baz extends Foo { int baz }");
IOutlineTreeProvider.ModeAware tp = (IOutlineTreeProvider.ModeAware) treeProvider;
tp.setCurrentMode(tp.getOutlineModes().get(1));
IOutlineNode outlineRoot = treeProvider.createRoot(bazXtendEditor.getDocument());
IOutlineNode bazNode = outlineRoot.getChildren().get(1);
assertEquals("Baz - outlinetest", bazNode.getText().toString());
assertTrue(bazNode.getChildren().size() > 2);
IOutlineNode baz = bazNode.getChildren().get(0);
assertEquals("baz : int - Baz", baz.getText().toString());
outlineNodeElementOpener.open(baz, bazXtendEditor.getInternalSourceViewer());
assertActiveEditor("org.eclipse.xtend.core.Xtend", "Baz.xtend", "baz");
IOutlineNode foo = bazNode.getChildren().get(1);
assertEquals("foo : int - Foo", foo.getText().toString());
outlineNodeElementOpener.open(foo, bazXtendEditor.getInternalSourceViewer());
assertActiveEditor("org.eclipse.xtend.core.Xtend", "Foo.xtend", "foo");
IOutlineNode bar = bazNode.getChildren().get(2);
assertEquals("bar : int - Bar", bar.getText().toString());
outlineNodeElementOpener.open(bar, bazXtendEditor.getInternalSourceViewer());
assertActiveEditor(JavaUI.ID_CU_EDITOR, "Bar.java", "bar");
}
use of org.eclipse.xtext.ui.editor.outline.IOutlineNode in project xtext-xtend by eclipse.
the class AbstractOutlineTests method newAssertBuilder.
protected AssertBuilder newAssertBuilder(XtendFile xtendFile) throws Exception, CoreException {
XtextDocument document = documentProvider.get();
document.setInput((XtextResource) xtendFile.eResource());
IOutlineNode root = treeProvider.createRoot(document);
AssertBuilder assertBuilder = new AssertBuilder(root);
return assertBuilder;
}
Aggregations