Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Which IValidationIssueProcessor should I use?
Which IValidationIssueProcessor should I use? [message #991156] Mon, 17 December 2012 15:04 Go to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
I need to programatically trigger re-validation of all xtext resources in the workspace / in a project (after changing warning severities via preferences).

I took inspiration from ValidateActionHandler and ValidationJob, but then I got confused which IValidationIssueProcessor I should use, since when simply copying code from ValidateActionHandler the error markers in the editor where no fully updated. Removing markers seemed to work, adding markers created the gray variants signaling some stale state.

The only solution I found was to use *both* an AnnotationIssueProcessor (if an editor can be found for a given file) *and* a MarkerIssueProcessor.

If I see correctly, the AnnotationIssueProcessor is responsible for handling markers in the editor and the MarkerIssueProcessor provides markers for the Problems view, is this correct?

If so, could it be that ValidateActionHandler is actually buggy in this respect? It prefers a MarkerIssueProcessor if an IResource could be found, missing to fully update markers in the editor.

thanks,
Stephan

[Updated on: Mon, 17 December 2012 16:38]

Report message to a moderator

Re: Which IValidationIssueProcessor should I use? [message #991255 is a reply to message #991156] Tue, 18 December 2012 07:02 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Stephan,

you should consider to trigger the Xtext builder for the affected
projects instead of validating everything by yourself.

Your conclusion about the IValidationIssueProcessors is correct: the
AnnotationIP will update annotations whereas the MarkerIP handles the
markers on IResources.

The ValidateActionHandler should update the annotations and markers if
you do not change the settings for the validation inbetween. Otherwise
there is a bug somewhere.

Regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 17.12.12 16:04, schrieb Stephan Herrmann:
> I need to manually trigger re-validation of all xtext resources in the
> workspace / in a project (after changing warning severities via
> preferences).
>
> I took inspiration from ValidateActionHandler and ValidationJob, but
> then I got confused which IValidationIssueProcessor I should use, since
> when simply copying code from ValidateActionHandler the error markers in
> the editor where no fully updated. Removing markers seemed to work,
> adding markers created the gray variants signaling some stale state.
>
> The only solution I found was to use *both* an AnnotationIssueProcessor
> (if an editor can be found for a given file) *and* a MarkerIssueProcessor.
>
> If I see correctly, the AnnotationIssueProcessor is responsible for
> handling markers in the editor and the MarkerIssueProcessor provides
> markers for the Problems view, is this correct?
>
> If so, could it be that ValidateActionHandler is actually buggy in this
> respect? It prefers a MarkerIssueProcessor if an IResource could be
> found, missing to fully update markers in the editor.
>
> thanks,
> Stephan
>
Re: Which IValidationIssueProcessor should I use? [message #991352 is a reply to message #991255] Tue, 18 December 2012 16:45 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Hi Sebastian,

Sebastian Zarnekow wrote on Tue, 18 December 2012 08:02

you should consider to trigger the Xtext builder for the affected
projects instead of validating everything by yourself.


I did consider that option, and decided against because
- I don't want to trigger any generation, just validation
- I didn't find an example demonstrating a build is actually easier than triggering validation for all relevant resources Smile

Quote:

Your conclusion about the IValidationIssueProcessors is correct: the
AnnotationIP will update annotations whereas the MarkerIP handles the
markers on IResources.


Sorry for being dense: What exactly is the Xtext editor showing? Annotations and/or Markers?

Quote:

The ValidateActionHandler should update the annotations and markers if
you do not change the settings for the validation inbetween. Otherwise
there is a bug somewhere.


Well, the code in ValidateActionHandler shows that exactly one of the issue processors is used, never both.

best,
Stephan

Re: Which IValidationIssueProcessor should I use? [message #992301 is a reply to message #991352] Fri, 21 December 2012 10:08 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Stephan,

see inline.

Am 18.12.12 17:45, schrieb Stephan Herrmann:
> Hi Sebastian,
>
> Sebastian Zarnekow wrote on Tue, 18 December 2012 08:02
>> you should consider to trigger the Xtext builder for the affected
>> projects instead of validating everything by yourself.
>
>
> I did consider that option, and decided against because
> - I don't want to trigger any generation, just validation

Do think there's an issue with that? Is the generation too expensive? If
a generator produces identical files, it'll usually skip those so no
IResource changes will be propagated.

> - I didn't find an example demonstrating a build is actually easier than
> triggering validation for all relevant resources :)
>

IProject.build(int, String, Map<String, String>, IProgressMonitor)
should do the trick. You may even want to consider using the
org.eclipse.xtext.builder.impl.BuildScheduler.scheduleBuildIfNecessary(Iterable<IProject>,
IBuildFlag...) which takes care of repeatedly scheduled builds for the
very same projects.

> Quote:
>> Your conclusion about the IValidationIssueProcessors is correct: the
>> AnnotationIP will update annotations whereas the MarkerIP handles the
>> markers on IResources.
>
>
> Sorry for being dense: What exactly is the Xtext editor showing?
> Annotations and/or Markers?
>

The editor's always showing annotations. Markers are converted to
annotations. If you edit the file to fix such an error, the annotations
will be updated, markers stay the same until you save the thing.

> Quote:
>> The ValidateActionHandler should update the annotations and markers if
>> you do not change the settings for the validation inbetween. Otherwise
>> there is a bug somewhere.
>
>
> Well, the code in ValidateActionHandler shows that exactly one of the
> issue processors is used, never both.

You are right, only one of the processors is used. The annotation model
listens to changes on the IResource to update the annotations as soon as
the markers change
(ResourceMarkerAnnotationModel.update(IMarkerDelta[]). Which implies
that existing annotations that do not reflect that state on disk will
not be updated if you trigger validation. Actually markers will be
persisted that do not match the content of the file on disk. This is a
bug. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=397065

>
> best,
> Stephan
>
>
Re: Which IValidationIssueProcessor should I use? [message #992329 is a reply to message #992301] Fri, 21 December 2012 11:14 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Hi Sebastian,

Sebastian Zarnekow wrote on Fri, 21 December 2012 11:08

>> you should consider to trigger the Xtext builder for the affected
>> projects instead of validating everything by yourself.
>
> I did consider that option, and decided against because
> - I don't want to trigger any generation, just validation

Do think there's an issue with that? Is the generation too expensive?


Well, generation isn't for free Smile. It may be acceptable even with 100 DLS files, but I'm sure once we approach 1000 files the difference will hurt. From work with large workspaces we know that "build all" should be avoided to the extent possible, right?

OTOH, your suggestion to do more work than necessary must have a reason. If it's code simplicity, I don't mind the lines I had to implement to trigger validation only. Is building a project optimized so that, e.g., resources are read more efficiently than when I trigger it myself?

Quote:

IProject.build(int, String, Map<String, String>, IProgressMonitor)
should do the trick.


Thanks, I should've known.
But wait: to trigger re-validation without source changes I'd need to pass FULL_BUILD, and then, if the project also has other builders, they will do a full build, too. Not a good idea Smile

Quote:
You may even want to consider using the
org.eclipse.xtext.builder.impl.BuildScheduler.scheduleBuildIfNecessary(Iterable<IProject>,
IBuildFlag...) which takes care of repeatedly scheduled builds for the
very same projects.

Cool, I'll take a look into that one.
Do you consider that class API (I see a suspecious "impl" in the package name)?

Quote:

See https://bugs.eclipse.org/bugs/show_bug.cgi?id=397065


Thanks for identifying the root issue. I've subscribed to that bug so I can update my implementation, once that bug is addressed.

thanks,
Stephan
Re: Which IValidationIssueProcessor should I use? [message #992536 is a reply to message #992329] Fri, 21 December 2012 22:31 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Stephan,

please find my comments inline.

Am 21.12.12 12:14, schrieb Stephan Herrmann:
> Hi Sebastian,
>
> Sebastian Zarnekow wrote on Fri, 21 December 2012 11:08
>> >> you should consider to trigger the Xtext builder for the affected
>> >> projects instead of validating everything by yourself.
>> >
>> > I did consider that option, and decided against because
>> > - I don't want to trigger any generation, just validation
>>
>> Do think there's an issue with that? Is the generation too expensive?
>
>
> Well, generation isn't for free :). It may be acceptable even with 100
> DLS files, but I'm sure once we approach 1000 files the difference will
> hurt. From work with large workspaces we know that "build all" should be
> avoided to the extent possible, right?

Agreed.

>
> OTOH, your suggestion to do more work than necessary must have a reason.
> If it's code simplicity, I don't mind the lines I had to implement to
> trigger validation only. Is building a project optimized so that, e.g.,
> resources are read more efficiently than when I trigger it myself?

Depending on the size of your resources, loading all of them into memory
may be problematic. The builder uses a clustering strategy to reduce the
max amount of memory that is necessary. In other regards, that one is
not optimized, no.

>
> Quote:
>> IProject.build(int, String, Map<String, String>, IProgressMonitor)
>> should do the trick.
>
>
> Thanks, I should've known. But wait: to trigger re-validation without
> source changes I'd need to pass FULL_BUILD, and then, if the project
> also has other builders, they will do a full build, too. Not a good idea :)
>

Didn't know that. I thought other builders would not be triggered if a
concrete builder ID is passed.

> Quote:
>> You may even want to consider using the
>> org.eclipse.xtext.builder.impl.BuildScheduler.scheduleBuildIfNecessary(Iterable<IProject>,
>> IBuildFlag...) which takes care of repeatedly scheduled builds for the
>> very same projects.
>
> Cool, I'll take a look into that one. Do you consider that class API (I
> see a suspecious "impl" in the package name)?

API in a sense that we are not inclined to change it right now: yes. In
a sense that it is carved in stone: no. Anyway, all the packages from
the builder bundle are marked as internal.

>
> Quote:
>> See https://bugs.eclipse.org/bugs/show_bug.cgi?id=397065
>
>
> Thanks for identifying the root issue. I've subscribed to that bug so I
> can update my implementation, once that bug is addressed.

Since we are working on customizable severities as part of the
validation API, it's quite likely that we'll come up with a reasonable
solution to that problem.

I wish you nice holidays,
Sebastian

>
> thanks,
> Stephan


--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: Which IValidationIssueProcessor should I use? [message #992545 is a reply to message #992536] Fri, 21 December 2012 23:06 Go to previous message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Sebastian Zarnekow wrote on Fri, 21 December 2012 23:31

> [..] But wait: to trigger re-validation without
> source changes I'd need to pass FULL_BUILD, and then, if the project
> also has other builders, they will do a full build, too. Not a good idea Smile
>

Didn't know that. I thought other builders would not be triggered if a
concrete builder ID is passed.


Oops, you're right, I missed the builderName part in the API you mentioned.
Sorry for unfounded claims.
Stephan
Previous Topic:Intermittent Validation Job failures on editor close
Next Topic:How to get rid of obsolete validation errors?
Goto Forum:
  


Current Time: Fri Apr 19 07:04:31 GMT 2024

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

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

Back to the top