org.eclipse.xtext.ui.editor.outline.impl.EStructuralFeatureNode Java Examples
The following examples show how to use
org.eclipse.xtext.ui.editor.outline.impl.EStructuralFeatureNode.
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: 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 #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: 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 #4
Source File: SARLOutlinePage.java From sarl with Apache License 2.0 | 6 votes |
@Override protected List<IOutlineNode> getInitiallyExpandedNodes() { // Automatically expend the rot nodes into the outline. final IOutlineNode rootNode = getTreeProvider().createRoot(getXtextDocument()); final List<IOutlineNode> result = newArrayList(rootNode); for (final IOutlineNode firstLevelNode: rootNode.getChildren()) { if (firstLevelNode instanceof EStructuralFeatureNode) { final EStructuralFeatureNode snode = (EStructuralFeatureNode) firstLevelNode; final EStructuralFeature feature = snode.getEStructuralFeature(); if (XtendTypeDeclaration.class.isAssignableFrom(feature.getContainerClass())) { result.add(firstLevelNode); } } } return result; }
Example #5
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 #6
Source File: AbstractMultiModeOutlineTreeProvider.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override public IXtendOutlineContext buildPackageNode(XtendFile xtendFile, IXtendOutlineContext context) { EclipseXtendOutlineContext eclipseXtendOutlineContext = (EclipseXtendOutlineContext) context; IOutlineNode parentNode = eclipseXtendOutlineContext.getParentNode(); String primaryPackage = xtendFile.getPackage(); EStructuralFeatureNode node = getOutlineNodeFactory().createEStructuralFeatureNode(parentNode, xtendFile, XtendPackage.Literals.XTEND_FILE__PACKAGE, images.forPackage(), primaryPackage, true); return eclipseXtendOutlineContext.withParentNode(node); }
Example #7
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 #8
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 #9
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 #10
Source File: SARLOutlineTreeProvider.java From sarl with Apache License 2.0 | 5 votes |
private void createInheritedConstructors(EStructuralFeatureNode elementNode, XtendClass modelElement) { final JvmTypeReference extend = modelElement.getExtends(); if (extend != null) { final LightweightTypeReference reference = Utils.toLightweightTypeReference(extend, this.services); if (reference != null) { final JvmType type = reference.getType(); if (type instanceof JvmDeclaredType) { for (final JvmConstructor constructor : ((JvmDeclaredType) type).getDeclaredConstructors()) { createNode(elementNode, constructor); } } } } }
Example #11
Source File: AbstractOutlineTreeProvider.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
/** * Default for createChildrenDispatcher with outline node as a parent node. * * @param parentNode * the {@link IOutlineNode} * @param modelElement * the {@link EObject} model element */ // CHECKSTYLE:CHECK-OFF Name (dispatcher enforces names starting with underscore) public void _createChildren(final IOutlineNode parentNode, final EObject modelElement) { // CHECKSTYLE:CHECK-ON if (modelElement != null && parentNode.hasChildren()) { if (parentNode instanceof DocumentRootNode) { internalCreateChildren((DocumentRootNode) parentNode, modelElement); } else if (parentNode instanceof EStructuralFeatureNode) { internalCreateChildren((EStructuralFeatureNode) parentNode, modelElement); } else { internalCreateChildren(parentNode, modelElement); } } }
Example #12
Source File: ScopeOutlineNodeComparator.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
@Override public int getCategory(final IOutlineNode node) { if (node instanceof EStructuralFeatureNode) { EStructuralFeature eStructuralFeature = ((EStructuralFeatureNode) node).getEStructuralFeature(); if (eStructuralFeature == ScopePackage.Literals.SCOPE_MODEL__IMPORTS) { return IMPORTS_ORDER; } } return 0; }
Example #13
Source File: ExportOutlineNodeComparator.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
@Override public int getCategory(final IOutlineNode node) { if (node instanceof EStructuralFeatureNode) { EStructuralFeature eStructuralFeature = ((EStructuralFeatureNode) node).getEStructuralFeature(); if (eStructuralFeature == ExportPackage.Literals.EXPORT_MODEL__IMPORTS) { return IMPORTS_ORDER; } } return 0; }
Example #14
Source File: ValidOutlineNodeComparator.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
@Override public int getCategory(final IOutlineNode node) { if (node instanceof EStructuralFeatureNode) { EStructuralFeature eStructuralFeature = ((EStructuralFeatureNode) node).getEStructuralFeature(); if (eStructuralFeature == ValidPackage.Literals.VALID_MODEL__IMPORTS) { return IMPORTS_ORDER; } } return 0; }
Example #15
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 #16
Source File: AbstractMultiModeOutlineTreeProvider.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override public IXtendOutlineContext buildImportSectionNode(XtendFile xtendFile, IXtendOutlineContext context) { EclipseXtendOutlineContext eclipseXtendOutlineContext = (EclipseXtendOutlineContext) context; IOutlineNode parentNode = eclipseXtendOutlineContext.getParentNode(); EStructuralFeatureNode node = getOutlineNodeFactory().createEStructuralFeatureNode(parentNode, xtendFile.getImportSection(), XtypePackage.Literals.XIMPORT_SECTION__IMPORT_DECLARATIONS, images.forImportContainer(), "import declarations", false); return eclipseXtendOutlineContext.withParentNode(node); }
Example #17
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 #18
Source File: AbstractOutlineTreeProvider.java From dsl-devkit with Eclipse Public License 1.0 | 4 votes |
/** * Creates a new structural feature node with a given image description and label. * * @param parentNode * the parent {@link IOutlineNode} * @param owner * a valid model element as {@link EObject} * @param feature * a structural feature {@link EStructuralFeature} * @param image * an image descriptor {@link ImageDescriptor} * @param text * the label text * @param isLeaf * true if feature is a leaf * @return newly created structural feature node */ protected EStructuralFeatureNode createEStructuralFeatureNode(final IOutlineNode parentNode, final EObject owner, final EStructuralFeature feature, final ImageDescriptor image, final Object text, final boolean isLeaf) { boolean isFeatureSet = owner.eIsSet(feature); EStructuralFeatureNode eStructuralFeatureNode = new EStructuralFeatureNode(owner, feature, parentNode, image, text, isLeaf || !isFeatureSet); if (isFeatureSet) { ITextRegion region = getLocationInFileProvider().getFullTextRegion(owner, feature, 0); if (feature.isMany()) { int numValues = ((Collection<?>) owner.eGet(feature)).size(); ITextRegion fullTextRegion = getLocationInFileProvider().getFullTextRegion(owner, feature, numValues - 1); if (fullTextRegion != null) { region = region.merge(fullTextRegion); } } eStructuralFeatureNode.setTextRegion(region); } return eStructuralFeatureNode; }
Example #19
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); } }
Example #20
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 #21
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 #22
Source File: SARLOutlineTreeProvider.java From sarl with Apache License 2.0 | 2 votes |
/** Create a node for the given feature container at the root level. * * @param parentNode the parent node. * @param modelElement the feature container for which a node should be created. */ protected void _createNode(EStructuralFeatureNode parentNode, XtendTypeDeclaration modelElement) { createTypeDeclarationNode(parentNode, modelElement); }