diff --git a/tests/org.eclipse.xtext.tests/META-INF/MANIFEST.MF_gen b/tests/org.eclipse.xtext.tests/META-INF/MANIFEST.MF_gen index f59b3eb2b..8ec9f757e 100644 --- a/tests/org.eclipse.xtext.tests/META-INF/MANIFEST.MF_gen +++ b/tests/org.eclipse.xtext.tests/META-INF/MANIFEST.MF_gen @@ -20,4 +20,4 @@ Import-Package: org.junit.runner;version="4.5.0", org.junit.runners;version="4.5.0", org.junit.runners.model;version="4.5.0", org.hamcrest.core -Bundle-Activator: org.eclipse.xtext.generator.ecore.ui.internal.SuperTestLanguageActivator +Bundle-Activator: org.eclipse.xtext.ui.internal.XtextGrammarTestLanguageActivator diff --git a/tests/org.eclipse.xtext.tests/model/generated/SubTestLanguage.ecore b/tests/org.eclipse.xtext.tests/model/generated/SubTestLanguage.ecore new file mode 100644 index 000000000..564a3db99 --- /dev/null +++ b/tests/org.eclipse.xtext.tests/model/generated/SubTestLanguage.ecore @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/tests/org.eclipse.xtext.tests/model/generated/SubTestLanguage.genmodel b/tests/org.eclipse.xtext.tests/model/generated/SubTestLanguage.genmodel new file mode 100644 index 000000000..9e1c0c71d --- /dev/null +++ b/tests/org.eclipse.xtext.tests/model/generated/SubTestLanguage.genmodel @@ -0,0 +1,15 @@ + + + + + + + + + + diff --git a/tests/org.eclipse.xtext.tests/model/generated/SuperTestLanguage.ecore b/tests/org.eclipse.xtext.tests/model/generated/SuperTestLanguage.ecore new file mode 100644 index 000000000..d7e5d0659 --- /dev/null +++ b/tests/org.eclipse.xtext.tests/model/generated/SuperTestLanguage.ecore @@ -0,0 +1,11 @@ + + + + + + + + + diff --git a/tests/org.eclipse.xtext.tests/model/generated/SuperTestLanguage.genmodel b/tests/org.eclipse.xtext.tests/model/generated/SuperTestLanguage.genmodel new file mode 100644 index 000000000..b213f44b1 --- /dev/null +++ b/tests/org.eclipse.xtext.tests/model/generated/SuperTestLanguage.genmodel @@ -0,0 +1,16 @@ + + + + + + + + + + + diff --git a/tests/org.eclipse.xtext.tests/plugin.xml_gen b/tests/org.eclipse.xtext.tests/plugin.xml_gen index eddcfebdf..950e635c9 100644 --- a/tests/org.eclipse.xtext.tests/plugin.xml_gen +++ b/tests/org.eclipse.xtext.tests/plugin.xml_gen @@ -3,24 +3,6 @@ - - - - - - - - - - - - bindIParser() { + return SubTestLanguageParser.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public Class bindITokenToStringConverter() { + return AntlrTokenToStringConverter.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public Class bindIAntlrTokenFileProvider() { + return SubTestLanguageAntlrTokenFileProvider.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public Class bindLexer() { + return InternalSubTestLanguageLexer.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public Class bindITokenDefProvider() { + return AntlrTokenDefProvider.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public Provider provideInternalSubTestLanguageLexer() { + return LexerProvider.create(InternalSubTestLanguageLexer.class); + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public void configureRuntimeLexer(Binder binder) { + binder.bind(Lexer.class) + .annotatedWith(Names.named(LexerBindings.RUNTIME)) + .to(InternalSubTestLanguageLexer.class); + } + + // contributed by org.eclipse.xtext.xtext.generator.grammarAccess.GrammarAccessFragment2 + public ClassLoader bindClassLoaderToInstance() { + return getClass().getClassLoader(); + } + + // contributed by org.eclipse.xtext.xtext.generator.grammarAccess.GrammarAccessFragment2 + public Class bindIGrammarAccess() { + return SubTestLanguageGrammarAccess.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.serializer.SerializerFragment2 + public Class bindISemanticSequencer() { + return SubTestLanguageSemanticSequencer.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.serializer.SerializerFragment2 + public Class bindISyntacticSequencer() { + return SubTestLanguageSyntacticSequencer.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.serializer.SerializerFragment2 + public Class bindISerializer() { + return Serializer.class; + } + +} diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/AbstractSuperTestLanguageRuntimeModule.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/AbstractSuperTestLanguageRuntimeModule.java new file mode 100644 index 000000000..3db2e7fe5 --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/AbstractSuperTestLanguageRuntimeModule.java @@ -0,0 +1,118 @@ +/* + * generated by Xtext + */ +package org.eclipse.xtext.generator.ecore; + +import com.google.inject.Binder; +import com.google.inject.Provider; +import com.google.inject.name.Names; +import java.util.Properties; +import org.eclipse.xtext.Constants; +import org.eclipse.xtext.IGrammarAccess; +import org.eclipse.xtext.generator.ecore.parser.antlr.SuperTestLanguageAntlrTokenFileProvider; +import org.eclipse.xtext.generator.ecore.parser.antlr.SuperTestLanguageParser; +import org.eclipse.xtext.generator.ecore.parser.antlr.internal.InternalSuperTestLanguageLexer; +import org.eclipse.xtext.generator.ecore.serializer.SuperTestLanguageSemanticSequencer; +import org.eclipse.xtext.generator.ecore.serializer.SuperTestLanguageSyntacticSequencer; +import org.eclipse.xtext.generator.ecore.services.SuperTestLanguageGrammarAccess; +import org.eclipse.xtext.parser.IParser; +import org.eclipse.xtext.parser.ITokenToStringConverter; +import org.eclipse.xtext.parser.antlr.AntlrTokenDefProvider; +import org.eclipse.xtext.parser.antlr.AntlrTokenToStringConverter; +import org.eclipse.xtext.parser.antlr.IAntlrTokenFileProvider; +import org.eclipse.xtext.parser.antlr.ITokenDefProvider; +import org.eclipse.xtext.parser.antlr.Lexer; +import org.eclipse.xtext.parser.antlr.LexerBindings; +import org.eclipse.xtext.parser.antlr.LexerProvider; +import org.eclipse.xtext.serializer.ISerializer; +import org.eclipse.xtext.serializer.impl.Serializer; +import org.eclipse.xtext.serializer.sequencer.ISemanticSequencer; +import org.eclipse.xtext.serializer.sequencer.ISyntacticSequencer; +import org.eclipse.xtext.service.DefaultRuntimeModule; + +/** + * Manual modifications go to {@link SuperTestLanguageRuntimeModule}. + */ +@SuppressWarnings("all") +public abstract class AbstractSuperTestLanguageRuntimeModule extends DefaultRuntimeModule { + + protected Properties properties = null; + + @Override + public void configure(Binder binder) { + properties = tryBindProperties(binder, "org/eclipse/xtext/generator/ecore/SuperTestLanguage.properties"); + super.configure(binder); + } + + public void configureLanguageName(Binder binder) { + binder.bind(String.class).annotatedWith(Names.named(Constants.LANGUAGE_NAME)).toInstance("org.eclipse.xtext.generator.ecore.SuperTestLanguage"); + } + + public void configureFileExtensions(Binder binder) { + if (properties == null || properties.getProperty(Constants.FILE_EXTENSIONS) == null) + binder.bind(String.class).annotatedWith(Names.named(Constants.FILE_EXTENSIONS)).toInstance("supertestlanguage"); + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public Class bindIParser() { + return SuperTestLanguageParser.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public Class bindITokenToStringConverter() { + return AntlrTokenToStringConverter.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public Class bindIAntlrTokenFileProvider() { + return SuperTestLanguageAntlrTokenFileProvider.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public Class bindLexer() { + return InternalSuperTestLanguageLexer.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public Class bindITokenDefProvider() { + return AntlrTokenDefProvider.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public Provider provideInternalSuperTestLanguageLexer() { + return LexerProvider.create(InternalSuperTestLanguageLexer.class); + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public void configureRuntimeLexer(Binder binder) { + binder.bind(Lexer.class) + .annotatedWith(Names.named(LexerBindings.RUNTIME)) + .to(InternalSuperTestLanguageLexer.class); + } + + // contributed by org.eclipse.xtext.xtext.generator.grammarAccess.GrammarAccessFragment2 + public ClassLoader bindClassLoaderToInstance() { + return getClass().getClassLoader(); + } + + // contributed by org.eclipse.xtext.xtext.generator.grammarAccess.GrammarAccessFragment2 + public Class bindIGrammarAccess() { + return SuperTestLanguageGrammarAccess.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.serializer.SerializerFragment2 + public Class bindISemanticSequencer() { + return SuperTestLanguageSemanticSequencer.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.serializer.SerializerFragment2 + public Class bindISyntacticSequencer() { + return SuperTestLanguageSyntacticSequencer.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.serializer.SerializerFragment2 + public Class bindISerializer() { + return Serializer.class; + } + +} diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/SubTestLanguage.xtextbin b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/SubTestLanguage.xtextbin new file mode 100644 index 000000000..386b721a9 Binary files /dev/null and b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/SubTestLanguage.xtextbin differ diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/SubTestLanguageStandaloneSetupGenerated.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/SubTestLanguageStandaloneSetupGenerated.java new file mode 100644 index 000000000..5ebe703ad --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/SubTestLanguageStandaloneSetupGenerated.java @@ -0,0 +1,41 @@ +/* + * generated by Xtext + */ +package org.eclipse.xtext.generator.ecore; + +import com.google.inject.Guice; +import com.google.inject.Injector; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.xtext.ISetup; +import org.eclipse.xtext.generator.ecore.subPackage.SubPackagePackage; +import org.eclipse.xtext.resource.IResourceFactory; +import org.eclipse.xtext.resource.IResourceServiceProvider; + +@SuppressWarnings("all") +public class SubTestLanguageStandaloneSetupGenerated implements ISetup { + + @Override + public Injector createInjectorAndDoEMFRegistration() { + SuperTestLanguageStandaloneSetup.doSetup(); + + Injector injector = createInjector(); + register(injector); + return injector; + } + + public Injector createInjector() { + return Guice.createInjector(new SubTestLanguageRuntimeModule()); + } + + public void register(Injector injector) { + if (!EPackage.Registry.INSTANCE.containsKey("http://www.eclipse.org/2009/tmf/xtext/SubTestLanguage")) { + EPackage.Registry.INSTANCE.put("http://www.eclipse.org/2009/tmf/xtext/SubTestLanguage", SubPackagePackage.eINSTANCE); + } + IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class); + IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class); + + Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("subtestlanguage", resourceFactory); + IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("subtestlanguage", serviceProvider); + } +} diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/SuperTestLanguage.xtextbin b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/SuperTestLanguage.xtextbin new file mode 100644 index 000000000..7f5ae95e1 Binary files /dev/null and b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/SuperTestLanguage.xtextbin differ diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/SuperTestLanguageStandaloneSetupGenerated.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/SuperTestLanguageStandaloneSetupGenerated.java new file mode 100644 index 000000000..2ae316caa --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/SuperTestLanguageStandaloneSetupGenerated.java @@ -0,0 +1,42 @@ +/* + * generated by Xtext + */ +package org.eclipse.xtext.generator.ecore; + +import com.google.inject.Guice; +import com.google.inject.Injector; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.xtext.ISetup; +import org.eclipse.xtext.common.TerminalsStandaloneSetup; +import org.eclipse.xtext.generator.ecore.superPackage.SuperPackagePackage; +import org.eclipse.xtext.resource.IResourceFactory; +import org.eclipse.xtext.resource.IResourceServiceProvider; + +@SuppressWarnings("all") +public class SuperTestLanguageStandaloneSetupGenerated implements ISetup { + + @Override + public Injector createInjectorAndDoEMFRegistration() { + TerminalsStandaloneSetup.doSetup(); + + Injector injector = createInjector(); + register(injector); + return injector; + } + + public Injector createInjector() { + return Guice.createInjector(new SuperTestLanguageRuntimeModule()); + } + + public void register(Injector injector) { + if (!EPackage.Registry.INSTANCE.containsKey("http://www.eclipse.org/2009/tmf/xtext/SuperTestLanguage")) { + EPackage.Registry.INSTANCE.put("http://www.eclipse.org/2009/tmf/xtext/SuperTestLanguage", SuperPackagePackage.eINSTANCE); + } + IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class); + IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class); + + Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("supertestlanguage", resourceFactory); + IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("supertestlanguage", serviceProvider); + } +} diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/SubTestLanguageAntlrTokenFileProvider.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/SubTestLanguageAntlrTokenFileProvider.java new file mode 100644 index 000000000..c40f107a1 --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/SubTestLanguageAntlrTokenFileProvider.java @@ -0,0 +1,16 @@ +/* + * generated by Xtext + */ +package org.eclipse.xtext.generator.ecore.parser.antlr; + +import java.io.InputStream; +import org.eclipse.xtext.parser.antlr.IAntlrTokenFileProvider; + +public class SubTestLanguageAntlrTokenFileProvider implements IAntlrTokenFileProvider { + + @Override + public InputStream getAntlrTokenFile() { + ClassLoader classLoader = getClass().getClassLoader(); + return classLoader.getResourceAsStream("org/eclipse/xtext/generator/ecore/parser/antlr/internal/InternalSubTestLanguage.tokens"); + } +} diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/SubTestLanguageParser.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/SubTestLanguageParser.java new file mode 100644 index 000000000..2594c990f --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/SubTestLanguageParser.java @@ -0,0 +1,40 @@ +/* + * generated by Xtext + */ +package org.eclipse.xtext.generator.ecore.parser.antlr; + +import com.google.inject.Inject; +import org.eclipse.xtext.generator.ecore.parser.antlr.internal.InternalSubTestLanguageParser; +import org.eclipse.xtext.generator.ecore.services.SubTestLanguageGrammarAccess; +import org.eclipse.xtext.parser.antlr.AbstractAntlrParser; +import org.eclipse.xtext.parser.antlr.XtextTokenStream; + +public class SubTestLanguageParser extends AbstractAntlrParser { + + @Inject + private SubTestLanguageGrammarAccess grammarAccess; + + @Override + protected void setInitialHiddenTokens(XtextTokenStream tokenStream) { + tokenStream.setInitialHiddenTokens("RULE_WS", "RULE_ML_COMMENT", "RULE_SL_COMMENT"); + } + + + @Override + protected InternalSubTestLanguageParser createParser(XtextTokenStream stream) { + return new InternalSubTestLanguageParser(stream, getGrammarAccess()); + } + + @Override + protected String getDefaultRuleName() { + return "SubMain"; + } + + public SubTestLanguageGrammarAccess getGrammarAccess() { + return this.grammarAccess; + } + + public void setGrammarAccess(SubTestLanguageGrammarAccess grammarAccess) { + this.grammarAccess = grammarAccess; + } +} diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/SuperTestLanguageAntlrTokenFileProvider.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/SuperTestLanguageAntlrTokenFileProvider.java new file mode 100644 index 000000000..91993e097 --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/SuperTestLanguageAntlrTokenFileProvider.java @@ -0,0 +1,16 @@ +/* + * generated by Xtext + */ +package org.eclipse.xtext.generator.ecore.parser.antlr; + +import java.io.InputStream; +import org.eclipse.xtext.parser.antlr.IAntlrTokenFileProvider; + +public class SuperTestLanguageAntlrTokenFileProvider implements IAntlrTokenFileProvider { + + @Override + public InputStream getAntlrTokenFile() { + ClassLoader classLoader = getClass().getClassLoader(); + return classLoader.getResourceAsStream("org/eclipse/xtext/generator/ecore/parser/antlr/internal/InternalSuperTestLanguage.tokens"); + } +} diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/SuperTestLanguageParser.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/SuperTestLanguageParser.java new file mode 100644 index 000000000..16d74de76 --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/SuperTestLanguageParser.java @@ -0,0 +1,40 @@ +/* + * generated by Xtext + */ +package org.eclipse.xtext.generator.ecore.parser.antlr; + +import com.google.inject.Inject; +import org.eclipse.xtext.generator.ecore.parser.antlr.internal.InternalSuperTestLanguageParser; +import org.eclipse.xtext.generator.ecore.services.SuperTestLanguageGrammarAccess; +import org.eclipse.xtext.parser.antlr.AbstractAntlrParser; +import org.eclipse.xtext.parser.antlr.XtextTokenStream; + +public class SuperTestLanguageParser extends AbstractAntlrParser { + + @Inject + private SuperTestLanguageGrammarAccess grammarAccess; + + @Override + protected void setInitialHiddenTokens(XtextTokenStream tokenStream) { + tokenStream.setInitialHiddenTokens("RULE_WS", "RULE_ML_COMMENT", "RULE_SL_COMMENT"); + } + + + @Override + protected InternalSuperTestLanguageParser createParser(XtextTokenStream stream) { + return new InternalSuperTestLanguageParser(stream, getGrammarAccess()); + } + + @Override + protected String getDefaultRuleName() { + return "SuperMain"; + } + + public SuperTestLanguageGrammarAccess getGrammarAccess() { + return this.grammarAccess; + } + + public void setGrammarAccess(SuperTestLanguageGrammarAccess grammarAccess) { + this.grammarAccess = grammarAccess; + } +} diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/internal/DebugInternalSubTestLanguage.g b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/internal/DebugInternalSubTestLanguage.g new file mode 100644 index 000000000..77fd39141 --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/internal/DebugInternalSubTestLanguage.g @@ -0,0 +1,39 @@ +/* + * generated by Xtext + */ +grammar DebugInternalSubTestLanguage; + +// Rule SubMain +ruleSubMain: + '{' + ruleSuperMain + '}' + ruleAnotherSuperMain + ? +; + +// Rule AnotherSuperMain +ruleAnotherSuperMain: + 'ups' + RULE_ID +; + +// Rule SuperMain +ruleSuperMain: + 'super' + RULE_ID +; + +RULE_ID : '^'? ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*; + +RULE_INT : ('0'..'9')+; + +RULE_STRING : ('"' ('\\' .|~(('\\'|'"')))* '"'|'\'' ('\\' .|~(('\\'|'\'')))* '\''); + +RULE_ML_COMMENT : '/*' ( options {greedy=false;} : . )*'*/' {skip();}; + +RULE_SL_COMMENT : '//' ~(('\n'|'\r'))* ('\r'? '\n')? {skip();}; + +RULE_WS : (' '|'\t'|'\r'|'\n')+ {skip();}; + +RULE_ANY_OTHER : .; diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/internal/DebugInternalSuperTestLanguage.g b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/internal/DebugInternalSuperTestLanguage.g new file mode 100644 index 000000000..bf44d1d87 --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/internal/DebugInternalSuperTestLanguage.g @@ -0,0 +1,24 @@ +/* + * generated by Xtext + */ +grammar DebugInternalSuperTestLanguage; + +// Rule SuperMain +ruleSuperMain: + 'super' + RULE_ID +; + +RULE_ID : '^'? ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*; + +RULE_INT : ('0'..'9')+; + +RULE_STRING : ('"' ('\\' .|~(('\\'|'"')))* '"'|'\'' ('\\' .|~(('\\'|'\'')))* '\''); + +RULE_ML_COMMENT : '/*' ( options {greedy=false;} : . )*'*/' {skip();}; + +RULE_SL_COMMENT : '//' ~(('\n'|'\r'))* ('\r'? '\n')? {skip();}; + +RULE_WS : (' '|'\t'|'\r'|'\n')+ {skip();}; + +RULE_ANY_OTHER : .; diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/internal/InternalSubTestLanguage.g b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/internal/InternalSubTestLanguage.g new file mode 100644 index 000000000..349ef04ed --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/internal/InternalSubTestLanguage.g @@ -0,0 +1,222 @@ +/* + * generated by Xtext + */ +grammar InternalSubTestLanguage; + +options { + superClass=AbstractInternalAntlrParser; +} + +@lexer::header { +package org.eclipse.xtext.generator.ecore.parser.antlr.internal; + +// Hack: Use our own Lexer superclass by means of import. +// Currently there is no other way to specify the superclass for the lexer. +import org.eclipse.xtext.parser.antlr.Lexer; +} + +@parser::header { +package org.eclipse.xtext.generator.ecore.parser.antlr.internal; + +import org.eclipse.xtext.*; +import org.eclipse.xtext.parser.*; +import org.eclipse.xtext.parser.impl.*; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.xtext.parser.antlr.AbstractInternalAntlrParser; +import org.eclipse.xtext.parser.antlr.XtextTokenStream; +import org.eclipse.xtext.parser.antlr.XtextTokenStream.HiddenTokens; +import org.eclipse.xtext.parser.antlr.AntlrDatatypeRuleToken; +import org.eclipse.xtext.generator.ecore.services.SubTestLanguageGrammarAccess; + +} + +@parser::members { + + private SubTestLanguageGrammarAccess grammarAccess; + + public InternalSubTestLanguageParser(TokenStream input, SubTestLanguageGrammarAccess grammarAccess) { + this(input); + this.grammarAccess = grammarAccess; + registerRules(grammarAccess.getGrammar()); + } + + @Override + protected String getFirstRuleName() { + return "SubMain"; + } + + @Override + protected SubTestLanguageGrammarAccess getGrammarAccess() { + return grammarAccess; + } + +} + +@rulecatch { + catch (RecognitionException re) { + recover(input,re); + appendSkippedTokens(); + } +} + +// Entry rule entryRuleSubMain +entryRuleSubMain returns [EObject current=null]: + { newCompositeNode(grammarAccess.getSubMainRule()); } + iv_ruleSubMain=ruleSubMain + { $current=$iv_ruleSubMain.current; } + EOF; + +// Rule SubMain +ruleSubMain returns [EObject current=null] +@init { + enterRule(); +} +@after { + leaveRule(); +}: + ( + otherlv_0='{' + { + newLeafNode(otherlv_0, grammarAccess.getSubMainAccess().getLeftCurlyBracketKeyword_0()); + } + ( + ( + { + newCompositeNode(grammarAccess.getSubMainAccess().getSuperMainsSuperMainParserRuleCall_1_0()); + } + lv_superMains_1_0=ruleSuperMain + { + if ($current==null) { + $current = createModelElementForParent(grammarAccess.getSubMainRule()); + } + add( + $current, + "superMains", + lv_superMains_1_0, + "org.eclipse.xtext.generator.ecore.SuperTestLanguage.SuperMain"); + afterParserOrEnumRuleCall(); + } + ) + ) + otherlv_2='}' + { + newLeafNode(otherlv_2, grammarAccess.getSubMainAccess().getRightCurlyBracketKeyword_2()); + } + ( + ( + { + newCompositeNode(grammarAccess.getSubMainAccess().getAnotherAnotherSuperMainParserRuleCall_3_0()); + } + lv_another_3_0=ruleAnotherSuperMain + { + if ($current==null) { + $current = createModelElementForParent(grammarAccess.getSubMainRule()); + } + set( + $current, + "another", + lv_another_3_0, + "org.eclipse.xtext.generator.ecore.SubTestLanguage.AnotherSuperMain"); + afterParserOrEnumRuleCall(); + } + ) + )? + ) +; + +// Entry rule entryRuleAnotherSuperMain +entryRuleAnotherSuperMain returns [EObject current=null]: + { newCompositeNode(grammarAccess.getAnotherSuperMainRule()); } + iv_ruleAnotherSuperMain=ruleAnotherSuperMain + { $current=$iv_ruleAnotherSuperMain.current; } + EOF; + +// Rule AnotherSuperMain +ruleAnotherSuperMain returns [EObject current=null] +@init { + enterRule(); +} +@after { + leaveRule(); +}: + ( + otherlv_0='ups' + { + newLeafNode(otherlv_0, grammarAccess.getAnotherSuperMainAccess().getUpsKeyword_0()); + } + ( + ( + lv_name_1_0=RULE_ID + { + newLeafNode(lv_name_1_0, grammarAccess.getAnotherSuperMainAccess().getNameIDTerminalRuleCall_1_0()); + } + { + if ($current==null) { + $current = createModelElement(grammarAccess.getAnotherSuperMainRule()); + } + setWithLastConsumed( + $current, + "name", + lv_name_1_0, + "org.eclipse.xtext.common.Terminals.ID"); + } + ) + ) + ) +; + +// Entry rule entryRuleSuperMain +entryRuleSuperMain returns [EObject current=null]: + { newCompositeNode(grammarAccess.getSuperMainRule()); } + iv_ruleSuperMain=ruleSuperMain + { $current=$iv_ruleSuperMain.current; } + EOF; + +// Rule SuperMain +ruleSuperMain returns [EObject current=null] +@init { + enterRule(); +} +@after { + leaveRule(); +}: + ( + otherlv_0='super' + { + newLeafNode(otherlv_0, grammarAccess.getSuperMainAccess().getSuperKeyword_0()); + } + ( + ( + lv_name_1_0=RULE_ID + { + newLeafNode(lv_name_1_0, grammarAccess.getSuperMainAccess().getNameIDTerminalRuleCall_1_0()); + } + { + if ($current==null) { + $current = createModelElement(grammarAccess.getSuperMainRule()); + } + setWithLastConsumed( + $current, + "name", + lv_name_1_0, + "org.eclipse.xtext.common.Terminals.ID"); + } + ) + ) + ) +; + +RULE_ID : '^'? ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*; + +RULE_INT : ('0'..'9')+; + +RULE_STRING : ('"' ('\\' .|~(('\\'|'"')))* '"'|'\'' ('\\' .|~(('\\'|'\'')))* '\''); + +RULE_ML_COMMENT : '/*' ( options {greedy=false;} : . )*'*/'; + +RULE_SL_COMMENT : '//' ~(('\n'|'\r'))* ('\r'? '\n')?; + +RULE_WS : (' '|'\t'|'\r'|'\n')+; + +RULE_ANY_OTHER : .; diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/internal/InternalSubTestLanguage.tokens b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/internal/InternalSubTestLanguage.tokens new file mode 100644 index 000000000..e133fec60 --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/internal/InternalSubTestLanguage.tokens @@ -0,0 +1,15 @@ +'super'=14 +'ups'=13 +'{'=11 +'}'=12 +RULE_ANY_OTHER=10 +RULE_ID=4 +RULE_INT=5 +RULE_ML_COMMENT=7 +RULE_SL_COMMENT=8 +RULE_STRING=6 +RULE_WS=9 +T__11=11 +T__12=12 +T__13=13 +T__14=14 diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/internal/InternalSubTestLanguageLexer.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/internal/InternalSubTestLanguageLexer.java new file mode 100644 index 000000000..2b10853fd --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/internal/InternalSubTestLanguageLexer.java @@ -0,0 +1,849 @@ +package org.eclipse.xtext.generator.ecore.parser.antlr.internal; + +// Hack: Use our own Lexer superclass by means of import. +// Currently there is no other way to specify the superclass for the lexer. +import org.eclipse.xtext.parser.antlr.Lexer; + + +import org.antlr.runtime.*; +import java.util.Stack; +import java.util.List; +import java.util.ArrayList; + +@SuppressWarnings("all") +public class InternalSubTestLanguageLexer extends Lexer { + public static final int RULE_ID=4; + public static final int RULE_STRING=6; + public static final int T__12=12; + public static final int T__11=11; + public static final int T__14=14; + public static final int T__13=13; + public static final int RULE_ANY_OTHER=10; + public static final int RULE_INT=5; + public static final int RULE_WS=9; + public static final int RULE_SL_COMMENT=8; + public static final int EOF=-1; + public static final int RULE_ML_COMMENT=7; + + // delegates + // delegators + + public InternalSubTestLanguageLexer() {;} + public InternalSubTestLanguageLexer(CharStream input) { + this(input, new RecognizerSharedState()); + } + public InternalSubTestLanguageLexer(CharStream input, RecognizerSharedState state) { + super(input,state); + + } + public String getGrammarFileName() { return "InternalSubTestLanguage.g"; } + + // $ANTLR start "T__11" + public final void mT__11() throws RecognitionException { + try { + int _type = T__11; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalSubTestLanguage.g:11:7: ( '{' ) + // InternalSubTestLanguage.g:11:9: '{' + { + match('{'); + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "T__11" + + // $ANTLR start "T__12" + public final void mT__12() throws RecognitionException { + try { + int _type = T__12; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalSubTestLanguage.g:12:7: ( '}' ) + // InternalSubTestLanguage.g:12:9: '}' + { + match('}'); + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "T__12" + + // $ANTLR start "T__13" + public final void mT__13() throws RecognitionException { + try { + int _type = T__13; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalSubTestLanguage.g:13:7: ( 'ups' ) + // InternalSubTestLanguage.g:13:9: 'ups' + { + match("ups"); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "T__13" + + // $ANTLR start "T__14" + public final void mT__14() throws RecognitionException { + try { + int _type = T__14; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalSubTestLanguage.g:14:7: ( 'super' ) + // InternalSubTestLanguage.g:14:9: 'super' + { + match("super"); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "T__14" + + // $ANTLR start "RULE_ID" + public final void mRULE_ID() throws RecognitionException { + try { + int _type = RULE_ID; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalSubTestLanguage.g:210:9: ( ( '^' )? ( 'a' .. 'z' | 'A' .. 'Z' | '_' ) ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' )* ) + // InternalSubTestLanguage.g:210:11: ( '^' )? ( 'a' .. 'z' | 'A' .. 'Z' | '_' ) ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' )* + { + // InternalSubTestLanguage.g:210:11: ( '^' )? + int alt1=2; + int LA1_0 = input.LA(1); + + if ( (LA1_0=='^') ) { + alt1=1; + } + switch (alt1) { + case 1 : + // InternalSubTestLanguage.g:210:11: '^' + { + match('^'); + + } + break; + + } + + if ( (input.LA(1)>='A' && input.LA(1)<='Z')||input.LA(1)=='_'||(input.LA(1)>='a' && input.LA(1)<='z') ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + // InternalSubTestLanguage.g:210:40: ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' )* + loop2: + do { + int alt2=2; + int LA2_0 = input.LA(1); + + if ( ((LA2_0>='0' && LA2_0<='9')||(LA2_0>='A' && LA2_0<='Z')||LA2_0=='_'||(LA2_0>='a' && LA2_0<='z')) ) { + alt2=1; + } + + + switch (alt2) { + case 1 : + // InternalSubTestLanguage.g: + { + if ( (input.LA(1)>='0' && input.LA(1)<='9')||(input.LA(1)>='A' && input.LA(1)<='Z')||input.LA(1)=='_'||(input.LA(1)>='a' && input.LA(1)<='z') ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + + } + break; + + default : + break loop2; + } + } while (true); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_ID" + + // $ANTLR start "RULE_INT" + public final void mRULE_INT() throws RecognitionException { + try { + int _type = RULE_INT; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalSubTestLanguage.g:212:10: ( ( '0' .. '9' )+ ) + // InternalSubTestLanguage.g:212:12: ( '0' .. '9' )+ + { + // InternalSubTestLanguage.g:212:12: ( '0' .. '9' )+ + int cnt3=0; + loop3: + do { + int alt3=2; + int LA3_0 = input.LA(1); + + if ( ((LA3_0>='0' && LA3_0<='9')) ) { + alt3=1; + } + + + switch (alt3) { + case 1 : + // InternalSubTestLanguage.g:212:13: '0' .. '9' + { + matchRange('0','9'); + + } + break; + + default : + if ( cnt3 >= 1 ) break loop3; + EarlyExitException eee = + new EarlyExitException(3, input); + throw eee; + } + cnt3++; + } while (true); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_INT" + + // $ANTLR start "RULE_STRING" + public final void mRULE_STRING() throws RecognitionException { + try { + int _type = RULE_STRING; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalSubTestLanguage.g:214:13: ( ( '\"' ( '\\\\' . | ~ ( ( '\\\\' | '\"' ) ) )* '\"' | '\\'' ( '\\\\' . | ~ ( ( '\\\\' | '\\'' ) ) )* '\\'' ) ) + // InternalSubTestLanguage.g:214:15: ( '\"' ( '\\\\' . | ~ ( ( '\\\\' | '\"' ) ) )* '\"' | '\\'' ( '\\\\' . | ~ ( ( '\\\\' | '\\'' ) ) )* '\\'' ) + { + // InternalSubTestLanguage.g:214:15: ( '\"' ( '\\\\' . | ~ ( ( '\\\\' | '\"' ) ) )* '\"' | '\\'' ( '\\\\' . | ~ ( ( '\\\\' | '\\'' ) ) )* '\\'' ) + int alt6=2; + int LA6_0 = input.LA(1); + + if ( (LA6_0=='\"') ) { + alt6=1; + } + else if ( (LA6_0=='\'') ) { + alt6=2; + } + else { + NoViableAltException nvae = + new NoViableAltException("", 6, 0, input); + + throw nvae; + } + switch (alt6) { + case 1 : + // InternalSubTestLanguage.g:214:16: '\"' ( '\\\\' . | ~ ( ( '\\\\' | '\"' ) ) )* '\"' + { + match('\"'); + // InternalSubTestLanguage.g:214:20: ( '\\\\' . | ~ ( ( '\\\\' | '\"' ) ) )* + loop4: + do { + int alt4=3; + int LA4_0 = input.LA(1); + + if ( (LA4_0=='\\') ) { + alt4=1; + } + else if ( ((LA4_0>='\u0000' && LA4_0<='!')||(LA4_0>='#' && LA4_0<='[')||(LA4_0>=']' && LA4_0<='\uFFFF')) ) { + alt4=2; + } + + + switch (alt4) { + case 1 : + // InternalSubTestLanguage.g:214:21: '\\\\' . + { + match('\\'); + matchAny(); + + } + break; + case 2 : + // InternalSubTestLanguage.g:214:28: ~ ( ( '\\\\' | '\"' ) ) + { + if ( (input.LA(1)>='\u0000' && input.LA(1)<='!')||(input.LA(1)>='#' && input.LA(1)<='[')||(input.LA(1)>=']' && input.LA(1)<='\uFFFF') ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + + } + break; + + default : + break loop4; + } + } while (true); + + match('\"'); + + } + break; + case 2 : + // InternalSubTestLanguage.g:214:48: '\\'' ( '\\\\' . | ~ ( ( '\\\\' | '\\'' ) ) )* '\\'' + { + match('\''); + // InternalSubTestLanguage.g:214:53: ( '\\\\' . | ~ ( ( '\\\\' | '\\'' ) ) )* + loop5: + do { + int alt5=3; + int LA5_0 = input.LA(1); + + if ( (LA5_0=='\\') ) { + alt5=1; + } + else if ( ((LA5_0>='\u0000' && LA5_0<='&')||(LA5_0>='(' && LA5_0<='[')||(LA5_0>=']' && LA5_0<='\uFFFF')) ) { + alt5=2; + } + + + switch (alt5) { + case 1 : + // InternalSubTestLanguage.g:214:54: '\\\\' . + { + match('\\'); + matchAny(); + + } + break; + case 2 : + // InternalSubTestLanguage.g:214:61: ~ ( ( '\\\\' | '\\'' ) ) + { + if ( (input.LA(1)>='\u0000' && input.LA(1)<='&')||(input.LA(1)>='(' && input.LA(1)<='[')||(input.LA(1)>=']' && input.LA(1)<='\uFFFF') ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + + } + break; + + default : + break loop5; + } + } while (true); + + match('\''); + + } + break; + + } + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_STRING" + + // $ANTLR start "RULE_ML_COMMENT" + public final void mRULE_ML_COMMENT() throws RecognitionException { + try { + int _type = RULE_ML_COMMENT; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalSubTestLanguage.g:216:17: ( '/*' ( options {greedy=false; } : . )* '*/' ) + // InternalSubTestLanguage.g:216:19: '/*' ( options {greedy=false; } : . )* '*/' + { + match("/*"); + + // InternalSubTestLanguage.g:216:24: ( options {greedy=false; } : . )* + loop7: + do { + int alt7=2; + int LA7_0 = input.LA(1); + + if ( (LA7_0=='*') ) { + int LA7_1 = input.LA(2); + + if ( (LA7_1=='/') ) { + alt7=2; + } + else if ( ((LA7_1>='\u0000' && LA7_1<='.')||(LA7_1>='0' && LA7_1<='\uFFFF')) ) { + alt7=1; + } + + + } + else if ( ((LA7_0>='\u0000' && LA7_0<=')')||(LA7_0>='+' && LA7_0<='\uFFFF')) ) { + alt7=1; + } + + + switch (alt7) { + case 1 : + // InternalSubTestLanguage.g:216:52: . + { + matchAny(); + + } + break; + + default : + break loop7; + } + } while (true); + + match("*/"); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_ML_COMMENT" + + // $ANTLR start "RULE_SL_COMMENT" + public final void mRULE_SL_COMMENT() throws RecognitionException { + try { + int _type = RULE_SL_COMMENT; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalSubTestLanguage.g:218:17: ( '//' (~ ( ( '\\n' | '\\r' ) ) )* ( ( '\\r' )? '\\n' )? ) + // InternalSubTestLanguage.g:218:19: '//' (~ ( ( '\\n' | '\\r' ) ) )* ( ( '\\r' )? '\\n' )? + { + match("//"); + + // InternalSubTestLanguage.g:218:24: (~ ( ( '\\n' | '\\r' ) ) )* + loop8: + do { + int alt8=2; + int LA8_0 = input.LA(1); + + if ( ((LA8_0>='\u0000' && LA8_0<='\t')||(LA8_0>='\u000B' && LA8_0<='\f')||(LA8_0>='\u000E' && LA8_0<='\uFFFF')) ) { + alt8=1; + } + + + switch (alt8) { + case 1 : + // InternalSubTestLanguage.g:218:24: ~ ( ( '\\n' | '\\r' ) ) + { + if ( (input.LA(1)>='\u0000' && input.LA(1)<='\t')||(input.LA(1)>='\u000B' && input.LA(1)<='\f')||(input.LA(1)>='\u000E' && input.LA(1)<='\uFFFF') ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + + } + break; + + default : + break loop8; + } + } while (true); + + // InternalSubTestLanguage.g:218:40: ( ( '\\r' )? '\\n' )? + int alt10=2; + int LA10_0 = input.LA(1); + + if ( (LA10_0=='\n'||LA10_0=='\r') ) { + alt10=1; + } + switch (alt10) { + case 1 : + // InternalSubTestLanguage.g:218:41: ( '\\r' )? '\\n' + { + // InternalSubTestLanguage.g:218:41: ( '\\r' )? + int alt9=2; + int LA9_0 = input.LA(1); + + if ( (LA9_0=='\r') ) { + alt9=1; + } + switch (alt9) { + case 1 : + // InternalSubTestLanguage.g:218:41: '\\r' + { + match('\r'); + + } + break; + + } + + match('\n'); + + } + break; + + } + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_SL_COMMENT" + + // $ANTLR start "RULE_WS" + public final void mRULE_WS() throws RecognitionException { + try { + int _type = RULE_WS; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalSubTestLanguage.g:220:9: ( ( ' ' | '\\t' | '\\r' | '\\n' )+ ) + // InternalSubTestLanguage.g:220:11: ( ' ' | '\\t' | '\\r' | '\\n' )+ + { + // InternalSubTestLanguage.g:220:11: ( ' ' | '\\t' | '\\r' | '\\n' )+ + int cnt11=0; + loop11: + do { + int alt11=2; + int LA11_0 = input.LA(1); + + if ( ((LA11_0>='\t' && LA11_0<='\n')||LA11_0=='\r'||LA11_0==' ') ) { + alt11=1; + } + + + switch (alt11) { + case 1 : + // InternalSubTestLanguage.g: + { + if ( (input.LA(1)>='\t' && input.LA(1)<='\n')||input.LA(1)=='\r'||input.LA(1)==' ' ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + + } + break; + + default : + if ( cnt11 >= 1 ) break loop11; + EarlyExitException eee = + new EarlyExitException(11, input); + throw eee; + } + cnt11++; + } while (true); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_WS" + + // $ANTLR start "RULE_ANY_OTHER" + public final void mRULE_ANY_OTHER() throws RecognitionException { + try { + int _type = RULE_ANY_OTHER; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalSubTestLanguage.g:222:16: ( . ) + // InternalSubTestLanguage.g:222:18: . + { + matchAny(); + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_ANY_OTHER" + + public void mTokens() throws RecognitionException { + // InternalSubTestLanguage.g:1:8: ( T__11 | T__12 | T__13 | T__14 | RULE_ID | RULE_INT | RULE_STRING | RULE_ML_COMMENT | RULE_SL_COMMENT | RULE_WS | RULE_ANY_OTHER ) + int alt12=11; + alt12 = dfa12.predict(input); + switch (alt12) { + case 1 : + // InternalSubTestLanguage.g:1:10: T__11 + { + mT__11(); + + } + break; + case 2 : + // InternalSubTestLanguage.g:1:16: T__12 + { + mT__12(); + + } + break; + case 3 : + // InternalSubTestLanguage.g:1:22: T__13 + { + mT__13(); + + } + break; + case 4 : + // InternalSubTestLanguage.g:1:28: T__14 + { + mT__14(); + + } + break; + case 5 : + // InternalSubTestLanguage.g:1:34: RULE_ID + { + mRULE_ID(); + + } + break; + case 6 : + // InternalSubTestLanguage.g:1:42: RULE_INT + { + mRULE_INT(); + + } + break; + case 7 : + // InternalSubTestLanguage.g:1:51: RULE_STRING + { + mRULE_STRING(); + + } + break; + case 8 : + // InternalSubTestLanguage.g:1:63: RULE_ML_COMMENT + { + mRULE_ML_COMMENT(); + + } + break; + case 9 : + // InternalSubTestLanguage.g:1:79: RULE_SL_COMMENT + { + mRULE_SL_COMMENT(); + + } + break; + case 10 : + // InternalSubTestLanguage.g:1:95: RULE_WS + { + mRULE_WS(); + + } + break; + case 11 : + // InternalSubTestLanguage.g:1:103: RULE_ANY_OTHER + { + mRULE_ANY_OTHER(); + + } + break; + + } + + } + + + protected DFA12 dfa12 = new DFA12(this); + static final String DFA12_eotS = + "\3\uffff\2\20\1\14\2\uffff\3\14\4\uffff\1\20\1\uffff\1\20\5\uffff\1\31\1\20\1\uffff\1\20\1\34\1\uffff"; + static final String DFA12_eofS = + "\35\uffff"; + static final String DFA12_minS = + "\1\0\2\uffff\1\160\1\165\1\101\2\uffff\2\0\1\52\4\uffff\1\163\1\uffff\1\160\5\uffff\1\60\1\145\1\uffff\1\162\1\60\1\uffff"; + static final String DFA12_maxS = + "\1\uffff\2\uffff\1\160\1\165\1\172\2\uffff\2\uffff\1\57\4\uffff\1\163\1\uffff\1\160\5\uffff\1\172\1\145\1\uffff\1\162\1\172\1\uffff"; + static final String DFA12_acceptS = + "\1\uffff\1\1\1\2\3\uffff\1\5\1\6\3\uffff\1\12\1\13\1\1\1\2\1\uffff\1\5\1\uffff\1\6\1\7\1\10\1\11\1\12\2\uffff\1\3\2\uffff\1\4"; + static final String DFA12_specialS = + "\1\1\7\uffff\1\0\1\2\23\uffff}>"; + static final String[] DFA12_transitionS = { + "\11\14\2\13\2\14\1\13\22\14\1\13\1\14\1\10\4\14\1\11\7\14\1\12\12\7\7\14\32\6\3\14\1\5\1\6\1\14\22\6\1\4\1\6\1\3\5\6\1\1\1\14\1\2\uff82\14", + "", + "", + "\1\17", + "\1\21", + "\32\20\4\uffff\1\20\1\uffff\32\20", + "", + "", + "\0\23", + "\0\23", + "\1\24\4\uffff\1\25", + "", + "", + "", + "", + "\1\27", + "", + "\1\30", + "", + "", + "", + "", + "", + "\12\20\7\uffff\32\20\4\uffff\1\20\1\uffff\32\20", + "\1\32", + "", + "\1\33", + "\12\20\7\uffff\32\20\4\uffff\1\20\1\uffff\32\20", + "" + }; + + static final short[] DFA12_eot = DFA.unpackEncodedString(DFA12_eotS); + static final short[] DFA12_eof = DFA.unpackEncodedString(DFA12_eofS); + static final char[] DFA12_min = DFA.unpackEncodedStringToUnsignedChars(DFA12_minS); + static final char[] DFA12_max = DFA.unpackEncodedStringToUnsignedChars(DFA12_maxS); + static final short[] DFA12_accept = DFA.unpackEncodedString(DFA12_acceptS); + static final short[] DFA12_special = DFA.unpackEncodedString(DFA12_specialS); + static final short[][] DFA12_transition; + + static { + int numStates = DFA12_transitionS.length; + DFA12_transition = new short[numStates][]; + for (int i=0; i='\u0000' && LA12_8<='\uFFFF')) ) {s = 19;} + + else s = 12; + + if ( s>=0 ) return s; + break; + case 1 : + int LA12_0 = input.LA(1); + + s = -1; + if ( (LA12_0=='{') ) {s = 1;} + + else if ( (LA12_0=='}') ) {s = 2;} + + else if ( (LA12_0=='u') ) {s = 3;} + + else if ( (LA12_0=='s') ) {s = 4;} + + else if ( (LA12_0=='^') ) {s = 5;} + + else if ( ((LA12_0>='A' && LA12_0<='Z')||LA12_0=='_'||(LA12_0>='a' && LA12_0<='r')||LA12_0=='t'||(LA12_0>='v' && LA12_0<='z')) ) {s = 6;} + + else if ( ((LA12_0>='0' && LA12_0<='9')) ) {s = 7;} + + else if ( (LA12_0=='\"') ) {s = 8;} + + else if ( (LA12_0=='\'') ) {s = 9;} + + else if ( (LA12_0=='/') ) {s = 10;} + + else if ( ((LA12_0>='\t' && LA12_0<='\n')||LA12_0=='\r'||LA12_0==' ') ) {s = 11;} + + else if ( ((LA12_0>='\u0000' && LA12_0<='\b')||(LA12_0>='\u000B' && LA12_0<='\f')||(LA12_0>='\u000E' && LA12_0<='\u001F')||LA12_0=='!'||(LA12_0>='#' && LA12_0<='&')||(LA12_0>='(' && LA12_0<='.')||(LA12_0>=':' && LA12_0<='@')||(LA12_0>='[' && LA12_0<=']')||LA12_0=='`'||LA12_0=='|'||(LA12_0>='~' && LA12_0<='\uFFFF')) ) {s = 12;} + + if ( s>=0 ) return s; + break; + case 2 : + int LA12_9 = input.LA(1); + + s = -1; + if ( ((LA12_9>='\u0000' && LA12_9<='\uFFFF')) ) {s = 19;} + + else s = 12; + + if ( s>=0 ) return s; + break; + } + NoViableAltException nvae = + new NoViableAltException(getDescription(), 12, _s, input); + error(nvae); + throw nvae; + } + } + + +} \ No newline at end of file diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/internal/InternalSubTestLanguageParser.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/internal/InternalSubTestLanguageParser.java new file mode 100644 index 000000000..2e842b7eb --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/internal/InternalSubTestLanguageParser.java @@ -0,0 +1,466 @@ +package org.eclipse.xtext.generator.ecore.parser.antlr.internal; + +import org.eclipse.xtext.*; +import org.eclipse.xtext.parser.*; +import org.eclipse.xtext.parser.impl.*; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.xtext.parser.antlr.AbstractInternalAntlrParser; +import org.eclipse.xtext.parser.antlr.XtextTokenStream; +import org.eclipse.xtext.parser.antlr.XtextTokenStream.HiddenTokens; +import org.eclipse.xtext.parser.antlr.AntlrDatatypeRuleToken; +import org.eclipse.xtext.generator.ecore.services.SubTestLanguageGrammarAccess; + + + +import org.antlr.runtime.*; +import java.util.Stack; +import java.util.List; +import java.util.ArrayList; + +@SuppressWarnings("all") +public class InternalSubTestLanguageParser extends AbstractInternalAntlrParser { + public static final String[] tokenNames = new String[] { + "", "", "", "", "RULE_ID", "RULE_INT", "RULE_STRING", "RULE_ML_COMMENT", "RULE_SL_COMMENT", "RULE_WS", "RULE_ANY_OTHER", "'{'", "'}'", "'ups'", "'super'" + }; + public static final int RULE_ID=4; + public static final int RULE_STRING=6; + public static final int T__12=12; + public static final int T__11=11; + public static final int T__14=14; + public static final int T__13=13; + public static final int RULE_ANY_OTHER=10; + public static final int RULE_INT=5; + public static final int RULE_WS=9; + public static final int RULE_SL_COMMENT=8; + public static final int EOF=-1; + public static final int RULE_ML_COMMENT=7; + + // delegates + // delegators + + + public InternalSubTestLanguageParser(TokenStream input) { + this(input, new RecognizerSharedState()); + } + public InternalSubTestLanguageParser(TokenStream input, RecognizerSharedState state) { + super(input, state); + + } + + + public String[] getTokenNames() { return InternalSubTestLanguageParser.tokenNames; } + public String getGrammarFileName() { return "InternalSubTestLanguage.g"; } + + + + private SubTestLanguageGrammarAccess grammarAccess; + + public InternalSubTestLanguageParser(TokenStream input, SubTestLanguageGrammarAccess grammarAccess) { + this(input); + this.grammarAccess = grammarAccess; + registerRules(grammarAccess.getGrammar()); + } + + @Override + protected String getFirstRuleName() { + return "SubMain"; + } + + @Override + protected SubTestLanguageGrammarAccess getGrammarAccess() { + return grammarAccess; + } + + + + + // $ANTLR start "entryRuleSubMain" + // InternalSubTestLanguage.g:64:1: entryRuleSubMain returns [EObject current=null] : iv_ruleSubMain= ruleSubMain EOF ; + public final EObject entryRuleSubMain() throws RecognitionException { + EObject current = null; + + EObject iv_ruleSubMain = null; + + + try { + // InternalSubTestLanguage.g:64:48: (iv_ruleSubMain= ruleSubMain EOF ) + // InternalSubTestLanguage.g:65:2: iv_ruleSubMain= ruleSubMain EOF + { + newCompositeNode(grammarAccess.getSubMainRule()); + pushFollow(FollowSets000.FOLLOW_1); + iv_ruleSubMain=ruleSubMain(); + + state._fsp--; + + current =iv_ruleSubMain; + match(input,EOF,FollowSets000.FOLLOW_2); + + } + + } + + catch (RecognitionException re) { + recover(input,re); + appendSkippedTokens(); + } + finally { + } + return current; + } + // $ANTLR end "entryRuleSubMain" + + + // $ANTLR start "ruleSubMain" + // InternalSubTestLanguage.g:71:1: ruleSubMain returns [EObject current=null] : (otherlv_0= '{' ( (lv_superMains_1_0= ruleSuperMain ) ) otherlv_2= '}' ( (lv_another_3_0= ruleAnotherSuperMain ) )? ) ; + public final EObject ruleSubMain() throws RecognitionException { + EObject current = null; + + Token otherlv_0=null; + Token otherlv_2=null; + EObject lv_superMains_1_0 = null; + + EObject lv_another_3_0 = null; + + + + enterRule(); + + try { + // InternalSubTestLanguage.g:77:2: ( (otherlv_0= '{' ( (lv_superMains_1_0= ruleSuperMain ) ) otherlv_2= '}' ( (lv_another_3_0= ruleAnotherSuperMain ) )? ) ) + // InternalSubTestLanguage.g:78:2: (otherlv_0= '{' ( (lv_superMains_1_0= ruleSuperMain ) ) otherlv_2= '}' ( (lv_another_3_0= ruleAnotherSuperMain ) )? ) + { + // InternalSubTestLanguage.g:78:2: (otherlv_0= '{' ( (lv_superMains_1_0= ruleSuperMain ) ) otherlv_2= '}' ( (lv_another_3_0= ruleAnotherSuperMain ) )? ) + // InternalSubTestLanguage.g:79:3: otherlv_0= '{' ( (lv_superMains_1_0= ruleSuperMain ) ) otherlv_2= '}' ( (lv_another_3_0= ruleAnotherSuperMain ) )? + { + otherlv_0=(Token)match(input,11,FollowSets000.FOLLOW_3); + + newLeafNode(otherlv_0, grammarAccess.getSubMainAccess().getLeftCurlyBracketKeyword_0()); + + // InternalSubTestLanguage.g:83:3: ( (lv_superMains_1_0= ruleSuperMain ) ) + // InternalSubTestLanguage.g:84:4: (lv_superMains_1_0= ruleSuperMain ) + { + // InternalSubTestLanguage.g:84:4: (lv_superMains_1_0= ruleSuperMain ) + // InternalSubTestLanguage.g:85:5: lv_superMains_1_0= ruleSuperMain + { + + newCompositeNode(grammarAccess.getSubMainAccess().getSuperMainsSuperMainParserRuleCall_1_0()); + + pushFollow(FollowSets000.FOLLOW_4); + lv_superMains_1_0=ruleSuperMain(); + + state._fsp--; + + + if (current==null) { + current = createModelElementForParent(grammarAccess.getSubMainRule()); + } + add( + current, + "superMains", + lv_superMains_1_0, + "org.eclipse.xtext.generator.ecore.SuperTestLanguage.SuperMain"); + afterParserOrEnumRuleCall(); + + + } + + + } + + otherlv_2=(Token)match(input,12,FollowSets000.FOLLOW_5); + + newLeafNode(otherlv_2, grammarAccess.getSubMainAccess().getRightCurlyBracketKeyword_2()); + + // InternalSubTestLanguage.g:106:3: ( (lv_another_3_0= ruleAnotherSuperMain ) )? + int alt1=2; + int LA1_0 = input.LA(1); + + if ( (LA1_0==13) ) { + alt1=1; + } + switch (alt1) { + case 1 : + // InternalSubTestLanguage.g:107:4: (lv_another_3_0= ruleAnotherSuperMain ) + { + // InternalSubTestLanguage.g:107:4: (lv_another_3_0= ruleAnotherSuperMain ) + // InternalSubTestLanguage.g:108:5: lv_another_3_0= ruleAnotherSuperMain + { + + newCompositeNode(grammarAccess.getSubMainAccess().getAnotherAnotherSuperMainParserRuleCall_3_0()); + + pushFollow(FollowSets000.FOLLOW_2); + lv_another_3_0=ruleAnotherSuperMain(); + + state._fsp--; + + + if (current==null) { + current = createModelElementForParent(grammarAccess.getSubMainRule()); + } + set( + current, + "another", + lv_another_3_0, + "org.eclipse.xtext.generator.ecore.SubTestLanguage.AnotherSuperMain"); + afterParserOrEnumRuleCall(); + + + } + + + } + break; + + } + + + } + + + } + + + leaveRule(); + + } + + catch (RecognitionException re) { + recover(input,re); + appendSkippedTokens(); + } + finally { + } + return current; + } + // $ANTLR end "ruleSubMain" + + + // $ANTLR start "entryRuleAnotherSuperMain" + // InternalSubTestLanguage.g:129:1: entryRuleAnotherSuperMain returns [EObject current=null] : iv_ruleAnotherSuperMain= ruleAnotherSuperMain EOF ; + public final EObject entryRuleAnotherSuperMain() throws RecognitionException { + EObject current = null; + + EObject iv_ruleAnotherSuperMain = null; + + + try { + // InternalSubTestLanguage.g:129:57: (iv_ruleAnotherSuperMain= ruleAnotherSuperMain EOF ) + // InternalSubTestLanguage.g:130:2: iv_ruleAnotherSuperMain= ruleAnotherSuperMain EOF + { + newCompositeNode(grammarAccess.getAnotherSuperMainRule()); + pushFollow(FollowSets000.FOLLOW_1); + iv_ruleAnotherSuperMain=ruleAnotherSuperMain(); + + state._fsp--; + + current =iv_ruleAnotherSuperMain; + match(input,EOF,FollowSets000.FOLLOW_2); + + } + + } + + catch (RecognitionException re) { + recover(input,re); + appendSkippedTokens(); + } + finally { + } + return current; + } + // $ANTLR end "entryRuleAnotherSuperMain" + + + // $ANTLR start "ruleAnotherSuperMain" + // InternalSubTestLanguage.g:136:1: ruleAnotherSuperMain returns [EObject current=null] : (otherlv_0= 'ups' ( (lv_name_1_0= RULE_ID ) ) ) ; + public final EObject ruleAnotherSuperMain() throws RecognitionException { + EObject current = null; + + Token otherlv_0=null; + Token lv_name_1_0=null; + + + enterRule(); + + try { + // InternalSubTestLanguage.g:142:2: ( (otherlv_0= 'ups' ( (lv_name_1_0= RULE_ID ) ) ) ) + // InternalSubTestLanguage.g:143:2: (otherlv_0= 'ups' ( (lv_name_1_0= RULE_ID ) ) ) + { + // InternalSubTestLanguage.g:143:2: (otherlv_0= 'ups' ( (lv_name_1_0= RULE_ID ) ) ) + // InternalSubTestLanguage.g:144:3: otherlv_0= 'ups' ( (lv_name_1_0= RULE_ID ) ) + { + otherlv_0=(Token)match(input,13,FollowSets000.FOLLOW_6); + + newLeafNode(otherlv_0, grammarAccess.getAnotherSuperMainAccess().getUpsKeyword_0()); + + // InternalSubTestLanguage.g:148:3: ( (lv_name_1_0= RULE_ID ) ) + // InternalSubTestLanguage.g:149:4: (lv_name_1_0= RULE_ID ) + { + // InternalSubTestLanguage.g:149:4: (lv_name_1_0= RULE_ID ) + // InternalSubTestLanguage.g:150:5: lv_name_1_0= RULE_ID + { + lv_name_1_0=(Token)match(input,RULE_ID,FollowSets000.FOLLOW_2); + + newLeafNode(lv_name_1_0, grammarAccess.getAnotherSuperMainAccess().getNameIDTerminalRuleCall_1_0()); + + + if (current==null) { + current = createModelElement(grammarAccess.getAnotherSuperMainRule()); + } + setWithLastConsumed( + current, + "name", + lv_name_1_0, + "org.eclipse.xtext.common.Terminals.ID"); + + + } + + + } + + + } + + + } + + + leaveRule(); + + } + + catch (RecognitionException re) { + recover(input,re); + appendSkippedTokens(); + } + finally { + } + return current; + } + // $ANTLR end "ruleAnotherSuperMain" + + + // $ANTLR start "entryRuleSuperMain" + // InternalSubTestLanguage.g:170:1: entryRuleSuperMain returns [EObject current=null] : iv_ruleSuperMain= ruleSuperMain EOF ; + public final EObject entryRuleSuperMain() throws RecognitionException { + EObject current = null; + + EObject iv_ruleSuperMain = null; + + + try { + // InternalSubTestLanguage.g:170:50: (iv_ruleSuperMain= ruleSuperMain EOF ) + // InternalSubTestLanguage.g:171:2: iv_ruleSuperMain= ruleSuperMain EOF + { + newCompositeNode(grammarAccess.getSuperMainRule()); + pushFollow(FollowSets000.FOLLOW_1); + iv_ruleSuperMain=ruleSuperMain(); + + state._fsp--; + + current =iv_ruleSuperMain; + match(input,EOF,FollowSets000.FOLLOW_2); + + } + + } + + catch (RecognitionException re) { + recover(input,re); + appendSkippedTokens(); + } + finally { + } + return current; + } + // $ANTLR end "entryRuleSuperMain" + + + // $ANTLR start "ruleSuperMain" + // InternalSubTestLanguage.g:177:1: ruleSuperMain returns [EObject current=null] : (otherlv_0= 'super' ( (lv_name_1_0= RULE_ID ) ) ) ; + public final EObject ruleSuperMain() throws RecognitionException { + EObject current = null; + + Token otherlv_0=null; + Token lv_name_1_0=null; + + + enterRule(); + + try { + // InternalSubTestLanguage.g:183:2: ( (otherlv_0= 'super' ( (lv_name_1_0= RULE_ID ) ) ) ) + // InternalSubTestLanguage.g:184:2: (otherlv_0= 'super' ( (lv_name_1_0= RULE_ID ) ) ) + { + // InternalSubTestLanguage.g:184:2: (otherlv_0= 'super' ( (lv_name_1_0= RULE_ID ) ) ) + // InternalSubTestLanguage.g:185:3: otherlv_0= 'super' ( (lv_name_1_0= RULE_ID ) ) + { + otherlv_0=(Token)match(input,14,FollowSets000.FOLLOW_6); + + newLeafNode(otherlv_0, grammarAccess.getSuperMainAccess().getSuperKeyword_0()); + + // InternalSubTestLanguage.g:189:3: ( (lv_name_1_0= RULE_ID ) ) + // InternalSubTestLanguage.g:190:4: (lv_name_1_0= RULE_ID ) + { + // InternalSubTestLanguage.g:190:4: (lv_name_1_0= RULE_ID ) + // InternalSubTestLanguage.g:191:5: lv_name_1_0= RULE_ID + { + lv_name_1_0=(Token)match(input,RULE_ID,FollowSets000.FOLLOW_2); + + newLeafNode(lv_name_1_0, grammarAccess.getSuperMainAccess().getNameIDTerminalRuleCall_1_0()); + + + if (current==null) { + current = createModelElement(grammarAccess.getSuperMainRule()); + } + setWithLastConsumed( + current, + "name", + lv_name_1_0, + "org.eclipse.xtext.common.Terminals.ID"); + + + } + + + } + + + } + + + } + + + leaveRule(); + + } + + catch (RecognitionException re) { + recover(input,re); + appendSkippedTokens(); + } + finally { + } + return current; + } + // $ANTLR end "ruleSuperMain" + + // Delegated rules + + + + + + private static class FollowSets000 { + public static final BitSet FOLLOW_1 = new BitSet(new long[]{0x0000000000000000L}); + public static final BitSet FOLLOW_2 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_3 = new BitSet(new long[]{0x0000000000004000L}); + public static final BitSet FOLLOW_4 = new BitSet(new long[]{0x0000000000001000L}); + public static final BitSet FOLLOW_5 = new BitSet(new long[]{0x0000000000002002L}); + public static final BitSet FOLLOW_6 = new BitSet(new long[]{0x0000000000000010L}); + } + + +} \ No newline at end of file diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/internal/InternalSuperTestLanguage.g b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/internal/InternalSuperTestLanguage.g new file mode 100644 index 000000000..5f14e7a5e --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/internal/InternalSuperTestLanguage.g @@ -0,0 +1,116 @@ +/* + * generated by Xtext + */ +grammar InternalSuperTestLanguage; + +options { + superClass=AbstractInternalAntlrParser; +} + +@lexer::header { +package org.eclipse.xtext.generator.ecore.parser.antlr.internal; + +// Hack: Use our own Lexer superclass by means of import. +// Currently there is no other way to specify the superclass for the lexer. +import org.eclipse.xtext.parser.antlr.Lexer; +} + +@parser::header { +package org.eclipse.xtext.generator.ecore.parser.antlr.internal; + +import org.eclipse.xtext.*; +import org.eclipse.xtext.parser.*; +import org.eclipse.xtext.parser.impl.*; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.xtext.parser.antlr.AbstractInternalAntlrParser; +import org.eclipse.xtext.parser.antlr.XtextTokenStream; +import org.eclipse.xtext.parser.antlr.XtextTokenStream.HiddenTokens; +import org.eclipse.xtext.parser.antlr.AntlrDatatypeRuleToken; +import org.eclipse.xtext.generator.ecore.services.SuperTestLanguageGrammarAccess; + +} + +@parser::members { + + private SuperTestLanguageGrammarAccess grammarAccess; + + public InternalSuperTestLanguageParser(TokenStream input, SuperTestLanguageGrammarAccess grammarAccess) { + this(input); + this.grammarAccess = grammarAccess; + registerRules(grammarAccess.getGrammar()); + } + + @Override + protected String getFirstRuleName() { + return "SuperMain"; + } + + @Override + protected SuperTestLanguageGrammarAccess getGrammarAccess() { + return grammarAccess; + } + +} + +@rulecatch { + catch (RecognitionException re) { + recover(input,re); + appendSkippedTokens(); + } +} + +// Entry rule entryRuleSuperMain +entryRuleSuperMain returns [EObject current=null]: + { newCompositeNode(grammarAccess.getSuperMainRule()); } + iv_ruleSuperMain=ruleSuperMain + { $current=$iv_ruleSuperMain.current; } + EOF; + +// Rule SuperMain +ruleSuperMain returns [EObject current=null] +@init { + enterRule(); +} +@after { + leaveRule(); +}: + ( + otherlv_0='super' + { + newLeafNode(otherlv_0, grammarAccess.getSuperMainAccess().getSuperKeyword_0()); + } + ( + ( + lv_name_1_0=RULE_ID + { + newLeafNode(lv_name_1_0, grammarAccess.getSuperMainAccess().getNameIDTerminalRuleCall_1_0()); + } + { + if ($current==null) { + $current = createModelElement(grammarAccess.getSuperMainRule()); + } + setWithLastConsumed( + $current, + "name", + lv_name_1_0, + "org.eclipse.xtext.common.Terminals.ID"); + } + ) + ) + ) +; + +RULE_ID : '^'? ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*; + +RULE_INT : ('0'..'9')+; + +RULE_STRING : ('"' ('\\' .|~(('\\'|'"')))* '"'|'\'' ('\\' .|~(('\\'|'\'')))* '\''); + +RULE_ML_COMMENT : '/*' ( options {greedy=false;} : . )*'*/'; + +RULE_SL_COMMENT : '//' ~(('\n'|'\r'))* ('\r'? '\n')?; + +RULE_WS : (' '|'\t'|'\r'|'\n')+; + +RULE_ANY_OTHER : .; diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/internal/InternalSuperTestLanguage.tokens b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/internal/InternalSuperTestLanguage.tokens new file mode 100644 index 000000000..981751071 --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/internal/InternalSuperTestLanguage.tokens @@ -0,0 +1,9 @@ +'super'=11 +RULE_ANY_OTHER=10 +RULE_ID=4 +RULE_INT=5 +RULE_ML_COMMENT=7 +RULE_SL_COMMENT=8 +RULE_STRING=6 +RULE_WS=9 +T__11=11 diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/internal/InternalSuperTestLanguageLexer.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/internal/InternalSuperTestLanguageLexer.java new file mode 100644 index 000000000..2f4754a41 --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/internal/InternalSuperTestLanguageLexer.java @@ -0,0 +1,750 @@ +package org.eclipse.xtext.generator.ecore.parser.antlr.internal; + +// Hack: Use our own Lexer superclass by means of import. +// Currently there is no other way to specify the superclass for the lexer. +import org.eclipse.xtext.parser.antlr.Lexer; + + +import org.antlr.runtime.*; +import java.util.Stack; +import java.util.List; +import java.util.ArrayList; + +@SuppressWarnings("all") +public class InternalSuperTestLanguageLexer extends Lexer { + public static final int RULE_ID=4; + public static final int RULE_STRING=6; + public static final int T__11=11; + public static final int RULE_ANY_OTHER=10; + public static final int RULE_INT=5; + public static final int RULE_WS=9; + public static final int RULE_SL_COMMENT=8; + public static final int EOF=-1; + public static final int RULE_ML_COMMENT=7; + + // delegates + // delegators + + public InternalSuperTestLanguageLexer() {;} + public InternalSuperTestLanguageLexer(CharStream input) { + this(input, new RecognizerSharedState()); + } + public InternalSuperTestLanguageLexer(CharStream input, RecognizerSharedState state) { + super(input,state); + + } + public String getGrammarFileName() { return "InternalSuperTestLanguage.g"; } + + // $ANTLR start "T__11" + public final void mT__11() throws RecognitionException { + try { + int _type = T__11; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalSuperTestLanguage.g:11:7: ( 'super' ) + // InternalSuperTestLanguage.g:11:9: 'super' + { + match("super"); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "T__11" + + // $ANTLR start "RULE_ID" + public final void mRULE_ID() throws RecognitionException { + try { + int _type = RULE_ID; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalSuperTestLanguage.g:104:9: ( ( '^' )? ( 'a' .. 'z' | 'A' .. 'Z' | '_' ) ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' )* ) + // InternalSuperTestLanguage.g:104:11: ( '^' )? ( 'a' .. 'z' | 'A' .. 'Z' | '_' ) ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' )* + { + // InternalSuperTestLanguage.g:104:11: ( '^' )? + int alt1=2; + int LA1_0 = input.LA(1); + + if ( (LA1_0=='^') ) { + alt1=1; + } + switch (alt1) { + case 1 : + // InternalSuperTestLanguage.g:104:11: '^' + { + match('^'); + + } + break; + + } + + if ( (input.LA(1)>='A' && input.LA(1)<='Z')||input.LA(1)=='_'||(input.LA(1)>='a' && input.LA(1)<='z') ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + // InternalSuperTestLanguage.g:104:40: ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' )* + loop2: + do { + int alt2=2; + int LA2_0 = input.LA(1); + + if ( ((LA2_0>='0' && LA2_0<='9')||(LA2_0>='A' && LA2_0<='Z')||LA2_0=='_'||(LA2_0>='a' && LA2_0<='z')) ) { + alt2=1; + } + + + switch (alt2) { + case 1 : + // InternalSuperTestLanguage.g: + { + if ( (input.LA(1)>='0' && input.LA(1)<='9')||(input.LA(1)>='A' && input.LA(1)<='Z')||input.LA(1)=='_'||(input.LA(1)>='a' && input.LA(1)<='z') ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + + } + break; + + default : + break loop2; + } + } while (true); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_ID" + + // $ANTLR start "RULE_INT" + public final void mRULE_INT() throws RecognitionException { + try { + int _type = RULE_INT; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalSuperTestLanguage.g:106:10: ( ( '0' .. '9' )+ ) + // InternalSuperTestLanguage.g:106:12: ( '0' .. '9' )+ + { + // InternalSuperTestLanguage.g:106:12: ( '0' .. '9' )+ + int cnt3=0; + loop3: + do { + int alt3=2; + int LA3_0 = input.LA(1); + + if ( ((LA3_0>='0' && LA3_0<='9')) ) { + alt3=1; + } + + + switch (alt3) { + case 1 : + // InternalSuperTestLanguage.g:106:13: '0' .. '9' + { + matchRange('0','9'); + + } + break; + + default : + if ( cnt3 >= 1 ) break loop3; + EarlyExitException eee = + new EarlyExitException(3, input); + throw eee; + } + cnt3++; + } while (true); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_INT" + + // $ANTLR start "RULE_STRING" + public final void mRULE_STRING() throws RecognitionException { + try { + int _type = RULE_STRING; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalSuperTestLanguage.g:108:13: ( ( '\"' ( '\\\\' . | ~ ( ( '\\\\' | '\"' ) ) )* '\"' | '\\'' ( '\\\\' . | ~ ( ( '\\\\' | '\\'' ) ) )* '\\'' ) ) + // InternalSuperTestLanguage.g:108:15: ( '\"' ( '\\\\' . | ~ ( ( '\\\\' | '\"' ) ) )* '\"' | '\\'' ( '\\\\' . | ~ ( ( '\\\\' | '\\'' ) ) )* '\\'' ) + { + // InternalSuperTestLanguage.g:108:15: ( '\"' ( '\\\\' . | ~ ( ( '\\\\' | '\"' ) ) )* '\"' | '\\'' ( '\\\\' . | ~ ( ( '\\\\' | '\\'' ) ) )* '\\'' ) + int alt6=2; + int LA6_0 = input.LA(1); + + if ( (LA6_0=='\"') ) { + alt6=1; + } + else if ( (LA6_0=='\'') ) { + alt6=2; + } + else { + NoViableAltException nvae = + new NoViableAltException("", 6, 0, input); + + throw nvae; + } + switch (alt6) { + case 1 : + // InternalSuperTestLanguage.g:108:16: '\"' ( '\\\\' . | ~ ( ( '\\\\' | '\"' ) ) )* '\"' + { + match('\"'); + // InternalSuperTestLanguage.g:108:20: ( '\\\\' . | ~ ( ( '\\\\' | '\"' ) ) )* + loop4: + do { + int alt4=3; + int LA4_0 = input.LA(1); + + if ( (LA4_0=='\\') ) { + alt4=1; + } + else if ( ((LA4_0>='\u0000' && LA4_0<='!')||(LA4_0>='#' && LA4_0<='[')||(LA4_0>=']' && LA4_0<='\uFFFF')) ) { + alt4=2; + } + + + switch (alt4) { + case 1 : + // InternalSuperTestLanguage.g:108:21: '\\\\' . + { + match('\\'); + matchAny(); + + } + break; + case 2 : + // InternalSuperTestLanguage.g:108:28: ~ ( ( '\\\\' | '\"' ) ) + { + if ( (input.LA(1)>='\u0000' && input.LA(1)<='!')||(input.LA(1)>='#' && input.LA(1)<='[')||(input.LA(1)>=']' && input.LA(1)<='\uFFFF') ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + + } + break; + + default : + break loop4; + } + } while (true); + + match('\"'); + + } + break; + case 2 : + // InternalSuperTestLanguage.g:108:48: '\\'' ( '\\\\' . | ~ ( ( '\\\\' | '\\'' ) ) )* '\\'' + { + match('\''); + // InternalSuperTestLanguage.g:108:53: ( '\\\\' . | ~ ( ( '\\\\' | '\\'' ) ) )* + loop5: + do { + int alt5=3; + int LA5_0 = input.LA(1); + + if ( (LA5_0=='\\') ) { + alt5=1; + } + else if ( ((LA5_0>='\u0000' && LA5_0<='&')||(LA5_0>='(' && LA5_0<='[')||(LA5_0>=']' && LA5_0<='\uFFFF')) ) { + alt5=2; + } + + + switch (alt5) { + case 1 : + // InternalSuperTestLanguage.g:108:54: '\\\\' . + { + match('\\'); + matchAny(); + + } + break; + case 2 : + // InternalSuperTestLanguage.g:108:61: ~ ( ( '\\\\' | '\\'' ) ) + { + if ( (input.LA(1)>='\u0000' && input.LA(1)<='&')||(input.LA(1)>='(' && input.LA(1)<='[')||(input.LA(1)>=']' && input.LA(1)<='\uFFFF') ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + + } + break; + + default : + break loop5; + } + } while (true); + + match('\''); + + } + break; + + } + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_STRING" + + // $ANTLR start "RULE_ML_COMMENT" + public final void mRULE_ML_COMMENT() throws RecognitionException { + try { + int _type = RULE_ML_COMMENT; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalSuperTestLanguage.g:110:17: ( '/*' ( options {greedy=false; } : . )* '*/' ) + // InternalSuperTestLanguage.g:110:19: '/*' ( options {greedy=false; } : . )* '*/' + { + match("/*"); + + // InternalSuperTestLanguage.g:110:24: ( options {greedy=false; } : . )* + loop7: + do { + int alt7=2; + int LA7_0 = input.LA(1); + + if ( (LA7_0=='*') ) { + int LA7_1 = input.LA(2); + + if ( (LA7_1=='/') ) { + alt7=2; + } + else if ( ((LA7_1>='\u0000' && LA7_1<='.')||(LA7_1>='0' && LA7_1<='\uFFFF')) ) { + alt7=1; + } + + + } + else if ( ((LA7_0>='\u0000' && LA7_0<=')')||(LA7_0>='+' && LA7_0<='\uFFFF')) ) { + alt7=1; + } + + + switch (alt7) { + case 1 : + // InternalSuperTestLanguage.g:110:52: . + { + matchAny(); + + } + break; + + default : + break loop7; + } + } while (true); + + match("*/"); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_ML_COMMENT" + + // $ANTLR start "RULE_SL_COMMENT" + public final void mRULE_SL_COMMENT() throws RecognitionException { + try { + int _type = RULE_SL_COMMENT; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalSuperTestLanguage.g:112:17: ( '//' (~ ( ( '\\n' | '\\r' ) ) )* ( ( '\\r' )? '\\n' )? ) + // InternalSuperTestLanguage.g:112:19: '//' (~ ( ( '\\n' | '\\r' ) ) )* ( ( '\\r' )? '\\n' )? + { + match("//"); + + // InternalSuperTestLanguage.g:112:24: (~ ( ( '\\n' | '\\r' ) ) )* + loop8: + do { + int alt8=2; + int LA8_0 = input.LA(1); + + if ( ((LA8_0>='\u0000' && LA8_0<='\t')||(LA8_0>='\u000B' && LA8_0<='\f')||(LA8_0>='\u000E' && LA8_0<='\uFFFF')) ) { + alt8=1; + } + + + switch (alt8) { + case 1 : + // InternalSuperTestLanguage.g:112:24: ~ ( ( '\\n' | '\\r' ) ) + { + if ( (input.LA(1)>='\u0000' && input.LA(1)<='\t')||(input.LA(1)>='\u000B' && input.LA(1)<='\f')||(input.LA(1)>='\u000E' && input.LA(1)<='\uFFFF') ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + + } + break; + + default : + break loop8; + } + } while (true); + + // InternalSuperTestLanguage.g:112:40: ( ( '\\r' )? '\\n' )? + int alt10=2; + int LA10_0 = input.LA(1); + + if ( (LA10_0=='\n'||LA10_0=='\r') ) { + alt10=1; + } + switch (alt10) { + case 1 : + // InternalSuperTestLanguage.g:112:41: ( '\\r' )? '\\n' + { + // InternalSuperTestLanguage.g:112:41: ( '\\r' )? + int alt9=2; + int LA9_0 = input.LA(1); + + if ( (LA9_0=='\r') ) { + alt9=1; + } + switch (alt9) { + case 1 : + // InternalSuperTestLanguage.g:112:41: '\\r' + { + match('\r'); + + } + break; + + } + + match('\n'); + + } + break; + + } + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_SL_COMMENT" + + // $ANTLR start "RULE_WS" + public final void mRULE_WS() throws RecognitionException { + try { + int _type = RULE_WS; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalSuperTestLanguage.g:114:9: ( ( ' ' | '\\t' | '\\r' | '\\n' )+ ) + // InternalSuperTestLanguage.g:114:11: ( ' ' | '\\t' | '\\r' | '\\n' )+ + { + // InternalSuperTestLanguage.g:114:11: ( ' ' | '\\t' | '\\r' | '\\n' )+ + int cnt11=0; + loop11: + do { + int alt11=2; + int LA11_0 = input.LA(1); + + if ( ((LA11_0>='\t' && LA11_0<='\n')||LA11_0=='\r'||LA11_0==' ') ) { + alt11=1; + } + + + switch (alt11) { + case 1 : + // InternalSuperTestLanguage.g: + { + if ( (input.LA(1)>='\t' && input.LA(1)<='\n')||input.LA(1)=='\r'||input.LA(1)==' ' ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + + } + break; + + default : + if ( cnt11 >= 1 ) break loop11; + EarlyExitException eee = + new EarlyExitException(11, input); + throw eee; + } + cnt11++; + } while (true); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_WS" + + // $ANTLR start "RULE_ANY_OTHER" + public final void mRULE_ANY_OTHER() throws RecognitionException { + try { + int _type = RULE_ANY_OTHER; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalSuperTestLanguage.g:116:16: ( . ) + // InternalSuperTestLanguage.g:116:18: . + { + matchAny(); + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_ANY_OTHER" + + public void mTokens() throws RecognitionException { + // InternalSuperTestLanguage.g:1:8: ( T__11 | RULE_ID | RULE_INT | RULE_STRING | RULE_ML_COMMENT | RULE_SL_COMMENT | RULE_WS | RULE_ANY_OTHER ) + int alt12=8; + alt12 = dfa12.predict(input); + switch (alt12) { + case 1 : + // InternalSuperTestLanguage.g:1:10: T__11 + { + mT__11(); + + } + break; + case 2 : + // InternalSuperTestLanguage.g:1:16: RULE_ID + { + mRULE_ID(); + + } + break; + case 3 : + // InternalSuperTestLanguage.g:1:24: RULE_INT + { + mRULE_INT(); + + } + break; + case 4 : + // InternalSuperTestLanguage.g:1:33: RULE_STRING + { + mRULE_STRING(); + + } + break; + case 5 : + // InternalSuperTestLanguage.g:1:45: RULE_ML_COMMENT + { + mRULE_ML_COMMENT(); + + } + break; + case 6 : + // InternalSuperTestLanguage.g:1:61: RULE_SL_COMMENT + { + mRULE_SL_COMMENT(); + + } + break; + case 7 : + // InternalSuperTestLanguage.g:1:77: RULE_WS + { + mRULE_WS(); + + } + break; + case 8 : + // InternalSuperTestLanguage.g:1:85: RULE_ANY_OTHER + { + mRULE_ANY_OTHER(); + + } + break; + + } + + } + + + protected DFA12 dfa12 = new DFA12(this); + static final String DFA12_eotS = + "\1\uffff\1\13\1\11\2\uffff\3\11\2\uffff\1\13\6\uffff\2\13\1\24\1\uffff"; + static final String DFA12_eofS = + "\25\uffff"; + static final String DFA12_minS = + "\1\0\1\165\1\101\2\uffff\2\0\1\52\2\uffff\1\160\6\uffff\1\145\1\162\1\60\1\uffff"; + static final String DFA12_maxS = + "\1\uffff\1\165\1\172\2\uffff\2\uffff\1\57\2\uffff\1\160\6\uffff\1\145\1\162\1\172\1\uffff"; + static final String DFA12_acceptS = + "\3\uffff\1\2\1\3\3\uffff\1\7\1\10\1\uffff\1\2\1\3\1\4\1\5\1\6\1\7\3\uffff\1\1"; + static final String DFA12_specialS = + "\1\2\4\uffff\1\0\1\1\16\uffff}>"; + static final String[] DFA12_transitionS = { + "\11\11\2\10\2\11\1\10\22\11\1\10\1\11\1\5\4\11\1\6\7\11\1\7\12\4\7\11\32\3\3\11\1\2\1\3\1\11\22\3\1\1\7\3\uff85\11", + "\1\12", + "\32\13\4\uffff\1\13\1\uffff\32\13", + "", + "", + "\0\15", + "\0\15", + "\1\16\4\uffff\1\17", + "", + "", + "\1\21", + "", + "", + "", + "", + "", + "", + "\1\22", + "\1\23", + "\12\13\7\uffff\32\13\4\uffff\1\13\1\uffff\32\13", + "" + }; + + static final short[] DFA12_eot = DFA.unpackEncodedString(DFA12_eotS); + static final short[] DFA12_eof = DFA.unpackEncodedString(DFA12_eofS); + static final char[] DFA12_min = DFA.unpackEncodedStringToUnsignedChars(DFA12_minS); + static final char[] DFA12_max = DFA.unpackEncodedStringToUnsignedChars(DFA12_maxS); + static final short[] DFA12_accept = DFA.unpackEncodedString(DFA12_acceptS); + static final short[] DFA12_special = DFA.unpackEncodedString(DFA12_specialS); + static final short[][] DFA12_transition; + + static { + int numStates = DFA12_transitionS.length; + DFA12_transition = new short[numStates][]; + for (int i=0; i='\u0000' && LA12_5<='\uFFFF')) ) {s = 13;} + + else s = 9; + + if ( s>=0 ) return s; + break; + case 1 : + int LA12_6 = input.LA(1); + + s = -1; + if ( ((LA12_6>='\u0000' && LA12_6<='\uFFFF')) ) {s = 13;} + + else s = 9; + + if ( s>=0 ) return s; + break; + case 2 : + int LA12_0 = input.LA(1); + + s = -1; + if ( (LA12_0=='s') ) {s = 1;} + + else if ( (LA12_0=='^') ) {s = 2;} + + else if ( ((LA12_0>='A' && LA12_0<='Z')||LA12_0=='_'||(LA12_0>='a' && LA12_0<='r')||(LA12_0>='t' && LA12_0<='z')) ) {s = 3;} + + else if ( ((LA12_0>='0' && LA12_0<='9')) ) {s = 4;} + + else if ( (LA12_0=='\"') ) {s = 5;} + + else if ( (LA12_0=='\'') ) {s = 6;} + + else if ( (LA12_0=='/') ) {s = 7;} + + else if ( ((LA12_0>='\t' && LA12_0<='\n')||LA12_0=='\r'||LA12_0==' ') ) {s = 8;} + + else if ( ((LA12_0>='\u0000' && LA12_0<='\b')||(LA12_0>='\u000B' && LA12_0<='\f')||(LA12_0>='\u000E' && LA12_0<='\u001F')||LA12_0=='!'||(LA12_0>='#' && LA12_0<='&')||(LA12_0>='(' && LA12_0<='.')||(LA12_0>=':' && LA12_0<='@')||(LA12_0>='[' && LA12_0<=']')||LA12_0=='`'||(LA12_0>='{' && LA12_0<='\uFFFF')) ) {s = 9;} + + if ( s>=0 ) return s; + break; + } + NoViableAltException nvae = + new NoViableAltException(getDescription(), 12, _s, input); + error(nvae); + throw nvae; + } + } + + +} \ No newline at end of file diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/internal/InternalSuperTestLanguageParser.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/internal/InternalSuperTestLanguageParser.java new file mode 100644 index 000000000..dbaf63057 --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/parser/antlr/internal/InternalSuperTestLanguageParser.java @@ -0,0 +1,193 @@ +package org.eclipse.xtext.generator.ecore.parser.antlr.internal; + +import org.eclipse.xtext.*; +import org.eclipse.xtext.parser.*; +import org.eclipse.xtext.parser.impl.*; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.xtext.parser.antlr.AbstractInternalAntlrParser; +import org.eclipse.xtext.parser.antlr.XtextTokenStream; +import org.eclipse.xtext.parser.antlr.XtextTokenStream.HiddenTokens; +import org.eclipse.xtext.parser.antlr.AntlrDatatypeRuleToken; +import org.eclipse.xtext.generator.ecore.services.SuperTestLanguageGrammarAccess; + + + +import org.antlr.runtime.*; +import java.util.Stack; +import java.util.List; +import java.util.ArrayList; + +@SuppressWarnings("all") +public class InternalSuperTestLanguageParser extends AbstractInternalAntlrParser { + public static final String[] tokenNames = new String[] { + "", "", "", "", "RULE_ID", "RULE_INT", "RULE_STRING", "RULE_ML_COMMENT", "RULE_SL_COMMENT", "RULE_WS", "RULE_ANY_OTHER", "'super'" + }; + public static final int RULE_ID=4; + public static final int RULE_STRING=6; + public static final int T__11=11; + public static final int RULE_ANY_OTHER=10; + public static final int RULE_INT=5; + public static final int RULE_WS=9; + public static final int RULE_SL_COMMENT=8; + public static final int EOF=-1; + public static final int RULE_ML_COMMENT=7; + + // delegates + // delegators + + + public InternalSuperTestLanguageParser(TokenStream input) { + this(input, new RecognizerSharedState()); + } + public InternalSuperTestLanguageParser(TokenStream input, RecognizerSharedState state) { + super(input, state); + + } + + + public String[] getTokenNames() { return InternalSuperTestLanguageParser.tokenNames; } + public String getGrammarFileName() { return "InternalSuperTestLanguage.g"; } + + + + private SuperTestLanguageGrammarAccess grammarAccess; + + public InternalSuperTestLanguageParser(TokenStream input, SuperTestLanguageGrammarAccess grammarAccess) { + this(input); + this.grammarAccess = grammarAccess; + registerRules(grammarAccess.getGrammar()); + } + + @Override + protected String getFirstRuleName() { + return "SuperMain"; + } + + @Override + protected SuperTestLanguageGrammarAccess getGrammarAccess() { + return grammarAccess; + } + + + + + // $ANTLR start "entryRuleSuperMain" + // InternalSuperTestLanguage.g:64:1: entryRuleSuperMain returns [EObject current=null] : iv_ruleSuperMain= ruleSuperMain EOF ; + public final EObject entryRuleSuperMain() throws RecognitionException { + EObject current = null; + + EObject iv_ruleSuperMain = null; + + + try { + // InternalSuperTestLanguage.g:64:50: (iv_ruleSuperMain= ruleSuperMain EOF ) + // InternalSuperTestLanguage.g:65:2: iv_ruleSuperMain= ruleSuperMain EOF + { + newCompositeNode(grammarAccess.getSuperMainRule()); + pushFollow(FollowSets000.FOLLOW_1); + iv_ruleSuperMain=ruleSuperMain(); + + state._fsp--; + + current =iv_ruleSuperMain; + match(input,EOF,FollowSets000.FOLLOW_2); + + } + + } + + catch (RecognitionException re) { + recover(input,re); + appendSkippedTokens(); + } + finally { + } + return current; + } + // $ANTLR end "entryRuleSuperMain" + + + // $ANTLR start "ruleSuperMain" + // InternalSuperTestLanguage.g:71:1: ruleSuperMain returns [EObject current=null] : (otherlv_0= 'super' ( (lv_name_1_0= RULE_ID ) ) ) ; + public final EObject ruleSuperMain() throws RecognitionException { + EObject current = null; + + Token otherlv_0=null; + Token lv_name_1_0=null; + + + enterRule(); + + try { + // InternalSuperTestLanguage.g:77:2: ( (otherlv_0= 'super' ( (lv_name_1_0= RULE_ID ) ) ) ) + // InternalSuperTestLanguage.g:78:2: (otherlv_0= 'super' ( (lv_name_1_0= RULE_ID ) ) ) + { + // InternalSuperTestLanguage.g:78:2: (otherlv_0= 'super' ( (lv_name_1_0= RULE_ID ) ) ) + // InternalSuperTestLanguage.g:79:3: otherlv_0= 'super' ( (lv_name_1_0= RULE_ID ) ) + { + otherlv_0=(Token)match(input,11,FollowSets000.FOLLOW_3); + + newLeafNode(otherlv_0, grammarAccess.getSuperMainAccess().getSuperKeyword_0()); + + // InternalSuperTestLanguage.g:83:3: ( (lv_name_1_0= RULE_ID ) ) + // InternalSuperTestLanguage.g:84:4: (lv_name_1_0= RULE_ID ) + { + // InternalSuperTestLanguage.g:84:4: (lv_name_1_0= RULE_ID ) + // InternalSuperTestLanguage.g:85:5: lv_name_1_0= RULE_ID + { + lv_name_1_0=(Token)match(input,RULE_ID,FollowSets000.FOLLOW_2); + + newLeafNode(lv_name_1_0, grammarAccess.getSuperMainAccess().getNameIDTerminalRuleCall_1_0()); + + + if (current==null) { + current = createModelElement(grammarAccess.getSuperMainRule()); + } + setWithLastConsumed( + current, + "name", + lv_name_1_0, + "org.eclipse.xtext.common.Terminals.ID"); + + + } + + + } + + + } + + + } + + + leaveRule(); + + } + + catch (RecognitionException re) { + recover(input,re); + appendSkippedTokens(); + } + finally { + } + return current; + } + // $ANTLR end "ruleSuperMain" + + // Delegated rules + + + + + + private static class FollowSets000 { + public static final BitSet FOLLOW_1 = new BitSet(new long[]{0x0000000000000000L}); + public static final BitSet FOLLOW_2 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_3 = new BitSet(new long[]{0x0000000000000010L}); + } + + +} \ No newline at end of file diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/serializer/SubTestLanguageSemanticSequencer.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/serializer/SubTestLanguageSemanticSequencer.java new file mode 100644 index 000000000..77253f05e --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/serializer/SubTestLanguageSemanticSequencer.java @@ -0,0 +1,84 @@ +/* + * generated by Xtext + */ +package org.eclipse.xtext.generator.ecore.serializer; + +import com.google.inject.Inject; +import java.util.Set; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.xtext.Action; +import org.eclipse.xtext.Parameter; +import org.eclipse.xtext.ParserRule; +import org.eclipse.xtext.generator.ecore.services.SubTestLanguageGrammarAccess; +import org.eclipse.xtext.generator.ecore.subPackage.AnotherSuperMain; +import org.eclipse.xtext.generator.ecore.subPackage.SubMain; +import org.eclipse.xtext.generator.ecore.subPackage.SubPackagePackage; +import org.eclipse.xtext.generator.ecore.superPackage.SuperMain; +import org.eclipse.xtext.generator.ecore.superPackage.SuperPackagePackage; +import org.eclipse.xtext.serializer.ISerializationContext; +import org.eclipse.xtext.serializer.acceptor.SequenceFeeder; +import org.eclipse.xtext.serializer.sequencer.ITransientValueService.ValueTransient; + +@SuppressWarnings("all") +public class SubTestLanguageSemanticSequencer extends SuperTestLanguageSemanticSequencer { + + @Inject + private SubTestLanguageGrammarAccess grammarAccess; + + @Override + public void sequence(ISerializationContext context, EObject semanticObject) { + EPackage epackage = semanticObject.eClass().getEPackage(); + ParserRule rule = context.getParserRule(); + Action action = context.getAssignedAction(); + Set parameters = context.getEnabledBooleanParameters(); + if (epackage == SubPackagePackage.eINSTANCE) + switch (semanticObject.eClass().getClassifierID()) { + case SubPackagePackage.ANOTHER_SUPER_MAIN: + sequence_AnotherSuperMain(context, (AnotherSuperMain) semanticObject); + return; + case SubPackagePackage.SUB_MAIN: + sequence_SubMain(context, (SubMain) semanticObject); + return; + } + else if (epackage == SuperPackagePackage.eINSTANCE) + switch (semanticObject.eClass().getClassifierID()) { + case SuperPackagePackage.SUPER_MAIN: + sequence_SuperMain(context, (SuperMain) semanticObject); + return; + } + if (errorAcceptor != null) + errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context)); + } + + /** + * Contexts: + * AnotherSuperMain returns AnotherSuperMain + * + * Constraint: + * name=ID + */ + protected void sequence_AnotherSuperMain(ISerializationContext context, AnotherSuperMain semanticObject) { + if (errorAcceptor != null) { + if (transientValues.isValueTransient(semanticObject, SuperPackagePackage.Literals.ANOTHER_SUPER_MAIN__NAME) == ValueTransient.YES) + errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, SuperPackagePackage.Literals.ANOTHER_SUPER_MAIN__NAME)); + } + SequenceFeeder feeder = createSequencerFeeder(context, semanticObject); + feeder.accept(grammarAccess.getAnotherSuperMainAccess().getNameIDTerminalRuleCall_1_0(), semanticObject.getName()); + feeder.finish(); + } + + + /** + * Contexts: + * SubMain returns SubMain + * + * Constraint: + * (superMains+=SuperMain another=AnotherSuperMain?) + */ + protected void sequence_SubMain(ISerializationContext context, SubMain semanticObject) { + genericSequencer.createSequence(context, semanticObject); + } + + +} diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/serializer/SubTestLanguageSyntacticSequencer.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/serializer/SubTestLanguageSyntacticSequencer.java new file mode 100644 index 000000000..9a0932b0c --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/serializer/SubTestLanguageSyntacticSequencer.java @@ -0,0 +1,43 @@ +/* + * generated by Xtext + */ +package org.eclipse.xtext.generator.ecore.serializer; + +import com.google.inject.Inject; +import java.util.List; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.xtext.IGrammarAccess; +import org.eclipse.xtext.RuleCall; +import org.eclipse.xtext.generator.ecore.services.SubTestLanguageGrammarAccess; +import org.eclipse.xtext.nodemodel.INode; +import org.eclipse.xtext.serializer.analysis.GrammarAlias.AbstractElementAlias; +import org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynTransition; +import org.eclipse.xtext.serializer.sequencer.AbstractSyntacticSequencer; + +@SuppressWarnings("all") +public class SubTestLanguageSyntacticSequencer extends AbstractSyntacticSequencer { + + protected SubTestLanguageGrammarAccess grammarAccess; + + @Inject + protected void init(IGrammarAccess access) { + grammarAccess = (SubTestLanguageGrammarAccess) access; + } + + @Override + protected String getUnassignedRuleCallToken(EObject semanticObject, RuleCall ruleCall, INode node) { + return ""; + } + + + @Override + protected void emitUnassignedTokens(EObject semanticObject, ISynTransition transition, INode fromNode, INode toNode) { + if (transition.getAmbiguousSyntaxes().isEmpty()) return; + List transitionNodes = collectNodes(fromNode, toNode); + for (AbstractElementAlias syntax : transition.getAmbiguousSyntaxes()) { + List syntaxNodes = getNodesFor(transitionNodes, syntax); + acceptNodes(getLastNavigableState(), syntaxNodes); + } + } + +} diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/serializer/SuperTestLanguageSemanticSequencer.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/serializer/SuperTestLanguageSemanticSequencer.java new file mode 100644 index 000000000..b8fee9284 --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/serializer/SuperTestLanguageSemanticSequencer.java @@ -0,0 +1,83 @@ +/* + * generated by Xtext + */ +package org.eclipse.xtext.generator.ecore.serializer; + +import com.google.inject.Inject; +import java.util.Set; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.xtext.Action; +import org.eclipse.xtext.Parameter; +import org.eclipse.xtext.ParserRule; +import org.eclipse.xtext.generator.ecore.services.SuperTestLanguageGrammarAccess; +import org.eclipse.xtext.generator.ecore.superPackage.AnotherSuperMain; +import org.eclipse.xtext.generator.ecore.superPackage.SuperMain; +import org.eclipse.xtext.generator.ecore.superPackage.SuperPackagePackage; +import org.eclipse.xtext.serializer.ISerializationContext; +import org.eclipse.xtext.serializer.acceptor.SequenceFeeder; +import org.eclipse.xtext.serializer.sequencer.AbstractDelegatingSemanticSequencer; +import org.eclipse.xtext.serializer.sequencer.ITransientValueService.ValueTransient; + +@SuppressWarnings("all") +public class SuperTestLanguageSemanticSequencer extends AbstractDelegatingSemanticSequencer { + + @Inject + private SuperTestLanguageGrammarAccess grammarAccess; + + @Override + public void sequence(ISerializationContext context, EObject semanticObject) { + EPackage epackage = semanticObject.eClass().getEPackage(); + ParserRule rule = context.getParserRule(); + Action action = context.getAssignedAction(); + Set parameters = context.getEnabledBooleanParameters(); + if (epackage == SuperPackagePackage.eINSTANCE) + switch (semanticObject.eClass().getClassifierID()) { + case SuperPackagePackage.ANOTHER_SUPER_MAIN: + sequence_AnotherSuperMain(context, (AnotherSuperMain) semanticObject); + return; + case SuperPackagePackage.SUPER_MAIN: + sequence_SuperMain(context, (SuperMain) semanticObject); + return; + } + if (errorAcceptor != null) + errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context)); + } + + /** + * Contexts: + * AnotherSuperMain returns AnotherSuperMain + * + * Constraint: + * name=ID + */ + protected void sequence_AnotherSuperMain(ISerializationContext context, AnotherSuperMain semanticObject) { + if (errorAcceptor != null) { + if (transientValues.isValueTransient(semanticObject, SuperPackagePackage.Literals.ANOTHER_SUPER_MAIN__NAME) == ValueTransient.YES) + errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, SuperPackagePackage.Literals.ANOTHER_SUPER_MAIN__NAME)); + } + SequenceFeeder feeder = createSequencerFeeder(context, semanticObject); + feeder.accept(grammarAccess.getAnotherSuperMainAccess().getNameIDTerminalRuleCall_1_0(), semanticObject.getName()); + feeder.finish(); + } + + + /** + * Contexts: + * SuperMain returns SuperMain + * + * Constraint: + * name=ID + */ + protected void sequence_SuperMain(ISerializationContext context, SuperMain semanticObject) { + if (errorAcceptor != null) { + if (transientValues.isValueTransient(semanticObject, SuperPackagePackage.Literals.SUPER_MAIN__NAME) == ValueTransient.YES) + errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, SuperPackagePackage.Literals.SUPER_MAIN__NAME)); + } + SequenceFeeder feeder = createSequencerFeeder(context, semanticObject); + feeder.accept(grammarAccess.getSuperMainAccess().getNameIDTerminalRuleCall_1_0(), semanticObject.getName()); + feeder.finish(); + } + + +} diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/serializer/SuperTestLanguageSyntacticSequencer.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/serializer/SuperTestLanguageSyntacticSequencer.java new file mode 100644 index 000000000..3a304227e --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/serializer/SuperTestLanguageSyntacticSequencer.java @@ -0,0 +1,43 @@ +/* + * generated by Xtext + */ +package org.eclipse.xtext.generator.ecore.serializer; + +import com.google.inject.Inject; +import java.util.List; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.xtext.IGrammarAccess; +import org.eclipse.xtext.RuleCall; +import org.eclipse.xtext.generator.ecore.services.SuperTestLanguageGrammarAccess; +import org.eclipse.xtext.nodemodel.INode; +import org.eclipse.xtext.serializer.analysis.GrammarAlias.AbstractElementAlias; +import org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynTransition; +import org.eclipse.xtext.serializer.sequencer.AbstractSyntacticSequencer; + +@SuppressWarnings("all") +public class SuperTestLanguageSyntacticSequencer extends AbstractSyntacticSequencer { + + protected SuperTestLanguageGrammarAccess grammarAccess; + + @Inject + protected void init(IGrammarAccess access) { + grammarAccess = (SuperTestLanguageGrammarAccess) access; + } + + @Override + protected String getUnassignedRuleCallToken(EObject semanticObject, RuleCall ruleCall, INode node) { + return ""; + } + + + @Override + protected void emitUnassignedTokens(EObject semanticObject, ISynTransition transition, INode fromNode, INode toNode) { + if (transition.getAmbiguousSyntaxes().isEmpty()) return; + List transitionNodes = collectNodes(fromNode, toNode); + for (AbstractElementAlias syntax : transition.getAmbiguousSyntaxes()) { + List syntaxNodes = getNodesFor(transitionNodes, syntax); + acceptNodes(getLastNavigableState(), syntaxNodes); + } + } + +} diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/services/SubTestLanguageGrammarAccess.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/services/SubTestLanguageGrammarAccess.java new file mode 100644 index 000000000..398155909 --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/services/SubTestLanguageGrammarAccess.java @@ -0,0 +1,207 @@ +/* + * generated by Xtext + */ +package org.eclipse.xtext.generator.ecore.services; + +import com.google.inject.Inject; +import com.google.inject.Singleton; +import java.util.List; +import org.eclipse.xtext.Assignment; +import org.eclipse.xtext.Grammar; +import org.eclipse.xtext.GrammarUtil; +import org.eclipse.xtext.Group; +import org.eclipse.xtext.Keyword; +import org.eclipse.xtext.ParserRule; +import org.eclipse.xtext.RuleCall; +import org.eclipse.xtext.TerminalRule; +import org.eclipse.xtext.common.services.TerminalsGrammarAccess; +import org.eclipse.xtext.service.AbstractElementFinder.AbstractGrammarElementFinder; +import org.eclipse.xtext.service.GrammarProvider; + +@Singleton +public class SubTestLanguageGrammarAccess extends AbstractGrammarElementFinder { + + public class SubMainElements extends AbstractParserRuleElementFinder { + private final ParserRule rule = (ParserRule) GrammarUtil.findRuleForName(getGrammar(), "org.eclipse.xtext.generator.ecore.SubTestLanguage.SubMain"); + private final Group cGroup = (Group)rule.eContents().get(1); + private final Keyword cLeftCurlyBracketKeyword_0 = (Keyword)cGroup.eContents().get(0); + private final Assignment cSuperMainsAssignment_1 = (Assignment)cGroup.eContents().get(1); + private final RuleCall cSuperMainsSuperMainParserRuleCall_1_0 = (RuleCall)cSuperMainsAssignment_1.eContents().get(0); + private final Keyword cRightCurlyBracketKeyword_2 = (Keyword)cGroup.eContents().get(2); + private final Assignment cAnotherAssignment_3 = (Assignment)cGroup.eContents().get(3); + private final RuleCall cAnotherAnotherSuperMainParserRuleCall_3_0 = (RuleCall)cAnotherAssignment_3.eContents().get(0); + + //SubMain: + // "{" superMains+=SuperMain "}" another=AnotherSuperMain?; + @Override public ParserRule getRule() { return rule; } + + //"{" superMains+=SuperMain "}" another=AnotherSuperMain? + public Group getGroup() { return cGroup; } + + //"{" + public Keyword getLeftCurlyBracketKeyword_0() { return cLeftCurlyBracketKeyword_0; } + + //superMains+=SuperMain + public Assignment getSuperMainsAssignment_1() { return cSuperMainsAssignment_1; } + + //SuperMain + public RuleCall getSuperMainsSuperMainParserRuleCall_1_0() { return cSuperMainsSuperMainParserRuleCall_1_0; } + + //"}" + public Keyword getRightCurlyBracketKeyword_2() { return cRightCurlyBracketKeyword_2; } + + //another=AnotherSuperMain? + public Assignment getAnotherAssignment_3() { return cAnotherAssignment_3; } + + //AnotherSuperMain + public RuleCall getAnotherAnotherSuperMainParserRuleCall_3_0() { return cAnotherAnotherSuperMainParserRuleCall_3_0; } + } + public class AnotherSuperMainElements extends AbstractParserRuleElementFinder { + private final ParserRule rule = (ParserRule) GrammarUtil.findRuleForName(getGrammar(), "org.eclipse.xtext.generator.ecore.SubTestLanguage.AnotherSuperMain"); + private final Group cGroup = (Group)rule.eContents().get(1); + private final Keyword cUpsKeyword_0 = (Keyword)cGroup.eContents().get(0); + private final Assignment cNameAssignment_1 = (Assignment)cGroup.eContents().get(1); + private final RuleCall cNameIDTerminalRuleCall_1_0 = (RuleCall)cNameAssignment_1.eContents().get(0); + + //AnotherSuperMain: + // "ups" name=ID; + @Override public ParserRule getRule() { return rule; } + + //"ups" name=ID + public Group getGroup() { return cGroup; } + + //"ups" + public Keyword getUpsKeyword_0() { return cUpsKeyword_0; } + + //name=ID + public Assignment getNameAssignment_1() { return cNameAssignment_1; } + + //ID + public RuleCall getNameIDTerminalRuleCall_1_0() { return cNameIDTerminalRuleCall_1_0; } + } + + + private final SubMainElements pSubMain; + private final AnotherSuperMainElements pAnotherSuperMain; + + private final Grammar grammar; + + private final SuperTestLanguageGrammarAccess gaSuperTestLanguage; + + private final TerminalsGrammarAccess gaTerminals; + + @Inject + public SubTestLanguageGrammarAccess(GrammarProvider grammarProvider, + SuperTestLanguageGrammarAccess gaSuperTestLanguage, + TerminalsGrammarAccess gaTerminals) { + this.grammar = internalFindGrammar(grammarProvider); + this.gaSuperTestLanguage = gaSuperTestLanguage; + this.gaTerminals = gaTerminals; + this.pSubMain = new SubMainElements(); + this.pAnotherSuperMain = new AnotherSuperMainElements(); + } + + protected Grammar internalFindGrammar(GrammarProvider grammarProvider) { + Grammar grammar = grammarProvider.getGrammar(this); + while (grammar != null) { + if ("org.eclipse.xtext.generator.ecore.SubTestLanguage".equals(grammar.getName())) { + return grammar; + } + List grammars = grammar.getUsedGrammars(); + if (!grammars.isEmpty()) { + grammar = grammars.iterator().next(); + } else { + return null; + } + } + return grammar; + } + + @Override + public Grammar getGrammar() { + return grammar; + } + + + public SuperTestLanguageGrammarAccess getSuperTestLanguageGrammarAccess() { + return gaSuperTestLanguage; + } + + public TerminalsGrammarAccess getTerminalsGrammarAccess() { + return gaTerminals; + } + + + //SubMain: + // "{" superMains+=SuperMain "}" another=AnotherSuperMain?; + public SubMainElements getSubMainAccess() { + return pSubMain; + } + + public ParserRule getSubMainRule() { + return getSubMainAccess().getRule(); + } + + //AnotherSuperMain: + // "ups" name=ID; + public AnotherSuperMainElements getAnotherSuperMainAccess() { + return pAnotherSuperMain; + } + + public ParserRule getAnotherSuperMainRule() { + return getAnotherSuperMainAccess().getRule(); + } + + //SuperMain: + // "super" name=ID; + public SuperTestLanguageGrammarAccess.SuperMainElements getSuperMainAccess() { + return gaSuperTestLanguage.getSuperMainAccess(); + } + + public ParserRule getSuperMainRule() { + return getSuperMainAccess().getRule(); + } + + //terminal ID: + // '^'? ('a'..'z' | 'A'..'Z' | '_') ('a'..'z' | 'A'..'Z' | '_' | '0'..'9')*; + public TerminalRule getIDRule() { + return gaTerminals.getIDRule(); + } + + //terminal INT returns ecore::EInt: + // '0'..'9'+; + public TerminalRule getINTRule() { + return gaTerminals.getINTRule(); + } + + //terminal STRING: + // '"' ('\\' . | !('\\' | '"'))* '"' | + // "'" ('\\' . | !('\\' | "'"))* "'"; + public TerminalRule getSTRINGRule() { + return gaTerminals.getSTRINGRule(); + } + + //terminal ML_COMMENT: + // '/ *'->'* /'; + public TerminalRule getML_COMMENTRule() { + return gaTerminals.getML_COMMENTRule(); + } + + //terminal SL_COMMENT: + // '//' !('\n' | '\r')* ('\r'? '\n')?; + public TerminalRule getSL_COMMENTRule() { + return gaTerminals.getSL_COMMENTRule(); + } + + //terminal WS: + // ' ' | '\t' | '\r' | '\n'+; + public TerminalRule getWSRule() { + return gaTerminals.getWSRule(); + } + + //terminal ANY_OTHER: + // .; + public TerminalRule getANY_OTHERRule() { + return gaTerminals.getANY_OTHERRule(); + } +} diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/services/SuperTestLanguageGrammarAccess.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/services/SuperTestLanguageGrammarAccess.java new file mode 100644 index 000000000..fbf81b499 --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/services/SuperTestLanguageGrammarAccess.java @@ -0,0 +1,177 @@ +/* + * generated by Xtext + */ +package org.eclipse.xtext.generator.ecore.services; + +import com.google.inject.Inject; +import com.google.inject.Singleton; +import java.util.List; +import org.eclipse.xtext.Assignment; +import org.eclipse.xtext.Grammar; +import org.eclipse.xtext.GrammarUtil; +import org.eclipse.xtext.Group; +import org.eclipse.xtext.Keyword; +import org.eclipse.xtext.ParserRule; +import org.eclipse.xtext.RuleCall; +import org.eclipse.xtext.TerminalRule; +import org.eclipse.xtext.common.services.TerminalsGrammarAccess; +import org.eclipse.xtext.service.AbstractElementFinder.AbstractGrammarElementFinder; +import org.eclipse.xtext.service.GrammarProvider; + +@Singleton +public class SuperTestLanguageGrammarAccess extends AbstractGrammarElementFinder { + + public class SuperMainElements extends AbstractParserRuleElementFinder { + private final ParserRule rule = (ParserRule) GrammarUtil.findRuleForName(getGrammar(), "org.eclipse.xtext.generator.ecore.SuperTestLanguage.SuperMain"); + private final Group cGroup = (Group)rule.eContents().get(1); + private final Keyword cSuperKeyword_0 = (Keyword)cGroup.eContents().get(0); + private final Assignment cNameAssignment_1 = (Assignment)cGroup.eContents().get(1); + private final RuleCall cNameIDTerminalRuleCall_1_0 = (RuleCall)cNameAssignment_1.eContents().get(0); + + //SuperMain: + // "super" name=ID; + @Override public ParserRule getRule() { return rule; } + + //"super" name=ID + public Group getGroup() { return cGroup; } + + //"super" + public Keyword getSuperKeyword_0() { return cSuperKeyword_0; } + + //name=ID + public Assignment getNameAssignment_1() { return cNameAssignment_1; } + + //ID + public RuleCall getNameIDTerminalRuleCall_1_0() { return cNameIDTerminalRuleCall_1_0; } + } + public class AnotherSuperMainElements extends AbstractParserRuleElementFinder { + private final ParserRule rule = (ParserRule) GrammarUtil.findRuleForName(getGrammar(), "org.eclipse.xtext.generator.ecore.SuperTestLanguage.AnotherSuperMain"); + private final Group cGroup = (Group)rule.eContents().get(1); + private final Keyword cAnotherKeyword_0 = (Keyword)cGroup.eContents().get(0); + private final Assignment cNameAssignment_1 = (Assignment)cGroup.eContents().get(1); + private final RuleCall cNameIDTerminalRuleCall_1_0 = (RuleCall)cNameAssignment_1.eContents().get(0); + + //AnotherSuperMain: + // "another" name=ID; + @Override public ParserRule getRule() { return rule; } + + //"another" name=ID + public Group getGroup() { return cGroup; } + + //"another" + public Keyword getAnotherKeyword_0() { return cAnotherKeyword_0; } + + //name=ID + public Assignment getNameAssignment_1() { return cNameAssignment_1; } + + //ID + public RuleCall getNameIDTerminalRuleCall_1_0() { return cNameIDTerminalRuleCall_1_0; } + } + + + private final SuperMainElements pSuperMain; + private final AnotherSuperMainElements pAnotherSuperMain; + + private final Grammar grammar; + + private final TerminalsGrammarAccess gaTerminals; + + @Inject + public SuperTestLanguageGrammarAccess(GrammarProvider grammarProvider, + TerminalsGrammarAccess gaTerminals) { + this.grammar = internalFindGrammar(grammarProvider); + this.gaTerminals = gaTerminals; + this.pSuperMain = new SuperMainElements(); + this.pAnotherSuperMain = new AnotherSuperMainElements(); + } + + protected Grammar internalFindGrammar(GrammarProvider grammarProvider) { + Grammar grammar = grammarProvider.getGrammar(this); + while (grammar != null) { + if ("org.eclipse.xtext.generator.ecore.SuperTestLanguage".equals(grammar.getName())) { + return grammar; + } + List grammars = grammar.getUsedGrammars(); + if (!grammars.isEmpty()) { + grammar = grammars.iterator().next(); + } else { + return null; + } + } + return grammar; + } + + @Override + public Grammar getGrammar() { + return grammar; + } + + + public TerminalsGrammarAccess getTerminalsGrammarAccess() { + return gaTerminals; + } + + + //SuperMain: + // "super" name=ID; + public SuperMainElements getSuperMainAccess() { + return pSuperMain; + } + + public ParserRule getSuperMainRule() { + return getSuperMainAccess().getRule(); + } + + //AnotherSuperMain: + // "another" name=ID; + public AnotherSuperMainElements getAnotherSuperMainAccess() { + return pAnotherSuperMain; + } + + public ParserRule getAnotherSuperMainRule() { + return getAnotherSuperMainAccess().getRule(); + } + + //terminal ID: + // '^'? ('a'..'z' | 'A'..'Z' | '_') ('a'..'z' | 'A'..'Z' | '_' | '0'..'9')*; + public TerminalRule getIDRule() { + return gaTerminals.getIDRule(); + } + + //terminal INT returns ecore::EInt: + // '0'..'9'+; + public TerminalRule getINTRule() { + return gaTerminals.getINTRule(); + } + + //terminal STRING: + // '"' ('\\' . | !('\\' | '"'))* '"' | + // "'" ('\\' . | !('\\' | "'"))* "'"; + public TerminalRule getSTRINGRule() { + return gaTerminals.getSTRINGRule(); + } + + //terminal ML_COMMENT: + // '/ *'->'* /'; + public TerminalRule getML_COMMENTRule() { + return gaTerminals.getML_COMMENTRule(); + } + + //terminal SL_COMMENT: + // '//' !('\n' | '\r')* ('\r'? '\n')?; + public TerminalRule getSL_COMMENTRule() { + return gaTerminals.getSL_COMMENTRule(); + } + + //terminal WS: + // ' ' | '\t' | '\r' | '\n'+; + public TerminalRule getWSRule() { + return gaTerminals.getWSRule(); + } + + //terminal ANY_OTHER: + // .; + public TerminalRule getANY_OTHERRule() { + return gaTerminals.getANY_OTHERRule(); + } +} diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/subPackage/AnotherSuperMain.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/subPackage/AnotherSuperMain.java new file mode 100644 index 000000000..edbc341b3 --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/subPackage/AnotherSuperMain.java @@ -0,0 +1,19 @@ +/** + * generated by Xtext + */ +package org.eclipse.xtext.generator.ecore.subPackage; + + +/** + * + * A representation of the model object 'Another Super Main'. + * + * + * + * @see org.eclipse.xtext.generator.ecore.subPackage.SubPackagePackage#getAnotherSuperMain() + * @model + * @generated + */ +public interface AnotherSuperMain extends org.eclipse.xtext.generator.ecore.superPackage.AnotherSuperMain +{ +} // AnotherSuperMain diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/subPackage/SubMain.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/subPackage/SubMain.java new file mode 100644 index 000000000..32102f559 --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/subPackage/SubMain.java @@ -0,0 +1,73 @@ +/** + * generated by Xtext + */ +package org.eclipse.xtext.generator.ecore.subPackage; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EObject; + +import org.eclipse.xtext.generator.ecore.superPackage.SuperMain; + +/** + * + * A representation of the model object 'Sub Main'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link org.eclipse.xtext.generator.ecore.subPackage.SubMain#getSuperMains Super Mains}
  • + *
  • {@link org.eclipse.xtext.generator.ecore.subPackage.SubMain#getAnother Another}
  • + *
+ * + * @see org.eclipse.xtext.generator.ecore.subPackage.SubPackagePackage#getSubMain() + * @model + * @generated + */ +public interface SubMain extends EObject +{ + /** + * Returns the value of the 'Super Mains' containment reference list. + * The list contents are of type {@link org.eclipse.xtext.generator.ecore.superPackage.SuperMain}. + * + *

+ * If the meaning of the 'Super Mains' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Super Mains' containment reference list. + * @see org.eclipse.xtext.generator.ecore.subPackage.SubPackagePackage#getSubMain_SuperMains() + * @model containment="true" + * @generated + */ + EList getSuperMains(); + + /** + * Returns the value of the 'Another' containment reference. + * + *

+ * If the meaning of the 'Another' containment reference isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Another' containment reference. + * @see #setAnother(AnotherSuperMain) + * @see org.eclipse.xtext.generator.ecore.subPackage.SubPackagePackage#getSubMain_Another() + * @model containment="true" + * @generated + */ + AnotherSuperMain getAnother(); + + /** + * Sets the value of the '{@link org.eclipse.xtext.generator.ecore.subPackage.SubMain#getAnother Another}' containment reference. + * + * + * @param value the new value of the 'Another' containment reference. + * @see #getAnother() + * @generated + */ + void setAnother(AnotherSuperMain value); + +} // SubMain diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/subPackage/SubPackageFactory.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/subPackage/SubPackageFactory.java new file mode 100644 index 000000000..876ddf9c0 --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/subPackage/SubPackageFactory.java @@ -0,0 +1,53 @@ +/** + * generated by Xtext + */ +package org.eclipse.xtext.generator.ecore.subPackage; + +import org.eclipse.emf.ecore.EFactory; + +/** + * + * The Factory for the model. + * It provides a create method for each non-abstract class of the model. + * + * @see org.eclipse.xtext.generator.ecore.subPackage.SubPackagePackage + * @generated + */ +public interface SubPackageFactory extends EFactory +{ + /** + * The singleton instance of the factory. + * + * + * @generated + */ + SubPackageFactory eINSTANCE = org.eclipse.xtext.generator.ecore.subPackage.impl.SubPackageFactoryImpl.init(); + + /** + * Returns a new object of class 'Sub Main'. + * + * + * @return a new object of class 'Sub Main'. + * @generated + */ + SubMain createSubMain(); + + /** + * Returns a new object of class 'Another Super Main'. + * + * + * @return a new object of class 'Another Super Main'. + * @generated + */ + AnotherSuperMain createAnotherSuperMain(); + + /** + * Returns the package supported by this factory. + * + * + * @return the package supported by this factory. + * @generated + */ + SubPackagePackage getSubPackagePackage(); + +} //SubPackageFactory diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/subPackage/SubPackagePackage.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/subPackage/SubPackagePackage.java new file mode 100644 index 000000000..a0ba7bc04 --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/subPackage/SubPackagePackage.java @@ -0,0 +1,230 @@ +/** + * generated by Xtext + */ +package org.eclipse.xtext.generator.ecore.subPackage; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; + +import org.eclipse.xtext.generator.ecore.superPackage.SuperPackagePackage; + +/** + * + * The Package for the model. + * It contains accessors for the meta objects to represent + *
    + *
  • each class,
  • + *
  • each feature of each class,
  • + *
  • each enum,
  • + *
  • and each data type
  • + *
+ * + * @see org.eclipse.xtext.generator.ecore.subPackage.SubPackageFactory + * @model kind="package" + * @generated + */ +public interface SubPackagePackage extends EPackage +{ + /** + * The package name. + * + * + * @generated + */ + String eNAME = "subPackage"; + + /** + * The package namespace URI. + * + * + * @generated + */ + String eNS_URI = "http://www.eclipse.org/2009/tmf/xtext/SubTestLanguage"; + + /** + * The package namespace name. + * + * + * @generated + */ + String eNS_PREFIX = "subPackage"; + + /** + * The singleton instance of the package. + * + * + * @generated + */ + SubPackagePackage eINSTANCE = org.eclipse.xtext.generator.ecore.subPackage.impl.SubPackagePackageImpl.init(); + + /** + * The meta object id for the '{@link org.eclipse.xtext.generator.ecore.subPackage.impl.SubMainImpl Sub Main}' class. + * + * + * @see org.eclipse.xtext.generator.ecore.subPackage.impl.SubMainImpl + * @see org.eclipse.xtext.generator.ecore.subPackage.impl.SubPackagePackageImpl#getSubMain() + * @generated + */ + int SUB_MAIN = 0; + + /** + * The feature id for the 'Super Mains' containment reference list. + * + * + * @generated + * @ordered + */ + int SUB_MAIN__SUPER_MAINS = 0; + + /** + * The feature id for the 'Another' containment reference. + * + * + * @generated + * @ordered + */ + int SUB_MAIN__ANOTHER = 1; + + /** + * The number of structural features of the 'Sub Main' class. + * + * + * @generated + * @ordered + */ + int SUB_MAIN_FEATURE_COUNT = 2; + + /** + * The meta object id for the '{@link org.eclipse.xtext.generator.ecore.subPackage.impl.AnotherSuperMainImpl Another Super Main}' class. + * + * + * @see org.eclipse.xtext.generator.ecore.subPackage.impl.AnotherSuperMainImpl + * @see org.eclipse.xtext.generator.ecore.subPackage.impl.SubPackagePackageImpl#getAnotherSuperMain() + * @generated + */ + int ANOTHER_SUPER_MAIN = 1; + + /** + * The feature id for the 'Name' attribute. + * + * + * @generated + * @ordered + */ + int ANOTHER_SUPER_MAIN__NAME = SuperPackagePackage.ANOTHER_SUPER_MAIN__NAME; + + /** + * The number of structural features of the 'Another Super Main' class. + * + * + * @generated + * @ordered + */ + int ANOTHER_SUPER_MAIN_FEATURE_COUNT = SuperPackagePackage.ANOTHER_SUPER_MAIN_FEATURE_COUNT + 0; + + + /** + * Returns the meta object for class '{@link org.eclipse.xtext.generator.ecore.subPackage.SubMain Sub Main}'. + * + * + * @return the meta object for class 'Sub Main'. + * @see org.eclipse.xtext.generator.ecore.subPackage.SubMain + * @generated + */ + EClass getSubMain(); + + /** + * Returns the meta object for the containment reference list '{@link org.eclipse.xtext.generator.ecore.subPackage.SubMain#getSuperMains Super Mains}'. + * + * + * @return the meta object for the containment reference list 'Super Mains'. + * @see org.eclipse.xtext.generator.ecore.subPackage.SubMain#getSuperMains() + * @see #getSubMain() + * @generated + */ + EReference getSubMain_SuperMains(); + + /** + * Returns the meta object for the containment reference '{@link org.eclipse.xtext.generator.ecore.subPackage.SubMain#getAnother Another}'. + * + * + * @return the meta object for the containment reference 'Another'. + * @see org.eclipse.xtext.generator.ecore.subPackage.SubMain#getAnother() + * @see #getSubMain() + * @generated + */ + EReference getSubMain_Another(); + + /** + * Returns the meta object for class '{@link org.eclipse.xtext.generator.ecore.subPackage.AnotherSuperMain Another Super Main}'. + * + * + * @return the meta object for class 'Another Super Main'. + * @see org.eclipse.xtext.generator.ecore.subPackage.AnotherSuperMain + * @generated + */ + EClass getAnotherSuperMain(); + + /** + * Returns the factory that creates the instances of the model. + * + * + * @return the factory that creates the instances of the model. + * @generated + */ + SubPackageFactory getSubPackageFactory(); + + /** + * + * Defines literals for the meta objects that represent + *
    + *
  • each class,
  • + *
  • each feature of each class,
  • + *
  • each enum,
  • + *
  • and each data type
  • + *
+ * + * @generated + */ + interface Literals + { + /** + * The meta object literal for the '{@link org.eclipse.xtext.generator.ecore.subPackage.impl.SubMainImpl Sub Main}' class. + * + * + * @see org.eclipse.xtext.generator.ecore.subPackage.impl.SubMainImpl + * @see org.eclipse.xtext.generator.ecore.subPackage.impl.SubPackagePackageImpl#getSubMain() + * @generated + */ + EClass SUB_MAIN = eINSTANCE.getSubMain(); + + /** + * The meta object literal for the 'Super Mains' containment reference list feature. + * + * + * @generated + */ + EReference SUB_MAIN__SUPER_MAINS = eINSTANCE.getSubMain_SuperMains(); + + /** + * The meta object literal for the 'Another' containment reference feature. + * + * + * @generated + */ + EReference SUB_MAIN__ANOTHER = eINSTANCE.getSubMain_Another(); + + /** + * The meta object literal for the '{@link org.eclipse.xtext.generator.ecore.subPackage.impl.AnotherSuperMainImpl Another Super Main}' class. + * + * + * @see org.eclipse.xtext.generator.ecore.subPackage.impl.AnotherSuperMainImpl + * @see org.eclipse.xtext.generator.ecore.subPackage.impl.SubPackagePackageImpl#getAnotherSuperMain() + * @generated + */ + EClass ANOTHER_SUPER_MAIN = eINSTANCE.getAnotherSuperMain(); + + } + +} //SubPackagePackage diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/subPackage/impl/AnotherSuperMainImpl.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/subPackage/impl/AnotherSuperMainImpl.java new file mode 100644 index 000000000..343712c71 --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/subPackage/impl/AnotherSuperMainImpl.java @@ -0,0 +1,41 @@ +/** + * generated by Xtext + */ +package org.eclipse.xtext.generator.ecore.subPackage.impl; + +import org.eclipse.emf.ecore.EClass; + +import org.eclipse.xtext.generator.ecore.subPackage.AnotherSuperMain; +import org.eclipse.xtext.generator.ecore.subPackage.SubPackagePackage; + +/** + * + * An implementation of the model object 'Another Super Main'. + * + * + * @generated + */ +public class AnotherSuperMainImpl extends org.eclipse.xtext.generator.ecore.superPackage.impl.AnotherSuperMainImpl implements AnotherSuperMain +{ + /** + * + * + * @generated + */ + protected AnotherSuperMainImpl() + { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() + { + return SubPackagePackage.Literals.ANOTHER_SUPER_MAIN; + } + +} //AnotherSuperMainImpl diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/subPackage/impl/SubMainImpl.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/subPackage/impl/SubMainImpl.java new file mode 100644 index 000000000..65b864cd6 --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/subPackage/impl/SubMainImpl.java @@ -0,0 +1,243 @@ +/** + * generated by Xtext + */ +package org.eclipse.xtext.generator.ecore.subPackage.impl; + +import java.util.Collection; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.ecore.util.EObjectContainmentEList; +import org.eclipse.emf.ecore.util.InternalEList; + +import org.eclipse.xtext.generator.ecore.subPackage.AnotherSuperMain; +import org.eclipse.xtext.generator.ecore.subPackage.SubMain; +import org.eclipse.xtext.generator.ecore.subPackage.SubPackagePackage; + +import org.eclipse.xtext.generator.ecore.superPackage.SuperMain; + +/** + * + * An implementation of the model object 'Sub Main'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link org.eclipse.xtext.generator.ecore.subPackage.impl.SubMainImpl#getSuperMains Super Mains}
  • + *
  • {@link org.eclipse.xtext.generator.ecore.subPackage.impl.SubMainImpl#getAnother Another}
  • + *
+ * + * @generated + */ +public class SubMainImpl extends MinimalEObjectImpl.Container implements SubMain +{ + /** + * The cached value of the '{@link #getSuperMains() Super Mains}' containment reference list. + * + * + * @see #getSuperMains() + * @generated + * @ordered + */ + protected EList superMains; + + /** + * The cached value of the '{@link #getAnother() Another}' containment reference. + * + * + * @see #getAnother() + * @generated + * @ordered + */ + protected AnotherSuperMain another; + + /** + * + * + * @generated + */ + protected SubMainImpl() + { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() + { + return SubPackagePackage.Literals.SUB_MAIN; + } + + /** + * + * + * @generated + */ + public EList getSuperMains() + { + if (superMains == null) + { + superMains = new EObjectContainmentEList(SuperMain.class, this, SubPackagePackage.SUB_MAIN__SUPER_MAINS); + } + return superMains; + } + + /** + * + * + * @generated + */ + public AnotherSuperMain getAnother() + { + return another; + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetAnother(AnotherSuperMain newAnother, NotificationChain msgs) + { + AnotherSuperMain oldAnother = another; + another = newAnother; + if (eNotificationRequired()) + { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SubPackagePackage.SUB_MAIN__ANOTHER, oldAnother, newAnother); + if (msgs == null) msgs = notification; else msgs.add(notification); + } + return msgs; + } + + /** + * + * + * @generated + */ + public void setAnother(AnotherSuperMain newAnother) + { + if (newAnother != another) + { + NotificationChain msgs = null; + if (another != null) + msgs = ((InternalEObject)another).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - SubPackagePackage.SUB_MAIN__ANOTHER, null, msgs); + if (newAnother != null) + msgs = ((InternalEObject)newAnother).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - SubPackagePackage.SUB_MAIN__ANOTHER, null, msgs); + msgs = basicSetAnother(newAnother, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SubPackagePackage.SUB_MAIN__ANOTHER, newAnother, newAnother)); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) + { + switch (featureID) + { + case SubPackagePackage.SUB_MAIN__SUPER_MAINS: + return ((InternalEList)getSuperMains()).basicRemove(otherEnd, msgs); + case SubPackagePackage.SUB_MAIN__ANOTHER: + return basicSetAnother(null, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case SubPackagePackage.SUB_MAIN__SUPER_MAINS: + return getSuperMains(); + case SubPackagePackage.SUB_MAIN__ANOTHER: + return getAnother(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case SubPackagePackage.SUB_MAIN__SUPER_MAINS: + getSuperMains().clear(); + getSuperMains().addAll((Collection)newValue); + return; + case SubPackagePackage.SUB_MAIN__ANOTHER: + setAnother((AnotherSuperMain)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) + { + switch (featureID) + { + case SubPackagePackage.SUB_MAIN__SUPER_MAINS: + getSuperMains().clear(); + return; + case SubPackagePackage.SUB_MAIN__ANOTHER: + setAnother((AnotherSuperMain)null); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case SubPackagePackage.SUB_MAIN__SUPER_MAINS: + return superMains != null && !superMains.isEmpty(); + case SubPackagePackage.SUB_MAIN__ANOTHER: + return another != null; + } + return super.eIsSet(featureID); + } + +} //SubMainImpl diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/subPackage/impl/SubPackageFactoryImpl.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/subPackage/impl/SubPackageFactoryImpl.java new file mode 100644 index 000000000..135b30a4b --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/subPackage/impl/SubPackageFactoryImpl.java @@ -0,0 +1,119 @@ +/** + * generated by Xtext + */ +package org.eclipse.xtext.generator.ecore.subPackage.impl; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.impl.EFactoryImpl; + +import org.eclipse.emf.ecore.plugin.EcorePlugin; + +import org.eclipse.xtext.generator.ecore.subPackage.*; + +/** + * + * An implementation of the model Factory. + * + * @generated + */ +public class SubPackageFactoryImpl extends EFactoryImpl implements SubPackageFactory +{ + /** + * Creates the default factory implementation. + * + * + * @generated + */ + public static SubPackageFactory init() + { + try + { + SubPackageFactory theSubPackageFactory = (SubPackageFactory)EPackage.Registry.INSTANCE.getEFactory(SubPackagePackage.eNS_URI); + if (theSubPackageFactory != null) + { + return theSubPackageFactory; + } + } + catch (Exception exception) + { + EcorePlugin.INSTANCE.log(exception); + } + return new SubPackageFactoryImpl(); + } + + /** + * Creates an instance of the factory. + * + * + * @generated + */ + public SubPackageFactoryImpl() + { + super(); + } + + /** + * + * + * @generated + */ + @Override + public EObject create(EClass eClass) + { + switch (eClass.getClassifierID()) + { + case SubPackagePackage.SUB_MAIN: return createSubMain(); + case SubPackagePackage.ANOTHER_SUPER_MAIN: return createAnotherSuperMain(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * + * + * @generated + */ + public SubMain createSubMain() + { + SubMainImpl subMain = new SubMainImpl(); + return subMain; + } + + /** + * + * + * @generated + */ + public AnotherSuperMain createAnotherSuperMain() + { + AnotherSuperMainImpl anotherSuperMain = new AnotherSuperMainImpl(); + return anotherSuperMain; + } + + /** + * + * + * @generated + */ + public SubPackagePackage getSubPackagePackage() + { + return (SubPackagePackage)getEPackage(); + } + + /** + * + * + * @deprecated + * @generated + */ + @Deprecated + public static SubPackagePackage getPackage() + { + return SubPackagePackage.eINSTANCE; + } + +} //SubPackageFactoryImpl diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/subPackage/impl/SubPackagePackageImpl.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/subPackage/impl/SubPackagePackageImpl.java new file mode 100644 index 000000000..22e6e1b54 --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/subPackage/impl/SubPackagePackageImpl.java @@ -0,0 +1,229 @@ +/** + * generated by Xtext + */ +package org.eclipse.xtext.generator.ecore.subPackage.impl; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; + +import org.eclipse.emf.ecore.impl.EPackageImpl; + +import org.eclipse.xtext.generator.ecore.subPackage.AnotherSuperMain; +import org.eclipse.xtext.generator.ecore.subPackage.SubMain; +import org.eclipse.xtext.generator.ecore.subPackage.SubPackageFactory; +import org.eclipse.xtext.generator.ecore.subPackage.SubPackagePackage; + +import org.eclipse.xtext.generator.ecore.superPackage.SuperPackagePackage; + +/** + * + * An implementation of the model Package. + * + * @generated + */ +public class SubPackagePackageImpl extends EPackageImpl implements SubPackagePackage +{ + /** + * + * + * @generated + */ + private EClass subMainEClass = null; + + /** + * + * + * @generated + */ + private EClass anotherSuperMainEClass = null; + + /** + * Creates an instance of the model Package, registered with + * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package + * package URI value. + *

Note: the correct way to create the package is via the static + * factory method {@link #init init()}, which also performs + * initialization of the package, or returns the registered package, + * if one already exists. + * + * + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see org.eclipse.xtext.generator.ecore.subPackage.SubPackagePackage#eNS_URI + * @see #init() + * @generated + */ + private SubPackagePackageImpl() + { + super(eNS_URI, SubPackageFactory.eINSTANCE); + } + + /** + * + * + * @generated + */ + private static boolean isInited = false; + + /** + * Creates, registers, and initializes the Package for this model, and for any others upon which it depends. + * + *

This method is used to initialize {@link SubPackagePackage#eINSTANCE} when that field is accessed. + * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. + * + * + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static SubPackagePackage init() + { + if (isInited) return (SubPackagePackage)EPackage.Registry.INSTANCE.getEPackage(SubPackagePackage.eNS_URI); + + // Obtain or create and register package + SubPackagePackageImpl theSubPackagePackage = (SubPackagePackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof SubPackagePackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new SubPackagePackageImpl()); + + isInited = true; + + // Initialize simple dependencies + SuperPackagePackage.eINSTANCE.eClass(); + + // Create package meta-data objects + theSubPackagePackage.createPackageContents(); + + // Initialize created meta-data + theSubPackagePackage.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theSubPackagePackage.freeze(); + + + // Update the registry and return the package + EPackage.Registry.INSTANCE.put(SubPackagePackage.eNS_URI, theSubPackagePackage); + return theSubPackagePackage; + } + + /** + * + * + * @generated + */ + public EClass getSubMain() + { + return subMainEClass; + } + + /** + * + * + * @generated + */ + public EReference getSubMain_SuperMains() + { + return (EReference)subMainEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EReference getSubMain_Another() + { + return (EReference)subMainEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + public EClass getAnotherSuperMain() + { + return anotherSuperMainEClass; + } + + /** + * + * + * @generated + */ + public SubPackageFactory getSubPackageFactory() + { + return (SubPackageFactory)getEFactoryInstance(); + } + + /** + * + * + * @generated + */ + private boolean isCreated = false; + + /** + * Creates the meta-model objects for the package. This method is + * guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void createPackageContents() + { + if (isCreated) return; + isCreated = true; + + // Create classes and their features + subMainEClass = createEClass(SUB_MAIN); + createEReference(subMainEClass, SUB_MAIN__SUPER_MAINS); + createEReference(subMainEClass, SUB_MAIN__ANOTHER); + + anotherSuperMainEClass = createEClass(ANOTHER_SUPER_MAIN); + } + + /** + * + * + * @generated + */ + private boolean isInitialized = false; + + /** + * Complete the initialization of the package and its meta-model. This + * method is guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void initializePackageContents() + { + if (isInitialized) return; + isInitialized = true; + + // Initialize package + setName(eNAME); + setNsPrefix(eNS_PREFIX); + setNsURI(eNS_URI); + + // Obtain other dependent packages + SuperPackagePackage theSuperPackagePackage = (SuperPackagePackage)EPackage.Registry.INSTANCE.getEPackage(SuperPackagePackage.eNS_URI); + + // Create type parameters + + // Set bounds for type parameters + + // Add supertypes to classes + anotherSuperMainEClass.getESuperTypes().add(theSuperPackagePackage.getAnotherSuperMain()); + + // Initialize classes and features; add operations and parameters + initEClass(subMainEClass, SubMain.class, "SubMain", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getSubMain_SuperMains(), theSuperPackagePackage.getSuperMain(), null, "superMains", null, 0, -1, SubMain.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getSubMain_Another(), this.getAnotherSuperMain(), null, "another", null, 0, 1, SubMain.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(anotherSuperMainEClass, AnotherSuperMain.class, "AnotherSuperMain", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + + // Create resource + createResource(eNS_URI); + } + +} //SubPackagePackageImpl diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/subPackage/util/SubPackageAdapterFactory.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/subPackage/util/SubPackageAdapterFactory.java new file mode 100644 index 000000000..0d1777cdd --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/subPackage/util/SubPackageAdapterFactory.java @@ -0,0 +1,173 @@ +/** + * generated by Xtext + */ +package org.eclipse.xtext.generator.ecore.subPackage.util; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notifier; + +import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; + +import org.eclipse.emf.ecore.EObject; + +import org.eclipse.xtext.generator.ecore.subPackage.*; + +/** + * + * The Adapter Factory for the model. + * It provides an adapter createXXX method for each class of the model. + * + * @see org.eclipse.xtext.generator.ecore.subPackage.SubPackagePackage + * @generated + */ +public class SubPackageAdapterFactory extends AdapterFactoryImpl +{ + /** + * The cached model package. + * + * + * @generated + */ + protected static SubPackagePackage modelPackage; + + /** + * Creates an instance of the adapter factory. + * + * + * @generated + */ + public SubPackageAdapterFactory() + { + if (modelPackage == null) + { + modelPackage = SubPackagePackage.eINSTANCE; + } + } + + /** + * Returns whether this factory is applicable for the type of the object. + * + * This implementation returns true if the object is either the model's package or is an instance object of the model. + * + * @return whether this factory is applicable for the type of the object. + * @generated + */ + @Override + public boolean isFactoryForType(Object object) + { + if (object == modelPackage) + { + return true; + } + if (object instanceof EObject) + { + return ((EObject)object).eClass().getEPackage() == modelPackage; + } + return false; + } + + /** + * The switch that delegates to the createXXX methods. + * + * + * @generated + */ + protected SubPackageSwitch modelSwitch = + new SubPackageSwitch() + { + @Override + public Adapter caseSubMain(SubMain object) + { + return createSubMainAdapter(); + } + @Override + public Adapter caseAnotherSuperMain(AnotherSuperMain object) + { + return createAnotherSuperMainAdapter(); + } + @Override + public Adapter caseSuperPackage_AnotherSuperMain(org.eclipse.xtext.generator.ecore.superPackage.AnotherSuperMain object) + { + return createSuperPackage_AnotherSuperMainAdapter(); + } + @Override + public Adapter defaultCase(EObject object) + { + return createEObjectAdapter(); + } + }; + + /** + * Creates an adapter for the target. + * + * + * @param target the object to adapt. + * @return the adapter for the target. + * @generated + */ + @Override + public Adapter createAdapter(Notifier target) + { + return modelSwitch.doSwitch((EObject)target); + } + + + /** + * Creates a new adapter for an object of class '{@link org.eclipse.xtext.generator.ecore.subPackage.SubMain Sub Main}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.xtext.generator.ecore.subPackage.SubMain + * @generated + */ + public Adapter createSubMainAdapter() + { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link org.eclipse.xtext.generator.ecore.subPackage.AnotherSuperMain Another Super Main}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.xtext.generator.ecore.subPackage.AnotherSuperMain + * @generated + */ + public Adapter createAnotherSuperMainAdapter() + { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link org.eclipse.xtext.generator.ecore.superPackage.AnotherSuperMain Another Super Main}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.xtext.generator.ecore.superPackage.AnotherSuperMain + * @generated + */ + public Adapter createSuperPackage_AnotherSuperMainAdapter() + { + return null; + } + + /** + * Creates a new adapter for the default case. + * + * This default implementation returns null. + * + * @return the new adapter. + * @generated + */ + public Adapter createEObjectAdapter() + { + return null; + } + +} //SubPackageAdapterFactory diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/subPackage/util/SubPackageSwitch.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/subPackage/util/SubPackageSwitch.java new file mode 100644 index 000000000..174c71d2b --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/subPackage/util/SubPackageSwitch.java @@ -0,0 +1,160 @@ +/** + * generated by Xtext + */ +package org.eclipse.xtext.generator.ecore.subPackage.util; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.util.Switch; + +import org.eclipse.xtext.generator.ecore.subPackage.*; + +/** + * + * The Switch for the model's inheritance hierarchy. + * It supports the call {@link #doSwitch(EObject) doSwitch(object)} + * to invoke the caseXXX method for each class of the model, + * starting with the actual class of the object + * and proceeding up the inheritance hierarchy + * until a non-null result is returned, + * which is the result of the switch. + * + * @see org.eclipse.xtext.generator.ecore.subPackage.SubPackagePackage + * @generated + */ +public class SubPackageSwitch extends Switch +{ + /** + * The cached model package + * + * + * @generated + */ + protected static SubPackagePackage modelPackage; + + /** + * Creates an instance of the switch. + * + * + * @generated + */ + public SubPackageSwitch() + { + if (modelPackage == null) + { + modelPackage = SubPackagePackage.eINSTANCE; + } + } + + /** + * Checks whether this is a switch for the given package. + * + * + * @param ePackage the package in question. + * @return whether this is a switch for the given package. + * @generated + */ + @Override + protected boolean isSwitchFor(EPackage ePackage) + { + return ePackage == modelPackage; + } + + /** + * Calls caseXXX for each class of the model until one returns a non null result; it yields that result. + * + * + * @return the first non-null result returned by a caseXXX call. + * @generated + */ + @Override + protected T doSwitch(int classifierID, EObject theEObject) + { + switch (classifierID) + { + case SubPackagePackage.SUB_MAIN: + { + SubMain subMain = (SubMain)theEObject; + T result = caseSubMain(subMain); + if (result == null) result = defaultCase(theEObject); + return result; + } + case SubPackagePackage.ANOTHER_SUPER_MAIN: + { + AnotherSuperMain anotherSuperMain = (AnotherSuperMain)theEObject; + T result = caseAnotherSuperMain(anotherSuperMain); + if (result == null) result = caseSuperPackage_AnotherSuperMain(anotherSuperMain); + if (result == null) result = defaultCase(theEObject); + return result; + } + default: return defaultCase(theEObject); + } + } + + /** + * Returns the result of interpreting the object as an instance of 'Sub Main'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Sub Main'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseSubMain(SubMain object) + { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Another Super Main'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Another Super Main'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseAnotherSuperMain(AnotherSuperMain object) + { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Another Super Main'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Another Super Main'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseSuperPackage_AnotherSuperMain(org.eclipse.xtext.generator.ecore.superPackage.AnotherSuperMain object) + { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'EObject'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch, but this is the last case anyway. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'EObject'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) + * @generated + */ + @Override + public T defaultCase(EObject object) + { + return null; + } + +} //SubPackageSwitch diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/superPackage/AnotherSuperMain.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/superPackage/AnotherSuperMain.java new file mode 100644 index 000000000..603e70e07 --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/superPackage/AnotherSuperMain.java @@ -0,0 +1,52 @@ +/** + * generated by Xtext + */ +package org.eclipse.xtext.generator.ecore.superPackage; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Another Super Main'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link org.eclipse.xtext.generator.ecore.superPackage.AnotherSuperMain#getName Name}
  • + *
+ * + * @see org.eclipse.xtext.generator.ecore.superPackage.SuperPackagePackage#getAnotherSuperMain() + * @model + * @generated + */ +public interface AnotherSuperMain extends EObject +{ + /** + * Returns the value of the 'Name' attribute. + * + *

+ * If the meaning of the 'Name' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Name' attribute. + * @see #setName(String) + * @see org.eclipse.xtext.generator.ecore.superPackage.SuperPackagePackage#getAnotherSuperMain_Name() + * @model + * @generated + */ + String getName(); + + /** + * Sets the value of the '{@link org.eclipse.xtext.generator.ecore.superPackage.AnotherSuperMain#getName Name}' attribute. + * + * + * @param value the new value of the 'Name' attribute. + * @see #getName() + * @generated + */ + void setName(String value); + +} // AnotherSuperMain diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/superPackage/SuperMain.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/superPackage/SuperMain.java new file mode 100644 index 000000000..d99aa6a5c --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/superPackage/SuperMain.java @@ -0,0 +1,52 @@ +/** + * generated by Xtext + */ +package org.eclipse.xtext.generator.ecore.superPackage; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Super Main'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link org.eclipse.xtext.generator.ecore.superPackage.SuperMain#getName Name}
  • + *
+ * + * @see org.eclipse.xtext.generator.ecore.superPackage.SuperPackagePackage#getSuperMain() + * @model + * @generated + */ +public interface SuperMain extends EObject +{ + /** + * Returns the value of the 'Name' attribute. + * + *

+ * If the meaning of the 'Name' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Name' attribute. + * @see #setName(String) + * @see org.eclipse.xtext.generator.ecore.superPackage.SuperPackagePackage#getSuperMain_Name() + * @model + * @generated + */ + String getName(); + + /** + * Sets the value of the '{@link org.eclipse.xtext.generator.ecore.superPackage.SuperMain#getName Name}' attribute. + * + * + * @param value the new value of the 'Name' attribute. + * @see #getName() + * @generated + */ + void setName(String value); + +} // SuperMain diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/superPackage/SuperPackageFactory.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/superPackage/SuperPackageFactory.java new file mode 100644 index 000000000..a28f2cc81 --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/superPackage/SuperPackageFactory.java @@ -0,0 +1,53 @@ +/** + * generated by Xtext + */ +package org.eclipse.xtext.generator.ecore.superPackage; + +import org.eclipse.emf.ecore.EFactory; + +/** + * + * The Factory for the model. + * It provides a create method for each non-abstract class of the model. + * + * @see org.eclipse.xtext.generator.ecore.superPackage.SuperPackagePackage + * @generated + */ +public interface SuperPackageFactory extends EFactory +{ + /** + * The singleton instance of the factory. + * + * + * @generated + */ + SuperPackageFactory eINSTANCE = org.eclipse.xtext.generator.ecore.superPackage.impl.SuperPackageFactoryImpl.init(); + + /** + * Returns a new object of class 'Super Main'. + * + * + * @return a new object of class 'Super Main'. + * @generated + */ + SuperMain createSuperMain(); + + /** + * Returns a new object of class 'Another Super Main'. + * + * + * @return a new object of class 'Another Super Main'. + * @generated + */ + AnotherSuperMain createAnotherSuperMain(); + + /** + * Returns the package supported by this factory. + * + * + * @return the package supported by this factory. + * @generated + */ + SuperPackagePackage getSuperPackagePackage(); + +} //SuperPackageFactory diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/superPackage/SuperPackagePackage.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/superPackage/SuperPackagePackage.java new file mode 100644 index 000000000..272987861 --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/superPackage/SuperPackagePackage.java @@ -0,0 +1,219 @@ +/** + * generated by Xtext + */ +package org.eclipse.xtext.generator.ecore.superPackage; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; + +/** + * + * The Package for the model. + * It contains accessors for the meta objects to represent + *
    + *
  • each class,
  • + *
  • each feature of each class,
  • + *
  • each enum,
  • + *
  • and each data type
  • + *
+ * + * @see org.eclipse.xtext.generator.ecore.superPackage.SuperPackageFactory + * @model kind="package" + * @generated + */ +public interface SuperPackagePackage extends EPackage +{ + /** + * The package name. + * + * + * @generated + */ + String eNAME = "superPackage"; + + /** + * The package namespace URI. + * + * + * @generated + */ + String eNS_URI = "http://www.eclipse.org/2009/tmf/xtext/SuperTestLanguage"; + + /** + * The package namespace name. + * + * + * @generated + */ + String eNS_PREFIX = "superPackage"; + + /** + * The singleton instance of the package. + * + * + * @generated + */ + SuperPackagePackage eINSTANCE = org.eclipse.xtext.generator.ecore.superPackage.impl.SuperPackagePackageImpl.init(); + + /** + * The meta object id for the '{@link org.eclipse.xtext.generator.ecore.superPackage.impl.SuperMainImpl Super Main}' class. + * + * + * @see org.eclipse.xtext.generator.ecore.superPackage.impl.SuperMainImpl + * @see org.eclipse.xtext.generator.ecore.superPackage.impl.SuperPackagePackageImpl#getSuperMain() + * @generated + */ + int SUPER_MAIN = 0; + + /** + * The feature id for the 'Name' attribute. + * + * + * @generated + * @ordered + */ + int SUPER_MAIN__NAME = 0; + + /** + * The number of structural features of the 'Super Main' class. + * + * + * @generated + * @ordered + */ + int SUPER_MAIN_FEATURE_COUNT = 1; + + /** + * The meta object id for the '{@link org.eclipse.xtext.generator.ecore.superPackage.impl.AnotherSuperMainImpl Another Super Main}' class. + * + * + * @see org.eclipse.xtext.generator.ecore.superPackage.impl.AnotherSuperMainImpl + * @see org.eclipse.xtext.generator.ecore.superPackage.impl.SuperPackagePackageImpl#getAnotherSuperMain() + * @generated + */ + int ANOTHER_SUPER_MAIN = 1; + + /** + * The feature id for the 'Name' attribute. + * + * + * @generated + * @ordered + */ + int ANOTHER_SUPER_MAIN__NAME = 0; + + /** + * The number of structural features of the 'Another Super Main' class. + * + * + * @generated + * @ordered + */ + int ANOTHER_SUPER_MAIN_FEATURE_COUNT = 1; + + + /** + * Returns the meta object for class '{@link org.eclipse.xtext.generator.ecore.superPackage.SuperMain Super Main}'. + * + * + * @return the meta object for class 'Super Main'. + * @see org.eclipse.xtext.generator.ecore.superPackage.SuperMain + * @generated + */ + EClass getSuperMain(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.xtext.generator.ecore.superPackage.SuperMain#getName Name}'. + * + * + * @return the meta object for the attribute 'Name'. + * @see org.eclipse.xtext.generator.ecore.superPackage.SuperMain#getName() + * @see #getSuperMain() + * @generated + */ + EAttribute getSuperMain_Name(); + + /** + * Returns the meta object for class '{@link org.eclipse.xtext.generator.ecore.superPackage.AnotherSuperMain Another Super Main}'. + * + * + * @return the meta object for class 'Another Super Main'. + * @see org.eclipse.xtext.generator.ecore.superPackage.AnotherSuperMain + * @generated + */ + EClass getAnotherSuperMain(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.xtext.generator.ecore.superPackage.AnotherSuperMain#getName Name}'. + * + * + * @return the meta object for the attribute 'Name'. + * @see org.eclipse.xtext.generator.ecore.superPackage.AnotherSuperMain#getName() + * @see #getAnotherSuperMain() + * @generated + */ + EAttribute getAnotherSuperMain_Name(); + + /** + * Returns the factory that creates the instances of the model. + * + * + * @return the factory that creates the instances of the model. + * @generated + */ + SuperPackageFactory getSuperPackageFactory(); + + /** + * + * Defines literals for the meta objects that represent + *
    + *
  • each class,
  • + *
  • each feature of each class,
  • + *
  • each enum,
  • + *
  • and each data type
  • + *
+ * + * @generated + */ + interface Literals + { + /** + * The meta object literal for the '{@link org.eclipse.xtext.generator.ecore.superPackage.impl.SuperMainImpl Super Main}' class. + * + * + * @see org.eclipse.xtext.generator.ecore.superPackage.impl.SuperMainImpl + * @see org.eclipse.xtext.generator.ecore.superPackage.impl.SuperPackagePackageImpl#getSuperMain() + * @generated + */ + EClass SUPER_MAIN = eINSTANCE.getSuperMain(); + + /** + * The meta object literal for the 'Name' attribute feature. + * + * + * @generated + */ + EAttribute SUPER_MAIN__NAME = eINSTANCE.getSuperMain_Name(); + + /** + * The meta object literal for the '{@link org.eclipse.xtext.generator.ecore.superPackage.impl.AnotherSuperMainImpl Another Super Main}' class. + * + * + * @see org.eclipse.xtext.generator.ecore.superPackage.impl.AnotherSuperMainImpl + * @see org.eclipse.xtext.generator.ecore.superPackage.impl.SuperPackagePackageImpl#getAnotherSuperMain() + * @generated + */ + EClass ANOTHER_SUPER_MAIN = eINSTANCE.getAnotherSuperMain(); + + /** + * The meta object literal for the 'Name' attribute feature. + * + * + * @generated + */ + EAttribute ANOTHER_SUPER_MAIN__NAME = eINSTANCE.getAnotherSuperMain_Name(); + + } + +} //SuperPackagePackage diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/superPackage/impl/AnotherSuperMainImpl.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/superPackage/impl/AnotherSuperMainImpl.java new file mode 100644 index 000000000..1c90716a5 --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/superPackage/impl/AnotherSuperMainImpl.java @@ -0,0 +1,178 @@ +/** + * generated by Xtext + */ +package org.eclipse.xtext.generator.ecore.superPackage.impl; + +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.emf.ecore.EClass; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.xtext.generator.ecore.superPackage.AnotherSuperMain; +import org.eclipse.xtext.generator.ecore.superPackage.SuperPackagePackage; + +/** + * + * An implementation of the model object 'Another Super Main'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link org.eclipse.xtext.generator.ecore.superPackage.impl.AnotherSuperMainImpl#getName Name}
  • + *
+ * + * @generated + */ +public class AnotherSuperMainImpl extends MinimalEObjectImpl.Container implements AnotherSuperMain +{ + /** + * The default value of the '{@link #getName() Name}' attribute. + * + * + * @see #getName() + * @generated + * @ordered + */ + protected static final String NAME_EDEFAULT = null; + + /** + * The cached value of the '{@link #getName() Name}' attribute. + * + * + * @see #getName() + * @generated + * @ordered + */ + protected String name = NAME_EDEFAULT; + + /** + * + * + * @generated + */ + protected AnotherSuperMainImpl() + { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() + { + return SuperPackagePackage.Literals.ANOTHER_SUPER_MAIN; + } + + /** + * + * + * @generated + */ + public String getName() + { + return name; + } + + /** + * + * + * @generated + */ + public void setName(String newName) + { + String oldName = name; + name = newName; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SuperPackagePackage.ANOTHER_SUPER_MAIN__NAME, oldName, name)); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case SuperPackagePackage.ANOTHER_SUPER_MAIN__NAME: + return getName(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case SuperPackagePackage.ANOTHER_SUPER_MAIN__NAME: + setName((String)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) + { + switch (featureID) + { + case SuperPackagePackage.ANOTHER_SUPER_MAIN__NAME: + setName(NAME_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case SuperPackagePackage.ANOTHER_SUPER_MAIN__NAME: + return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() + { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (name: "); + result.append(name); + result.append(')'); + return result.toString(); + } + +} //AnotherSuperMainImpl diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/superPackage/impl/SuperMainImpl.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/superPackage/impl/SuperMainImpl.java new file mode 100644 index 000000000..9c7722cc9 --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/superPackage/impl/SuperMainImpl.java @@ -0,0 +1,178 @@ +/** + * generated by Xtext + */ +package org.eclipse.xtext.generator.ecore.superPackage.impl; + +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.emf.ecore.EClass; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.xtext.generator.ecore.superPackage.SuperMain; +import org.eclipse.xtext.generator.ecore.superPackage.SuperPackagePackage; + +/** + * + * An implementation of the model object 'Super Main'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link org.eclipse.xtext.generator.ecore.superPackage.impl.SuperMainImpl#getName Name}
  • + *
+ * + * @generated + */ +public class SuperMainImpl extends MinimalEObjectImpl.Container implements SuperMain +{ + /** + * The default value of the '{@link #getName() Name}' attribute. + * + * + * @see #getName() + * @generated + * @ordered + */ + protected static final String NAME_EDEFAULT = null; + + /** + * The cached value of the '{@link #getName() Name}' attribute. + * + * + * @see #getName() + * @generated + * @ordered + */ + protected String name = NAME_EDEFAULT; + + /** + * + * + * @generated + */ + protected SuperMainImpl() + { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() + { + return SuperPackagePackage.Literals.SUPER_MAIN; + } + + /** + * + * + * @generated + */ + public String getName() + { + return name; + } + + /** + * + * + * @generated + */ + public void setName(String newName) + { + String oldName = name; + name = newName; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SuperPackagePackage.SUPER_MAIN__NAME, oldName, name)); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case SuperPackagePackage.SUPER_MAIN__NAME: + return getName(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case SuperPackagePackage.SUPER_MAIN__NAME: + setName((String)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) + { + switch (featureID) + { + case SuperPackagePackage.SUPER_MAIN__NAME: + setName(NAME_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case SuperPackagePackage.SUPER_MAIN__NAME: + return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() + { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (name: "); + result.append(name); + result.append(')'); + return result.toString(); + } + +} //SuperMainImpl diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/superPackage/impl/SuperPackageFactoryImpl.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/superPackage/impl/SuperPackageFactoryImpl.java new file mode 100644 index 000000000..002143ee1 --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/superPackage/impl/SuperPackageFactoryImpl.java @@ -0,0 +1,119 @@ +/** + * generated by Xtext + */ +package org.eclipse.xtext.generator.ecore.superPackage.impl; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.impl.EFactoryImpl; + +import org.eclipse.emf.ecore.plugin.EcorePlugin; + +import org.eclipse.xtext.generator.ecore.superPackage.*; + +/** + * + * An implementation of the model Factory. + * + * @generated + */ +public class SuperPackageFactoryImpl extends EFactoryImpl implements SuperPackageFactory +{ + /** + * Creates the default factory implementation. + * + * + * @generated + */ + public static SuperPackageFactory init() + { + try + { + SuperPackageFactory theSuperPackageFactory = (SuperPackageFactory)EPackage.Registry.INSTANCE.getEFactory(SuperPackagePackage.eNS_URI); + if (theSuperPackageFactory != null) + { + return theSuperPackageFactory; + } + } + catch (Exception exception) + { + EcorePlugin.INSTANCE.log(exception); + } + return new SuperPackageFactoryImpl(); + } + + /** + * Creates an instance of the factory. + * + * + * @generated + */ + public SuperPackageFactoryImpl() + { + super(); + } + + /** + * + * + * @generated + */ + @Override + public EObject create(EClass eClass) + { + switch (eClass.getClassifierID()) + { + case SuperPackagePackage.SUPER_MAIN: return createSuperMain(); + case SuperPackagePackage.ANOTHER_SUPER_MAIN: return createAnotherSuperMain(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * + * + * @generated + */ + public SuperMain createSuperMain() + { + SuperMainImpl superMain = new SuperMainImpl(); + return superMain; + } + + /** + * + * + * @generated + */ + public AnotherSuperMain createAnotherSuperMain() + { + AnotherSuperMainImpl anotherSuperMain = new AnotherSuperMainImpl(); + return anotherSuperMain; + } + + /** + * + * + * @generated + */ + public SuperPackagePackage getSuperPackagePackage() + { + return (SuperPackagePackage)getEPackage(); + } + + /** + * + * + * @deprecated + * @generated + */ + @Deprecated + public static SuperPackagePackage getPackage() + { + return SuperPackagePackage.eINSTANCE; + } + +} //SuperPackageFactoryImpl diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/superPackage/impl/SuperPackagePackageImpl.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/superPackage/impl/SuperPackagePackageImpl.java new file mode 100644 index 000000000..7b3c23783 --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/superPackage/impl/SuperPackagePackageImpl.java @@ -0,0 +1,227 @@ +/** + * generated by Xtext + */ +package org.eclipse.xtext.generator.ecore.superPackage.impl; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EcorePackage; + +import org.eclipse.emf.ecore.impl.EPackageImpl; + +import org.eclipse.xtext.generator.ecore.superPackage.AnotherSuperMain; +import org.eclipse.xtext.generator.ecore.superPackage.SuperMain; +import org.eclipse.xtext.generator.ecore.superPackage.SuperPackageFactory; +import org.eclipse.xtext.generator.ecore.superPackage.SuperPackagePackage; + +/** + * + * An implementation of the model Package. + * + * @generated + */ +public class SuperPackagePackageImpl extends EPackageImpl implements SuperPackagePackage +{ + /** + * + * + * @generated + */ + private EClass superMainEClass = null; + + /** + * + * + * @generated + */ + private EClass anotherSuperMainEClass = null; + + /** + * Creates an instance of the model Package, registered with + * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package + * package URI value. + *

Note: the correct way to create the package is via the static + * factory method {@link #init init()}, which also performs + * initialization of the package, or returns the registered package, + * if one already exists. + * + * + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see org.eclipse.xtext.generator.ecore.superPackage.SuperPackagePackage#eNS_URI + * @see #init() + * @generated + */ + private SuperPackagePackageImpl() + { + super(eNS_URI, SuperPackageFactory.eINSTANCE); + } + + /** + * + * + * @generated + */ + private static boolean isInited = false; + + /** + * Creates, registers, and initializes the Package for this model, and for any others upon which it depends. + * + *

This method is used to initialize {@link SuperPackagePackage#eINSTANCE} when that field is accessed. + * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. + * + * + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static SuperPackagePackage init() + { + if (isInited) return (SuperPackagePackage)EPackage.Registry.INSTANCE.getEPackage(SuperPackagePackage.eNS_URI); + + // Obtain or create and register package + SuperPackagePackageImpl theSuperPackagePackage = (SuperPackagePackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof SuperPackagePackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new SuperPackagePackageImpl()); + + isInited = true; + + // Initialize simple dependencies + EcorePackage.eINSTANCE.eClass(); + + // Create package meta-data objects + theSuperPackagePackage.createPackageContents(); + + // Initialize created meta-data + theSuperPackagePackage.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theSuperPackagePackage.freeze(); + + + // Update the registry and return the package + EPackage.Registry.INSTANCE.put(SuperPackagePackage.eNS_URI, theSuperPackagePackage); + return theSuperPackagePackage; + } + + /** + * + * + * @generated + */ + public EClass getSuperMain() + { + return superMainEClass; + } + + /** + * + * + * @generated + */ + public EAttribute getSuperMain_Name() + { + return (EAttribute)superMainEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EClass getAnotherSuperMain() + { + return anotherSuperMainEClass; + } + + /** + * + * + * @generated + */ + public EAttribute getAnotherSuperMain_Name() + { + return (EAttribute)anotherSuperMainEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public SuperPackageFactory getSuperPackageFactory() + { + return (SuperPackageFactory)getEFactoryInstance(); + } + + /** + * + * + * @generated + */ + private boolean isCreated = false; + + /** + * Creates the meta-model objects for the package. This method is + * guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void createPackageContents() + { + if (isCreated) return; + isCreated = true; + + // Create classes and their features + superMainEClass = createEClass(SUPER_MAIN); + createEAttribute(superMainEClass, SUPER_MAIN__NAME); + + anotherSuperMainEClass = createEClass(ANOTHER_SUPER_MAIN); + createEAttribute(anotherSuperMainEClass, ANOTHER_SUPER_MAIN__NAME); + } + + /** + * + * + * @generated + */ + private boolean isInitialized = false; + + /** + * Complete the initialization of the package and its meta-model. This + * method is guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void initializePackageContents() + { + if (isInitialized) return; + isInitialized = true; + + // Initialize package + setName(eNAME); + setNsPrefix(eNS_PREFIX); + setNsURI(eNS_URI); + + // Obtain other dependent packages + EcorePackage theEcorePackage = (EcorePackage)EPackage.Registry.INSTANCE.getEPackage(EcorePackage.eNS_URI); + + // Create type parameters + + // Set bounds for type parameters + + // Add supertypes to classes + + // Initialize classes and features; add operations and parameters + initEClass(superMainEClass, SuperMain.class, "SuperMain", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getSuperMain_Name(), theEcorePackage.getEString(), "name", null, 0, 1, SuperMain.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(anotherSuperMainEClass, AnotherSuperMain.class, "AnotherSuperMain", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getAnotherSuperMain_Name(), theEcorePackage.getEString(), "name", null, 0, 1, AnotherSuperMain.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + // Create resource + createResource(eNS_URI); + } + +} //SuperPackagePackageImpl diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/superPackage/util/SuperPackageAdapterFactory.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/superPackage/util/SuperPackageAdapterFactory.java new file mode 100644 index 000000000..af91c06b0 --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/superPackage/util/SuperPackageAdapterFactory.java @@ -0,0 +1,153 @@ +/** + * generated by Xtext + */ +package org.eclipse.xtext.generator.ecore.superPackage.util; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notifier; + +import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; + +import org.eclipse.emf.ecore.EObject; + +import org.eclipse.xtext.generator.ecore.superPackage.*; + +/** + * + * The Adapter Factory for the model. + * It provides an adapter createXXX method for each class of the model. + * + * @see org.eclipse.xtext.generator.ecore.superPackage.SuperPackagePackage + * @generated + */ +public class SuperPackageAdapterFactory extends AdapterFactoryImpl +{ + /** + * The cached model package. + * + * + * @generated + */ + protected static SuperPackagePackage modelPackage; + + /** + * Creates an instance of the adapter factory. + * + * + * @generated + */ + public SuperPackageAdapterFactory() + { + if (modelPackage == null) + { + modelPackage = SuperPackagePackage.eINSTANCE; + } + } + + /** + * Returns whether this factory is applicable for the type of the object. + * + * This implementation returns true if the object is either the model's package or is an instance object of the model. + * + * @return whether this factory is applicable for the type of the object. + * @generated + */ + @Override + public boolean isFactoryForType(Object object) + { + if (object == modelPackage) + { + return true; + } + if (object instanceof EObject) + { + return ((EObject)object).eClass().getEPackage() == modelPackage; + } + return false; + } + + /** + * The switch that delegates to the createXXX methods. + * + * + * @generated + */ + protected SuperPackageSwitch modelSwitch = + new SuperPackageSwitch() + { + @Override + public Adapter caseSuperMain(SuperMain object) + { + return createSuperMainAdapter(); + } + @Override + public Adapter caseAnotherSuperMain(AnotherSuperMain object) + { + return createAnotherSuperMainAdapter(); + } + @Override + public Adapter defaultCase(EObject object) + { + return createEObjectAdapter(); + } + }; + + /** + * Creates an adapter for the target. + * + * + * @param target the object to adapt. + * @return the adapter for the target. + * @generated + */ + @Override + public Adapter createAdapter(Notifier target) + { + return modelSwitch.doSwitch((EObject)target); + } + + + /** + * Creates a new adapter for an object of class '{@link org.eclipse.xtext.generator.ecore.superPackage.SuperMain Super Main}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.xtext.generator.ecore.superPackage.SuperMain + * @generated + */ + public Adapter createSuperMainAdapter() + { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link org.eclipse.xtext.generator.ecore.superPackage.AnotherSuperMain Another Super Main}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.xtext.generator.ecore.superPackage.AnotherSuperMain + * @generated + */ + public Adapter createAnotherSuperMainAdapter() + { + return null; + } + + /** + * Creates a new adapter for the default case. + * + * This default implementation returns null. + * + * @return the new adapter. + * @generated + */ + public Adapter createEObjectAdapter() + { + return null; + } + +} //SuperPackageAdapterFactory diff --git a/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/superPackage/util/SuperPackageSwitch.java b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/superPackage/util/SuperPackageSwitch.java new file mode 100644 index 000000000..fd37e29e6 --- /dev/null +++ b/tests/org.eclipse.xtext.tests/src-gen2/org/eclipse/xtext/generator/ecore/superPackage/util/SuperPackageSwitch.java @@ -0,0 +1,143 @@ +/** + * generated by Xtext + */ +package org.eclipse.xtext.generator.ecore.superPackage.util; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.util.Switch; + +import org.eclipse.xtext.generator.ecore.superPackage.*; + +/** + * + * The Switch for the model's inheritance hierarchy. + * It supports the call {@link #doSwitch(EObject) doSwitch(object)} + * to invoke the caseXXX method for each class of the model, + * starting with the actual class of the object + * and proceeding up the inheritance hierarchy + * until a non-null result is returned, + * which is the result of the switch. + * + * @see org.eclipse.xtext.generator.ecore.superPackage.SuperPackagePackage + * @generated + */ +public class SuperPackageSwitch extends Switch +{ + /** + * The cached model package + * + * + * @generated + */ + protected static SuperPackagePackage modelPackage; + + /** + * Creates an instance of the switch. + * + * + * @generated + */ + public SuperPackageSwitch() + { + if (modelPackage == null) + { + modelPackage = SuperPackagePackage.eINSTANCE; + } + } + + /** + * Checks whether this is a switch for the given package. + * + * + * @param ePackage the package in question. + * @return whether this is a switch for the given package. + * @generated + */ + @Override + protected boolean isSwitchFor(EPackage ePackage) + { + return ePackage == modelPackage; + } + + /** + * Calls caseXXX for each class of the model until one returns a non null result; it yields that result. + * + * + * @return the first non-null result returned by a caseXXX call. + * @generated + */ + @Override + protected T doSwitch(int classifierID, EObject theEObject) + { + switch (classifierID) + { + case SuperPackagePackage.SUPER_MAIN: + { + SuperMain superMain = (SuperMain)theEObject; + T result = caseSuperMain(superMain); + if (result == null) result = defaultCase(theEObject); + return result; + } + case SuperPackagePackage.ANOTHER_SUPER_MAIN: + { + AnotherSuperMain anotherSuperMain = (AnotherSuperMain)theEObject; + T result = caseAnotherSuperMain(anotherSuperMain); + if (result == null) result = defaultCase(theEObject); + return result; + } + default: return defaultCase(theEObject); + } + } + + /** + * Returns the result of interpreting the object as an instance of 'Super Main'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Super Main'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseSuperMain(SuperMain object) + { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Another Super Main'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Another Super Main'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseAnotherSuperMain(AnotherSuperMain object) + { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'EObject'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch, but this is the last case anyway. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'EObject'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) + * @generated + */ + @Override + public T defaultCase(EObject object) + { + return null; + } + +} //SuperPackageSwitch diff --git a/tests/org.eclipse.xtext.tests/src/org/eclipse/xtext/GenerateAllTestLanguages.mwe2 b/tests/org.eclipse.xtext.tests/src/org/eclipse/xtext/GenerateAllTestLanguages.mwe2 index fe6fb0325..cf68a8e2e 100644 --- a/tests/org.eclipse.xtext.tests/src/org/eclipse/xtext/GenerateAllTestLanguages.mwe2 +++ b/tests/org.eclipse.xtext.tests/src/org/eclipse/xtext/GenerateAllTestLanguages.mwe2 @@ -66,16 +66,16 @@ Workflow { pathTestProject = runtimeProject projectNameRt = projectName - language = { - uri = "classpath:/org/eclipse/xtext/generator/ecore/SuperTestLanguage.xtext" - fragment = @TestLanguagesFragments { - srcGenOnly = false - } - } - language = { - uri = "classpath:/org/eclipse/xtext/generator/ecore/SubTestLanguage.xtext" - fragment = @TestLanguagesFragments {} - } +// language = { +// uri = "classpath:/org/eclipse/xtext/generator/ecore/SuperTestLanguage.xtext" +// fragment = @TestLanguagesFragments { +// srcGenOnly = false +// } +// } +// language = { +// uri = "classpath:/org/eclipse/xtext/generator/ecore/SubTestLanguage.xtext" +// fragment = @TestLanguagesFragments {} +// } language = { uri = "classpath:/org/eclipse/xtext/XtextGrammarTestLanguage.xtext" fragment = @TestLanguagesFragments {} diff --git a/tests/org.eclipse.xtext.tests/src/org/eclipse/xtext/GenerateAllTestLanguages2.mwe2 b/tests/org.eclipse.xtext.tests/src/org/eclipse/xtext/GenerateAllTestLanguages2.mwe2 index fd9151e82..ffda922f4 100644 --- a/tests/org.eclipse.xtext.tests/src/org/eclipse/xtext/GenerateAllTestLanguages2.mwe2 +++ b/tests/org.eclipse.xtext.tests/src/org/eclipse/xtext/GenerateAllTestLanguages2.mwe2 @@ -89,9 +89,15 @@ Workflow { } language = TestLanguage { name = "org.eclipse.xtext.generator.ecore.SuperTestLanguage" + ideaPlugin = { + generateXtendStub = true + } } language = TestLanguage { name = "org.eclipse.xtext.generator.ecore.SubTestLanguage" + ideaPlugin = { + generateXtendStub = true + } } // language = TestLanguage { // name = "org.eclipse.xtext.XtextGrammarTestLanguage" diff --git a/tests/org.eclipse.xtext.tests/src/org/eclipse/xtext/generator/ecore/serializer/SuperTestLanguageSemanticSequencer.java b/tests/org.eclipse.xtext.tests/src/org/eclipse/xtext/generator/ecore/serializer/SuperTestLanguageSemanticSequencer.java deleted file mode 100644 index 1d82c8baf..000000000 --- a/tests/org.eclipse.xtext.tests/src/org/eclipse/xtext/generator/ecore/serializer/SuperTestLanguageSemanticSequencer.java +++ /dev/null @@ -1,4 +0,0 @@ -package org.eclipse.xtext.generator.ecore.serializer; - -public class SuperTestLanguageSemanticSequencer extends AbstractSuperTestLanguageSemanticSequencer { -} diff --git a/tests/org.eclipse.xtext.tests/src/org/eclipse/xtext/generator/ecore/serializer/SuperTestLanguageSyntacticSequencer.java b/tests/org.eclipse.xtext.tests/src/org/eclipse/xtext/generator/ecore/serializer/SuperTestLanguageSyntacticSequencer.java deleted file mode 100644 index f3e28bc32..000000000 --- a/tests/org.eclipse.xtext.tests/src/org/eclipse/xtext/generator/ecore/serializer/SuperTestLanguageSyntacticSequencer.java +++ /dev/null @@ -1,4 +0,0 @@ -package org.eclipse.xtext.generator.ecore.serializer; - -public class SuperTestLanguageSyntacticSequencer extends AbstractSuperTestLanguageSyntacticSequencer { -}