XText - Cannot load model in standalone setup

143 views
Skip to first unread message

Cuong Tran

unread,
Sep 8, 2014, 8:32:50 AM9/8/14
to spray...@googlegroups.com
Hi Joerg and everyone,

I have defined a language to define conditional expressions using XText. The generated editor works fine that should indicate the parser and other components are valid. I want to use ONLY the parser in my scenario and I followed the instructions at http://wiki.eclipse.org/Xtext/FAQ#Why_do_I_get_compilation_errors_when_trying_to_import_an_existing_Xtext_grammar_using_the_with_statement.3F

Here is my code of Unit test (written in Xtend):

import uk.ac.man.xman.dsl.ConditionDSLStandaloneSetup

@RunWith(XtextRunner)

class ParsingText {

       @Test

       def void parseSampleText () {

               new StandaloneSetup().setPlatformUri("../");


                val injector = new ConditionDSLStandaloneSetup().createInjectorAndDoEMFRegistration();


                val resourceSet = injector.getInstance(typeof(XtextResourceSet));


                resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);


                val uri  = URI.createURI("dummy:/example.cdsl")


                val resource = resourceSet.createResource(uri); //ERROR happened here


                val in = new ByteArrayInputStream("((id1 == 1) && (id2 == 2))".getBytes());


                resource.load(in, resourceSet.getLoadOptions());

       }

}




However, I faced an exception:
com.google.inject.ProvisionException: Guice provision errors:

1) Error injecting constructor, org.eclipse.emf.common.util.WrappedException: java.lang.ArrayIndexOutOfBoundsException: 3
  at org.eclipse.xtext.common.services.TerminalsGrammarAccess.<init>(Unknown Source)
  at org.eclipse.xtext.common.services.TerminalsGrammarAccess.class(Unknown Source)
  while locating org.eclipse.xtext.common.services.TerminalsGrammarAccess
    for parameter 1 at uk.ac.man.xman.dsl.services.ConditionDSLGrammarAccess.<init>(Unknown Source)
  at uk.ac.man.xman.dsl.services.ConditionDSLGrammarAccess.class(Unknown Source)
  while locating uk.ac.man.xman.dsl.services.ConditionDSLGrammarAccess
  while locating org.eclipse.xtext.IGrammarAccess
    for field at org.eclipse.xtext.linking.lazy.LazyLinker.grammarAccess(Unknown Source)
  while locating org.eclipse.xtext.linking.lazy.LazyLinker
  while locating org.eclipse.xtext.linking.ILinker
    for field at org.eclipse.xtext.resource.XtextResource.linker(Unknown Source)
  while locating org.eclipse.xtext.linking.lazy.LazyLinkingResource
  while locating org.eclipse.xtext.resource.XtextResource
Caused by: org.eclipse.emf.common.util.WrappedException: java.lang.ArrayIndexOutOfBoundsException: 3
at org.eclipse.xtext.parser.BaseEPackageAccess.loadResource(BaseEPackageAccess.java:57)
at org.eclipse.xtext.parser.BaseEPackageAccess.loadGrammarFile(BaseEPackageAccess.java:44)
at org.eclipse.xtext.service.GrammarProvider.getGrammar(GrammarProvider.java:60)
at org.eclipse.xtext.common.services.TerminalsGrammarAccess.internalFindGrammar(TerminalsGrammarAccess.java:37)
at org.eclipse.xtext.common.services.TerminalsGrammarAccess.<init>(TerminalsGrammarAccess.java:33)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
....

Any idea why this happened? Your help is appreciated.




Reply all
Reply to author
Forward
0 new messages