org.eclipse.xtext.ui.editor.outline.impl.EObjectNode Java Examples
The following examples show how to use
org.eclipse.xtext.ui.editor.outline.impl.EObjectNode.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MetaTypeAwareComparator.java From n4js with Eclipse Public License 1.0 | 6 votes |
private int getCategory(IOutlineNode node) { if (node instanceof EObjectNode) { EClass eclass = ((EObjectNode) node).getEClass(); int id = eclass.getClassifierID(); int key = 10000 + id; Integer sortKey = METATYPESORTORDER.get(id); if (sortKey != null) { key = sortKey * 1000; } if (node instanceof N4JSEObjectNode) { N4JSEObjectNode n4node = (N4JSEObjectNode) node; if (!n4node.isStatic) { key += 100; } if (n4node.isConstructor) { key -= 50; } } return key; } return -1; }
Example #2
Source File: SARLOutlineTreeProvider.java From sarl with Apache License 2.0 | 6 votes |
private EObjectNode createCapacityUseNode(EStructuralFeatureNode elementNode, SarlCapacityUses feature, EObjectNode oldCapacityUseNode) { EObjectNode capacityUseNode = oldCapacityUseNode; if (capacityUseNode == null) { capacityUseNode = createEObjectNode( elementNode, feature, this.imageDispatcher.invoke(feature), this.textDispatcher.invoke(feature), false); } for (final JvmParameterizedTypeReference item : feature.getCapacities()) { createEObjectNode( capacityUseNode, item, this.imageDispatcher.invoke(item), this.textDispatcher.invoke(item), true); } return capacityUseNode; }
Example #3
Source File: SARLOutlineTreeProvider.java From sarl with Apache License 2.0 | 6 votes |
private EObjectNode createRequiredCapacityNode(EStructuralFeatureNode elementNode, SarlRequiredCapacity feature, EObjectNode oldCapacityRequirementNode) { EObjectNode capacityRequirementNode = oldCapacityRequirementNode; if (capacityRequirementNode == null) { capacityRequirementNode = createEObjectNode( elementNode, feature, this.imageDispatcher.invoke(feature), this.textDispatcher.invoke(feature), false); } for (final JvmParameterizedTypeReference item : feature.getCapacities()) { createEObjectNode( capacityRequirementNode, item, this.imageDispatcher.invoke(item), this.textDispatcher.invoke(item), true); } return capacityRequirementNode; }
Example #4
Source File: CheckOutlineTreeProvider.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
@Override protected void internalCreateChildren(final DocumentRootNode parentNode, final EObject modelElement) { CheckCatalog catalog = (CheckCatalog) modelElement; if (catalog.getPackageName() != null) { getOutlineNodeFactory().createEStructuralFeatureNode(parentNode, catalog, CheckPackage.Literals.CHECK_CATALOG__PACKAGE_NAME, ImageDescriptor.createFromImage(checkImages.forPackage()), catalog.getPackageName(), true); } if (catalog.getImports() != null && !catalog.getImports().getImportDeclarations().isEmpty()) { EStructuralFeatureNode importNode = getOutlineNodeFactory().createEStructuralFeatureNode(parentNode, catalog, CheckPackage.Literals.CHECK_CATALOG__IMPORTS, ImageDescriptor.createFromImage(checkImages.forImportContainer()), "Import declarations", false); for (final org.eclipse.xtext.xtype.XImportDeclaration imported : catalog.getImports().getImportDeclarations()) { createNode(importNode, imported); } } EObjectNode catalogNode = createNode(parentNode, catalog); for (final Category category : catalog.getCategories()) { createNode(catalogNode, category); } for (final Check check : catalog.getChecks()) { createNode(catalogNode, check); } }
Example #5
Source File: AbstractOutlineTest.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** * Add the given outline node to the outline map. * * @param node * IOutlineNode to add. */ private void addToOutlineMap(final IOutlineNode node) { EStructuralFeature eFeature = null; if (node instanceof EObjectNode) { eFeature = ((EObjectNode) node).getEObject(getTestSource().getXtextResource()).eContainingFeature(); // TODO : remove the following part once all tests have been refactored Class<?> nodeClazz = ((EObjectNode) node).getEClass().getInstanceClass(); if (!getOutlineMap().containsKey(nodeClazz)) { getOutlineMap().put(nodeClazz, new ArrayList<IOutlineNode>()); } getOutlineMap().get(nodeClazz).add(node); } else if (node instanceof EStructuralFeatureNode) { eFeature = ((EStructuralFeatureNode) node).getEStructuralFeature(); } if (eFeature == null) { return; } if (!getOutlineMap().containsKey(eFeature)) { getOutlineMap().put(eFeature, new ArrayList<IOutlineNode>()); } getOutlineMap().get(eFeature).add(node); }
Example #6
Source File: XtextElementSelectionListener.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** * Gets the URI of the semantic element currently selected. * * @return URI or null */ public URI getSelectedElementUri() { if (selection instanceof IStructuredSelection) { if (((IStructuredSelection) selection).getFirstElement() instanceof InternalEObject) { // structured selection, e.g. GMFEditor return EcoreUtil.getURI((EObject) ((IStructuredSelection) selection).getFirstElement()); } else if (((IStructuredSelection) selection).getFirstElement() instanceof EObjectNode) { // selection in outline return ((EObjectNode) ((IStructuredSelection) selection).getFirstElement()).getEObjectURI(); } } else { ILeafNode node = nodeAtTextSelection(); EObject semanticObject = NodeModelUtils.findActualSemanticObjectFor(node); if (semanticObject != null) { return EcoreUtil.getURI(semanticObject); } } return null; }
Example #7
Source File: XtextElementSelectionListener.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** * Gets the EClass of the semantic element currently selected. * * @return EClass or null */ public EClass getSelectedElementType() { if (selection instanceof IStructuredSelection) { if (((IStructuredSelection) selection).getFirstElement() instanceof EObject) { // structured selection, e.g. GMFEditor EObject eObject = (EObject) ((IStructuredSelection) selection).getFirstElement(); if (eObject.eResource() != null) { return eObject.eClass(); } } else if (((IStructuredSelection) selection).getFirstElement() instanceof EObjectNode) { // selection in outline return ((EObjectNode) ((IStructuredSelection) selection).getFirstElement()).getEClass(); } } else { ILeafNode node = nodeAtTextSelection(); EObject semanticObject = NodeModelUtils.findActualSemanticObjectFor(node); if (semanticObject != null) { return semanticObject.eClass(); } } return null; }
Example #8
Source File: OutlineNodeComparerTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@SuppressWarnings("unused") @Test public void testEquivalentIndex() throws Exception { DocumentRootNode rootNode = new DocumentRootNode(image, "Root", null, null); EObjectNode node = new EObjectNode(eObject, rootNode, image, "Node", false); DocumentRootNode rootNode2 = new DocumentRootNode(image, "Root", null, null); EObjectNode node2 = new EObjectNode(eObject, rootNode2, image, "Node", false); assertTrue(comparer.equals(node, node2)); EObjectNode node3 = new EObjectNode(eObject, rootNode2, image, "OtherNode", false); assertTrue(comparer.equals(node, node2)); DocumentRootNode rootNode3 = new DocumentRootNode(image, "Root", null, null); EObjectNode node4 = new EObjectNode(eObject, rootNode3, image, "OtherNode", false); EObjectNode node5 = new EObjectNode(eObject, rootNode3, image, "Node", false); assertTrue(comparer.equals(node, node5)); EObjectNode node6 = new EObjectNode(eObject, rootNode3, image, "OtherNode", false); assertFalse(comparer.equals(node, node5)); }
Example #9
Source File: OutlineFilterAndSorterTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@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; } }); Model model = OutlineTestFactory.eINSTANCE.createModel(); nodes = Lists.newArrayList(); nodes.add(new EObjectNode(model, null, (ImageDescriptor) null, "one", true)); nodes.add(new EObjectNode(model, null, (ImageDescriptor) null, "two", true)); nodes.add(new EObjectNode(model, null, (ImageDescriptor) null, "three", true)); filterAndSorter = new OutlineFilterAndSorter(); }
Example #10
Source File: SARLFieldOutlineFilter.java From sarl with Apache License 2.0 | 5 votes |
@Override protected boolean apply(IOutlineNode node) { if (node instanceof EObjectNode) { return !isField(((EObjectNode) node).getEClass()); } if (node instanceof EStructuralFeatureNode) { return !isField(((EStructuralFeatureNode) node).getEStructuralFeature().eClass()); } return true; }
Example #11
Source File: OutlineNodeTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Test public void testAddChildToLeafNode() { EObjectNode parentNode = new EObjectNode(parentElement, null, (ImageDescriptor) null, "parent", true); assertFalse(parentNode.hasChildren()); assertTrue(parentNode.getChildren().isEmpty()); EObjectNode childNode = new EObjectNode(child0Element, parentNode, (ImageDescriptor) null, "child", false); assertTrue(parentNode.hasChildren()); assertTrue(parentNode.getChildren().contains(childNode)); }
Example #12
Source File: OutlineNodeTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Test public void testMethodsDelegateToParent() { DocumentRootNode rootNode = createRootNode(); EObjectNode parentNode = new EObjectNode(parentElement, rootNode, (ImageDescriptor) null, "parent", false); assertNotNull(parentNode.getDocument()); assertNotNull(parentNode.getTreeProvider()); assertEquals(rootNode.getDocument(), parentNode.getDocument()); assertEquals(rootNode.getTreeProvider(), parentNode.getTreeProvider()); }
Example #13
Source File: SARLOutlineTreeProvider.java From sarl with Apache License 2.0 | 5 votes |
@Override protected EObjectNode createEObjectNode( IOutlineNode parentNode, EObject modelElement, Image image, Object text, boolean isLeaf) { final SARLEObjectNode objectNode = new SARLEObjectNode(modelElement, parentNode, image, text, isLeaf); configureNode(parentNode, modelElement, objectNode); return objectNode; }
Example #14
Source File: SARLOperationOutlineFilter.java From sarl with Apache License 2.0 | 5 votes |
@Override protected boolean apply(IOutlineNode node) { if (node instanceof EObjectNode) { return !isAction(((EObjectNode) node).getEClass()); } if (node instanceof EStructuralFeatureNode) { return !isAction(((EStructuralFeatureNode) node).getEStructuralFeature().eClass()); } return true; }
Example #15
Source File: OutlineNodeTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@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)); }
Example #16
Source File: SARLBehaviorUnitOutlineFilter.java From sarl with Apache License 2.0 | 5 votes |
@Override protected boolean apply(IOutlineNode node) { if (node instanceof EObjectNode) { return !isBehaviorUnit(((EObjectNode) node).getEClass()); } if (node instanceof EStructuralFeatureNode) { return !isBehaviorUnit(((EStructuralFeatureNode) node).getEStructuralFeature().eClass()); } return true; }
Example #17
Source File: XtendOutlinePage.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@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; }
Example #18
Source File: XtendOutlineJvmTreeProvider.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@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; }
Example #19
Source File: XtendOutlineNodeComparator.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
protected int internalGetCategory(IOutlineNode node) { if (node instanceof EStructuralFeatureNode) { EStructuralFeature feature = ((EStructuralFeatureNode) node).getEStructuralFeature(); if (feature == XtendPackage.Literals.XTEND_FILE__PACKAGE) return 0; else return 10; } boolean isStatic = node instanceof XtendFeatureNode && ((XtendEObjectNode) node).isStatic(); if (node instanceof EObjectNode) { EClass eClass = ((EObjectNode) node).getEClass(); if (XtendPackage.Literals.XTEND_TYPE_DECLARATION.isSuperTypeOf(eClass) || TypesPackage.Literals.JVM_DECLARED_TYPE.isSuperTypeOf(eClass) || TypesPackage.Literals.JVM_ENUMERATION_LITERAL.isSuperTypeOf(eClass)) return 20; if (eClass == XtendPackage.Literals.XTEND_FIELD || eClass == TypesPackage.Literals.JVM_FIELD) return isStatic ? 30 : 50; if (eClass == XtendPackage.Literals.XTEND_CONSTRUCTOR || eClass == TypesPackage.Literals.JVM_CONSTRUCTOR) return 60; if (eClass == XtendPackage.Literals.XTEND_FUNCTION || eClass == TypesPackage.Literals.JVM_OPERATION) { if (isStatic) return 40; else return (node instanceof XtendFeatureNode && ((XtendFeatureNode) node).isDispatch()) ? 70 : 80; } } return Integer.MAX_VALUE; }
Example #20
Source File: AbstractMultiModeOutlineTreeProvider.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override public IXtendOutlineContext buildXtendNode(EObject modelElement, IXtendOutlineContext context) { EclipseXtendOutlineContext eclipseXtendOutlineContext = (EclipseXtendOutlineContext) context; IOutlineNode parentNode = eclipseXtendOutlineContext.getParentNode(); int inheritanceDepth = eclipseXtendOutlineContext.getInheritanceDepth(); EObjectNode xtendNode = createXtendNode(parentNode, modelElement, inheritanceDepth); return eclipseXtendOutlineContext.withParentNode(xtendNode); }
Example #21
Source File: AbstractMultiModeOutlineTreeProvider.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override public IXtendOutlineContext buildEObjectNode(EObject modelElement, IXtendOutlineContext context) { EclipseXtendOutlineContext eclipseXtendOutlineContext = (EclipseXtendOutlineContext) context; IOutlineNode parentNode = eclipseXtendOutlineContext.getParentNode(); EObjectNode node = createNode(parentNode, modelElement); return eclipseXtendOutlineContext.withParentNode(node); }
Example #22
Source File: DotHtmlLabelOutlineTreeProvider.java From gef with Eclipse Public License 2.0 | 5 votes |
@Override protected EObjectNode createEObjectNode(IOutlineNode parentNode, EObject modelElement, Image image, Object text, boolean isLeaf) { EObjectNode eObjectNode = new EObjectNode(modelElement, parentNode, image, text, isLeaf) { @Override public IXtextDocument getDocument() { return xtextDocument != null ? xtextDocument : super.getDocument(); } }; ICompositeNode parserNode = NodeModelUtils.getNode(modelElement); if (parserNode != null) { ITextRegion parserNodeTextRegion = parserNode.getTextRegion(); ITextRegion newTextRegion = new TextRegion( parserNodeTextRegion.getOffset() + offset, parserNodeTextRegion.getLength()); eObjectNode.setTextRegion(newTextRegion); } /* if (isLocalElement(parentNode, modelElement)) { */ ITextRegion significantTextRegion = locationInFileProvider .getSignificantTextRegion(modelElement); ITextRegion shortTextRegion = new TextRegion( significantTextRegion.getOffset() + offset, significantTextRegion.getLength()); eObjectNode.setShortTextRegion(shortTextRegion); // } return eObjectNode; }
Example #23
Source File: DotOutlineTreeProvider.java From gef with Eclipse Public License 2.0 | 5 votes |
@Override protected EObjectNode createEObjectNode(IOutlineNode parentNode, EObject modelElement, Image image, Object text, boolean isLeaf) { if (EcoreUtil2.getContainerOfType(modelElement, HtmlLabel.class) != null) { // in case of a html-like label addition offset should be calculated EObjectNode eObjectNode = new EObjectNode(modelElement, parentNode, image, text, isLeaf); ICompositeNode parserNode = NodeModelUtils.getNode(modelElement); if (parserNode != null) { ITextRegion parserNodeTextRegion = parserNode.getTextRegion(); ITextRegion newTextRegion = new TextRegion( parserNodeTextRegion.getOffset() + attributeValueStartOffset, parserNodeTextRegion.getLength()); eObjectNode.setTextRegion(newTextRegion); } if (isLocalElement(parentNode, modelElement)) { ITextRegion significantTextRegion = locationInFileProvider .getSignificantTextRegion(modelElement); ITextRegion shortTextRegion = new TextRegion( significantTextRegion.getOffset() + attributeValueStartOffset, significantTextRegion.getLength()); eObjectNode.setShortTextRegion(shortTextRegion); } return eObjectNode; } else { return super.createEObjectNode(parentNode, modelElement, image, text, isLeaf); } }
Example #24
Source File: XtextOutlineNodeComparator.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public int getCategory(IOutlineNode node) { if (node instanceof EObjectNode && ((EObjectNode) node).getEClass().getEAllSuperTypes().contains(XtextPackage.Literals.ABSTRACT_METAMODEL_DECLARATION)) return -10; return 0; }
Example #25
Source File: OutlineNodeTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected DocumentRootNode createRootNode() { XtextDocument document = get(XtextDocument.class); document.setInput(resource); IOutlineTreeStructureProvider treeStructureProvider = new IOutlineTreeStructureProvider() { @Override public void createChildren(IOutlineNode parentNode, EObject modelElement) { new EObjectNode(child0Element, parentNode, (ImageDescriptor) null, "child", false); } }; DocumentRootNode rootNode = new DocumentRootNode((ImageDescriptor) null, "root", document, treeStructureProvider); return rootNode; }
Example #26
Source File: OutlineNodeComparerTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Test public void testPropertyEquality() { EObjectNode node = new EObjectNode(eObject, null, image, new StyledString("Node"), false); assertFalse(comparer.equals(node, new DocumentRootNode(image, new StyledString("Node"), null, null))); assertTrue(comparer.equals(node, new EObjectNode(OutlineTestFactory.eINSTANCE.createElement(), null, image, new StyledString("Node"), false))); assertFalse(comparer.equals(node, new EObjectNode(eObject, node, image, new StyledString("Node"), false))); assertFalse(comparer.equals(node, new EObjectNode(eObject, null, image2, new StyledString("Node"), false))); assertFalse(comparer.equals(node, new EObjectNode(eObject, null, image, new StyledString("Node2"), false))); assertTrue(comparer.equals(node, new EObjectNode(eObject, null, image, "Node", false))); }
Example #27
Source File: SARLOutlineNodeComparator.java From sarl with Apache License 2.0 | 4 votes |
@SuppressWarnings({"checkstyle:npathcomplexity", "checkstyle:returncount", "checkstyle:cyclomaticcomplexity"}) @Override public int getCategory(IOutlineNode node) { if (node instanceof EStructuralFeatureNode) { final EStructuralFeature feature = ((EStructuralFeatureNode) node).getEStructuralFeature(); if (feature == XTEND_FILE__PACKAGE) { return SCRIPT_PRIORITY; } return TOPELEMENT_PRIORITY; } if (node instanceof EObjectNode) { final EObjectNode objectNode = (EObjectNode) node; final EClass objectNodeType = objectNode.getEClass(); if (XIMPORT_SECTION.isSuperTypeOf(objectNodeType)) { return IMPORT_PRIORITY; } if (XtendPackage.Literals.XTEND_TYPE_DECLARATION.isSuperTypeOf(objectNodeType) || TypesPackage.Literals.JVM_DECLARED_TYPE.isSuperTypeOf(objectNodeType) || TypesPackage.Literals.JVM_ENUMERATION_LITERAL.isSuperTypeOf(objectNodeType)) { if (isStatic(objectNode)) { return STATIC_INNER_TYPE_PRIORITY; } return INNER_TYPE_PRIORITY; } if (isCapacityUses(objectNodeType)) { return CAPACITY_USE_PRIORITY; } if (SARL_REQUIRED_CAPACITY.isSuperTypeOf(objectNodeType)) { return CAPACITY_REQUIREMENT_PRIORITY; } if (isField(objectNodeType)) { if (isStatic(objectNode)) { return STATIC_FIELD_PRIORITY; } return FIELD_PRIORITY; } if (isAction(objectNodeType)) { if (isStatic(objectNode)) { return STATIC_METHOD_PRIORITY; } return METHOD_PRIORITY; } if (isConstructor(objectNodeType)) { if (isStatic(objectNode)) { return STATIC_CONSTRUCTOR; } return CONSTRUCTOR_PRIORITY; } if (isBehaviorUnit(objectNodeType)) { return BEHAVIOR_UNIT_PRIORITY; } } return Integer.MAX_VALUE; }
Example #28
Source File: SARLOutlineNodeComparator.java From sarl with Apache License 2.0 | 4 votes |
private static boolean isStatic(EObjectNode eobjectNode) { if (eobjectNode instanceof SARLEObjectNode) { return ((SARLEObjectNode) eobjectNode).isStatic(); } return false; }
Example #29
Source File: SARLOutlineNodeComparatorTest.java From sarl with Apache License 2.0 | 4 votes |
/** */ @Before public void setUp() { this.sarlScript = mock(EStructuralFeatureNode.class); when(this.sarlScript.getEStructuralFeature()).thenReturn(XtendPackage.Literals.XTEND_FILE__PACKAGE); this.agentFeature1 = mock(EStructuralFeatureNode.class); this.agentFeature2 = mock(EStructuralFeatureNode.class); this.behaviorFeature1 = mock(EStructuralFeatureNode.class); this.behaviorFeature2 = mock(EStructuralFeatureNode.class); this.capacityFeature1 = mock(EStructuralFeatureNode.class); this.capacityFeature2 = mock(EStructuralFeatureNode.class); this.skillFeature1 = mock(EStructuralFeatureNode.class); this.skillFeature2 = mock(EStructuralFeatureNode.class); this.eventFeature1 = mock(EStructuralFeatureNode.class); this.eventFeature2 = mock(EStructuralFeatureNode.class); this.otherFeature1 = mock(EStructuralFeatureNode.class); when(this.otherFeature1.getEStructuralFeature()).thenReturn(mock(EStructuralFeature.class)); this.otherFeature2 = mock(EStructuralFeatureNode.class); when(this.otherFeature2.getEStructuralFeature()).thenReturn(mock(EStructuralFeature.class)); this.importFeature1 = mock(EObjectNode.class); when(this.importFeature1.getEClass()).thenReturn(XtypePackage.Literals.XIMPORT_SECTION); this.importFeature2 = mock(EObjectNode.class); when(this.importFeature2.getEClass()).thenReturn(XtypePackage.Literals.XIMPORT_SECTION); this.capacityUseFeature1 = mock(EObjectNode.class); when(this.capacityUseFeature1.getEClass()).thenReturn(SarlPackage.Literals.SARL_CAPACITY_USES); this.capacityUseFeature2 = mock(EObjectNode.class); when(this.capacityUseFeature2.getEClass()).thenReturn(SarlPackage.Literals.SARL_CAPACITY_USES); this.capacityRequirementFeature1 = mock(EObjectNode.class); when(this.capacityRequirementFeature1.getEClass()).thenReturn(SarlPackage.Literals.SARL_REQUIRED_CAPACITY); this.capacityRequirementFeature2 = mock(EObjectNode.class); when(this.capacityRequirementFeature2.getEClass()).thenReturn(SarlPackage.Literals.SARL_REQUIRED_CAPACITY); this.attributeFeature1 = mock(EObjectNode.class); when(this.attributeFeature1.getEClass()).thenReturn(SarlPackage.Literals.SARL_FIELD); this.attributeFeature2 = mock(EObjectNode.class); when(this.attributeFeature2.getEClass()).thenReturn(SarlPackage.Literals.SARL_FIELD); this.constructorFeature1 = mock(EObjectNode.class); when(this.constructorFeature1.getEClass()).thenReturn(SarlPackage.Literals.SARL_CONSTRUCTOR); this.constructorFeature2 = mock(EObjectNode.class); when(this.constructorFeature2.getEClass()).thenReturn(SarlPackage.Literals.SARL_CONSTRUCTOR); this.actionFeature1 = mock(EObjectNode.class); when(this.actionFeature1.getEClass()).thenReturn(SarlPackage.Literals.SARL_ACTION); this.actionFeature2 = mock(EObjectNode.class); when(this.actionFeature2.getEClass()).thenReturn(SarlPackage.Literals.SARL_ACTION); this.behaviorUnitFeature1 = mock(EObjectNode.class); when(this.behaviorUnitFeature1.getEClass()).thenReturn(SarlPackage.Literals.SARL_BEHAVIOR_UNIT); this.behaviorUnitFeature2 = mock(EObjectNode.class); when(this.behaviorUnitFeature2.getEClass()).thenReturn(SarlPackage.Literals.SARL_BEHAVIOR_UNIT); this.comparator = new SARLOutlineNodeComparator(); }
Example #30
Source File: SARLOutlineTreeProvider.java From sarl with Apache License 2.0 | 4 votes |
@SuppressWarnings("checkstyle:cyclomaticcomplexity") private void createTypeDeclarationNode(IOutlineNode parentNode, XtendTypeDeclaration modelElement) { // // The text region is set to the model element, not to the model element's name as in the // default implementation of createStructuralFeatureNode(). // The text region computation is overridden in order to have a correct link to the editor. // final boolean isFeatureSet = modelElement.eIsSet(XtendPackage.Literals.XTEND_TYPE_DECLARATION__NAME); final EStructuralFeatureNode elementNode = new EStructuralFeatureNode( modelElement, XtendPackage.Literals.XTEND_TYPE_DECLARATION__NAME, parentNode, this.imageDispatcher.invoke(modelElement), this.textDispatcher.invoke(modelElement), modelElement.getMembers().isEmpty() || !isFeatureSet); final EObject primarySourceElement = this.associations.getPrimarySourceElement(modelElement); final ICompositeNode parserNode = NodeModelUtils.getNode( (primarySourceElement == null) ? modelElement : primarySourceElement); elementNode.setTextRegion(parserNode.getTextRegion()); // boolean hasConstructor = false; if (!modelElement.getMembers().isEmpty()) { EObjectNode capacityUseNode = null; EObjectNode capacityRequirementNode = null; for (final EObject feature : modelElement.getMembers()) { if (feature instanceof SarlConstructor) { hasConstructor = true; createNode(elementNode, feature); } else if (feature instanceof SarlField) { final SarlField field = (SarlField) feature; createNode(elementNode, field); createAutomaticAccessors(elementNode, field); } else if (feature instanceof SarlAction || feature instanceof SarlBehaviorUnit || feature instanceof XtendTypeDeclaration) { createNode(elementNode, feature); } else if (feature instanceof SarlCapacityUses) { capacityUseNode = createCapacityUseNode(elementNode, (SarlCapacityUses) feature, capacityUseNode); } else if (feature instanceof SarlRequiredCapacity) { capacityRequirementNode = createRequiredCapacityNode(elementNode, (SarlRequiredCapacity) feature, capacityRequirementNode); } } } if (!hasConstructor && modelElement instanceof XtendClass) { createInheritedConstructors(elementNode, (XtendClass) modelElement); } }