summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorszarnekow2009-03-19 11:40:24 (EDT)
committer sefftinge2009-03-19 11:40:24 (EDT)
commit1227f7779f3868c435dc1a05dd5a675933a62ace (patch)
tree1b158a8c4e465b5050439fde5c8784cf845bed0b
parent089e76552615f349dcf42aae1e8a72e8e7cceed7 (diff)
downloadorg.eclipse.xtext-1227f7779f3868c435dc1a05dd5a675933a62ace.zip
org.eclipse.xtext-1227f7779f3868c435dc1a05dd5a675933a62ace.tar.gz
org.eclipse.xtext-1227f7779f3868c435dc1a05dd5a675933a62ace.tar.bz2
enum rules: added some validation
-rw-r--r--tests/org.eclipse.xtext.generator.tests/plugin.xml_gen311
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src-gen/org/eclipse/xtext/grammarinheritance/services/ConcreteTestLanguageGrammarAccess.java4
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/enumrules/GrammarParserTest.java19
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/xtext/XtextValidationTest.java32
-rw-r--r--tests/org.eclipse.xtext.ui.common.tests/src-gen/org/eclipse/xtext/GenXtextGrammarTestLanguageScopeProvider.ext20
-rw-r--r--tests/org.eclipse.xtext.ui.common.tests/src-gen/org/eclipse/xtext/testlanguages/GenReferenceGrammarTestLanguageScopeProvider.ext8
-rw-r--r--tests/org.eclipse.xtext.xtend.tests/src-gen/org/eclipse/xtext/GenXtextGrammarTestLanguageScopeProvider.ext26
-rw-r--r--tests/org.eclipse.xtext.xtend.tests/src-gen/org/eclipse/xtext/testlanguages/GenReferenceGrammarTestLanguageScopeProvider.ext12
8 files changed, 397 insertions, 35 deletions
diff --git a/tests/org.eclipse.xtext.generator.tests/plugin.xml_gen b/tests/org.eclipse.xtext.generator.tests/plugin.xml_gen
index f18e1f3..e3727a2 100644
--- a/tests/org.eclipse.xtext.generator.tests/plugin.xml_gen
+++ b/tests/org.eclipse.xtext.generator.tests/plugin.xml_gen
@@ -5,6 +5,42 @@
<extension point="org.eclipse.emf.ecore.generated_package">
<package
+ uri = "http://www.eclipse.org/2008/Test/XtextTest"
+ class = "org.eclipse.xtext.xtextTest.XtextTestPackage"
+ genModel = "org/eclipse/xtext/XtextGrammarTestLanguage.genmodel" />
+
+ </extension>
+
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://eclipse.org/xtext/importUriTestLanguage"
+ class = "org.eclipse.xtext.crossrefs.importedURI.ImportedURIPackage"
+ genModel = "org/eclipse/xtext/crossrefs/ImportUriTestLanguage.genmodel" />
+
+ </extension>
+
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://eclipse.org/xtext/langATestLanguage"
+ class = "org.eclipse.xtext.crossrefs.langATestLanguage.LangATestLanguagePackage"
+ genModel = "org/eclipse/xtext/crossrefs/LangATestLanguage.genmodel" />
+
+ </extension>
+
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://www.eclipse.org/2008/xtext/DummyLang"
+ class = "org.eclipse.xtext.dummy.dummyLang.DummyLangPackage"
+ genModel = "org/eclipse/xtext/dummy/DummyTestLanguage.genmodel" />
+
+ </extension>
+
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
uri = "http://www.eclipse.org/2009/tmf/xtext/EnumRulesTest"
class = "org.eclipse.xtext.enumrules.enumRulesTestLanguage.EnumRulesTestLanguagePackage"
genModel = "org/eclipse/xtext/enumrules/EnumRulesTestLanguage.genmodel" />
@@ -12,4 +48,279 @@
</extension>
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://www.eclipse.org/2009/tmf/xtext/lowerCaseNamedTestLanguage"
+ class = "org.eclipse.xtext.generator.lowerCaseNamedTestLanguage.LowerCaseNamedTestLanguagePackage"
+ genModel = "org/eclipse/xtext/generator/lowerCaseNamedTestLanguage.genmodel" />
+
+ </extension>
+
+
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://www.eclipse.org/2009/tmf/xtext/BaseInheritanceTestLanguage"
+ class = "org.eclipse.xtext.grammarinheritance.baseInheritanceTest.BaseInheritanceTestPackage"
+ genModel = "org/eclipse/xtext/grammarinheritance/BaseInheritanceTestLanguage.genmodel" />
+
+ </extension>
+
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://holla"
+ class = "org.eclipse.xtext.grammarinheritance.foo.FooPackage"
+ genModel = "org/eclipse/xtext/grammarinheritance/ConcreteTestLanguage.genmodel" />
+
+ </extension>
+
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://www.eclipse.org/2009/tmf/xtext/InheritanceTestLanguage"
+ class = "org.eclipse.xtext.grammarinheritance.inheritanceTest.InheritanceTestPackage"
+ genModel = "org/eclipse/xtext/grammarinheritance/InheritanceTestLanguage.genmodel" />
+
+ </extension>
+
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://eclipse.org/xtext/tests/AnotherSimpleTest"
+ class = "org.eclipse.xtext.metamodelreferencing.tests.anotherSimpleTest.AnotherSimpleTestPackage"
+ genModel = "org/eclipse/xtext/metamodelreferencing/tests/MetamodelRefTestLanguage.genmodel" />
+
+ </extension>
+
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://eclipse.org/xtext/tests/SimpleTest"
+ class = "org.eclipse.xtext.metamodelreferencing.tests.simpleTest.SimpleTestPackage"
+ genModel = "org/eclipse/xtext/metamodelreferencing/tests/MultiGenMMTestLanguage.genmodel" />
+ <package
+ uri = "http://eclipse.org/xtext/tests/OtherTest"
+ class = "org.eclipse.xtext.metamodelreferencing.tests.otherTest.OtherTestPackage"
+ genModel = "org/eclipse/xtext/metamodelreferencing/tests/MultiGenMMTestLanguage.genmodel" />
+
+ </extension>
+
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://www.eclipse.org/2008/tmf/xtext/DatatypeRulesTest"
+ class = "org.eclipse.xtext.parser.datatyperules.datatypeRulesTestLanguage.DatatypeRulesTestLanguagePackage"
+ genModel = "org/eclipse/xtext/parser/datatyperules/DatatypeRulesTestLanguage.genmodel" />
+
+ </extension>
+
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://www.eclipse.org/2008/tmf/xtext/EpatchTestLanguage"
+ class = "org.eclipse.xtext.parser.epatch.epatchTestLanguage.EpatchTestLanguagePackage"
+ genModel = "org/eclipse/xtext/parser/epatch/EpatchTestLanguage.genmodel" />
+
+ </extension>
+
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://www.eclipse.org/2009/tmf/xtext/KeywordsTestLanguage"
+ class = "org.eclipse.xtext.parser.keywords.keywordsTestLanguage.KeywordsTestLanguagePackage"
+ genModel = "org/eclipse/xtext/parser/keywords/KeywordsTestLanguage.genmodel" />
+
+ </extension>
+
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://www.eclipse.org/2008/tmf/xtext/HiddenTerminalsTest"
+ class = "org.eclipse.xtext.parser.terminalrules.hiddenTerminalsTestLanguage.HiddenTerminalsTestLanguagePackage"
+ genModel = "org/eclipse/xtext/parser/terminalrules/HiddenTerminalsTestLanguage.genmodel" />
+
+ </extension>
+
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://www.eclipse.org/2008/tmf/xtext/TerminalRulesTest"
+ class = "org.eclipse.xtext.parser.terminalrules.terminalRulesTestLanguage.TerminalRulesTestLanguagePackage"
+ genModel = "org/eclipse/xtext/parser/terminalrules/TerminalRulesTestLanguage.genmodel" />
+
+ </extension>
+
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://www.eclipse.org/2008/tmf/xtext/XtextTerminalsTestLanguage"
+ class = "org.eclipse.xtext.parser.terminalrules.xtextTerminalsTestLanguage.XtextTerminalsTestLanguagePackage"
+ genModel = "org/eclipse/xtext/parser/terminalrules/XtextTerminalsTestLanguage.genmodel" />
+
+ </extension>
+
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://simple/formattertestlanguage"
+ class = "org.eclipse.xtext.parsetree.formatter.formattertestlanguage.FormattertestlanguagePackage"
+ genModel = "org/eclipse/xtext/parsetree/formatter/FormatterTestLanguage.genmodel" />
+
+ </extension>
+
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://complex/rewrite/test"
+ class = "org.eclipse.xtext.parsetree.reconstr.complexrewritetest.ComplexrewritetestPackage"
+ genModel = "org/eclipse/xtext/parsetree/reconstr/ComplexReconstrTestLanguage.genmodel" />
+
+ </extension>
+
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://simple/rewrite/test"
+ class = "org.eclipse.xtext.parsetree.reconstr.simplerewritetest.SimplerewritetestPackage"
+ genModel = "org/eclipse/xtext/parsetree/reconstr/SimpleReconstrTestLanguage.genmodel" />
+
+ </extension>
+
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://www.eclipse.org/2009/tmf/xtext/SerializationBugTest/269362"
+ class = "org.eclipse.xtext.parsetree.reconstr.serializationBug269362TestLanguage.SerializationBug269362TestLanguagePackage"
+ genModel = "org/eclipse/xtext/parsetree/reconstr/SerializationBug269362TestLanguage.genmodel" />
+
+ </extension>
+
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://simple/transientvaluestest"
+ class = "org.eclipse.xtext.parsetree.transientvalues.transientvaluestest.TransientvaluestestPackage"
+ genModel = "org/eclipse/xtext/parsetree/transientvalues/TransientValuesTest.genmodel" />
+
+ </extension>
+
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://www.eclipse.org/2008/xtext/MultiValueFeatureTestLanguage"
+ class = "org.eclipse.xtext.resource.metamodel.multiValueFeatureTestLanguage.MultiValueFeatureTestLanguagePackage"
+ genModel = "org/eclipse/xtext/resource/metamodel/MultiValueFeatureTestLanguage.genmodel" />
+
+ </extension>
+
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://www.eclipse.org/2008/tmf/xtext/ActionLang"
+ class = "org.eclipse.xtext.testlanguages.actionLang.ActionLangPackage"
+ genModel = "org/eclipse/xtext/testlanguages/ActionTestLanguage.genmodel" />
+
+ </extension>
+
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://www.eclipse.org/2008/xtext/tests/ContentAssist"
+ class = "org.eclipse.xtext.testlanguages.contentAssistTestLanguage.ContentAssistTestLanguagePackage"
+ genModel = "org/eclipse/xtext/testlanguages/ContentAssistTestLanguage.genmodel" />
+
+ </extension>
+
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://example.xtext.org/FowlerDslTestLanguage"
+ class = "org.eclipse.xtext.testlanguages.fowlerdsl.FowlerdslPackage"
+ genModel = "org/eclipse/xtext/testlanguages/FowlerDslTestLanguage.genmodel" />
+
+ </extension>
+
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://www.eclipse.org/2008/xtext/LexerLang"
+ class = "org.eclipse.xtext.testlanguages.lexerLang.LexerLangPackage"
+ genModel = "org/eclipse/xtext/testlanguages/LexerTestLanguage.genmodel" />
+
+ </extension>
+
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://www.eclipse.org/2008/xtext/LookaheadLang"
+ class = "org.eclipse.xtext.testlanguages.lookaheadLang.LookaheadLangPackage"
+ genModel = "org/eclipse/xtext/testlanguages/LookaheadTestLanguage.genmodel" />
+
+ </extension>
+
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://www.eclipse.org/2008/tmf/xtext/OptionalEmpty"
+ class = "org.eclipse.xtext.testlanguages.optionalEmpty.OptionalEmptyPackage"
+ genModel = "org/eclipse/xtext/testlanguages/OptionalEmptyTestLanguage.genmodel" />
+
+ </extension>
+
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://example.xtext.org/PartialParserTestLanguage"
+ class = "org.eclipse.xtext.testlanguages.partialParserTestLanguage.PartialParserTestLanguagePackage"
+ genModel = "org/eclipse/xtext/testlanguages/PartialParserTestLanguage.genmodel" />
+
+ </extension>
+
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://eclipse.org/xtext/reference/ReferenceGrammar"
+ class = "org.eclipse.xtext.testlanguages.referenceGrammar.ReferenceGrammarPackage"
+ genModel = "org/eclipse/xtext/testlanguages/ReferenceGrammarTestLanguage.genmodel" />
+
+ </extension>
+
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://www.eclipse.org/xtext/test/simpleExpressions"
+ class = "org.eclipse.xtext.testlanguages.simpleExpressions.SimpleExpressionsPackage"
+ genModel = "org/eclipse/xtext/testlanguages/SimpleExpressionsTestLanguage.genmodel" />
+
+ </extension>
+
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://www.eclipse.org/2008/xtext/TestLang"
+ class = "org.eclipse.xtext.testlanguages.testLang.TestLangPackage"
+ genModel = "org/eclipse/xtext/testlanguages/TestLanguage.genmodel" />
+
+ </extension>
+
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://www.eclipse.org/2008/tmf/xtext/TreeTestLanguage"
+ class = "org.eclipse.xtext.testlanguages.treeTestLanguage.TreeTestLanguagePackage"
+ genModel = "org/eclipse/xtext/testlanguages/TreeTestLanguage.genmodel" />
+
+ </extension>
+
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://org.eclipse.xtext.valueconverter.Bug250313"
+ class = "org.eclipse.xtext.valueconverter.bug250313.Bug250313Package"
+ genModel = "org/eclipse/xtext/valueconverter/Bug250313.genmodel" />
+
+ </extension>
+
+
</plugin>
diff --git a/tests/org.eclipse.xtext.generator.tests/src-gen/org/eclipse/xtext/grammarinheritance/services/ConcreteTestLanguageGrammarAccess.java b/tests/org.eclipse.xtext.generator.tests/src-gen/org/eclipse/xtext/grammarinheritance/services/ConcreteTestLanguageGrammarAccess.java
index 98f9a5b..3100c4b 100644
--- a/tests/org.eclipse.xtext.generator.tests/src-gen/org/eclipse/xtext/grammarinheritance/services/ConcreteTestLanguageGrammarAccess.java
+++ b/tests/org.eclipse.xtext.generator.tests/src-gen/org/eclipse/xtext/grammarinheritance/services/ConcreteTestLanguageGrammarAccess.java
@@ -436,7 +436,7 @@ public class ConcreteTestLanguageGrammarAccess implements IGrammarAccess {
return getInheritedParserRuleAccess().getRule();
}
- //org.eclipse.xtext.parsetree.reconstr.XtextSerializationException: Error serializing CrossRefs: Unable to create a string represenation for reference 'AbstractRule' using org.eclipse.xtext.xtext.XtextLinkingService EReference: rule Context:org.eclipse.xtext.impl.RuleCallImpl@455910 (cardinality: null) Target:org.eclipse.xtext.impl.ParserRuleImpl@62a121 (name: OverridableParserRule) (definesHiddenTokens: false)
+ //org.eclipse.xtext.parsetree.reconstr.XtextSerializationException: Error serializing CrossRefs: Unable to create a string represenation for reference 'AbstractRule' using org.eclipse.xtext.xtext.XtextLinkingService EReference: rule Context:org.eclipse.xtext.impl.RuleCallImpl@a3476b (cardinality: null) Target:org.eclipse.xtext.impl.ParserRuleImpl@169680 (name: OverridableParserRule) (definesHiddenTokens: false)
public AbstractTestLanguageGrammarAccess.AbstractCallOverridenParserRuleElements getAbstractCallOverridenParserRuleAccess() {
return gaAbstractTestLanguage.getAbstractCallOverridenParserRuleAccess();
}
@@ -445,7 +445,7 @@ public class ConcreteTestLanguageGrammarAccess implements IGrammarAccess {
return getAbstractCallOverridenParserRuleAccess().getRule();
}
- //org.eclipse.xtext.parsetree.reconstr.XtextSerializationException: Error serializing CrossRefs: Unable to create a string represenation for reference 'AbstractRule' using org.eclipse.xtext.xtext.XtextLinkingService EReference: rule Context:org.eclipse.xtext.impl.RuleCallImpl@6e3a9c (cardinality: null) Target:org.eclipse.xtext.impl.ParserRuleImpl@f35bd (name: ExtendableParserRule) (definesHiddenTokens: false)
+ //org.eclipse.xtext.parsetree.reconstr.XtextSerializationException: Error serializing CrossRefs: Unable to create a string represenation for reference 'AbstractRule' using org.eclipse.xtext.xtext.XtextLinkingService EReference: rule Context:org.eclipse.xtext.impl.RuleCallImpl@96cd00 (cardinality: null) Target:org.eclipse.xtext.impl.ParserRuleImpl@80d5d5 (name: ExtendableParserRule) (definesHiddenTokens: false)
public AbstractTestLanguageGrammarAccess.AbstractCallExtendedParserRuleElements getAbstractCallExtendedParserRuleAccess() {
return gaAbstractTestLanguage.getAbstractCallExtendedParserRuleAccess();
}
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/enumrules/GrammarParserTest.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/enumrules/GrammarParserTest.java
index 4d86af3..7ecda4b 100644
--- a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/enumrules/GrammarParserTest.java
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/enumrules/GrammarParserTest.java
@@ -7,9 +7,12 @@
*******************************************************************************/
package org.eclipse.xtext.enumrules;
+import java.util.List;
+
import org.eclipse.emf.ecore.EEnum;
import org.eclipse.emf.ecore.EEnumLiteral;
import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.xtext.EcoreUtil2;
import org.eclipse.xtext.EnumLiteralDeclaration;
import org.eclipse.xtext.EnumRule;
import org.eclipse.xtext.Grammar;
@@ -28,6 +31,13 @@ public class GrammarParserTest extends AbstractEnumRulesTest {
with(XtextStandaloneSetup.class);
}
+ private void checkEnums(Grammar grammar) {
+ List<EnumLiteralDeclaration> decls = EcoreUtil2.getAllContentsOfType(grammar, EnumLiteralDeclaration.class);
+ for(EnumLiteralDeclaration decl: decls) {
+ assertNotNull(decl.getLiteral());
+ }
+ }
+
public void testEnum_01() throws Exception {
String modelAsString =
"grammar TestLanguage with org.eclipse.xtext.common.Terminals\n" +
@@ -36,6 +46,7 @@ public class GrammarParserTest extends AbstractEnumRulesTest {
"enum MyEnum: Value1;";
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/EnumRulesTest/TestEnum/1", pack.getNsURI());
EEnum eEnum = (EEnum) pack.getEClassifier("MyEnum");
@@ -55,6 +66,7 @@ public class GrammarParserTest extends AbstractEnumRulesTest {
"enum MyEnumRule returns MyEnum: Value1;";
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/EnumRulesTest/TestEnum/2", pack.getNsURI());
EEnum eEnum = (EEnum) pack.getEClassifier("MyEnum");
@@ -74,6 +86,7 @@ public class GrammarParserTest extends AbstractEnumRulesTest {
"enum MyEnumRule returns MyEnum: Value1 = 'value';";
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/EnumRulesTest/TestEnum/3", pack.getNsURI());
EEnum eEnum = (EEnum) pack.getEClassifier("MyEnum");
@@ -94,6 +107,7 @@ public class GrammarParserTest extends AbstractEnumRulesTest {
"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");
@@ -121,6 +135,7 @@ public class GrammarParserTest extends AbstractEnumRulesTest {
"enum ExistingEnum: SameName = 'value';";
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");
@@ -147,6 +162,7 @@ public class GrammarParserTest extends AbstractEnumRulesTest {
"enum MyEnum: Value1 | Value2='value' | Value3;";
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/EnumRulesTest/TestEnum/6", pack.getNsURI());
EEnum eEnum = (EEnum) pack.getEClassifier("MyEnum");
@@ -176,6 +192,7 @@ public class GrammarParserTest extends AbstractEnumRulesTest {
"enum MyEnum: Value | Value;";
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/EnumRulesTest/TestEnum/7", pack.getNsURI());
EEnum eEnum = (EEnum) pack.getEClassifier("MyEnum");
@@ -195,6 +212,7 @@ public class GrammarParserTest extends AbstractEnumRulesTest {
"enum MyEnum: Value | Value = 'foo';";
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/EnumRulesTest/TestEnum/8", pack.getNsURI());
EEnum eEnum = (EEnum) pack.getEClassifier("MyEnum");
@@ -229,6 +247,7 @@ public class GrammarParserTest extends AbstractEnumRulesTest {
"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");
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/xtext/XtextValidationTest.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/xtext/XtextValidationTest.java
index 59d7930..d7b0ad6 100644
--- a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/xtext/XtextValidationTest.java
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/xtext/XtextValidationTest.java
@@ -73,4 +73,36 @@ public class XtextValidationTest extends AbstractGeneratorTest {
assertEquals(diag.getChildren().toString(), 2, diag.getChildren().size());
assertEquals("diag.isError", diag.getSeverity(), Diagnostic.ERROR);
}
+
+ public void testDuplicateEnumLiterals() throws Exception {
+ XtextResource resource = getResourceFromString(
+ "grammar org.foo.Bar 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/validation/literal/1'\n" +
+ "Model: enumValue=ExistingEnum;\n" +
+ "enum ExistingEnum: SameName | DifferentName='SameName';");
+ assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty());
+ assertTrue(resource.getWarnings().toString(), resource.getWarnings().isEmpty());
+
+ Diagnostic diag = Diagnostician.INSTANCE.validate(resource.getContents().get(0));
+ assertNotNull("diag", diag);
+ assertEquals(diag.getChildren().toString(), 2, diag.getChildren().size());
+ assertEquals("diag.isError", diag.getSeverity(), Diagnostic.ERROR);
+ }
+
+ public void testDefinedLiteralTwice() throws Exception {
+ XtextResource resource = getResourceFromString(
+ "grammar org.foo.Bar with org.eclipse.xtext.common.Terminals\n" +
+ "generate testLanguage 'http://www.eclipse.org/2009/tmf/xtext/validation/literal/2'\n" +
+ "Model: enumValue=GeneratedEnum;\n" +
+ "enum GeneratedEnum: SameName ='value' | SameName='otherValue';");
+ assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty());
+ assertTrue(resource.getWarnings().toString(), resource.getWarnings().isEmpty());
+
+ Diagnostic diag = Diagnostician.INSTANCE.validate(resource.getContents().get(0));
+ assertNotNull("diag", diag);
+ assertEquals(diag.getChildren().toString(), 1, diag.getChildren().size());
+ assertEquals("diag.isWarning", diag.getSeverity(), Diagnostic.WARNING);
+ }
+
}
diff --git a/tests/org.eclipse.xtext.ui.common.tests/src-gen/org/eclipse/xtext/GenXtextGrammarTestLanguageScopeProvider.ext b/tests/org.eclipse.xtext.ui.common.tests/src-gen/org/eclipse/xtext/GenXtextGrammarTestLanguageScopeProvider.ext
index a4086bf..cfa49ae 100644
--- a/tests/org.eclipse.xtext.ui.common.tests/src-gen/org/eclipse/xtext/GenXtextGrammarTestLanguageScopeProvider.ext
+++ b/tests/org.eclipse.xtext.ui.common.tests/src-gen/org/eclipse/xtext/GenXtextGrammarTestLanguageScopeProvider.ext
@@ -17,10 +17,16 @@ extension org::eclipse::xtend::util::stdlib::io;
*/
-List[IScopedElement] scope_hiddenTokens(Grammar this):
+List[IScopedElement] scope_usedGrammars(Grammar this):
+ allElements().typeSelect(Grammar).collect(x | createScopedElement(x.referenceName(), x));
+
+List[IScopedElement] scope_usedGrammars(emf::EObject this) :
+ allElements().collect(x | createScopedElement(x.referenceName(), x));
+
+List[IScopedElement] scope_rule(RuleCall this):
allElements().typeSelect(AbstractRule).collect(x | createScopedElement(x.referenceName(), x));
-List[IScopedElement] scope_hiddenTokens(emf::EObject this) :
+List[IScopedElement] scope_rule(emf::EObject this) :
allElements().collect(x | createScopedElement(x.referenceName(), x));
List[IScopedElement] scope_ePackage(AbstractMetamodelDeclaration this):
@@ -35,10 +41,10 @@ List[IScopedElement] scope_metamodel(TypeRef this):
List[IScopedElement] scope_metamodel(emf::EObject this) :
allElements().collect(x | createScopedElement(x.referenceName(), x));
-List[IScopedElement] scope_rule(RuleCall this):
+List[IScopedElement] scope_hiddenTokens(Grammar this):
allElements().typeSelect(AbstractRule).collect(x | createScopedElement(x.referenceName(), x));
-List[IScopedElement] scope_rule(emf::EObject this) :
+List[IScopedElement] scope_hiddenTokens(emf::EObject this) :
allElements().collect(x | createScopedElement(x.referenceName(), x));
List[IScopedElement] scope_hiddenTokens(ParserRule this):
@@ -53,9 +59,3 @@ List[IScopedElement] scope_classifier(TypeRef this):
List[IScopedElement] scope_classifier(emf::EObject this) :
allElements().collect(x | createScopedElement(x.referenceName(), x));
-List[IScopedElement] scope_usedGrammars(Grammar this):
- allElements().typeSelect(Grammar).collect(x | createScopedElement(x.referenceName(), x));
-
-List[IScopedElement] scope_usedGrammars(emf::EObject this) :
- allElements().collect(x | createScopedElement(x.referenceName(), x));
-
diff --git a/tests/org.eclipse.xtext.ui.common.tests/src-gen/org/eclipse/xtext/testlanguages/GenReferenceGrammarTestLanguageScopeProvider.ext b/tests/org.eclipse.xtext.ui.common.tests/src-gen/org/eclipse/xtext/testlanguages/GenReferenceGrammarTestLanguageScopeProvider.ext
index efbcf20..e112e8f 100644
--- a/tests/org.eclipse.xtext.ui.common.tests/src-gen/org/eclipse/xtext/testlanguages/GenReferenceGrammarTestLanguageScopeProvider.ext
+++ b/tests/org.eclipse.xtext.ui.common.tests/src-gen/org/eclipse/xtext/testlanguages/GenReferenceGrammarTestLanguageScopeProvider.ext
@@ -22,15 +22,15 @@ List[IScopedElement] scope_kinder(Familie this):
List[IScopedElement] scope_kinder(emf::EObject this) :
allElements().collect(x | createScopedElement(x.referenceName(), x));
-List[IScopedElement] scope_vater(Familie this):
+List[IScopedElement] scope_mutter(Familie this):
allElements().typeSelect(Erwachsener).collect(x | createScopedElement(x.referenceName(), x));
-List[IScopedElement] scope_vater(emf::EObject this) :
+List[IScopedElement] scope_mutter(emf::EObject this) :
allElements().collect(x | createScopedElement(x.referenceName(), x));
-List[IScopedElement] scope_mutter(Familie this):
+List[IScopedElement] scope_vater(Familie this):
allElements().typeSelect(Erwachsener).collect(x | createScopedElement(x.referenceName(), x));
-List[IScopedElement] scope_mutter(emf::EObject this) :
+List[IScopedElement] scope_vater(emf::EObject this) :
allElements().collect(x | createScopedElement(x.referenceName(), x));
diff --git a/tests/org.eclipse.xtext.xtend.tests/src-gen/org/eclipse/xtext/GenXtextGrammarTestLanguageScopeProvider.ext b/tests/org.eclipse.xtext.xtend.tests/src-gen/org/eclipse/xtext/GenXtextGrammarTestLanguageScopeProvider.ext
index 07ff7fc..ad0a9a1 100644
--- a/tests/org.eclipse.xtext.xtend.tests/src-gen/org/eclipse/xtext/GenXtextGrammarTestLanguageScopeProvider.ext
+++ b/tests/org.eclipse.xtext.xtend.tests/src-gen/org/eclipse/xtext/GenXtextGrammarTestLanguageScopeProvider.ext
@@ -23,16 +23,16 @@ List[IScopedElement] scope_metamodel(TypeRef this):
List[IScopedElement] scope_metamodel(emf::EObject this) :
allElements().collect(x | createScopedElement(x.referenceName(), x));
-List[IScopedElement] scope_hiddenTokens(Grammar this):
+List[IScopedElement] scope_hiddenTokens(ParserRule this):
allElements().typeSelect(AbstractRule).collect(x | createScopedElement(x.referenceName(), x));
List[IScopedElement] scope_hiddenTokens(emf::EObject this) :
allElements().collect(x | createScopedElement(x.referenceName(), x));
-List[IScopedElement] scope_ePackage(AbstractMetamodelDeclaration this):
- allElements().typeSelect(ecore::EPackage).collect(x | createScopedElement(x.referenceName(), x));
+List[IScopedElement] scope_usedGrammars(Grammar this):
+ allElements().typeSelect(Grammar).collect(x | createScopedElement(x.referenceName(), x));
-List[IScopedElement] scope_ePackage(emf::EObject this) :
+List[IScopedElement] scope_usedGrammars(emf::EObject this) :
allElements().collect(x | createScopedElement(x.referenceName(), x));
List[IScopedElement] scope_rule(RuleCall this):
@@ -41,16 +41,10 @@ List[IScopedElement] scope_rule(RuleCall this):
List[IScopedElement] scope_rule(emf::EObject this) :
allElements().collect(x | createScopedElement(x.referenceName(), x));
-List[IScopedElement] scope_usedGrammars(Grammar this):
- allElements().typeSelect(Grammar).collect(x | createScopedElement(x.referenceName(), x));
-
-List[IScopedElement] scope_usedGrammars(emf::EObject this) :
- allElements().collect(x | createScopedElement(x.referenceName(), x));
-
-List[IScopedElement] scope_hiddenTokens(ParserRule this):
- allElements().typeSelect(AbstractRule).collect(x | createScopedElement(x.referenceName(), x));
+List[IScopedElement] scope_ePackage(AbstractMetamodelDeclaration this):
+ allElements().typeSelect(ecore::EPackage).collect(x | createScopedElement(x.referenceName(), x));
-List[IScopedElement] scope_hiddenTokens(emf::EObject this) :
+List[IScopedElement] scope_ePackage(emf::EObject this) :
allElements().collect(x | createScopedElement(x.referenceName(), x));
List[IScopedElement] scope_classifier(TypeRef this):
@@ -59,3 +53,9 @@ List[IScopedElement] scope_classifier(TypeRef this):
List[IScopedElement] scope_classifier(emf::EObject this) :
allElements().collect(x | createScopedElement(x.referenceName(), x));
+List[IScopedElement] scope_hiddenTokens(Grammar this):
+ allElements().typeSelect(AbstractRule).collect(x | createScopedElement(x.referenceName(), x));
+
+List[IScopedElement] scope_hiddenTokens(emf::EObject this) :
+ allElements().collect(x | createScopedElement(x.referenceName(), x));
+
diff --git a/tests/org.eclipse.xtext.xtend.tests/src-gen/org/eclipse/xtext/testlanguages/GenReferenceGrammarTestLanguageScopeProvider.ext b/tests/org.eclipse.xtext.xtend.tests/src-gen/org/eclipse/xtext/testlanguages/GenReferenceGrammarTestLanguageScopeProvider.ext
index e112e8f..485886c 100644
--- a/tests/org.eclipse.xtext.xtend.tests/src-gen/org/eclipse/xtext/testlanguages/GenReferenceGrammarTestLanguageScopeProvider.ext
+++ b/tests/org.eclipse.xtext.xtend.tests/src-gen/org/eclipse/xtext/testlanguages/GenReferenceGrammarTestLanguageScopeProvider.ext
@@ -16,12 +16,6 @@ extension org::eclipse::xtend::util::stdlib::io;
*/
-List[IScopedElement] scope_kinder(Familie this):
- allElements().typeSelect(Kind).collect(x | createScopedElement(x.referenceName(), x));
-
-List[IScopedElement] scope_kinder(emf::EObject this) :
- allElements().collect(x | createScopedElement(x.referenceName(), x));
-
List[IScopedElement] scope_mutter(Familie this):
allElements().typeSelect(Erwachsener).collect(x | createScopedElement(x.referenceName(), x));
@@ -34,3 +28,9 @@ List[IScopedElement] scope_vater(Familie this):
List[IScopedElement] scope_vater(emf::EObject this) :
allElements().collect(x | createScopedElement(x.referenceName(), x));
+List[IScopedElement] scope_kinder(Familie this):
+ allElements().typeSelect(Kind).collect(x | createScopedElement(x.referenceName(), x));
+
+List[IScopedElement] scope_kinder(emf::EObject this) :
+ allElements().collect(x | createScopedElement(x.referenceName(), x));
+