[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [xtext-dev] how to resolve import files when using in standalone mode
|
This mailing-list is about the development of XText, for help about
how to use it you can ask questions at:
http://www.eclipse.org/forums/index.php?t=thread&frm_id=27&,
Federico
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.
>
>
> _______________________________________________
> xtext-dev mailing list
> xtext-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/xtext-dev
>
>
--
Website at http://www.federico-tomassetti.it