|
Re: Saving java file fires two IResourceChangeEvent [message #1694819 is a reply to message #1694776] |
Fri, 08 May 2015 08:20 |
Ed Merks Messages: 33141 Registered: July 2009 |
Senior Member |
|
|
Simon,
Comments below.
On 07/05/2015 9:17 PM, Simon Laffoy wrote:
> HI,
>
> 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
>
> /JavaProject/src/pkg/MyClass.java
Such a save will kick off a build, and that of course produces many
additional files.
>
> 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:
>
> ResourceDelta(/JavaProject/src/pkg/MyClass.java
> ............................................../bin/pkg/MyClass.class
>
> 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
> possible?
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.
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Saving java file fires two IResourceChangeEvent [message #1694826 is a reply to message #1694819] |
Fri, 08 May 2015 09:09 |
Simon Laffoy Messages: 19 Registered: January 2015 |
Junior Member |
|
|
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).
Thanks again
Simon
[Updated on: Fri, 08 May 2015 09:10] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.02934 seconds