Changes to a java file can be known by method org.eclipse.jdt.core.JavaCore.addElementChangedListener(IElementChangedListener)
.
There’s this scenario:
- primitive code:
public class X {
}
- Add a new field
a
public class X {
int a ;
}
-
Receives an event
POST_RECONCILE
saying that a new elementa
has been added. -
Add a new field
b
public class X {
int a ;
int b ;
}
-
Receives an event
POST_RECONCILE
saying that a new elementb
has been added. -
Remove the field
b
public class X {
int a ;
}
-
Receives an event
POST_RECONCILE
saying that a new elementb
has been removed. -
Save this file.
-
Receives an event
POST_CHANGE
saying that the elementX
has been changed.
My intention is to know what has changed in that file between two save
operations, as in the above scenario where element a
is added, not necessary to know that element b
.
However, this doesn’t seem to be possible if I’m only listening to the POST_CHANGE
event, and if I’m also listening to the POST_RECONCILE
event, it seems to require a lot of checking and judging on my part.
Is there a simpler way to do this?