use of org.eclipse.xtext.ui.editor.outline.impl.DefaultOutlineTreeProvider in project xtext-eclipse by eclipse.
the class OutlineTreeProviderTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
final Injector injector = TestsActivator.getInstance().getInjector("org.eclipse.xtext.ui.tests.editor.outline.OutlineTestLanguage");
with(new ISetup() {
@Override
public Injector createInjectorAndDoEMFRegistration() {
return injector;
}
});
treeProvider = new DefaultOutlineTreeProvider(new DefaultEObjectLabelProvider(), new DefaultLocationInFileProvider());
}
use of org.eclipse.xtext.ui.editor.outline.impl.DefaultOutlineTreeProvider in project xtext-eclipse by eclipse.
the class OutlineTreeProviderTest method testNoNames.
@Test
public void testNoNames() throws Exception {
final DefaultOutlineTreeProvider noNamesTreeProvider = new DefaultOutlineTreeProvider(new DefaultEObjectLabelProvider(), new DefaultLocationInFileProvider()) {
@Override
protected Object _text(Object modelElement) {
return null;
}
};
final String modelAsText = "element1 { element11 {}} element2 {}";
IXtextDocument document = createXtextDocument(modelAsText);
final IOutlineNode rootNode = noNamesTreeProvider.createRoot(document);
document.readOnly(new IUnitOfWork.Void<XtextResource>() {
@Override
public void process(XtextResource state) throws Exception {
noNamesTreeProvider.createChildren(rootNode, state.getContents().get(0));
assertEquals(1, rootNode.getChildren().size());
IOutlineNode modelNode = rootNode.getChildren().get(0);
assertEquals(state.getURI().trimFileExtension().lastSegment(), modelNode.getText());
assertTrue(modelNode.hasChildren());
assertEquals(1, modelNode.getChildren().size());
IOutlineNode element1 = modelNode.getChildren().get(0);
assertEquals("<unnamed>", element1.getText().toString());
assertEquals(new TextRegion(0, 8), element1.getSignificantTextRegion());
assertEquals(new TextRegion(0, 24), element1.getFullTextRegion());
assertEquals(modelNode, element1.getParent());
// node does not know that its children will be skipped
assertTrue(element1.hasChildren());
assertTrue(element1.getChildren().isEmpty());
}
});
}
Aggregations