Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext standalone validation issue
Xtext standalone validation issue [message #1744763] Fri, 30 September 2016 05:56 Go to next message
Sam Patterson is currently offline Sam PattersonFriend
Messages: 18
Registered: June 2016
Junior Member
Hello,

I'm having an issue validating multiple model files of the same type. I'm not sure if this is the correct way, but what I'm currently doing is create a single resource set and using the createResource method when there's a new model that needs to be validated.

The problem I'm having is that I will validate a model that I know is correct and there won't be any issues, but when I go validate a model I know has errors it will say there are no issues when I know for a fact there is (this is all during the same instance of the application and using the same resource set within a standalone program).

I was able to resolve the issue by creating a separate resource set for each resource, but isn't the whole point of a resource set to contain multiple resources? This issue is quite puzzling, if anyone has any suggestions please let me know.

Thank you.
Re: Xtext standalone validation issue [message #1744765 is a reply to message #1744763] Fri, 30 September 2016 06:10 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

Hi Sam,

of course it is normal to put several resouces in a ResourceSet and validate them. Without having one ResourceSet it would not be possible to do linking across multiple resources. When you say you have a standalone scenario then have a look at MWE2 workflows that use the org.eclipse.xtext.mwe.Reader component. This is actually doing rather the same as you want to achieve: It reads a set of resources into a ResourceSet and validates them with an IResourceValidator.

Kind regards,
~Karsten
Re: Xtext standalone validation issue [message #1744826 is a reply to message #1744765] Fri, 30 September 2016 15:15 Go to previous messageGo to next message
Sam Patterson is currently offline Sam PattersonFriend
Messages: 18
Registered: June 2016
Junior Member
The problem is the models need to be validated individually, they don't rely on other models so no linking is required and they aren't being validated at the same time. The application I'm building is used to develop models and then validate them etc. using a GUI, so the user may create model A and validate it and then decide to create model B and validate it and that's where the issues lies, if model A is validated then I receive the expected result, but once I then go to validate a different model I don't get the results I expect. To sum it up, the very first model that is validated returns the expected result, every model after does not. It must be something to do with the resource set because as I said in my original post, creating a new resource set each time fixed the issue but it doesn't make sense of course.
Re: Xtext standalone validation issue [message #1744876 is a reply to message #1744826] Sat, 01 October 2016 07:57 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Can you show the code of what you are actually doing

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext standalone validation issue [message #1744894 is a reply to message #1744876] Sat, 01 October 2016 19:40 Go to previous messageGo to next message
Sam Patterson is currently offline Sam PattersonFriend
Messages: 18
Registered: June 2016
Junior Member
Sure.

I initially create the injector using the createInjectorAndDoEMFRegistration method. Once I have that I create the ResourceSet and IResourceValidator using the injector to get an instance of each.

So when it comes to actually validating a new model, I use the following method.

public List<Issue> validateModel(String modelName, String model){
Resource modelResource = resourceSet.createResource(URI.createURI(modelName + ".rsl"));
try {
modelResource.load(new StringInputStream(model), null);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return validator.validate(modelResource, CheckMode.ALL, CancelIndicator.NullImpl);
}

I've seemed to deduce that the moment a model is validated successfully and contains no errors, subsequent models (regardless of whether or not they contain errors in the language) will always return an empty array of issues.
Re: Xtext standalone validation issue [message #1744896 is a reply to message #1744894] Sat, 01 October 2016 20:40 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Without a reproducing example e.g. Based on the hello world grammar incarnation help you

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Xtext lexer ambiguity
Next Topic:Parse part of file and ignore anything else
Goto Forum:
  


Current Time: Thu Apr 25 01:54:47 GMT 2024

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

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

Back to the top