org.eclipse.xtext.EnumLiteralDeclaration Java Examples
The following examples show how to use
org.eclipse.xtext.EnumLiteralDeclaration.
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: TokenDiagnosticProvider.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override 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, grammarAccess.getGrammar(), msg.toString()); }
Example #2
Source File: XtextLabelProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
StyledString text(EnumLiteralDeclaration object) { String literalName = getLiteralName(object); Keyword kw = object.getLiteral(); String kwValue = kw == null ? "" : " = '" + kw.getValue() + "'"; return new StyledString(literalName + kwValue, UNKNOWN.equalsIgnoreCase(literalName) ? stylerFactory.createStyler( JFacePreferences.ERROR_COLOR, null) : null); }
Example #3
Source File: DebugConsumerUtility.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public int consumeEnum(EnumLiteralDeclaration literal, ICharacterClass notFollowedBy) { if (log.isDebugEnabled()) { log.debug("consumeEnum(enum = '" + literal.getEnumLiteral().getName() + "', " + "literal = " + literal.getLiteral() + ")"); } int result = delegate.consumeEnum(literal, notFollowedBy); if (log.isDebugEnabled()) { log.debug("consumeKeyword('" + literal.getLiteral() + "') = " + result); } return result; }
Example #4
Source File: GrammarParserTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testEnum_04() throws Exception { String modelAsString = "grammar TestLanguage with org.eclipse.xtext.common.Terminals\n" + "import 'classpath:/org/eclipse/xtext/enumrules/enums.ecore'\n" + "generate testLanguage 'http://www.eclipse.org/2009/tmf/xtext/AbstractEnumRulesTest/TestEnum/4'\n" + "Model: enumValue=ExistingEnum;\n" + "enum ExistingEnum: SameName;"; Grammar grammar = (Grammar) getModel(modelAsString); assertTrue(grammar.eResource().getErrors().toString(), grammar.eResource().getErrors().isEmpty()); checkEnums(grammar); EPackage pack = grammar.getMetamodelDeclarations().get(0).getEPackage(); assertEquals("http://www.eclipse.org/2009/tmf/xtext/EnumRulesTestLanguage/imported", pack.getNsURI()); EEnum eEnum = (EEnum) pack.getEClassifier("ExistingEnum"); assertNotNull(eEnum); assertEquals(3, eEnum.getELiterals().size()); EEnumLiteral value = eEnum.getELiterals().get(0); assertEquals(ExistingEnum.SAME_NAME.getName(), value.getName()); assertEquals(ExistingEnum.SAME_NAME.getValue(), value.getValue()); assertEquals(ExistingEnum.SAME_NAME.getLiteral(), value.getLiteral()); EnumRule rule = (EnumRule) grammar.getRules().get(1); assertEquals(eEnum, rule.getType().getClassifier()); EnumLiteralDeclaration decl = (EnumLiteralDeclaration) rule.getAlternatives(); assertEquals(value, decl.getEnumLiteral()); assertNotNull(decl.getLiteral()); assertEquals(value.getLiteral(), decl.getLiteral().getValue()); }
Example #5
Source File: XtextGrammarQuickfixProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Fix(EMPTY_ENUM_LITERAL) public void fixEmptyEnumLiteral(final Issue issue, IssueResolutionAcceptor acceptor) { acceptor.acceptMulti(issue, "Fix empty enum literal", "Fix empty enum literal", NULL_QUICKFIX_IMAGE, (EObject element) -> { EnumLiteralDeclaration enumLiteralDeclaration = (EnumLiteralDeclaration) element; Keyword keyword = XtextFactory.eINSTANCE.createKeyword(); keyword.setValue(enumLiteralDeclaration.getEnumLiteral().getName().toLowerCase()); enumLiteralDeclaration.setLiteral(keyword); }); }
Example #6
Source File: GrammarParserTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testEnum_10() throws Exception { String modelAsString = "grammar TestLanguage with org.eclipse.xtext.enumrules.EnumRulesTestLanguage\n" + "import 'classpath:/org/eclipse/xtext/enumrules/enums.ecore'\n" + "generate testLanguage 'http://www.eclipse.org/2009/tmf/xtext/AbstractEnumRulesTest/TestEnum/10'\n" + "Model: enumValue=ExistingEnum;\n" + "enum ExistingEnum: SameName;"; Grammar grammar = (Grammar) getModel(modelAsString); assertTrue(grammar.eResource().getErrors().toString(), grammar.eResource().getErrors().isEmpty()); checkEnums(grammar); EPackage pack = grammar.getMetamodelDeclarations().get(0).getEPackage(); assertEquals("http://www.eclipse.org/2009/tmf/xtext/EnumRulesTestLanguage/imported", pack.getNsURI()); EEnum eEnum = (EEnum) pack.getEClassifier("ExistingEnum"); assertNotNull(eEnum); assertEquals(3, eEnum.getELiterals().size()); EEnumLiteral value = eEnum.getELiterals().get(0); assertEquals(ExistingEnum.SAME_NAME.getName(), value.getName()); assertEquals(ExistingEnum.SAME_NAME.getValue(), value.getValue()); assertEquals(ExistingEnum.SAME_NAME.getLiteral(), value.getLiteral()); EnumRule rule = (EnumRule) grammar.getRules().get(1); assertEquals(eEnum, rule.getType().getClassifier()); EnumLiteralDeclaration decl = (EnumLiteralDeclaration) rule.getAlternatives(); assertEquals(value, decl.getEnumLiteral()); assertNotNull(decl.getLiteral()); assertEquals("SameName", decl.getLiteral().getValue()); }
Example #7
Source File: EnumLiteralSerializer.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected Keyword getLiteral(INode node) { if (node != null) { for(ILeafNode leaf: node.getLeafNodes()) { if (leaf.getGrammarElement() instanceof EnumLiteralDeclaration) return ((EnumLiteralDeclaration) leaf.getGrammarElement()).getLiteral(); } } return null; }
Example #8
Source File: AntlrGrammarGenerator.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override protected String _ebnf2(final EnumLiteralDeclaration it, final AntlrOptions options, final boolean supportActions) { String _xifexpression = null; if ((!supportActions)) { _xifexpression = super._ebnf2(it, options, supportActions); } else { StringConcatenation _builder = new StringConcatenation(); String _localVar = this._grammarAccessExtensions.localVar(it); _builder.append(_localVar); _builder.append("="); String __ebnf2 = super._ebnf2(it, options, supportActions); _builder.append(__ebnf2); _builder.newLineIfNotEmpty(); _builder.append("{"); _builder.newLine(); _builder.append("\t"); _builder.append("$current = grammarAccess."); String _grammarElementAccess = this._grammarAccessExtensions.grammarElementAccess(AntlrGrammarGenUtil.<EnumLiteralDeclaration>getOriginalElement(it)); _builder.append(_grammarElementAccess, "\t"); _builder.append(".getEnumLiteral().getInstance();"); _builder.newLineIfNotEmpty(); _builder.append("\t"); CharSequence _newLeafNode = this.newLeafNode(it, this._grammarAccessExtensions.localVar(it)); _builder.append(_newLeafNode, "\t"); _builder.newLineIfNotEmpty(); _builder.append("}"); _builder.newLine(); _xifexpression = _builder.toString(); } return _xifexpression; }
Example #9
Source File: EnumLiteralSerializer.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected Keyword getLiteral(INode node) { if (node != null) { for (ILeafNode leaf : node.getLeafNodes()) { if (leaf.getGrammarElement() instanceof EnumLiteralDeclaration) return ((EnumLiteralDeclaration) leaf.getGrammarElement()).getLiteral(); } } return null; }
Example #10
Source File: ParsedEnumLiteral.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
public ParsedEnumLiteral(int offset, int length, EnumLiteralDeclaration literal, IParsedTokenSource source, boolean optional) { super(offset, length, literal, source, optional); }
Example #11
Source File: Xtext2RailroadTransformer.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
protected ISegmentFigure transformInternal(EnumLiteralDeclaration enumLiteralDeclaration) { return factory.createNodeSegment(enumLiteralDeclaration); }
Example #12
Source File: ParserBasedContentAssistContextFactory.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
@Override public Boolean caseEnumLiteralDeclaration(EnumLiteralDeclaration object) { return doSwitch(object.getLiteral()); }
Example #13
Source File: GrammarAccessExtensions.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
protected String _localVar(final EnumLiteralDeclaration it) { int _indexOf = this.contentsAsList(GrammarUtil.containingEnumRule(it).getAlternatives()).indexOf(it); return ("enumLiteral_" + Integer.valueOf(_indexOf)); }
Example #14
Source File: FollowElementCalculator.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override public Boolean caseEnumLiteralDeclaration(EnumLiteralDeclaration object) { return doSwitch(object.getLiteral()); }
Example #15
Source File: AbstractPackratParser.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override public int consumeEnum(EnumLiteralDeclaration literal, ICharacterClass notFollowedBy) { literalConsumer.configure(literal, notFollowedBy); return consumeTerminal(literalConsumer, null, false, false, literal, ISequenceMatcher.Factory.nullMatcher(), false); }
Example #16
Source File: ContentAssistNoTerminalExtensionTestLanguageGrammarAccess.java From xtext-eclipse with Eclipse Public License 2.0 | votes |
public EnumLiteralDeclaration getPolygonEnumLiteralDeclaration_7() { return cPolygonEnumLiteralDeclaration_7; }
Example #17
Source File: Bug287941TestLanguageGrammarAccess.java From xtext-eclipse with Eclipse Public License 2.0 | votes |
public EnumLiteralDeclaration getNotEqualEnumLiteralDeclaration_5() { return cNotEqualEnumLiteralDeclaration_5; }
Example #18
Source File: Bug287941TestLanguageGrammarAccess.java From xtext-eclipse with Eclipse Public License 2.0 | votes |
public EnumLiteralDeclaration getEqualEnumLiteralDeclaration_0() { return cEqualEnumLiteralDeclaration_0; }
Example #19
Source File: ConcreteSyntaxValidationTestLanguageGrammarAccess.java From xtext-core with Eclipse Public License 2.0 | votes |
public EnumLiteralDeclaration getLit1EnumLiteralDeclaration_0() { return cLit1EnumLiteralDeclaration_0; }
Example #20
Source File: Bug378967TestLanguageGrammarAccess.java From xtext-core with Eclipse Public License 2.0 | votes |
public EnumLiteralDeclaration getValueEnumLiteralDeclaration() { return cValueEnumLiteralDeclaration; }
Example #21
Source File: ContentAssistNoTerminalExtensionTestLanguageGrammarAccess.java From xtext-eclipse with Eclipse Public License 2.0 | votes |
public EnumLiteralDeclaration getRnastabEnumLiteralDeclaration_18() { return cRnastabEnumLiteralDeclaration_18; }
Example #22
Source File: ContentAssistNoTerminalExtensionTestLanguageGrammarAccess.java From xtext-eclipse with Eclipse Public License 2.0 | votes |
public EnumLiteralDeclaration getRibositeEnumLiteralDeclaration_17() { return cRibositeEnumLiteralDeclaration_17; }
Example #23
Source File: ContextFinderTestLanguageGrammarAccess.java From xtext-core with Eclipse Public License 2.0 | votes |
public EnumLiteralDeclaration getLit2EnumLiteralDeclaration() { return cLit2EnumLiteralDeclaration; }
Example #24
Source File: ContentAssistNoTerminalExtensionTestLanguageGrammarAccess.java From xtext-eclipse with Eclipse Public License 2.0 | votes |
public EnumLiteralDeclaration getRestrictionsiteEnumLiteralDeclaration_16() { return cRestrictionsiteEnumLiteralDeclaration_16; }
Example #25
Source File: ContentAssistNoTerminalExtensionTestLanguageGrammarAccess.java From xtext-eclipse with Eclipse Public License 2.0 | votes |
public EnumLiteralDeclaration getRarrowEnumLiteralDeclaration_12() { return cRarrowEnumLiteralDeclaration_12; }
Example #26
Source File: FormatterTestLanguageGrammarAccess.java From xtext-core with Eclipse Public License 2.0 | votes |
public EnumLiteralDeclaration getLit3EnumLiteralDeclaration_2() { return cLit3EnumLiteralDeclaration_2; }
Example #27
Source File: ContentAssistNoTerminalExtensionTestLanguageGrammarAccess.java From xtext-eclipse with Eclipse Public License 2.0 | votes |
public EnumLiteralDeclaration getPromoterEnumLiteralDeclaration_9() { return cPromoterEnumLiteralDeclaration_9; }
Example #28
Source File: ContentAssistNoTerminalExtensionTestLanguageGrammarAccess.java From xtext-eclipse with Eclipse Public License 2.0 | votes |
public EnumLiteralDeclaration getProteasesiteEnumLiteralDeclaration_10() { return cProteasesiteEnumLiteralDeclaration_10; }
Example #29
Source File: MultiRuleEnumTestLanguageGrammarAccess.java From xtext-core with Eclipse Public License 2.0 | votes |
public EnumLiteralDeclaration getBEnumLiteralDeclaration_1() { return cBEnumLiteralDeclaration_1; }
Example #30
Source File: ContentAssistNoTerminalExtensionTestLanguageGrammarAccess.java From xtext-eclipse with Eclipse Public License 2.0 | votes |
public EnumLiteralDeclaration getRecordEnumLiteralDeclaration_13() { return cRecordEnumLiteralDeclaration_13; }