On Tue, May 18, 2010 at 1:04 PM, lee youpeng <
loveyoupeng@xxxxxxxxx> wrote:
> hi,
> I am new to XText. I try to use the parser in standalone mode, however, it
> do not resole imported files automatically, how to make the parser to parser
> the imported files?
> using the Xtext entity demo as an example:
> // grammar
> Model :
> (imports+=Import)*
> (elements+=Type)*;
>
> Import :
> 'import' importURI=STRING;
>
> Type:
> SimpleType | Entity;
>
> SimpleType:
> 'type' name=ID;
>
> Entity :
> 'entity' name=ID ('extends' extends=[Entity])? '{'
> properties+=Property*
> '}';
> ......
>
>
> DSL files:
>
> // file a.dsl
> entity A{}....
>
> // file b.dsl
> import "a.dsl"
>
> entity B extends A{}
>
> // standalone code
> new org.eclipse.emf.mwe.utils.StandaloneSetup().setPlatformUri("../");
> Injector injector = new
> MyDslStandaloneSetup().createInjectorAndDoEMFRegistration();
> XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class);
> resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
> Resource resource = resourceSet.getResource(
> URI.createURI("b.dsl"), true);
> Model model = (Model) resource.getContents().get(0);
> // it do not resolve a.dsl here and get null pointer error.
>
>