private IScope scope_TextPropertyAssignment_Attribute(EObject context) { NodeElement nodeElement = EcoreUtil2.getContainerOfType(context, NodeElement.class); EdgeElement edgeElement = EcoreUtil2.getContainerOfType(context, EdgeElement.class); if (nodeElement != null || edgeElement != null) { Predicate<EObject> filterPredicate = new Predicate<EObject>() { @Override public boolean apply(EObject input) { if (input instanceof EAttribute) { if (((EAttribute) input).getEType().getName().equals("EString")) { return true; } } return false; } }; if (nodeElement != null) { return MapBasedScope.createScope( IScope.NULLSCOPE, Scopes.scopedElementsFor( Iterables.filter(nodeElement.getType().getEAllAttributes(), filterPredicate))); } else { return MapBasedScope.createScope( IScope.NULLSCOPE, Scopes.scopedElementsFor( Iterables.filter(edgeElement.getType().getEAllAttributes(), filterPredicate))); } } else { return IScope.NULLSCOPE; } }
private IScope scope_NodeBehaviorSectionCreateableIn(EObject context, EReference reference) { Diagram diagram = EcoreUtil2.getContainerOfType(context, Diagram.class); NodeElement nodeElement = EcoreUtil2.getContainerOfType(context, NodeElement.class); if (diagram == null || nodeElement == null) { return IScope.NULLSCOPE; } // all eClasses that are direct containments of context's diagram model type final EClass diagramModelType = diagram.getModelType(); if (diagramModelType == null || diagramModelType.getEPackage() == null) { return IScope.NULLSCOPE; } List<EReference> containmentReferences = new ArrayList<EReference>(); for (EClassifier eClassifiers : diagramModelType.getEPackage().getEClassifiers()) { if (eClassifiers instanceof EClass) { for (EReference ref : ((EClass) eClassifiers).getEAllContainments()) { if (ref.getEType() instanceof EClass && ((EClass) ref.getEType()).isSuperTypeOf(nodeElement.getType())) { containmentReferences.add(ref); } } } } return Scopes.scopeFor(containmentReferences); }