aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorszarnekow2009-03-18 14:30:10 (EDT)
committersefftinge2009-03-18 14:30:10 (EDT)
commitad75617488f4750ec8a57bf918ce9cf0d14f00ca (patch)
tree6c89d12419bf63879833515a896c6d98f3f9a986
parent7df1bc43a3d185f62ac97b429e93aa89d74b1762 (diff)
downloadorg.eclipse.xtext-ad75617488f4750ec8a57bf918ce9cf0d14f00ca.zip
org.eclipse.xtext-ad75617488f4750ec8a57bf918ce9cf0d14f00ca.tar.gz
org.eclipse.xtext-ad75617488f4750ec8a57bf918ce9cf0d14f00ca.tar.bz2
enum rules continued, implemented scope provider, some more tests
-rw-r--r--tests/org.eclipse.xtext.generator.tests/plugin.xml_gen304
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src-gen/org/eclipse/xtext/enumrules/EnumRulesTestLanguage.ecore2
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src-gen/org/eclipse/xtext/enumrules/EnumRulesTestLanguage.xmi10
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src-gen/org/eclipse/xtext/enumrules/EnumRulesTestLanguageStandaloneSetup.java4
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src-gen/org/eclipse/xtext/enumrules/enumRulesTestLanguage/EnumRulesTestLanguagePackage.java2
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src-gen/org/eclipse/xtext/enumrules/enumRulesTestLanguage/impl/EnumRulesTestLanguageFactoryImpl.java2
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src-gen/org/eclipse/xtext/enumrules/services/EnumRulesTestLanguageGrammarAccess.java22
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/enumrules/EnumRulesTestLanguage.xtext2
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/enumrules/GrammarParserTest.java141
9 files changed, 164 insertions, 325 deletions
diff --git a/tests/org.eclipse.xtext.generator.tests/plugin.xml_gen b/tests/org.eclipse.xtext.generator.tests/plugin.xml_gen
index 604856e..f18e1f3 100644
--- a/tests/org.eclipse.xtext.generator.tests/plugin.xml_gen
+++ b/tests/org.eclipse.xtext.generator.tests/plugin.xml_gen
@@ -5,313 +5,11 @@
<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/2008/tmf/xtext/EnumRulesTest"
+ uri = "http://www.eclipse.org/2009/tmf/xtext/EnumRulesTest"
class = "org.eclipse.xtext.enumrules.enumRulesTestLanguage.EnumRulesTestLanguagePackage"
genModel = "org/eclipse/xtext/enumrules/EnumRulesTestLanguage.genmodel" />
</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://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/enumrules/EnumRulesTestLanguage.ecore b/tests/org.eclipse.xtext.generator.tests/src-gen/org/eclipse/xtext/enumrules/EnumRulesTestLanguage.ecore
index 400d053..34cf6fa 100644
--- a/tests/org.eclipse.xtext.generator.tests/src-gen/org/eclipse/xtext/enumrules/EnumRulesTestLanguage.ecore
+++ b/tests/org.eclipse.xtext.generator.tests/src-gen/org/eclipse/xtext/enumrules/EnumRulesTestLanguage.ecore
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="ASCII"?>
-<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="enumRulesTestLanguage" nsURI="http://www.eclipse.org/2008/tmf/xtext/EnumRulesTest" nsPrefix="enumRulesTestLanguage">
+<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="enumRulesTestLanguage" nsURI="http://www.eclipse.org/2009/tmf/xtext/EnumRulesTest" nsPrefix="enumRulesTestLanguage">
<eClassifiers xsi:type="ecore:EClass" name="Model">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="existing">
<eType xsi:type="ecore:EEnum" href="http://www.eclipse.org/2009/tmf/xtext/EnumRulesTestLanguage/imported#//ExistingEnum"/>
diff --git a/tests/org.eclipse.xtext.generator.tests/src-gen/org/eclipse/xtext/enumrules/EnumRulesTestLanguage.xmi b/tests/org.eclipse.xtext.generator.tests/src-gen/org/eclipse/xtext/enumrules/EnumRulesTestLanguage.xmi
index 2ea6c87..74e267c 100644
--- a/tests/org.eclipse.xtext.generator.tests/src-gen/org/eclipse/xtext/enumrules/EnumRulesTestLanguage.xmi
+++ b/tests/org.eclipse.xtext.generator.tests/src-gen/org/eclipse/xtext/enumrules/EnumRulesTestLanguage.xmi
@@ -5,11 +5,11 @@
<ePackage href="http://www.eclipse.org/2009/tmf/xtext/EnumRulesTestLanguage/imported#/"/>
</metamodelDeclarations>
<metamodelDeclarations xsi:type="xtext:GeneratedMetamodel" name="enumRulesTestLanguage">
- <ePackage href="http://www.eclipse.org/2008/tmf/xtext/EnumRulesTest#/"/>
+ <ePackage href="http://www.eclipse.org/2009/tmf/xtext/EnumRulesTest#/"/>
</metamodelDeclarations>
<rules xsi:type="xtext:ParserRule" name="Model">
<type metamodel="/0/@metamodelDeclarations.1">
- <classifier xsi:type="ecore:EClass" href="http://www.eclipse.org/2008/tmf/xtext/EnumRulesTest#//Model"/>
+ <classifier xsi:type="ecore:EClass" href="http://www.eclipse.org/2009/tmf/xtext/EnumRulesTest#//Model"/>
</type>
<alternatives xsi:type="xtext:Alternatives">
<groups xsi:type="xtext:Group">
@@ -47,15 +47,15 @@
</rules>
<rules xsi:type="xtext:EnumRule" name="GeneratedEnum">
<type metamodel="/0/@metamodelDeclarations.1">
- <classifier xsi:type="ecore:EEnum" href="http://www.eclipse.org/2008/tmf/xtext/EnumRulesTest#//GeneratedEnum"/>
+ <classifier xsi:type="ecore:EEnum" href="http://www.eclipse.org/2009/tmf/xtext/EnumRulesTest#//GeneratedEnum"/>
</type>
<alternatives xsi:type="xtext:Alternatives">
<groups xsi:type="xtext:EnumLiteralDeclaration">
- <enumLiteral href="http://www.eclipse.org/2008/tmf/xtext/EnumRulesTest#//GeneratedEnum/SameName"/>
+ <enumLiteral href="http://www.eclipse.org/2009/tmf/xtext/EnumRulesTest#//GeneratedEnum/SameName"/>
<literal value="SameName"/>
</groups>
<groups xsi:type="xtext:EnumLiteralDeclaration">
- <enumLiteral href="http://www.eclipse.org/2008/tmf/xtext/EnumRulesTest#//GeneratedEnum/DifferentName"/>
+ <enumLiteral href="http://www.eclipse.org/2009/tmf/xtext/EnumRulesTest#//GeneratedEnum/DifferentName"/>
<literal value="DifferentLiteral"/>
</groups>
</alternatives>
diff --git a/tests/org.eclipse.xtext.generator.tests/src-gen/org/eclipse/xtext/enumrules/EnumRulesTestLanguageStandaloneSetup.java b/tests/org.eclipse.xtext.generator.tests/src-gen/org/eclipse/xtext/enumrules/EnumRulesTestLanguageStandaloneSetup.java
index 81697e1..d216ad7 100644
--- a/tests/org.eclipse.xtext.generator.tests/src-gen/org/eclipse/xtext/enumrules/EnumRulesTestLanguageStandaloneSetup.java
+++ b/tests/org.eclipse.xtext.generator.tests/src-gen/org/eclipse/xtext/enumrules/EnumRulesTestLanguageStandaloneSetup.java
@@ -31,8 +31,8 @@ public class EnumRulesTestLanguageStandaloneSetup implements ISetup {
}
public void register(Injector injector) {
- if (!EPackage.Registry.INSTANCE.containsKey("http://www.eclipse.org/2008/tmf/xtext/EnumRulesTest")) {
- EPackage.Registry.INSTANCE.put("http://www.eclipse.org/2008/tmf/xtext/EnumRulesTest", org.eclipse.xtext.enumrules.enumRulesTestLanguage.EnumRulesTestLanguagePackage.eINSTANCE);
+ if (!EPackage.Registry.INSTANCE.containsKey("http://www.eclipse.org/2009/tmf/xtext/EnumRulesTest")) {
+ EPackage.Registry.INSTANCE.put("http://www.eclipse.org/2009/tmf/xtext/EnumRulesTest", org.eclipse.xtext.enumrules.enumRulesTestLanguage.EnumRulesTestLanguagePackage.eINSTANCE);
}
//TODO registration of EValidators should be added here, too
diff --git a/tests/org.eclipse.xtext.generator.tests/src-gen/org/eclipse/xtext/enumrules/enumRulesTestLanguage/EnumRulesTestLanguagePackage.java b/tests/org.eclipse.xtext.generator.tests/src-gen/org/eclipse/xtext/enumrules/enumRulesTestLanguage/EnumRulesTestLanguagePackage.java
index 26880ab..403c3d2 100644
--- a/tests/org.eclipse.xtext.generator.tests/src-gen/org/eclipse/xtext/enumrules/enumRulesTestLanguage/EnumRulesTestLanguagePackage.java
+++ b/tests/org.eclipse.xtext.generator.tests/src-gen/org/eclipse/xtext/enumrules/enumRulesTestLanguage/EnumRulesTestLanguagePackage.java
@@ -41,7 +41,7 @@ public interface EnumRulesTestLanguagePackage extends EPackage
* <!-- end-user-doc -->
* @generated
*/
- String eNS_URI = "http://www.eclipse.org/2008/tmf/xtext/EnumRulesTest";
+ String eNS_URI = "http://www.eclipse.org/2009/tmf/xtext/EnumRulesTest";
/**
* The package namespace name.
diff --git a/tests/org.eclipse.xtext.generator.tests/src-gen/org/eclipse/xtext/enumrules/enumRulesTestLanguage/impl/EnumRulesTestLanguageFactoryImpl.java b/tests/org.eclipse.xtext.generator.tests/src-gen/org/eclipse/xtext/enumrules/enumRulesTestLanguage/impl/EnumRulesTestLanguageFactoryImpl.java
index dd3b8a6..10a362c 100644
--- a/tests/org.eclipse.xtext.generator.tests/src-gen/org/eclipse/xtext/enumrules/enumRulesTestLanguage/impl/EnumRulesTestLanguageFactoryImpl.java
+++ b/tests/org.eclipse.xtext.generator.tests/src-gen/org/eclipse/xtext/enumrules/enumRulesTestLanguage/impl/EnumRulesTestLanguageFactoryImpl.java
@@ -34,7 +34,7 @@ public class EnumRulesTestLanguageFactoryImpl extends EFactoryImpl implements En
{
try
{
- EnumRulesTestLanguageFactory theEnumRulesTestLanguageFactory = (EnumRulesTestLanguageFactory)EPackage.Registry.INSTANCE.getEFactory("http://www.eclipse.org/2008/tmf/xtext/EnumRulesTest");
+ EnumRulesTestLanguageFactory theEnumRulesTestLanguageFactory = (EnumRulesTestLanguageFactory)EPackage.Registry.INSTANCE.getEFactory("http://www.eclipse.org/2009/tmf/xtext/EnumRulesTest");
if (theEnumRulesTestLanguageFactory != null)
{
return theEnumRulesTestLanguageFactory;
diff --git a/tests/org.eclipse.xtext.generator.tests/src-gen/org/eclipse/xtext/enumrules/services/EnumRulesTestLanguageGrammarAccess.java b/tests/org.eclipse.xtext.generator.tests/src-gen/org/eclipse/xtext/enumrules/services/EnumRulesTestLanguageGrammarAccess.java
index 534d28a..909f661 100644
--- a/tests/org.eclipse.xtext.generator.tests/src-gen/org/eclipse/xtext/enumrules/services/EnumRulesTestLanguageGrammarAccess.java
+++ b/tests/org.eclipse.xtext.generator.tests/src-gen/org/eclipse/xtext/enumrules/services/EnumRulesTestLanguageGrammarAccess.java
@@ -72,25 +72,25 @@ public class EnumRulesTestLanguageGrammarAccess implements IGrammarAccess {
private final EnumLiteralDeclaration cDifferentNameEnumLiteralDeclaration_2 = (EnumLiteralDeclaration)cAlternatives.eContents().get(2);
private final Keyword cDifferentNameDifferentLiteralKeyword_2_0 = (Keyword)cDifferentNameEnumLiteralDeclaration_2.eContents().get(0);
- //org.eclipse.xtext.parsetree.reconstr.XtextSerializationException: Error serializing CrossRefs: Unable to create a string represenation for reference 'EEnumLiteral' using org.eclipse.xtext.xtext.XtextLinkingService EReference: enumLiteral Context:org.eclipse.xtext.impl.EnumLiteralDeclarationImpl@c528c5 (cardinality: null) Target:SameName
+ //enum ExistingEnum returns ExistingEnum : SameName | OverriddenLiteral = "overridden" | DifferentName ;
public EnumRule getRule() { return rule; }
- //org.eclipse.xtext.parsetree.reconstr.XtextSerializationException: Error serializing CrossRefs: Unable to create a string represenation for reference 'EEnumLiteral' using org.eclipse.xtext.xtext.XtextLinkingService EReference: enumLiteral Context:org.eclipse.xtext.impl.EnumLiteralDeclarationImpl@c528c5 (cardinality: null) Target:SameName
+ //SameName | OverriddenLiteral = "overridden" | DifferentName
public Alternatives getAlternatives() { return cAlternatives; }
- //org.eclipse.xtext.parsetree.reconstr.XtextSerializationException: Error serializing CrossRefs: Unable to create a string represenation for reference 'EEnumLiteral' using org.eclipse.xtext.xtext.XtextLinkingService EReference: enumLiteral Context:org.eclipse.xtext.impl.EnumLiteralDeclarationImpl@c528c5 (cardinality: null) Target:SameName
+ //SameName
public EnumLiteralDeclaration getSameNameEnumLiteralDeclaration_0() { return cSameNameEnumLiteralDeclaration_0; }
//"SameName"
public Keyword getSameNameSameNameKeyword_0_0() { return cSameNameSameNameKeyword_0_0; }
- //org.eclipse.xtext.parsetree.reconstr.XtextSerializationException: Error serializing CrossRefs: Unable to create a string represenation for reference 'EEnumLiteral' using org.eclipse.xtext.xtext.XtextLinkingService EReference: enumLiteral Context:org.eclipse.xtext.impl.EnumLiteralDeclarationImpl@ce35ac (cardinality: null) Target:OtherLiteral
+ //OverriddenLiteral = "overridden"
public EnumLiteralDeclaration getOverriddenLiteralEnumLiteralDeclaration_1() { return cOverriddenLiteralEnumLiteralDeclaration_1; }
//"overridden"
public Keyword getOverriddenLiteralOverriddenKeyword_1_0() { return cOverriddenLiteralOverriddenKeyword_1_0; }
- //org.eclipse.xtext.parsetree.reconstr.XtextSerializationException: Error serializing CrossRefs: Unable to create a string represenation for reference 'EEnumLiteral' using org.eclipse.xtext.xtext.XtextLinkingService EReference: enumLiteral Context:org.eclipse.xtext.impl.EnumLiteralDeclarationImpl@25dd43 (cardinality: null) Target:DifferentLiteral
+ //DifferentName
public EnumLiteralDeclaration getDifferentNameEnumLiteralDeclaration_2() { return cDifferentNameEnumLiteralDeclaration_2; }
//"DifferentLiteral"
@@ -105,19 +105,19 @@ public class EnumRulesTestLanguageGrammarAccess implements IGrammarAccess {
private final EnumLiteralDeclaration cDifferentNameEnumLiteralDeclaration_1 = (EnumLiteralDeclaration)cAlternatives.eContents().get(1);
private final Keyword cDifferentNameDifferentLiteralKeyword_1_0 = (Keyword)cDifferentNameEnumLiteralDeclaration_1.eContents().get(0);
- //org.eclipse.xtext.parsetree.reconstr.XtextSerializationException: Error serializing CrossRefs: Unable to create a string represenation for reference 'EEnumLiteral' using org.eclipse.xtext.xtext.XtextLinkingService EReference: enumLiteral Context:org.eclipse.xtext.impl.EnumLiteralDeclarationImpl@3ed9a3 (cardinality: null) Target:SameName
+ //enum GeneratedEnum returns GeneratedEnum : SameName | DifferentName ;
public EnumRule getRule() { return rule; }
- //org.eclipse.xtext.parsetree.reconstr.XtextSerializationException: Error serializing CrossRefs: Unable to create a string represenation for reference 'EEnumLiteral' using org.eclipse.xtext.xtext.XtextLinkingService EReference: enumLiteral Context:org.eclipse.xtext.impl.EnumLiteralDeclarationImpl@3ed9a3 (cardinality: null) Target:SameName
+ //SameName | DifferentName
public Alternatives getAlternatives() { return cAlternatives; }
- //org.eclipse.xtext.parsetree.reconstr.XtextSerializationException: Error serializing CrossRefs: Unable to create a string represenation for reference 'EEnumLiteral' using org.eclipse.xtext.xtext.XtextLinkingService EReference: enumLiteral Context:org.eclipse.xtext.impl.EnumLiteralDeclarationImpl@3ed9a3 (cardinality: null) Target:SameName
+ //SameName
public EnumLiteralDeclaration getSameNameEnumLiteralDeclaration_0() { return cSameNameEnumLiteralDeclaration_0; }
//"SameName"
public Keyword getSameNameSameNameKeyword_0_0() { return cSameNameSameNameKeyword_0_0; }
- //org.eclipse.xtext.parsetree.reconstr.XtextSerializationException: Error serializing CrossRefs: Unable to create a string represenation for reference 'EEnumLiteral' using org.eclipse.xtext.xtext.XtextLinkingService EReference: enumLiteral Context:org.eclipse.xtext.impl.EnumLiteralDeclarationImpl@4280df (cardinality: null) Target:DifferentLiteral
+ //DifferentName
public EnumLiteralDeclaration getDifferentNameEnumLiteralDeclaration_1() { return cDifferentNameEnumLiteralDeclaration_1; }
//"DifferentLiteral"
@@ -159,7 +159,7 @@ public class EnumRulesTestLanguageGrammarAccess implements IGrammarAccess {
return getModelAccess().getRule();
}
- //org.eclipse.xtext.parsetree.reconstr.XtextSerializationException: Error serializing CrossRefs: Unable to create a string represenation for reference 'EEnumLiteral' using org.eclipse.xtext.xtext.XtextLinkingService EReference: enumLiteral Context:org.eclipse.xtext.impl.EnumLiteralDeclarationImpl@c528c5 (cardinality: null) Target:SameName
+ //enum ExistingEnum returns ExistingEnum : SameName | OverriddenLiteral = "overridden" | DifferentName ;
public ExistingEnumElements getExistingEnumAccess() {
return (unknownRuleExistingEnum != null) ? unknownRuleExistingEnum : (unknownRuleExistingEnum = new ExistingEnumElements());
}
@@ -168,7 +168,7 @@ public class EnumRulesTestLanguageGrammarAccess implements IGrammarAccess {
return getExistingEnumAccess().getRule();
}
- //org.eclipse.xtext.parsetree.reconstr.XtextSerializationException: Error serializing CrossRefs: Unable to create a string represenation for reference 'EEnumLiteral' using org.eclipse.xtext.xtext.XtextLinkingService EReference: enumLiteral Context:org.eclipse.xtext.impl.EnumLiteralDeclarationImpl@3ed9a3 (cardinality: null) Target:SameName
+ //enum GeneratedEnum returns GeneratedEnum : SameName | DifferentName ;
public GeneratedEnumElements getGeneratedEnumAccess() {
return (unknownRuleGeneratedEnum != null) ? unknownRuleGeneratedEnum : (unknownRuleGeneratedEnum = new GeneratedEnumElements());
}
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/enumrules/EnumRulesTestLanguage.xtext b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/enumrules/EnumRulesTestLanguage.xtext
index c2455da..ee044db 100644
--- a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/enumrules/EnumRulesTestLanguage.xtext
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/enumrules/EnumRulesTestLanguage.xtext
@@ -9,7 +9,7 @@
grammar org.eclipse.xtext.enumrules.EnumRulesTestLanguage with org.eclipse.xtext.common.Terminals
import "classpath:/org/eclipse/xtext/enumrules/enums.ecore"
-generate enumRulesTestLanguage "http://www.eclipse.org/2008/tmf/xtext/EnumRulesTest"
+generate enumRulesTestLanguage "http://www.eclipse.org/2009/tmf/xtext/EnumRulesTest"
Model:
'existing' existing=ExistingEnum | 'generated' generated=GeneratedEnum
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
new file mode 100644
index 0000000..f7d7903
--- /dev/null
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/enumrules/GrammarParserTest.java
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * Copyright (c) 2009 itemis AG (http://www.itemis.eu) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.xtext.enumrules;
+
+import org.eclipse.emf.ecore.EEnum;
+import org.eclipse.emf.ecore.EEnumLiteral;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.xtext.EnumLiteralDeclaration;
+import org.eclipse.xtext.EnumRule;
+import org.eclipse.xtext.Grammar;
+import org.eclipse.xtext.XtextStandaloneSetup;
+import org.eclipse.xtext.enumrules.enums.ExistingEnum;
+import org.eclipse.xtext.junit.AbstractXtextTests;
+
+/**
+ * @author Sebastian Zarnekow - Initial contribution and API
+ */
+public class GrammarParserTest extends AbstractXtextTests {
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ with(XtextStandaloneSetup.class);
+ }
+
+ public void testEnum_01() throws Exception {
+ String modelAsString =
+ "grammar TestLanguage with org.eclipse.xtext.common.Terminals\n" +
+ "generate testLanguage 'http://www.eclipse.org/2009/tmf/xtext/EnumRulesTest/TestEnum/1'\n" +
+ "Model: enumValue=MyEnum;\n" +
+ "enum MyEnum: Value1;";
+ Grammar grammar = (Grammar) getModel(modelAsString);
+ assertTrue(grammar.eResource().getErrors().toString(), grammar.eResource().getErrors().isEmpty());
+ 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");
+ assertNotNull(eEnum);
+ assertEquals(1, eEnum.getELiterals().size());
+ EEnumLiteral value = eEnum.getELiterals().get(0);
+ assertEquals("Value1", value.getName());
+ assertEquals(0, value.getValue());
+ assertEquals("Value1", value.getLiteral());
+ }
+
+ public void testEnum_02() throws Exception {
+ String modelAsString =
+ "grammar TestLanguage with org.eclipse.xtext.common.Terminals\n" +
+ "generate testLanguage 'http://www.eclipse.org/2009/tmf/xtext/EnumRulesTest/TestEnum/2'\n" +
+ "Model: enumValue=MyEnumRule;\n" +
+ "enum MyEnumRule returns MyEnum: Value1;";
+ Grammar grammar = (Grammar) getModel(modelAsString);
+ assertTrue(grammar.eResource().getErrors().toString(), grammar.eResource().getErrors().isEmpty());
+ 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");
+ assertNotNull(eEnum);
+ assertEquals(1, eEnum.getELiterals().size());
+ EEnumLiteral value = eEnum.getELiterals().get(0);
+ assertEquals("Value1", value.getName());
+ assertEquals(0, value.getValue());
+ assertEquals("Value1", value.getLiteral());
+ }
+
+ public void testEnum_03() throws Exception {
+ String modelAsString =
+ "grammar TestLanguage with org.eclipse.xtext.common.Terminals\n" +
+ "generate testLanguage 'http://www.eclipse.org/2009/tmf/xtext/EnumRulesTest/TestEnum/3'\n" +
+ "Model: enumValue=MyEnumRule;\n" +
+ "enum MyEnumRule returns MyEnum: Value1 = 'value';";
+ Grammar grammar = (Grammar) getModel(modelAsString);
+ assertTrue(grammar.eResource().getErrors().toString(), grammar.eResource().getErrors().isEmpty());
+ 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");
+ assertNotNull(eEnum);
+ assertEquals(1, eEnum.getELiterals().size());
+ EEnumLiteral value = eEnum.getELiterals().get(0);
+ assertEquals("Value1", value.getName());
+ assertEquals(0, value.getValue());
+ assertEquals("value", value.getLiteral());
+ }
+
+ 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/EnumRulesTest/TestEnum/4'\n" +
+ "Model: enumValue=ExistingEnum;\n" +
+ "enum ExistingEnum: SameName;";
+ Grammar grammar = (Grammar) getModel(modelAsString);
+ assertTrue(grammar.eResource().getErrors().toString(), grammar.eResource().getErrors().isEmpty());
+ 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());
+ }
+
+ public void testEnum_05() 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/EnumRulesTest/TestEnum/5'\n" +
+ "Model: enumValue=ExistingEnum;\n" +
+ "enum ExistingEnum: SameName = 'value';";
+ Grammar grammar = (Grammar) getModel(modelAsString);
+ assertTrue(grammar.eResource().getErrors().toString(), grammar.eResource().getErrors().isEmpty());
+ 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", decl.getLiteral().getValue());
+ }
+}