use of org.eclipse.xtext.ui.editor.outline.impl.DocumentRootNode in project xtext-eclipse by eclipse.
the class OutlineNodeTest method testStateAccess.
@Test
public void testStateAccess() {
DocumentRootNode rootNode = createRootNode();
EObjectNode parentNode = new EObjectNode(parentElement, rootNode, (ImageDescriptor) null, "parent", false);
EStructuralFeatureNode featureNode = new EStructuralFeatureNode(parentElement, OutlineTestPackage.Literals.ELEMENT__XREFS, parentNode, (ImageDescriptor) null, "eClassifiers", true);
IUnitOfWork<Boolean, EObject> work = new IUnitOfWork<Boolean, EObject>() {
@Override
public Boolean exec(EObject state) throws Exception {
return state != null;
}
};
assertTrue(rootNode.readOnly(work));
assertTrue(parentNode.readOnly(work));
assertTrue(featureNode.readOnly(work));
}
use of org.eclipse.xtext.ui.editor.outline.impl.DocumentRootNode in project xtext-eclipse by eclipse.
the class OutlineTreeProviderTest method testCreateRoot.
@Test
public void testCreateRoot() throws Exception {
XtextDocument document = createXtextDocument("element {}");
IOutlineNode rootNode = treeProvider.createRoot(document);
assertTrue(rootNode instanceof DocumentRootNode);
assertEquals(treeProvider, ((DocumentRootNode) rootNode).getTreeProvider());
assertEquals(new TextRegion(0, 10), rootNode.getFullTextRegion());
assertEquals(new TextRegion(0, 10), rootNode.getSignificantTextRegion());
assertEquals(document, ((DocumentRootNode) rootNode).getDocument());
}
use of org.eclipse.xtext.ui.editor.outline.impl.DocumentRootNode in project xtext-xtend by eclipse.
the class XtendOutlineJvmTreeProvider method buildXtendNode.
@Override
public IXtendOutlineContext buildXtendNode(EObject modelElement, IXtendOutlineContext context) {
IXtendOutlineContext resultedContext = super.buildXtendNode(modelElement, context);
if (!context.isShowInherited()) {
EclipseXtendOutlineContext eclipseXtendOutlineContext = (EclipseXtendOutlineContext) context;
IOutlineNode parentNode = eclipseXtendOutlineContext.getParentNode();
if (parentNode instanceof DocumentRootNode) {
if (modelElement instanceof JvmDeclaredType) {
JvmDeclaredType jvmDeclaredType = (JvmDeclaredType) modelElement;
String packageName = jvmDeclaredType.getPackageName();
if (packageName != null) {
EObject rootElement = modelElement.eResource().getContents().get(0);
if (rootElement instanceof XtendFile) {
XtendFile xtendFile = (XtendFile) rootElement;
String primaryPackage = xtendFile.getPackage();
if (!packageName.equals(primaryPackage)) {
EObjectNode typeNode = (EObjectNode) ((EclipseXtendOutlineContext) resultedContext).getParentNode();
if (typeNode.getText() instanceof StyledString) {
typeNode.setText(((StyledString) typeNode.getText()).append(new StyledString(" - " + packageName, StyledString.QUALIFIER_STYLER)));
}
}
}
}
}
}
}
return resultedContext;
}
Aggregations