|Re: Saving java file fires two IResourceChangeEvent [message #1694819 is a reply to message #1694776]
||Fri, 08 May 2015 08:20
| Ed Merks
Registered: July 2009
On 07/05/2015 9:17 PM, Simon Laffoy wrote:
> Everytime a .java file is saved in the workspace I want to do some
> processing of the changes in it. To do this I have a
> WorkspaceChangeListener which receives IResourceChangeEvents. This all
> works fine, except that the processing is performed twice for every
> saved .java file.
Probably it would be better to use a Save Participant.
> Two ResourceChangeEvents are received. The first is just for the saved
> .java file and is as I would expect. The delta tree would look like
Such a save will kick off a build, and that of course produces many
> The second ResourceChangeEvent concerns the corresponding newly
> compiled and built .class file.
Yes, as expected.
> (I have Automatic Build turned on. if I turn this off the second
> ResourceChangeEvent is merely delayed, not eliminated).
Eventually you'll want to build it and get those deltas.
> The delta for this second event has two branches below the project
> level. The tree would look like:
> I would also like to know if there are any situations in which the
> code changes to the .java file (the first event) and the .class file
> compilation (the second event) are handled by a single event? Is this
Deltas are often groups when the things making the changes using a
workspace modify operation...
> If the answer is to this question is 'no', then I can just ignore any
> events with a delta including a .class file.
A save participant would be a better approach, especially if you intend
to further modify the workspace and cause more deltas...
> Thanks in advance.
|Re: Saving java file fires two IResourceChangeEvent [message #1694826 is a reply to message #1694819]
||Fri, 08 May 2015 09:09
| Simon Laffoy
Registered: January 2015
Thanks for the response Ed,|
I just came up with my own solution. The flags of the IResourceDelta class tell me if the change involves the content of the file or not.
As we don't intend to trigger further workspace changes after having received the change events, I feel it would not be necessary to use the save participants, but I appreciate that you drew my attention to them (I hadn't heard of them before).
[Updated on: Fri, 08 May 2015 09:10]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.02702 seconds