XtextLinkingDiagnostic Error while loading xtext model [message #1791009] |
Thu, 21 June 2018 07:35  |
Eclipse User |
|
|
|
Hi,
I'm loading a xtext model in an java application.
There are no errors if a load a model with no further reference to other models.
But if I load a xtext model that has a reference to another model I get following error message:
XtextLinkingDiagnostic: null:27 Couldn't resolve reference to <[Referenced Element Type]> '[Reference Element Name]'. (I replaced the real names of Element and Element Type)
This is the way I load the model:
public static void main(String[] args) {
Injector injector = new MyDslStandaloneSetup().createInjectorAndDoEMFRegistration();
new MySecondDslStandaloneSetup().register(injector);
XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class);
resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
File file = new File("/path/to/model.mdl");
Resource resource = resourceSet.getResource(URI.createURI(file.toURI().toString()), true);
for(Diagnostic error : resource.getErrors() )
System.err.println(error.toString());
Just to make it clear: The application does not throw any exception. The error is obtained from the resource (see for-loop). Also the model itself is loaded properly, only the references to the other model are missing.
I think the problem is the way, I import the referenced model (this is the first line of model.mdl):
IMPORT "my_second_model.mdl2"
Both of the two models are in the same folder. Do I have to write something like IMPORT "/platform..."?
Currently, even if i import a non existing model, there are no further errors. It seems like the import statement is just ignored while loading the model like this (the models itself are working properly, references are resolved while editing the model).
|
|
|
|
|
|
Re: XtextLinkingDiagnostic Error while loading xtext model [message #1791019 is a reply to message #1791012] |
Thu, 21 June 2018 09:20  |
Eclipse User |
|
|
|
Resource resource = resourceSet.getResource(URI.createURI(file.toURI().toString()), true);
Resource resource2 = resourceSet.getResource(URI.createURI(file2.toURI().toString()), true);
Resource resource3 = resourceSet.getResource(URI.createURI(file3.toURI().toString()), true);
Resource resource4 = resourceSet.getResource(URI.createURI(file4.toURI().toString()), true);
Resource resource5 = resourceSet.getResource(URI.createURI(file5.toURI().toString()), true);
|
|
|
Powered by
FUDForum. Page generated in 0.03675 seconds