org.eclipse.xtext.XtextStandaloneSetup Java Examples
The following examples show how to use
org.eclipse.xtext.XtextStandaloneSetup.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PartialParserTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
/** * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=273209 */ @Test public void testBug273209_03() throws Exception { with(XtextStandaloneSetup.class); String model = "grammar org.eclipse.Bug273209_01 with org.eclipse.xtext.common.Terminals \n" + "generate testLanguage 'http://www.eclipse.org/2009/tmf/xtext/partialParsing/Bug273209/3'\n" + "Model : \n" + " ('model' ':' name=ID ';'*);"; XtextResource resource = getResourceFromString(model); assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty()); model = resource.getParseResult().getRootNode().getText(); resource.update(model.indexOf("*);") + 1, 2, ""); assertEquals(resource.getErrors().toString(), 1, resource.getErrors().size()); model = resource.getParseResult().getRootNode().getText(); resource.update(model.indexOf("*") + 1, 0, " "); assertEquals(resource.getErrors().toString(), 1, resource.getErrors().size()); model = resource.getParseResult().getRootNode().getText(); resource.update(model.indexOf("* ") + 2, 0, ");"); assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty()); }
Example #2
Source File: DeclarativeValueConverterServiceTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Override public void setUp() throws Exception { super.setUp(); with(new XtextStandaloneSetup() { @Override public Injector createInjector() { return Guice.createInjector(new org.eclipse.xtext.XtextRuntimeModule() { @SuppressWarnings("unused") public DeclarativeValueConverterServiceTest bindTest() { return DeclarativeValueConverterServiceTest.this; } }); } }); }
Example #3
Source File: ParsetreeUtilTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Override public void setUp() throws Exception { super.setUp(); with(XtextStandaloneSetup.class); modelAsString = "\n" + "grammar org.eclipse.xtext.parsetree.impl.LineTestLanguage with org.eclipse.xtext.common.Terminals\n" + "\n" + "generate testLanguage \"http://www.eclipse.org/2009/tmf/xtext/ParsetreeUtilTest\"\n" + " \n" + "Model:\n" + " name=ID\n" + ";\n" + "\n" + "\n"; grammar = (Grammar) getModel(modelAsString); grammarNode = NodeModelUtils.getNode(grammar); metamodelNode = NodeModelUtils.getNode(grammar.getMetamodelDeclarations().get(0)); parentMetamodelNode = metamodelNode.getParent(); }
Example #4
Source File: GrammarUtilTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Test public void testFindCurrentType_04() throws Exception { this.with(XtextStandaloneSetup.class); StringConcatenation _builder = new StringConcatenation(); _builder.append("grammar myLang with org.eclipse.xtext.common.Terminals"); _builder.newLine(); _builder.append("generate g \'http://1\'"); _builder.newLine(); _builder.append("Rule:"); _builder.newLine(); _builder.append("\t"); _builder.append("Fragment;"); _builder.newLine(); _builder.append("fragment Fragment: name=ID SecondFragment?;"); _builder.newLine(); _builder.append("fragment SecondFragment: {SubRule.named=current} value=ID;"); _builder.newLine(); String model = _builder.toString(); final XtextResource r = this.getResourceFromString(model); EObject _get = r.getContents().get(0); final Grammar grammar = ((Grammar) _get); final AbstractRule rule = IterableExtensions.<AbstractRule>head(grammar.getRules()); final AbstractElement fragmentCall = rule.getAlternatives(); final EClassifier currentType = GrammarUtil.findCurrentType(fragmentCall); Assert.assertEquals("Rule", currentType.getName()); }
Example #5
Source File: Bug281990Test.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Override public void setUp() throws Exception { super.setUp(); XtextStandaloneSetup.doSetup(); with(new LazyLinkingTestLanguageRuntimeModule() { @Override public Class<? extends IScopeProvider> bindIScopeProvider() { return org.eclipse.xtext.linking.lazy.Bug281990Test.RecursiveScopeProvider.class; } @Override public void configure(Binder binder) { super.configure(binder); binder.bindConstant().annotatedWith(Names.named(LazyLinkingResource.CYCLIC_LINKING_DECTECTION_COUNTER_LIMIT)).to(0); } }); new LazyLinkingTestLanguageStandaloneSetup().register(getInjector()); }
Example #6
Source File: GrammarUtilTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Test public void testFindCurrentType_01() throws Exception { this.with(XtextStandaloneSetup.class); StringConcatenation _builder = new StringConcatenation(); _builder.append("grammar myLang with org.eclipse.xtext.common.Terminals"); _builder.newLine(); _builder.append("generate g \'http://1\'"); _builder.newLine(); _builder.append("Rule:"); _builder.newLine(); _builder.append("\t"); _builder.append("Fragment;"); _builder.newLine(); _builder.append("fragment Fragment*: name=ID;"); _builder.newLine(); String model = _builder.toString(); final XtextResource r = this.getResourceFromString(model); EObject _get = r.getContents().get(0); final Grammar grammar = ((Grammar) _get); final AbstractRule rule = IterableExtensions.<AbstractRule>head(grammar.getRules()); final AbstractElement fragmentCall = rule.getAlternatives(); final EClassifier currentType = GrammarUtil.findCurrentType(fragmentCall); Assert.assertEquals("Rule", currentType.getName()); }
Example #7
Source File: PartialParserTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
/** * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=273209 */ @Test public void testBug273209_01() throws Exception { with(XtextStandaloneSetup.class); String model = "grammar org.eclipse.Bug273209_01 with org.eclipse.xtext.common.Terminals \n" + "generate testLanguage 'http://www.eclipse.org/2009/tmf/xtext/partialParsing/Bug273209/1'\n" + "Model : \n" + " 'model' ':' name=ID ';'*;"; XtextResource resource = getResourceFromString(model); assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty()); model = resource.getParseResult().getRootNode().getText(); resource.update(model.indexOf("*;") + 1, 1, ""); assertEquals(resource.getErrors().toString(), 1, resource.getErrors().size()); model = resource.getParseResult().getRootNode().getText(); resource.update(model.indexOf("*") + 1, 0, " "); assertEquals(resource.getErrors().toString(), 1, resource.getErrors().size()); model = resource.getParseResult().getRootNode().getText(); resource.update(model.indexOf("* ") + 2, 0, ";"); assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty()); }
Example #8
Source File: GrammarUtilTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Test public void testFindCurrentType_03() throws Exception { this.with(XtextStandaloneSetup.class); StringConcatenation _builder = new StringConcatenation(); _builder.append("grammar myLang with org.eclipse.xtext.common.Terminals"); _builder.newLine(); _builder.append("generate g \'http://1\'"); _builder.newLine(); _builder.append("Rule:"); _builder.newLine(); _builder.append("\t"); _builder.append("Fragment;"); _builder.newLine(); _builder.append("fragment Fragment: name=ID SecondFragment;"); _builder.newLine(); _builder.append("fragment SecondFragment: {SubRule.named=current} value=ID;"); _builder.newLine(); String model = _builder.toString(); final XtextResource r = this.getResourceFromString(model); EObject _get = r.getContents().get(0); final Grammar grammar = ((Grammar) _get); final AbstractRule rule = IterableExtensions.<AbstractRule>head(grammar.getRules()); final AbstractElement fragmentCall = rule.getAlternatives(); final EClassifier currentType = GrammarUtil.findCurrentType(fragmentCall); Assert.assertEquals("SubRule", currentType.getName()); }
Example #9
Source File: GrammarUtilTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Test public void testFindCurrentType_02() throws Exception { this.with(XtextStandaloneSetup.class); StringConcatenation _builder = new StringConcatenation(); _builder.append("grammar myLang with org.eclipse.xtext.common.Terminals"); _builder.newLine(); _builder.append("generate g \'http://1\'"); _builder.newLine(); _builder.append("Rule:"); _builder.newLine(); _builder.append("\t"); _builder.append("Fragment;"); _builder.newLine(); _builder.append("fragment Fragment: name=ID {SubRule.named=current};"); _builder.newLine(); String model = _builder.toString(); final XtextResource r = this.getResourceFromString(model); EObject _get = r.getContents().get(0); final Grammar grammar = ((Grammar) _get); final AbstractRule rule = IterableExtensions.<AbstractRule>head(grammar.getRules()); final AbstractElement fragmentCall = rule.getAlternatives(); final EClassifier currentType = GrammarUtil.findCurrentType(fragmentCall); Assert.assertEquals("SubRule", currentType.getName()); }
Example #10
Source File: XtextFormatterTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Override public void setUp() throws Exception { super.setUp(); with(new XtextStandaloneSetup() { @Override public Injector createInjector() { return Guice.createInjector(new org.eclipse.xtext.XtextRuntimeModule() { @SuppressWarnings("unused") public Class<? extends ILineSeparatorInformation> bindILineSeparatorInformation() { return FormatterTestLineSeparatorInformation.class; } }); } }); get(FormatterTestLineSeparatorInformation.class).setLineSeparator("\n"); }
Example #11
Source File: DocumentBasedDirtyResourceTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override public void setUp() throws Exception { super.setUp(); with(XtextStandaloneSetup.class); uri = URI.createURI("scheme:/foobar.xtext"); documentContent = "grammar foo with org.eclipse.xtext.common.Terminals\n" + "generate test 'http://test'\n" + "Model: name=ID;"; resource = getResource(documentContent, uri.toString()); DefaultResourceServiceProvider provider = new DefaultResourceServiceProvider() { @Override public org.eclipse.xtext.resource.IResourceDescription.Manager getResourceDescriptionManager() { return DocumentBasedDirtyResourceTest.this; } }; resource.setResourceServiceProvider(provider); dirtyResource = new DocumentBasedDirtyResource(); description = this; }
Example #12
Source File: GrammarUtilTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Test public void testFindRuleByName() throws Exception { this.with(XtextStandaloneSetup.class); StringConcatenation _builder = new StringConcatenation(); _builder.append("grammar myLang with org.eclipse.xtext.common.Terminals"); _builder.newLine(); _builder.append("generate g \'http://1\'"); _builder.newLine(); _builder.append("Rule:"); _builder.newLine(); _builder.append("\t"); _builder.append("name=ID;"); _builder.newLine(); _builder.append("terminal STRING: \'\"\';"); _builder.newLine(); String model = _builder.toString(); XtextResource r = this.getResourceFromString(model); EObject _get = r.getContents().get(0); Grammar grammar = ((Grammar) _get); Assert.assertEquals(grammar, GrammarUtil.findRuleForName(grammar, "Rule").eContainer()); Assert.assertNull(GrammarUtil.findRuleForName(grammar, "org.eclipse.xtext.common.Terminals.Rule")); Assert.assertEquals(IterableExtensions.<Grammar>head(grammar.getUsedGrammars()), GrammarUtil.findRuleForName(grammar, "ID").eContainer()); Assert.assertEquals(grammar, GrammarUtil.findRuleForName(grammar, "STRING").eContainer()); Assert.assertEquals(IterableExtensions.<Grammar>head(grammar.getUsedGrammars()), GrammarUtil.findRuleForName(grammar, "org.eclipse.xtext.common.Terminals.STRING").eContainer()); }
Example #13
Source File: MetamodelTransformationTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Override public void setUp() throws Exception { super.setUp(); with(XtextStandaloneSetup.class); model = "grammar datatypetests with org.eclipse.xtext.common.Terminals\n" + "import 'http://www.eclipse.org/emf/2002/Ecore' as ecore\n" + "generate metamodel 'http://fooo'\n" + "Start:\n" + " id=StartId id2=RecursiveId id3=CalledId value=Value;\n" + "StartId returns ecore::EInt: ID '.' (ID|INT);\n" + "RecursiveId: ID ('/' RecursiveId)?;\n" + "CalledId: StartId '-' ID;\n" + "Value: name=StartId;\n" + "OnlyKeywords: 'foo';\n" + "AssignmentWithAlternative: foo=('1'|'2');\n" + "Farbe :\n" + " wert=(\"ROT\" | \"BLAU\" | \"GELB\" | \"GR�N\");\n" + "UnorderedGroupDataType: ID & STRING & CalledId & 'keyword';\n" + "UnorderedGroupClass: ID & name=STRING & CalledId & 'keyword';\n"; grammar = (Grammar) getModel(model); pack = grammar.getMetamodelDeclarations().get(1).getEPackage(); }
Example #14
Source File: KeywordHelperTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Before @Override public void setUp() throws Exception { globalStateMemento = GlobalRegistries.makeCopyOfGlobalState(); super.setUp(); EPackage.Registry.INSTANCE.put(XMLTypePackage.eNS_URI, XMLTypePackage.eINSTANCE); with(XtextStandaloneSetup.class); }
Example #15
Source File: GrammarUtilTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testAllMetamodelDeclarations_02() throws Exception { this.with(XtextStandaloneSetup.class); StringConcatenation _builder = new StringConcatenation(); _builder.append("grammar foo with org.eclipse.xtext.common.Terminals"); _builder.newLine(); _builder.append("import \'http://www.eclipse.org/emf/2002/Ecore\' as bar"); _builder.newLine(); _builder.append("generate g \'http://3\' as bar"); _builder.newLine(); _builder.append("startrule returns bar::startrule: name=ID;"); _builder.newLine(); String model = _builder.toString(); Resource r = this.getResourceFromString(model); EObject _get = r.getContents().get(0); Grammar g = ((Grammar) _get); List<AbstractMetamodelDeclaration> decls = GrammarUtil.allMetamodelDeclarations(g); Assert.assertEquals(3, decls.size()); AbstractMetamodelDeclaration decl = decls.get(0); Assert.assertTrue((decl instanceof ReferencedMetamodel)); Assert.assertNotNull(decl.getEPackage()); Assert.assertEquals("http://www.eclipse.org/emf/2002/Ecore", decl.getEPackage().getNsURI()); Assert.assertEquals("bar", decl.getAlias()); decl = decls.get(1); Assert.assertEquals("bar", decl.getAlias()); Assert.assertNotNull(decl.getEPackage()); Assert.assertEquals("http://3", decl.getEPackage().getNsURI()); decl = decls.get(2); Assert.assertTrue((decl instanceof ReferencedMetamodel)); Assert.assertNotNull(decl.getEPackage()); Assert.assertEquals("http://www.eclipse.org/emf/2002/Ecore", decl.getEPackage().getNsURI()); Assert.assertEquals("ecore", decl.getAlias()); AbstractRule abstractRule = g.getRules().get(0); Assert.assertSame(decls.get(1), abstractRule.getType().getMetamodel()); }
Example #16
Source File: Xtext2EcoreTransformerTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public void setUp() throws Exception { super.setUp(); TestErrorAcceptor _testErrorAcceptor = new TestErrorAcceptor(); this.errorAcceptorMock = _testErrorAcceptor; this.with(XtextStandaloneSetup.class); }
Example #17
Source File: STRINGConverterTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public void setUp() throws Exception { super.setUp(); with(XtextStandaloneSetup.class); valueConverter = get(STRINGValueConverter.class); valueConverter.setRule(GrammarUtil.findRuleForName(getGrammarAccess().getGrammar(), "STRING")); }
Example #18
Source File: XtextContentAssistTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
public ISetup doGetSetup() { return new XtextStandaloneSetup() { @Override public Injector createInjector() { return Guice.createInjector(Modules2.mixin(new XtextRuntimeModule(),new XtextUIModuleInternal(Activator.getDefault()) { @Override public void configureContentProposalLabelProvider(com.google.inject.Binder binder) { binder.bind(ILabelProvider.class).annotatedWith(ContentProposalLabelProvider.class).to(DefaultEObjectLabelProvider.class); } }, new SharedStateModule())); } }; }
Example #19
Source File: XtextInjectorProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public Injector getInjector() { if (injector == null) { this.injector = new XtextStandaloneSetup().createInjectorAndDoEMFRegistration(); stateAfterInjectorCreation = GlobalRegistries.makeCopyOfGlobalState(); } return injector; }
Example #20
Source File: XtextLocationInFileProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public void setUp() throws Exception { super.setUp(); with(XtextStandaloneSetup.class); grammar = (Grammar) getModel(grammarText); locationInFileProvider = get(ILocationInFileProvider.class); }
Example #21
Source File: XtextInjectorProvider.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override public Injector getInjector() { if (injector == null) { this.injector = new XtextStandaloneSetup().createInjectorAndDoEMFRegistration(); stateAfterInjectorCreation = GlobalRegistries.makeCopyOfGlobalState(); } return injector; }
Example #22
Source File: MultiGenMMTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public void setUp() throws Exception { super.setUp(); with(new XtextStandaloneSetup()); with(new MultiGenMMTestLanguageStandaloneSetup()); }
Example #23
Source File: GrammarUtilTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testAllMetamodelDeclarations_01() throws Exception { this.with(XtextStandaloneSetup.class); StringConcatenation _builder = new StringConcatenation(); _builder.append("grammar foo with org.eclipse.xtext.common.Terminals"); _builder.newLine(); _builder.append("import \'http://www.eclipse.org/emf/2002/Ecore\' as ecore"); _builder.newLine(); _builder.append("generate g \'http://3\' as ecore"); _builder.newLine(); _builder.append("startrule returns ecore::startrule: name=ID;"); _builder.newLine(); String model = _builder.toString(); Resource r = this.getResourceFromString(model); EObject _get = r.getContents().get(0); Grammar g = ((Grammar) _get); List<AbstractMetamodelDeclaration> decls = GrammarUtil.allMetamodelDeclarations(g); Assert.assertEquals(2, decls.size()); AbstractMetamodelDeclaration decl = decls.get(0); Assert.assertTrue((decl instanceof ReferencedMetamodel)); Assert.assertNotNull(decl.getEPackage()); Assert.assertEquals("http://www.eclipse.org/emf/2002/Ecore", decl.getEPackage().getNsURI()); Assert.assertEquals("ecore", decl.getAlias()); decl = decls.get(1); Assert.assertEquals("ecore", decl.getAlias()); Assert.assertNotNull(decl.getEPackage()); Assert.assertEquals("http://3", decl.getEPackage().getNsURI()); }
Example #24
Source File: AbstractXtextInspectorTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public void setUp() throws Exception { super.setUp(); with(XtextStandaloneSetup.class); warnings = Lists.newArrayList(); errors = Lists.newArrayList(); infos = Lists.newArrayList(); }
Example #25
Source File: GrammarUtilTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testAllRules() throws Exception { this.with(XtextStandaloneSetup.class); StringConcatenation _builder = new StringConcatenation(); _builder.append("grammar myLang with org.eclipse.xtext.common.Terminals"); _builder.newLine(); _builder.append("generate g \'http://1\'"); _builder.newLine(); _builder.append("Rule:"); _builder.newLine(); _builder.append("\t"); _builder.append("name=super::STRING;"); _builder.newLine(); _builder.append("terminal STRING: \'\"\';"); _builder.newLine(); String model = _builder.toString(); final XtextResource r = this.getResourceFromString(model); EObject _get = r.getContents().get(0); final Grammar grammar = ((Grammar) _get); final List<AbstractRule> allRules = GrammarUtil.allRules(grammar); final Function1<AbstractRule, String> _function = (AbstractRule it) -> { return it.getName(); }; Assert.assertEquals( Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("Rule", "STRING", "ID", "INT", "STRING", "ML_COMMENT", "SL_COMMENT", "WS", "ANY_OTHER")).toString(), ListExtensions.<AbstractRule, String>map(allRules, _function).toString()); }
Example #26
Source File: GrammarUtilTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testAllMetamodelDeclarations_03() throws Exception { this.with(XtextStandaloneSetup.class); StringConcatenation _builder = new StringConcatenation(); _builder.append("grammar foo with org.eclipse.xtext.common.Terminals"); _builder.newLine(); _builder.append("generate g \'http://3\' as bar"); _builder.newLine(); _builder.append("import \'http://www.eclipse.org/emf/2002/Ecore\' as bar"); _builder.newLine(); _builder.append("startrule returns bar::startrule: name=ID;"); _builder.newLine(); String model = _builder.toString(); Resource r = this.getResourceFromString(model); EObject _get = r.getContents().get(0); Grammar g = ((Grammar) _get); List<AbstractMetamodelDeclaration> decls = GrammarUtil.allMetamodelDeclarations(g); Assert.assertEquals(3, decls.size()); AbstractMetamodelDeclaration decl = decls.get(0); Assert.assertTrue((decl instanceof GeneratedMetamodel)); Assert.assertEquals("bar", decl.getAlias()); Assert.assertNotNull(decl.getEPackage()); Assert.assertEquals("http://3", decl.getEPackage().getNsURI()); decl = decls.get(1); Assert.assertTrue((decl instanceof ReferencedMetamodel)); Assert.assertNotNull(decl.getEPackage()); Assert.assertEquals("http://www.eclipse.org/emf/2002/Ecore", decl.getEPackage().getNsURI()); Assert.assertEquals("bar", decl.getAlias()); decl = decls.get(2); Assert.assertTrue((decl instanceof ReferencedMetamodel)); Assert.assertNotNull(decl.getEPackage()); Assert.assertEquals("http://www.eclipse.org/emf/2002/Ecore", decl.getEPackage().getNsURI()); Assert.assertEquals("ecore", decl.getAlias()); AbstractRule abstractRule = g.getRules().get(0); Assert.assertSame(decls.get(0), abstractRule.getType().getMetamodel()); }
Example #27
Source File: XtextScopingTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public void setUp() throws Exception { super.setUp(); with(XtextStandaloneSetup.class); XtextResourceSet resourceSet = get(XtextResourceSet.class); resourceSet.setClasspathURIContext(getClass().getClassLoader()); Resource resource = resourceSet.getResource( URI.createURI("classpath:/org/eclipse/xtext/grammarinheritance/ConcreteTestLanguage.xtext"), true); grammar = (Grammar) resource.getContents().get(0); }
Example #28
Source File: PartialParserTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testReparseEmptyString() throws Exception { with(XtextStandaloneSetup.class); String model = "grammar org.eclipse.Bug273209_01 with org.eclipse.xtext.common.Terminals \n" + "generate testLanguage 'http://www.eclipse.org/2009/tmf/xtext/partialParsing/Bug273209/3'\n" + "Model : \n" + " ('model' ':' name=ID ';'*);"; XtextResource resource = getResourceFromString(model); assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty()); resource.update(0, model.length(), ""); assertTrue(resource.getContents().isEmpty()); }
Example #29
Source File: ExternalContentSupportTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public void setUp() throws Exception { super.setUp(); with(XtextStandaloneSetup.class); uriToContent = Maps.newHashMap(); support = new ExternalContentSupport(); }
Example #30
Source File: MetamodelTransformationErrorTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public void setUp() throws Exception { super.setUp(); with(XtextStandaloneSetup.class); model = "grammar datatypetests with org.eclipse.xtext.common.Terminals\n" + "import 'http://www.eclipse.org/emf/2002/Ecore' as ecore\n" + "generate metamodel 'http://fooo'\n" + "Start:\n" + " id=ValidId id2=ValidId2 failure1=FailureId failure2=Failure2;\n" + "ValidId returns ecore::EString: ID '.' ID;\n" + "ValidId2 returns ecore::EString: ID '.' ValidId;\n" + "FailureId returns ecore::EString: name=ID;\n" + "Failure2 returns ecore::EString: name=Start;"; resource = getResourceFromStringAndExpect(model, 2); grammar = (Grammar) resource.getContents().get(0); transformer = new Xtext2EcoreTransformer(grammar); errorAcceptor = new TestErrorAcceptor(); transformer.setErrorAcceptor(errorAcceptor); }