Skip to main content



      Home
Home » Modeling » TMF (Xtext) » XtextLinkingDiagnostic Error while loading xtext model
XtextLinkingDiagnostic Error while loading xtext model [message #1791009] Thu, 21 June 2018 07:35 Go to next message
Eclipse UserFriend
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 #1791010 is a reply to message #1791009] Thu, 21 June 2018 07:40 Go to previous messageGo to next message
Eclipse UserFriend
there is no import traversal => you need to populate the resourceset with all resources upfront.
Re: XtextLinkingDiagnostic Error while loading xtext model [message #1791011 is a reply to message #1791010] Thu, 21 June 2018 07:45 Go to previous messageGo to next message
Eclipse UserFriend
and you should remove the resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
and do a manual ecoreuril.resolveall after loading all resources
Re: XtextLinkingDiagnostic Error while loading xtext model [message #1791012 is a reply to message #1791010] Thu, 21 June 2018 07:50 Go to previous messageGo to next message
Eclipse UserFriend
Thanks very much.
I do not clearly understand, how to do that.
Can you show some lines of code?
Re: XtextLinkingDiagnostic Error while loading xtext model [message #1791019 is a reply to message #1791012] Thu, 21 June 2018 09:20 Go to previous message
Eclipse UserFriend
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);
Previous Topic:Syntax Error in lambda implementing Xtext quickfixes
Next Topic:Formatting multiple parser rules within curly brackets
Goto Forum:
  


Current Time: Tue May 13 11:14:08 EDT 2025

Powered by FUDForum. Page generated in 0.03675 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top