public static List<Action> containedActions(EObject e) { List<Action> allContentsOfType = getAllContentsOfType(e, Action.class); return allContentsOfType; }
public static List<RuleCall> containedRuleCalls(EObject e) { return getAllContentsOfType(e, RuleCall.class); }
public static List<Keyword> containedKeywords(EObject e) { return getAllContentsOfType(e, Keyword.class); }
public static List<Assignment> containedAssignments(EObject e) { return getAllContentsOfType(e, Assignment.class); }
public static List<CrossReference> containedCrossReferences(EObject e) { return getAllContentsOfType(e, CrossReference.class); }
private Collection<Feature> getAllFeatures(Structure type) { Collection<Feature> result = Sets.newLinkedHashSet(); if (type != null) { result.addAll(getAllContentsOfType(type, Feature.class)); result.addAll(InheritanceUtils.getInheritedFeatures(type)); } return result; }
private List<PrimitiveType> getPredefinedSimpleTypes() { ZenModel library = getSimpleTypeLibraryModel(); List<PrimitiveType> elementsFromLib = getAllContentsOfType(library, PrimitiveType.class); return elementsFromLib; }
private List<PrimitiveType> getPredefinedPrimitiveTypesTypes() { ZenModel library = getSimpleTypeLibraryModel(); List<PrimitiveType> elementsFromLib = getAllContentsOfType(library, PrimitiveType.class); return elementsFromLib; }
@Override protected void before(XExpression expression, IAppendable output, IExtraLanguageGeneratorContext context) { if (!(expression instanceof XClosure) && !(expression instanceof AnonymousClass)) { // Generate the closure definitions before their usage in the expressions for (final XClosure closure : EcoreUtil2.getAllContentsOfType(expression, XClosure.class)) { generateClosureDefinition(closure, output, context); } // Generate the closure definitions before their usage in the expressions for (final AnonymousClass anonClass : EcoreUtil2.getAllContentsOfType(expression, AnonymousClass.class)) { generateAnonymousClassDefinition(anonClass, output, context); } } }
public T getElement(String name) { if (elementsByName.isEmpty()) { for (T element : EcoreUtil2.getAllContentsOfType(getLibraryModel(libraryURI), type)) { elementsByName.put(getElementId().apply(element), element); } } return elementsByName.get(name); }
protected int getElementID(AbstractElement ele) { if (elementIDCache == null) { elementIDCache = Maps.newHashMap(); int counter = 0; for (ParserRule pr : GrammarUtil.allParserRules(grammar.getGrammar())) for (AbstractElement e : EcoreUtil2.getAllContentsOfType(pr, AbstractElement.class)) elementIDCache.put(e, counter++); } return elementIDCache.get(ele); }
public ISerializationDiagnostic getInvalidEnumValueDiagnostic(EObject semanticObject, RuleCall rc, Object value) { List<String> valid = Lists.newArrayList(); for (EnumLiteralDeclaration eld : org.eclipse.xtext.EcoreUtil2.getAllContentsOfType(rc.getRule(), EnumLiteralDeclaration.class)) valid.add(eld.getEnumLiteral().getInstance().getName()); StringBuilder msg = new StringBuilder(); msg.append("The value '" + value + "' is invalid for enum " + rc.getRule().getName() + "\n"); msg.append("Valid values are: " + Joiner.on(", ").join(valid)); return new SerializationDiagnostic(INVALID_ENUM_VALUE, semanticObject, rc, msg.toString()); }
private static boolean isLocalExpression(XExpression expression, ISideEffectContext context, boolean dereference) { if (expression == null) { return true; } if (expression instanceof XAbstractFeatureCall) { return isLocalExpression((XAbstractFeatureCall) expression, context, dereference); } for (final XAbstractFeatureCall featureCall : EcoreUtil2.getAllContentsOfType(expression, XAbstractFeatureCall.class)) { if (!isLocalExpression(featureCall, context, dereference)) { return false; } } return true; }
private IScope getScopeForDataResource(ServiceDataResource dataResource) { Set<PrimitiveProperty> result = Sets.newLinkedHashSet(); if (dataResource != null && dataResource.getDataType() != null) { Structure structure = dataResource.getDataType(); result.addAll(getAllContentsOfType(structure, PrimitiveProperty.class)); result.addAll(getInheritedPrimitiveProperties(structure)); } return Scopes.scopeFor(result); }
private void reportError(EClassifierInfo info, TransformationErrorCode errorCode, String message) { if (grammar == null) { reportError(errorCode, message, null); return; } List<TypeRef> typeRefs = EcoreUtil2.getAllContentsOfType(grammar, TypeRef.class); for(TypeRef typeRef: typeRefs) { EClassifierInfo otherInfo = infos.getInfo(typeRef); if (otherInfo == info) reportError(errorCode, message, typeRef); } }
IScope scope_TypedMessage_mediaTypes(TypedMessage message, EReference eRef) { IScope outer = delegateGetScope(message, eRef); // Add library to the scope try { ZenModel library = getStandardMediaTypesModel(); List<MediaType> elementsFromLib = getAllContentsOfType(library, MediaType.class); return Scopes.scopeFor(elementsFromLib, outer); } catch (Exception e) { RestApiXtextPlugin.log(e); } return outer; }
IScope scope_ResourceDefinition_mediaTypes(ResourceAPI resourceAPI, EReference eRef) { IScope outer = delegateGetScope(resourceAPI, eRef); // Add library to the scope try { ZenModel library = getStandardMediaTypesModel(); List<MediaType> elementsFromLib = getAllContentsOfType(library, MediaType.class); return Scopes.scopeFor(elementsFromLib, outer); } catch (Exception e) { RestApiXtextPlugin.log(e); } return outer; }
IScope scope_ReferenceLink_linkRelation(ReferenceLink referenceLink, EReference eRef) { IScope outer = delegateGetScope(referenceLink, eRef); // Add library to the scope try { ZenModel library = getIanaLinkRelationsModel(); List<LinkRelation> elementsFromLib = getAllContentsOfType(library, LinkRelation.class); return Scopes.scopeFor(elementsFromLib, outer); } catch (Exception e) { RestApiXtextPlugin.log(e); } return outer; }
public IScope scope_ReferencedXMAComposite_xmaComposite(ReferencedXMAComposite referencedXMAComposite, EReference eReference) { ReferencedXMAPage containingPage = EcoreUtil2.getContainerOfType(referencedXMAComposite, ReferencedXMAPage.class); XMAPage xmaPage = containingPage.getXmaPage(); return new SimpleScope(Scopes.scopedElementsFor(EcoreUtil2.getAllContentsOfType(xmaPage, XMAComposite.class), guiDesignNameFunction)); }
@Check public void checkEnumLiteralIsUnique(EnumLiteralDeclaration decl) { EnumRule rule = GrammarUtil.containingEnumRule(decl); List<EnumLiteralDeclaration> declarations = EcoreUtil2.getAllContentsOfType(rule, EnumLiteralDeclaration.class); String literal = decl.getLiteral().getValue(); if (literal != null) { for (EnumLiteralDeclaration otherDecl : declarations) { if (otherDecl != decl && literal.equals(otherDecl.getLiteral().getValue())) { error("Enum literal '" + literal + "' is used multiple times in enum rule '" + rule.getName() + "'.", XtextPackage.Literals.ENUM_LITERAL_DECLARATION__LITERAL); } } } }