Java Code Examples for org.eclipse.emf.ecore.EObject#eContents()
The following examples show how to use
org.eclipse.emf.ecore.EObject#eContents() .
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: XbaseUsageCrossReferencer.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Override protected TreeIterator<Notifier> newContentsIterator() { return new ContentTreeIterator<Notifier>(emfObjects) { private static final long serialVersionUID = 1L; @Override protected Iterator<? extends EObject> getEObjectChildren(EObject eObject) { if(eObject instanceof XAbstractFeatureCall){ Iterable<EObject> result = eObject.eContents(); XAbstractFeatureCall featureCall = (XAbstractFeatureCall) eObject; XExpression implicitReceiver = featureCall.getImplicitReceiver(); if(implicitReceiver != null) result = Iterables.concat(result, Collections.singleton(implicitReceiver)); XExpression implicitFirstArgument = featureCall.getImplicitFirstArgument(); if(implicitFirstArgument != null) result = Iterables.concat(result, Collections.singleton(implicitFirstArgument)); return result.iterator(); } else return super.getEObjectChildren(eObject); } }; }
Example 2
Source File: ModelComparer.java From slr-toolkit with Eclipse Public License 1.0 | 6 votes |
/** * Compares to objects and their descendants recursively. * Returns true if the objects and their descendants are structurally equal. * Order of descendants is not taken into account. */ public boolean equals(EObject obj1, EObject obj2){ if(obj1 == null || obj2 == null){ return false; } Comparator<EObject> comparator = new EObjectComparator(); if(comparator.compare(obj1, obj2) != 0 || obj1.eContents().size() != obj2.eContents().size()){ return false; } List<EObject> sortedList1 = new ArrayList<EObject>(obj1.eContents()); List<EObject> sortedList2 = new ArrayList<EObject>(obj2.eContents()); Collections.sort(sortedList1, comparator); Collections.sort(sortedList2, comparator); for(int i = 0; i < sortedList1.size(); i++){ if(!equals(sortedList1.get(i), sortedList2.get(i))){ return false; } } return true; }
Example 3
Source File: EmfStructureComparator.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected List<EObject> getRelevantChildren(EObject _this) { List<EObject> relevantChildren = new ArrayList<EObject>(_this.eContents()); for (Iterator<EObject> i = relevantChildren.iterator(); i.hasNext();) { EObject next = i.next(); if (!isRelevantChild(_this, next)) { i.remove(); } } return relevantChildren; }
Example 4
Source File: ExternalRepositoryInfoResponseContentHandlerV1.java From ADT_Frontend with MIT License | 5 votes |
public IExternalRepositoryInfo loadEmf(Resource resource) { //use some virtual resource name EObject documentRoot = resource.getContents().get(0); if (documentRoot != null) { for (EObject element : documentRoot.eContents()) { if (element instanceof IExternalRepositoryInfo) { return (IExternalRepositoryInfo) element; } } } throw new IllegalArgumentException("Invalid XML content - root model entity not found"); //$NON-NLS-1$ }
Example 5
Source File: ModelHelper.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private static <T extends EObject> void addAllItemsOfContainer(final EObject container, final List<T> res, final Class<T> type) { if (container != null) { if (type.isAssignableFrom(container.getClass())) { res.add((T) container); } for (final EObject child : container.eContents()) { addAllItemsOfContainer(child, res, type); } } }
Example 6
Source File: ModelHelper.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * Applies the specifier {@link ElementProcessor} to all instance of eClass * in specified model and children * * @param model * @param eClass * @param elementProcessor */ @SuppressWarnings("unchecked") public static <T extends EObject> void applyTo(final EObject model, final EClass eClass, final ElementProcessor<T> elementProcessor) { if (eClass.isSuperTypeOf(model.eClass())) { elementProcessor.apply((T) model); } for (final EObject content : model.eContents()) { applyTo(content, eClass, elementProcessor); } }
Example 7
Source File: N4JSResource.java From n4js with Eclipse Public License 1.0 | 5 votes |
private void proxifyASTReferences(EObject object) { if (object instanceof SyntaxRelatedTElement) { SyntaxRelatedTElement element = (SyntaxRelatedTElement) object; EObject astElement = element.getAstElement(); if (astElement != null && !astElement.eIsProxy()) { InternalEObject proxy = (InternalEObject) EcoreUtil.create(astElement.eClass()); proxy.eSetProxyURI(EcoreUtil.getURI(astElement)); element.setAstElement(proxy); } } for (EObject child : object.eContents()) { proxifyASTReferences(child); } }
Example 8
Source File: XbaseImportedNamespaceScopeProvider.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected List<ImportNormalizer> internalGetImportedNamespaceResolvers(final EObject context, boolean ignoreCase) { List<ImportNormalizer> importedNamespaceResolvers = Lists.newArrayList(); EList<EObject> eContents = context.eContents(); for (EObject child : eContents) { String value = getImportedNamespace(child); ImportNormalizer resolver = createImportedNamespaceResolver(value, ignoreCase); if (resolver != null) importedNamespaceResolvers.add(resolver); } return importedNamespaceResolvers; }
Example 9
Source File: EarlyExitValidator.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected void collectExits(EObject expr, List<XExpression> found) { if (expr instanceof XReturnExpression) { found.add((XExpression) expr); } else if (expr instanceof XThrowExpression) { found.add((XExpression) expr); } else if (expr instanceof XClosure) { return; } for (EObject child : expr.eContents()) { collectExits(child, found); } }
Example 10
Source File: AbapGitStagingContentHandler.java From ADT_Frontend with MIT License | 5 votes |
public IAbapGitStaging loadEmf(Resource resource) { //use some virtual resource name EObject documentRoot = resource.getContents().get(0); if (documentRoot != null) { for (EObject element : documentRoot.eContents()) { if (element instanceof IAbapGitStaging) { return (IAbapGitStaging) element; } } } throw new IllegalArgumentException("Invalid XML content - root model entity not found"); //$NON-NLS-1$ }
Example 11
Source File: DotRecordBasedJavaFxNode.java From gef with Eclipse Public License 2.0 | 5 votes |
private void addToFx(EObject parsedObject, LabelNode treeNode) { for (EObject child : parsedObject.eContents()) { if (child instanceof Field && ((Field) child).getLabel() != null) { addToFx(((Field) child).getLabel(), treeNode.childNode()); } else if (child instanceof Field && ((Field) child).getFieldID() != null) { treeNode.addText(((Field) child).getFieldID().getName(), zestNodeLabelCssStyle); } } }
Example 12
Source File: ImportedNamespaceAwareLocalScopeProvider.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected List<ImportNormalizer> internalGetImportedNamespaceResolvers(final EObject context, boolean ignoreCase) { List<ImportNormalizer> importedNamespaceResolvers = Lists.newArrayList(); EList<EObject> eContents = context.eContents(); for (EObject child : eContents) { String value = getImportedNamespace(child); ImportNormalizer resolver = createImportedNamespaceResolver(value, ignoreCase); if (resolver != null) importedNamespaceResolvers.add(resolver); } return importedNamespaceResolvers; }
Example 13
Source File: LocalUniqueNameContext.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
public LocalUniqueNameContext(EObject container, boolean deep, Function<EObject, String> nameFunction, CancelIndicator ci) { this(deep ? () -> container.eAllContents() : container.eContents(), nameFunction, ci); }
Example 14
Source File: AbstractFormatter2.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
/** * Fall-back for types that are not handled by a subclasse's dispatch method. */ protected void _format(EObject obj, IFormattableDocument document) { for (EObject child : obj.eContents()) document.format(child); }
Example 15
Source File: JFlexGeneratorFragmentTemplate.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
protected void _collectTokens(final EObject it, final List<String> known) { EList<EObject> _eContents = it.eContents(); for (final EObject e : _eContents) { this.collectTokens(e, known); } }
Example 16
Source File: BackgroundOutlineTreeProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
protected void internalCreateChildren(IOutlineNode parentNode, EObject modelElement) { for (EObject childElement : modelElement.eContents()) createNode(parentNode, childElement); }
Example 17
Source File: DefaultOutlineTreeProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
protected void _createChildren(IOutlineNode parentNode, EObject modelElement) { for (EObject childElement : modelElement.eContents()) createNode(parentNode, childElement); }
Example 18
Source File: DomainmodelOutlineTreeProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
@Override protected void _createChildren(DocumentRootNode parentNode, EObject rootElement) { for (EObject content : rootElement.eContents()) { createNode(parentNode, content); } }
Example 19
Source File: TemplateCustomProperties.java From M2Doc with Eclipse Public License 1.0 | 4 votes |
/** * Walks the given {@link EObject} for missing variables. * * @param declarations * the known declarations * @param missing * the missing declarations * @param used * the used declarations * @param eObj * the current {@link EObject} to walk */ private void walkForNeededVariables(List<String> declarations, Set<String> missing, Set<String> used, EObject eObj) { if (eObj instanceof VarRef) { final String variableName = ((VarRef) eObj).getVariableName(); used.add(variableName); if (!declarations.contains(variableName)) { missing.add(variableName); } } else if (eObj instanceof Repetition) { walkForNeededVariables(declarations, missing, used, ((Repetition) eObj).getQuery().getAst()); declarations.add(((Repetition) eObj).getIterationVar()); walkForNeededVariables(declarations, missing, used, ((Repetition) eObj).getBody()); declarations.remove(((Repetition) eObj).getIterationVar()); } else if (eObj instanceof Let) { walkForNeededVariables(declarations, missing, used, ((Let) eObj).getValue().getAst()); declarations.add(((Let) eObj).getName()); walkForNeededVariables(declarations, missing, used, ((Let) eObj).getBody()); declarations.remove(((Let) eObj).getName()); } else if (eObj instanceof Conditional) { walkForNeededVariables(declarations, missing, used, ((Conditional) eObj).getCondition().getAst()); walkForNeededVariables(declarations, missing, used, ((Conditional) eObj).getThen()); if (((Conditional) eObj).getElse() != null) { walkForNeededVariables(declarations, missing, used, ((Conditional) eObj).getElse()); } } else if (eObj instanceof Link) { walkForNeededVariables(declarations, missing, used, ((Link) eObj).getName().getAst()); walkForNeededVariables(declarations, missing, used, ((Link) eObj).getText().getAst()); } else if (eObj instanceof Bookmark) { walkForNeededVariables(declarations, missing, used, ((Bookmark) eObj).getName().getAst()); walkForNeededVariables(declarations, missing, used, ((Bookmark) eObj).getBody()); } else if (eObj instanceof org.obeonetwork.m2doc.template.Query) { walkForNeededVariables(declarations, missing, used, ((org.obeonetwork.m2doc.template.Query) eObj).getQuery().getAst()); } else if (eObj instanceof Lambda) { final List<String> lambdaDeclartations = new ArrayList<>(); for (VariableDeclaration parameter : ((Lambda) eObj).getParameters()) { lambdaDeclartations.add(parameter.getName()); } declarations.addAll(lambdaDeclartations); walkForNeededVariables(declarations, missing, used, ((Lambda) eObj).getExpression()); declarations.removeAll(lambdaDeclartations); } else if (eObj instanceof org.eclipse.acceleo.query.ast.Let) { final List<String> letDeclartations = new ArrayList<>(); for (Binding binding : ((org.eclipse.acceleo.query.ast.Let) eObj).getBindings()) { letDeclartations.add(binding.getName()); walkForNeededVariables(declarations, missing, used, binding.getValue()); } declarations.addAll(letDeclartations); walkForNeededVariables(declarations, missing, used, ((org.eclipse.acceleo.query.ast.Let) eObj).getBody()); declarations.removeAll(letDeclartations); } else { for (EObject child : eObj.eContents()) { walkForNeededVariables(declarations, missing, used, child); } } }
Example 20
Source File: AbstractModelInferrer.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
public void _infer(EObject e, /* @NonNull */ IJvmDeclaredTypeAcceptor acceptor, boolean preIndexingPhase) { for (EObject child : e.eContents()) { infer(child, acceptor, preIndexingPhase); } }