protected TerminalRule getWSRule() { // FIXME: make this configurable return (TerminalRule) GrammarUtil.findRuleForName(grammar.getGrammar(), "WS"); }
protected Assignment getAssignment(AbstractElement ele) { Assignment ass = GrammarUtil.containingAssignment(ele); if (ass == null) throw new RuntimeException("Only Assigned " + ele.eClass().getName() + "s are allowed"); return ass; }
protected void lookupCrossReference(CrossReference crossReference, ContentAssistContext contentAssistContext, ICompletionProposalAcceptor acceptor, Predicate<IEObjectDescription> filter) { ParserRule containingParserRule = GrammarUtil.containingParserRule(crossReference); if (!GrammarUtil.isDatatypeRule(containingParserRule)) { EReference ref = GrammarUtil.getReference(crossReference); lookupCrossReference(crossReference, ref, contentAssistContext, acceptor, filter); } }
/** * @since 2.0 */ public static boolean isAssignedEObjectRuleCall(EObject ele) { if (!isEObjectRuleCall(ele)) return false; return GrammarUtil.containingAssignment(ele) != null; }
protected ConstraintElement(EObject context, ConstraintElementType type, AbstractElement element) { this(context, type, element, type != ConstraintElementType.ASSIGNED_ACTION_CALL && GrammarUtil.isMultipleCardinality(element), type != ConstraintElementType.ASSIGNED_ACTION_CALL && GrammarUtil.isOptionalCardinality(element)); }
private boolean isUnassignedRuleCall(final RuleCall c) { boolean _isEObjectRuleCall = GrammarUtil.isEObjectRuleCall(c); if (_isEObjectRuleCall) { return false; } final Assignment ass = GrammarUtil.containingAssignment(c); return ((ass == null) || GrammarUtil.isBooleanAssignment(ass)); }
public void accept(AbstractElement element) { ParserRule rule = GrammarUtil.containingParserRule(element); if (rule == null || !GrammarUtil.isDatatypeRule(rule)) result.add(element); } };
@Override public Boolean caseAbstractElement(AbstractElement object) { return !GrammarUtil.isOptionalCardinality(object); }
@Override public Boolean caseParserRule(ParserRule object) { assignedActionAllowed = !GrammarUtil.isDatatypeRule(object); return assignedActionAllowed; }
@Override public Boolean caseRuleCall(RuleCall object) { if (GrammarUtil.isOptionalCardinality(object)) return Boolean.FALSE; return object.getRule() == null || (object.getRule() instanceof ParserRule && !GrammarUtil.isDatatypeRule((ParserRule) object.getRule())); }
/** * @since 2.4 * @nooverride This method is not intended to be re-implemented or extended by clients. * @noreference This method is not intended to be referenced by clients. */ protected void registerEFactoryConverters(Map<String, IValueConverter<Object>> converters) { for (ParserRule parserRule : allParserRules(getGrammar())) { if (isDatatypeRule(parserRule) && !converters.containsKey(parserRule.getName())) { EDataType datatype = (EDataType) parserRule.getType().getClassifier(); converters.put(parserRule.getName(), new EFactoryValueConverter(datatype)); } } for (TerminalRule terminalRule : allTerminalRules(getGrammar())) { if (!terminalRule.isFragment()) { String terminalRuleName = terminalRule.getName(); if (!converters.containsKey(terminalRuleName)) { converters.put(terminalRuleName, defaultTerminalConverterFactory.create(terminalRule)); } } } }
StringConcatenation _builder = new StringConcatenation(); List<ParserRule> _allParserRules = GrammarUtil.allParserRules(g); List<EnumRule> _allEnumRules = GrammarUtil.allEnumRules(g); Iterable<AbstractRule> _plus = Iterables.<AbstractRule>concat(_allParserRules, _allEnumRules); Collection<? extends AbstractElement> _allAlternatives = GrammarUtil.getAllAlternatives(g); Iterable<EObject> _plus_1 = Iterables.<EObject>concat(_plus, _allAlternatives); Collection<? extends AbstractElement> _allGroups = GrammarUtil.getAllGroups(g); Iterable<EObject> _plus_2 = Iterables.<EObject>concat(_plus_1, _allGroups); Collection<? extends AbstractElement> _allUnorderedGroups = GrammarUtil.getAllUnorderedGroups(g); Iterable<EObject> _plus_3 = Iterables.<EObject>concat(_plus_2, _allUnorderedGroups); Collection<? extends AbstractElement> _allAssignments = GrammarUtil.getAllAssignments(g); final Function1<EObject, Boolean> _function = (EObject it) -> { return Boolean.valueOf(this._grammarAccessExtensions.isCalled(GrammarUtil.containingRule(it), g)); }; Iterable<EObject> _filter = IterableExtensions.<EObject>filter(Iterables.<EObject>concat(_plus_3, _allAssignments), _function);
protected String _localVar(final AbstractElement it) { String _xblockexpression = null; { final ParserRule rule = GrammarUtil.containingParserRule(it); final int index = this.contentsAsList(rule).indexOf(it); _xblockexpression = ("otherlv_" + Integer.valueOf(index)); } return _xblockexpression; }
public List<EObject> getAllContexts(Grammar grammar) { List<EObject> result = Lists.newArrayList(); for (ParserRule pr : GrammarUtil.allParserRules(grammar)) if (GrammarUtil.isEObjectRule(pr)) { result.add(pr); for (Action action : GrammarUtil.containedActions(pr)) if (GrammarUtil.isAssignedAction(action)) result.add(action); } return result; }
@Override protected boolean canInspect(ParserRule rule) { if (GrammarUtil.getGrammar(rule).getRules().get(0) != rule) return false; if (GrammarUtil.isDatatypeRule(rule) || rule.getAlternatives() == null) return false; return super.canInspect(rule); }
protected String getUnassignedRuleCallToken(RuleCall ruleCall, INode node) { Assignment ass = GrammarUtil.containingAssignment(ruleCall); if (ass != null && !GrammarUtil.isBooleanAssignment(ass)) throw new IllegalStateException("RuleCall is invalid; Can not determine token."); return getUnassignedRuleCallToken(contexts.peek().semanticObject, ruleCall, node); }
public static Set<String> getAllKeywords(Grammar g) { Set<String> kws = new HashSet<String>(); List<ParserRule> rules = allParserRules(g); for (ParserRule parserRule : rules) { List<Keyword> list = typeSelect(eAllContentsAsList(parserRule), Keyword.class); for (Keyword keyword : list) { kws.add(keyword.getValue()); } } List<EnumRule> enumRules = allEnumRules(g); for (EnumRule enumRule : enumRules) { List<Keyword> list = typeSelect(eAllContentsAsList(enumRule), Keyword.class); for (Keyword keyword : list) { kws.add(keyword.getValue()); } } return kws; }
/** * @since 2.0 */ protected EClass getConstructedType(AbstractElement ele) { if (ele instanceof Action) return (EClass) ((Action) ele).getType().getClassifier(); if (GrammarUtil.containingAssignment(ele) != null) return (EClass) GrammarUtil.containingRule(ele).getType().getClassifier(); return null; }
public static Collection<EPackage> allEPackagesToValidate(final Grammar _this) { Iterable<TypeRef> allTypeRefs = concat(transform(allParserRules(_this), new Function<ParserRule, Iterable<TypeRef>>() { public Iterable<TypeRef> apply(ParserRule from) { return EcoreUtil2.eAllOfType(from, TypeRef.class); } })); return newLinkedHashSet(transform(filter(allTypeRefs, new Predicate<TypeRef>() { public boolean apply(TypeRef input) { return !(input.eContainer() instanceof CrossReference) && input.getClassifier() instanceof EClass; } }), new Function<TypeRef, EPackage>() { public EPackage apply(TypeRef from) { return from.getClassifier().getEPackage(); } })); }
protected void collectReachableRules(ParserRule pr, Set<ParserRule> rules, Set<ParserRule> visited) { if (!visited.add(pr)) return; for (RuleCall rc : GrammarUtil.containedRuleCalls(pr)) if (isParserRule(rc.getRule())) { if (GrammarUtil.containingAssignment(rc) != null) rules.add((ParserRule) rc.getRule()); collectReachableRules((ParserRule) rc.getRule(), rules, visited); } }