Bourbon_7
Bourbon_7

Reputation: 351

How to know the difference between a java file on fields and methods under two save operations?

Changes to a java file can be known by method org.eclipse.jdt.core.JavaCore.addElementChangedListener(IElementChangedListener).

There's this scenario:

  1. primitive code:
public class X {

}
  1. Add a new field a
public class X {
    int a ;
}
  1. Receives an event POST_RECONCILE saying that a new element a has been added.

  2. Add a new field b

public class X {
    int a ;
    int b ;
}
  1. Receives an event POST_RECONCILE saying that a new element b has been added.

  2. Remove the field b

public class X {
    int a ;
}
  1. Receives an event POST_RECONCILE saying that a new element b has been removed.

  2. Save this file.

  3. Receives an event POST_CHANGE saying that the element X 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?

Upvotes: 0

Views: 26

Answers (0)

Related Questions