Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext validation(Getting org.eclipse.xtext.validation.Issue from resource)
Xtext validation [message #1767699] Mon, 10 July 2017 06:42 Go to next message
Virag Purnam is currently offline Virag PurnamFriend
Messages: 142
Registered: June 2014
Senior Member
I am calling EXPENSIVE check programmatically on resource.
Side effect is that, I loose all the error, warning and info markers, which are set through FAST and NORMAL checks.

Is there a way to get all the resource issues.
I will collect the issues and then I will call expensive check on resource.
Re: Xtext validation [message #1767700 is a reply to message #1767699] Mon, 10 July 2017 06:48 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Have a look at

org.eclipse.xtext.ui.editor.handler.ValidateActionHandler

the mode you have to use is CheckMode.ALL


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext validation [message #1767702 is a reply to message #1767700] Mon, 10 July 2017 07:16 Go to previous messageGo to next message
Virag Purnam is currently offline Virag PurnamFriend
Messages: 142
Registered: June 2014
Senior Member
First of all thanks Mr. DietrichFriend for reply.

Actually, In my project, Fast and Normal checks are done with editor touch and save.
In my project, I need to call cross reference checks through Expensive check. So I want to retrieve all the issues in resource before calling expensive check.

In my project using CheckMode.ALL callls the validation two times. Once when I save resource and second time at the place where i am calling expensive check.
Re: Xtext validation [message #1767704 is a reply to message #1767702] Mon, 10 July 2017 07:21 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
if you really want to change this i have no idea
hmmm then you should look how removes the markers/annotations and change that code


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext validation [message #1768120 is a reply to message #1767704] Thu, 13 July 2017 18:16 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
The following could work:
1) create your own subclass of MarkerIssueProcessor and in processIssues pass only 'MarkerTypes.EXPENSIVE_VALIDATION' to the constructor of the AddMarkersOperation
2) Use this subclass in your own subclass of ValidateActionHandler
3) Bind your handler instead of the default.


---
Get professional support from the Xtext committers at www.typefox.io
Re: Xtext validation [message #1769646 is a reply to message #1768120] Wed, 02 August 2017 11:30 Go to previous messageGo to next message
Virag Purnam is currently offline Virag PurnamFriend
Messages: 142
Registered: June 2014
Senior Member
Thanks Mr. Koehnlein for reply.
I will try the approach suggested by you.
I will update here the result.

[Updated on: Wed, 02 August 2017 11:31]

Report message to a moderator

Re: Xtext validation [message #1770225 is a reply to message #1769646] Wed, 09 August 2017 08:37 Go to previous message
Virag Purnam is currently offline Virag PurnamFriend
Messages: 142
Registered: June 2014
Senior Member
List<Issue> projectIssues = new ArrayList<>();
for (Resource resource : loadAllResourcesFromBuildContext(context, delta)) {
List<Issue> resourceIssues = crossReferenceValidator.validate(resource, CheckMode.EXPENSIVE_ONLY,
CancelIndicator.NullImpl);
projectIssues.addAll(resourceIssues);
}


public List<Issue> validate(Resource resource, CheckMode mode, CancelIndicator mon) throws OperationCanceledError {
List<Issue> issues = new ArrayList<>();
EcoreUtil.resolveAll(resource);
issues.addAll(collectNormalAndFastIssues(resource));

LOGGER.info("Validating cross references...");

issues.addAll(super.validate(resource, mode, mon));
return issues;
}

I know this is not efficient as Normal and Fast checks gets called twice. But it works as of now. I am finding better approach also.
Previous Topic:Implicit reference to an EObject
Next Topic:Expression Parser
Goto Forum:
  


Current Time: Thu Apr 25 06:22:18 GMT 2024

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

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

Back to the top