org.eclipse.xtext.AbstractElement Java Examples

The following examples show how to use org.eclipse.xtext.AbstractElement. 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: AntlrContentAssistGrammarGenerator.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected String ebnf2(final AbstractElement it, final AntlrOptions options, final boolean supportActions) {
  if (it instanceof Alternatives) {
    return _ebnf2((Alternatives)it, options, supportActions);
  } else if (it instanceof Group) {
    return _ebnf2((Group)it, options, supportActions);
  } else if (it instanceof UnorderedGroup) {
    return _ebnf2((UnorderedGroup)it, options, supportActions);
  } else if (it instanceof Action) {
    return _ebnf2((Action)it, options, supportActions);
  } else if (it instanceof Assignment) {
    return _ebnf2((Assignment)it, options, supportActions);
  } else if (it instanceof EnumLiteralDeclaration) {
    return _ebnf2((EnumLiteralDeclaration)it, options, supportActions);
  } else if (it instanceof Keyword) {
    return _ebnf2((Keyword)it, options, supportActions);
  } else if (it instanceof RuleCall) {
    return _ebnf2((RuleCall)it, options, supportActions);
  } else if (it != null) {
    return _ebnf2(it, options, supportActions);
  } else {
    throw new IllegalArgumentException("Unhandled parameter types: " +
      Arrays.<Object>asList(it, options, supportActions).toString());
  }
}
 
Example #2
Source File: ContentAssistContextFactory.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
/**
 * AD 08/13 : Workaround for a bug manifesting itself as an infinite recursion over an AlternativesImpl element. The
 * choice here is to allow for 10 occurrences of the element to be computed and then fall back to the caller.
 */
@Override
protected void computeFollowElements(final FollowElementCalculator calculator, final FollowElement element,
		final Multimap<Integer, List<AbstractElement>> visited) {
	if (stop) { return; }
	final AbstractElement e = element.getGrammarElement();
	if (!recurse.containsKey(e)) {
		recurse.put(e, 1);
	} else {
		recurse.put(e, recurse.get(e) + 1);
	}
	if (recurse.get(e) > 3) {
		// GAMA.getGui().debug("Infinite recursion detected in completion proposal for " + e);
		stop = true;
		recurse.clear();
		return;
	}

	// scope.getGui().debug(" Computing FollowElement -- + visited : " +
	// element +
	// " ; number of times : " + recurse.get(e));
	super.computeFollowElements(calculator, element, visited);
}
 
Example #3
Source File: AntlrContentAssistGrammarGenerator.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected String assignmentEbnf(final AbstractElement it, final Assignment assignment, final AntlrOptions options, final boolean supportsActions) {
  if (it instanceof Alternatives) {
    return _assignmentEbnf((Alternatives)it, assignment, options, supportsActions);
  } else if (it instanceof Group) {
    return _assignmentEbnf((Group)it, assignment, options, supportsActions);
  } else if (it instanceof Action) {
    return _assignmentEbnf((Action)it, assignment, options, supportsActions);
  } else if (it instanceof Assignment) {
    return _assignmentEbnf((Assignment)it, assignment, options, supportsActions);
  } else if (it instanceof CrossReference) {
    return _assignmentEbnf((CrossReference)it, assignment, options, supportsActions);
  } else if (it instanceof RuleCall) {
    return _assignmentEbnf((RuleCall)it, assignment, options, supportsActions);
  } else if (it != null) {
    return _assignmentEbnf(it, assignment, options, supportsActions);
  } else {
    throw new IllegalArgumentException("Unhandled parameter types: " +
      Arrays.<Object>asList(it, assignment, options, supportsActions).toString());
  }
}
 
Example #4
Source File: TokenTypeRewriter.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
private static void rewriteIdentifiers(N4JSGrammarAccess ga,
		ImmutableMap.Builder<AbstractElement, Integer> builder) {
	ImmutableSet<AbstractRule> identifierRules = ImmutableSet.of(
			ga.getBindingIdentifierRule(),
			ga.getIdentifierNameRule(),
			ga.getIDENTIFIERRule());
	for (ParserRule rule : GrammarUtil.allParserRules(ga.getGrammar())) {
		for (EObject obj : EcoreUtil2.eAllContents(rule.getAlternatives())) {
			if (obj instanceof Assignment) {
				Assignment assignment = (Assignment) obj;
				AbstractElement terminal = assignment.getTerminal();
				int type = InternalN4JSParser.RULE_IDENTIFIER;
				if (terminal instanceof CrossReference) {
					terminal = ((CrossReference) terminal).getTerminal();
					type = IDENTIFIER_REF_TOKEN;
				}
				if (terminal instanceof RuleCall) {
					AbstractRule calledRule = ((RuleCall) terminal).getRule();
					if (identifierRules.contains(calledRule)) {
						builder.put(assignment, type);
					}
				}
			}
		}
	}
}
 
Example #5
Source File: CustomN4JSParser.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * First pass. Use the tokens that have been computed from the production parser's result and collect the follow
 * elements from those.
 */
private CustomInternalN4JSParser collectFollowElements(
		TokenSource tokens,
		AbstractElement grammarElement,
		String ruleName,
		boolean strict,
		Set<FollowElement> result) {
	CustomInternalN4JSParser parser = createParser();
	parser.setStrict(strict);
	try {
		if (grammarElement != null)
			parser.getGrammarElements().add(grammarElement);
		ObservableXtextTokenStream tokenStream = new ObservableXtextTokenStream(tokens, parser);
		result.addAll(doGetFollowElements(parser, tokenStream, ruleName));
	} catch (InfiniteRecursion infinite) {
		// this guards against erroneous infinite recovery loops in Antlr.
		// Grammar dependent and not expected something that is expected for N4JS
		// is used in the base class thus also used here.
		result.addAll(parser.getFollowElements());
	}
	return parser;
}
 
Example #6
Source File: BaseContentAssistParser.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
protected AbstractElement getEntryGrammarElement(ICompositeNode entryPoint) {
	EObject grammarElement = entryPoint.getGrammarElement();
	if (grammarElement instanceof RuleCall) {
		AbstractRule rule = ((RuleCall) grammarElement).getRule();
		if (rule instanceof ParserRule) {
			if (!GrammarUtil.isMultipleCardinality(rule.getAlternatives())) {
				grammarElement = rule.getAlternatives();
			}
		}
	} else if (grammarElement instanceof ParserRule) {
		grammarElement = ((ParserRule) grammarElement).getAlternatives();
	} else if (grammarElement instanceof CrossReference) {
		grammarElement = GrammarUtil.containingAssignment(grammarElement);
	}
	AbstractElement result = (AbstractElement) grammarElement;
	if (result instanceof Action) {
		return getEntryGrammarElement((ICompositeNode) entryPoint.getFirstChild());
	}
	return result;
}
 
Example #7
Source File: SyntacticSequencerPDAProvider.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Extracts the grammar from this transition or the NFA if this transition does not point to an
 * {@link AbstractElement}.
 */
private Grammar getGrammar(Nfa<ISynState> nfa) {
	AbstractElement grammarElement = getGrammarElement();
	if (grammarElement == null) {
		grammarElement = nfa.getStart().getGrammarElement();
		if (grammarElement == null) {
			grammarElement = nfa.getStop().getGrammarElement();
			if (grammarElement == null) {
				Iterator<ISynState> iter = nfa.getStart().getFollowers().iterator();
				while (grammarElement == null && iter.hasNext()) {
					grammarElement = iter.next().getGrammarElement();
				}
			}
		}
	}
	Grammar grammar = GrammarUtil.getGrammar(grammarElement);
	return grammar;
}
 
Example #8
Source File: DelegatingContentAssistContextFactory.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected ContentAssistContext.Builder convert(org.eclipse.xtext.ide.editor.contentassist.ContentAssistContext delegateContext) {
	ContentAssistContext.Builder context = contentAssistContextProvider.get();

	context.setRootNode(delegateContext.getRootNode());
	context.setLastCompleteNode(delegateContext.getLastCompleteNode());
	context.setCurrentNode(delegateContext.getCurrentNode());

	context.setRootModel(delegateContext.getRootModel());
	context.setCurrentModel(delegateContext.getCurrentModel());
	context.setPreviousModel(delegateContext.getPreviousModel());
	context.setOffset(delegateContext.getOffset());
	context.setViewer(viewer);
	context.setPrefix(delegateContext.getPrefix());
	Region region = new Region(delegateContext.getReplaceRegion().getOffset(), delegateContext.getReplaceRegion().getLength());
	context.setReplaceRegion(region);
	context.setSelectedText(delegateContext.getSelectedText());
	context.setMatcher(matcher);
	context.setResource(resource);
	for (AbstractElement grammarElement : delegateContext.getFirstSetGrammarElements()) {
		context.accept(grammarElement);
	}
	return context;
}
 
Example #9
Source File: TokenTypeRewriter.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
private static void rewriteKeywords(AbstractRule rule, N4JSKeywords keywords,
		ImmutableMap.Builder<AbstractElement, Integer> builder) {
	for (EObject obj : EcoreUtil2.eAllContents(rule.getAlternatives())) {
		if (obj instanceof Keyword) {
			Keyword keyword = (Keyword) obj;
			Integer type = keywords.getTokenType(keyword);
			if (type != null) {
				if (keyword.eContainer() instanceof EnumLiteralDeclaration) {
					builder.put((AbstractElement) keyword.eContainer(), type);
				} else {
					builder.put(keyword, type);
				}
			}
		}
	}
}
 
Example #10
Source File: KeywordAlternativeConverter.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * @throws IllegalArgumentException if the rule is not a datatype rule or does not match
 *   the pattern <pre>RuleName: 'keyword' | 'other';</pre>
 */
@Override
public void setRule(AbstractRule rule) {
	if (!GrammarUtil.isDatatypeRule(rule))
		throw new IllegalArgumentException(rule.getName() + " is not a data type rule");
	if (!(rule.getAlternatives() instanceof Alternatives)) {
		if (rule.getAlternatives() instanceof RuleCall) {
			delegateRule = ((RuleCall) rule.getAlternatives()).getRule();
			keywords = Collections.emptySet();
			return;
		}
		throw mismatchedRuleBody(rule);
	}
	Alternatives alternatives = (Alternatives) rule.getAlternatives();
	ImmutableSet.Builder<String> builder = ImmutableSet.builder();
	for (AbstractElement element : alternatives.getElements()) {
		processElement(element, rule, builder);
	}
	keywords = builder.build();
}
 
Example #11
Source File: GrammarAccessExtensions.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Returns the invocation of an element or rule accessor, including the .getType() call.
 * Example1: getFooRule().getType()
 * Example2: getBarRule().getFooAction().getType()
 */
public String gaTypeAccessor(final TypeRef ele) {
  String _switchResult = null;
  EObject _eContainer = ele.eContainer();
  final EObject cnt = _eContainer;
  boolean _matched = false;
  if (cnt instanceof AbstractElement) {
    _matched=true;
    String _gaRuleElementAccessor = this.gaRuleElementAccessor(((AbstractElement)cnt));
    _switchResult = (_gaRuleElementAccessor + ".getType()");
  }
  if (!_matched) {
    if (cnt instanceof AbstractRule) {
      _matched=true;
      String _gaRuleAccessor = this.gaRuleAccessor(((AbstractRule)cnt));
      _switchResult = (_gaRuleAccessor + ".getType()");
    }
  }
  if (!_matched) {
    String _name = ele.eContainer().eClass().getName();
    String _plus = ("<error: unknown type " + _name);
    _switchResult = (_plus + ">");
  }
  return _switchResult;
}
 
Example #12
Source File: ParserBasedContentAssistContextFactory.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Boolean caseGroup(Group object) {
	boolean more = true;
	if (object.getGuardCondition() != null) {
		Set<Parameter> parameterValues = getParameterValues(object);
		more = new ConditionEvaluator(parameterValues).evaluate(object.getGuardCondition());
	}
	if (more) {
		for(AbstractElement element: object.getElements()) {
			more = more && doSwitch(element);
		}
	}
	return more || isOptional(object);
}
 
Example #13
Source File: XbaseIdeContentProposalProvider.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected void completeBinaryOperation(final EObject model, final Assignment assignment, final ContentAssistContext context, final IIdeContentProposalAcceptor acceptor) {
  if ((model instanceof XBinaryOperation)) {
    int _length = context.getPrefix().length();
    boolean _tripleEquals = (_length == 0);
    if (_tripleEquals) {
      final INode currentNode = context.getCurrentNode();
      final int offset = currentNode.getOffset();
      final int endOffset = currentNode.getEndOffset();
      if ((((offset < context.getOffset()) && (endOffset >= context.getOffset())) && (currentNode.getGrammarElement() instanceof CrossReference))) {
        return;
      }
    }
    int _endOffset = NodeModelUtils.findActualNodeFor(model).getEndOffset();
    int _offset = context.getOffset();
    boolean _lessEqualsThan = (_endOffset <= _offset);
    if (_lessEqualsThan) {
      AbstractElement _terminal = assignment.getTerminal();
      this.createReceiverProposals(((XExpression) model), ((CrossReference) _terminal), context, acceptor);
    } else {
      AbstractElement _terminal_1 = assignment.getTerminal();
      this.createReceiverProposals(((XBinaryOperation)model).getLeftOperand(), 
        ((CrossReference) _terminal_1), context, acceptor);
    }
  } else {
    final EObject previousModel = context.getPreviousModel();
    if ((previousModel instanceof XExpression)) {
      if (((context.getPrefix().length() == 0) && (NodeModelUtils.getNode(previousModel).getEndOffset() > context.getOffset()))) {
        return;
      }
      AbstractElement _terminal_2 = assignment.getTerminal();
      this.createReceiverProposals(((XExpression)previousModel), 
        ((CrossReference) _terminal_2), context, acceptor);
    }
  }
}
 
Example #14
Source File: GrammarAccessExtensions.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
public CharSequence toStringLiteral(final AbstractElement it) {
  CharSequence _switchResult = null;
  boolean _matched = false;
  if (it instanceof RuleCall) {
    AbstractRule _rule = ((RuleCall)it).getRule();
    boolean _tripleNotEquals = (_rule != null);
    if (_tripleNotEquals) {
      _matched=true;
      _switchResult = AntlrGrammarGenUtil.getQualifiedNameAsString(((RuleCall)it));
    }
  }
  if (!_matched) {
    if (it instanceof Keyword) {
      _matched=true;
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("\"");
      String _stringInAntlrAction = AntlrGrammarGenUtil.toStringInAntlrAction(((Keyword)it).getValue());
      _builder.append(_stringInAntlrAction);
      _builder.append("\"");
      _switchResult = _builder;
    }
  }
  if (!_matched) {
    _switchResult = "null";
  }
  return _switchResult;
}
 
Example #15
Source File: ContentAssistContext.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void accept(AbstractElement element) {
	if (element == null)
		throw new NullPointerException("element may not be null");
	assertCanModify();
	context.firstSetGrammarElements = null;
	context.mutableFirstSetGrammarElements.add(element);
}
 
Example #16
Source File: GrammarAccess.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Returns the invocation of an element or rule accessor. Example1:
 * getFooRule() Example2: getBarRule().getFooAction()
 */
public String gaAccessor(EObject ele) {
	if (ele instanceof AbstractElement) {
		return gaRuleElementAccessor((AbstractElement) ele);
	} else if (ele instanceof AbstractRule) {
		return gaRuleAccessor((AbstractRule) ele);
	} else {
		return "<error: unknown type " + ele.eClass().getName() + ">";
	}
}
 
Example #17
Source File: PackratParserGenUtil.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
public static List<String> getConflictingKeywords(final AbstractElement element, final Grammar grammar) {
	if (element instanceof RuleCall) {
		AbstractRule rule = ((RuleCall) element).getRule();
		if (rule instanceof TerminalRule)
			return getConflictingKeywordsImpl(grammar, (TerminalRule) rule);
	}
	return null;
}
 
Example #18
Source File: FollowElementComputer.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @since 2.14
 */
protected int setParamConfigAndUpdateOffset(FollowElementCalculator calculator, List<Integer> paramStack, int paramIndex, AbstractElement abstractElement) {
	if (paramIndex >= 0) {
		calculator.setParameterConfig(paramStack.get(paramIndex));
	} else {
		calculator.setParameterConfig(0);
	}
	if (abstractElement instanceof RuleCall) {
		RuleCall call = (RuleCall) abstractElement;
		if (!call.getArguments().isEmpty()) {
			paramIndex++;
		}
	}
	return paramIndex;
}
 
Example #19
Source File: AbstractParserTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test public void testGrammarWithUsed_02() throws RecognitionException {
	String input = "grammar with org"; // default error recovery simply skips the keyword 'with'
	Set<AbstractElement> expected = Sets.<AbstractElement>newHashSet(
			grammarAccess.getGrammarIDAccess().getGroup_1(),
			grammarAccess.getGrammarAccess().getGroup_2(),
			grammarAccess.getGrammarAccess().getGroup_3(),
			grammarAccess.getGrammarAccess().getMetamodelDeclarationsAssignment_4(),
			grammarAccess.getAbstractRuleAccess().getAlternatives(),
			grammarAccess.getGrammarAccess().getRulesAssignment_5()
	);
	assertFollowers(input, expected);
}
 
Example #20
Source File: AntlrFragmentHelper.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
public Collection<? extends AbstractElement> getAllPredicatedElements(Grammar g) {
	Collection<AbstractElement> unfiltered = getAllElementsByType(g, AbstractElement.class);
	Collection<AbstractElement> result = Collections2.filter(unfiltered, new Predicate<AbstractElement>() {
		@Override
		public boolean apply(AbstractElement input) {
			return input.isPredicated();
		}
	});
	return result;
}
 
Example #21
Source File: Bug282031ParserTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private void assertFollowers(String input, Set<AbstractElement> expected) {
		Collection<FollowElement> followSet = getFollowSet(input);
//		Collection<FollowElement> followList = com.google.common.collect.Lists.newArrayList(getFollowSet(input));
		assertEquals(expected.size(), followSet.size());
		Set<AbstractElement> grammarElements = computeSearchElements(followSet);
		assertEquals(grammarElements.toString(), expected, grammarElements);
	}
 
Example #22
Source File: AssignmentFinderTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
private String findAssignments(EObject obj, Object value, AbstractElement... assignments) {
	AbstractElement element = (AbstractElement) NodeModelUtils.getNode(obj).getGrammarElement();
	ISerializationContext ctx = SerializationContext.forChild(null, element, obj);
	Multimap<AbstractElement, ISerializationContext> ass = ArrayListMultimap.create();
	for (AbstractElement e : assignments)
		ass.put(e, ctx);
	List<AbstractElement> found = Lists.newArrayList(finder.findAssignmentsByValue(obj, ass, value, null));
	Collections.sort(found, GrammarElementDeclarationOrder.get(GrammarUtil.getGrammar(assignments[0])));
	return Joiner.on(", ").join(Iterables.transform(found, new GrammarElementTitleSwitch().showAssignments()));
}
 
Example #23
Source File: FollowElementCalculator.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
public void doSwitch(UnorderedGroup group, List<AbstractElement> handledAlternatives) {
	this.group = group;
	this.handledAlternatives = handledAlternatives;
	try {
		doSwitch(group);
	} finally {
		this.handledAlternatives = null;
		this.group = null;
	}
}
 
Example #24
Source File: RuleWithoutInstantiationInspector.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Boolean caseCompoundElement(CompoundElement object) {
	if (GrammarUtil.isOptionalCardinality(object))
		return Boolean.FALSE;
	for(AbstractElement element: object.getElements()) {
		if (doSwitch(element))
			return Boolean.TRUE;
	}
	return Boolean.FALSE;
}
 
Example #25
Source File: TreeConstState.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
public Status getStatus() {
	if (distances == null) {
		AbstractElement rootEle = containingRule(element).getAlternatives();
		builder.getState(rootEle).initStatus();
	}
	return getStatusInternal();
}
 
Example #26
Source File: Bug347012TestLanguageParser.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private static void init(ImmutableMap.Builder<AbstractElement, String> builder, Bug347012TestLanguageGrammarAccess grammarAccess) {
	builder.put(grammarAccess.getVirtualSemiAccess().getAlternatives(), "rule__VirtualSemi__Alternatives");
	builder.put(grammarAccess.getLiteralAccess().getAlternatives(), "rule__Literal__Alternatives");
	builder.put(grammarAccess.getMyPrimaryAccess().getAlternatives(), "rule__MyPrimary__Alternatives");
	builder.put(grammarAccess.getMyAttributeAccess().getAlternatives(), "rule__MyAttribute__Alternatives");
	builder.put(grammarAccess.getMyProgramAccess().getGroup(), "rule__MyProgram__Group__0");
	builder.put(grammarAccess.getFQNAccess().getGroup(), "rule__FQN__Group__0");
	builder.put(grammarAccess.getFQNAccess().getGroup_1(), "rule__FQN__Group_1__0");
	builder.put(grammarAccess.getMyPackageAccess().getGroup(), "rule__MyPackage__Group__0");
	builder.put(grammarAccess.getMyPackageAccess().getGroup_6(), "rule__MyPackage__Group_6__0");
	builder.put(grammarAccess.getMyClassAccess().getGroup(), "rule__MyClass__Group__0");
	builder.put(grammarAccess.getMyClassAccess().getGroup_7(), "rule__MyClass__Group_7__0");
	builder.put(grammarAccess.getMyAttributesAccess().getGroup(), "rule__MyAttributes__Group__0");
	builder.put(grammarAccess.getMyFieldAccess().getGroup(), "rule__MyField__Group__0");
	builder.put(grammarAccess.getMyFieldAccess().getGroup_4(), "rule__MyField__Group_4__0");
	builder.put(grammarAccess.getMyBindingAccess().getGroup(), "rule__MyBinding__Group__0");
	builder.put(grammarAccess.getMyBindingAccess().getGroup_1(), "rule__MyBinding__Group_1__0");
	builder.put(grammarAccess.getMyBindingAccess().getGroup_2(), "rule__MyBinding__Group_2__0");
	builder.put(grammarAccess.getMyProgramAccess().getPackageAssignment_2(), "rule__MyProgram__PackageAssignment_2");
	builder.put(grammarAccess.getIdentifierAccess().getNameAssignment(), "rule__Identifier__NameAssignment");
	builder.put(grammarAccess.getLiteralAccess().getNumAssignment_0(), "rule__Literal__NumAssignment_0");
	builder.put(grammarAccess.getLiteralAccess().getStrAssignment_1(), "rule__Literal__StrAssignment_1");
	builder.put(grammarAccess.getLiteralAccess().getBoolAssignment_2(), "rule__Literal__BoolAssignment_2");
	builder.put(grammarAccess.getLiteralAccess().getBoolAssignment_3(), "rule__Literal__BoolAssignment_3");
	builder.put(grammarAccess.getMyPackageAccess().getNameAssignment_2(), "rule__MyPackage__NameAssignment_2");
	builder.put(grammarAccess.getMyPackageAccess().getDirectivesAssignment_6_0(), "rule__MyPackage__DirectivesAssignment_6_0");
	builder.put(grammarAccess.getMyClassAccess().getNameAssignment_3(), "rule__MyClass__NameAssignment_3");
	builder.put(grammarAccess.getMyClassAccess().getDirectivesAssignment_7_0(), "rule__MyClass__DirectivesAssignment_7_0");
	builder.put(grammarAccess.getMyAttributeAccess().getPUBLICAssignment_0(), "rule__MyAttribute__PUBLICAssignment_0");
	builder.put(grammarAccess.getMyAttributeAccess().getPRIVATEAssignment_1(), "rule__MyAttribute__PRIVATEAssignment_1");
	builder.put(grammarAccess.getMyAttributesAccess().getAttributesAssignment_1(), "rule__MyAttributes__AttributesAssignment_1");
	builder.put(grammarAccess.getMyFieldAccess().getAttrAssignment_0(), "rule__MyField__AttrAssignment_0");
	builder.put(grammarAccess.getMyFieldAccess().getBindingsAssignment_3(), "rule__MyField__BindingsAssignment_3");
	builder.put(grammarAccess.getMyFieldAccess().getBindingsAssignment_4_3(), "rule__MyField__BindingsAssignment_4_3");
	builder.put(grammarAccess.getMyBindingAccess().getNameAssignment_0(), "rule__MyBinding__NameAssignment_0");
	builder.put(grammarAccess.getMyBindingAccess().getTypeAssignment_1_3(), "rule__MyBinding__TypeAssignment_1_3");
	builder.put(grammarAccess.getMyBindingAccess().getExpressionAssignment_2_3(), "rule__MyBinding__ExpressionAssignment_2_3");
}
 
Example #27
Source File: ReferenceGrammarUiTestLanguageParser.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private static void init(ImmutableMap.Builder<AbstractElement, String> builder, ReferenceGrammarUiTestLanguageGrammarAccess grammarAccess) {
	builder.put(grammarAccess.getSpielplatzAccess().getAlternatives_4(), "rule__Spielplatz__Alternatives_4");
	builder.put(grammarAccess.getPersonAccess().getAlternatives(), "rule__Person__Alternatives");
	builder.put(grammarAccess.getFarbeAccess().getWertAlternatives_0(), "rule__Farbe__WertAlternatives_0");
	builder.put(grammarAccess.getFamilieAccess().getNameAlternatives_2_0(), "rule__Familie__NameAlternatives_2_0");
	builder.put(grammarAccess.getSpielplatzAccess().getGroup(), "rule__Spielplatz__Group__0");
	builder.put(grammarAccess.getKindAccess().getGroup(), "rule__Kind__Group__0");
	builder.put(grammarAccess.getErwachsenerAccess().getGroup(), "rule__Erwachsener__Group__0");
	builder.put(grammarAccess.getSpielzeugAccess().getGroup(), "rule__Spielzeug__Group__0");
	builder.put(grammarAccess.getFamilieAccess().getGroup(), "rule__Familie__Group__0");
	builder.put(grammarAccess.getFamilieAccess().getGroup_6(), "rule__Familie__Group_6__0");
	builder.put(grammarAccess.getSpielplatzAccess().getGroesseAssignment_1(), "rule__Spielplatz__GroesseAssignment_1");
	builder.put(grammarAccess.getSpielplatzAccess().getBeschreibungAssignment_2(), "rule__Spielplatz__BeschreibungAssignment_2");
	builder.put(grammarAccess.getSpielplatzAccess().getKinderAssignment_4_0(), "rule__Spielplatz__KinderAssignment_4_0");
	builder.put(grammarAccess.getSpielplatzAccess().getErzieherAssignment_4_1(), "rule__Spielplatz__ErzieherAssignment_4_1");
	builder.put(grammarAccess.getSpielplatzAccess().getSpielzeugeAssignment_4_2(), "rule__Spielplatz__SpielzeugeAssignment_4_2");
	builder.put(grammarAccess.getSpielplatzAccess().getFamilieAssignment_4_3(), "rule__Spielplatz__FamilieAssignment_4_3");
	builder.put(grammarAccess.getKindAccess().getNameAssignment_2(), "rule__Kind__NameAssignment_2");
	builder.put(grammarAccess.getKindAccess().getAgeAssignment_3(), "rule__Kind__AgeAssignment_3");
	builder.put(grammarAccess.getErwachsenerAccess().getNameAssignment_2(), "rule__Erwachsener__NameAssignment_2");
	builder.put(grammarAccess.getErwachsenerAccess().getAgeAssignment_3(), "rule__Erwachsener__AgeAssignment_3");
	builder.put(grammarAccess.getSpielzeugAccess().getNameAssignment_2(), "rule__Spielzeug__NameAssignment_2");
	builder.put(grammarAccess.getSpielzeugAccess().getFarbeAssignment_3(), "rule__Spielzeug__FarbeAssignment_3");
	builder.put(grammarAccess.getFarbeAccess().getWertAssignment(), "rule__Farbe__WertAssignment");
	builder.put(grammarAccess.getFamilieAccess().getNameAssignment_2(), "rule__Familie__NameAssignment_2");
	builder.put(grammarAccess.getFamilieAccess().getMutterAssignment_3(), "rule__Familie__MutterAssignment_3");
	builder.put(grammarAccess.getFamilieAccess().getVaterAssignment_4(), "rule__Familie__VaterAssignment_4");
	builder.put(grammarAccess.getFamilieAccess().getKinderAssignment_5(), "rule__Familie__KinderAssignment_5");
	builder.put(grammarAccess.getFamilieAccess().getKinderAssignment_6_1(), "rule__Familie__KinderAssignment_6_1");
}
 
Example #28
Source File: GrammarPDAProvider.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public ISerState createState(SerializerPDA nfa, AbstractElement token) {
	AbstractElement original = original(token);
	ISerState state = states.get(original);
	if (state == null) {
		state = delegate.createState(nfa, original);
		states.put(original, state);
	}
	return state;
}
 
Example #29
Source File: CfgAdapter.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Iterable<AbstractElement> getAlternativeChildren(AbstractElement ele) {
	switch (ele.eClass().getClassifierID()) {
		case XtextPackage.ALTERNATIVES:
			return ((Alternatives) ele).getElements();
		default:
			return null;
	}
}
 
Example #30
Source File: FollowElementComputer.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
private boolean isAlternativeWithEmptyPath(AbstractElement abstractElement) {
	if (abstractElement instanceof Alternatives) {
		Alternatives alternatives = (Alternatives) abstractElement;
		for(AbstractElement path: alternatives.getElements()) {
			if (GrammarUtil.isOptionalCardinality(path))
				return true;
		}
	}
	return false;
}