Bug 100267 - Fine-grained IElementChangedListener notification on content change that is not a structural change
Summary: Fine-grained IElementChangedListener notification on content change that is n...
Status: REOPENED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0.1   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Jay Arthanareeswaran CLA
QA Contact:
URL:
Whiteboard:
Keywords: api
Depends on:
Blocks:
 
Reported: 2005-06-15 14:42 EDT by Dave Ruest CLA
Modified: 2011-12-02 00:10 EST (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dave Ruest CLA 2005-06-15 14:42:19 EDT
Several types of changes do not notify the listener of the specific element 
that was modified. The listener only receives the modified class. Our plugin 
provides warning markers when elements with @generated have been modified. 
Without the specific element, we can only generate a warning for the class, and 
not also for the element as we would prefer.

The cases where we would like to receive the specific element modified:

1) modifying field initializer
2) modifying method body
3) modifying method throws clause
4) changing parameter name
Comment 1 Philipe Mulet CLA 2005-06-15 15:57:57 EDT
We provide fine grain deltas during reconcile operations. 
We do not provide more than a converted platform delta in case the file got
changed as a result of regular resource changes.

Providing a fine grain delta in all cases would require holding an entire
picture of the workspace before a change so as to tell how different it became.

Please explain better your testcase, to see if there is more we can do to help.
Comment 2 Jerome Lanneluc CLA 2005-11-28 07:25:10 EST
Closing since there was no response
Comment 3 Markus Keller CLA 2011-03-21 11:55:09 EDT
This would be helpful for all clients that compute and cache their own state based on an analysis of method content (e.g. for interprocedural analysis). 

Currently, they just get this change event:

[Working copy] Try.java[*]: {CONTENT | FINE GRAINED}

But when e.g. a local class is added (a structural change), then they get:

[Working copy] Try.java[*]: {CHILDREN | FINE GRAINED | AST AFFECTED}
	Try[*]: {CHILDREN | FINE GRAINED}
		foo(String, int)[*]: {CHILDREN | FINE GRAINED}
			Local[+]: {}

It would be nice if they could get a delta like this if the content of a method changed (but the method didn't change structurally):

[Working copy] Try.java[*]: {CHILDREN | FINE GRAINED | AST AFFECTED}
	Try[*]: {CHILDREN | FINE GRAINED}
		foo(String, int)[*]: {FINE GRAINED}

Since existing element delta listeners don't expect such events, I guess we need a new ElementChangedEvent constant so that clients can explicitly request the additional information, e.g. #FINE_GRAINED_CONTENT_CHANGE.


(In reply to comment #1)
> We do not provide more than a converted platform delta in case the file got
> changed as a result of regular resource changes.

Yes, I guess we have to live with that.
Comment 4 Jay Arthanareeswaran CLA 2011-03-23 10:12:36 EDT
(In reply to comment #3)
> 
> Since existing element delta listeners don't expect such events, I guess we
> need a new ElementChangedEvent constant so that clients can explicitly request
> the additional information, e.g. #FINE_GRAINED_CONTENT_CHANGE.


Markus, what problem do you see with this?
A.java[*]: {CHILDREN | FINE GRAINED | PRIMARY RESOURCE}
	A[*]: {CHILDREN | FINE GRAINED}
		foo(String, int)[*]: {CONTENT | FINE GRAINED}
Comment 5 Markus Keller CLA 2011-03-23 15:21:40 EDT
(In reply to comment #4)
> Markus, what problem do you see with this?

It breaks the contracts of IJavaElementDelta#F_CONTENT and #F_FINE_GRAINED. The latter is mentioned in the IJavaElementDelta Javadoc, where it talks about "structural changes". Changing that silently to also also include non-structural changes would be a breaking change.

Furthermore, it can be a performance problem or just reveal other problems in existing listeners that don't expect these additional child elements in deltas.

> A.java[*]: {CHILDREN | FINE GRAINED | PRIMARY RESOURCE}
>     A[*]: {CHILDREN | FINE GRAINED}
>         foo(String, int)[*]: {CONTENT | FINE GRAINED}
Comment 6 Jay Arthanareeswaran CLA 2011-03-24 03:43:43 EDT
I don't know if this is a stupid question and I think I should have asked 'this' first.

Why isn't a simple IJavaElementDelta#F_CONTENT enough to cover the cases mentioned in comment #0?

e.g., 
A.java[*]: {CHILDREN | FINE GRAINED | PRIMARY RESOURCE}
    A[*]: {CHILDREN | FINE GRAINED}
        foo(String, int)[*]: {CONTENT}
Comment 7 Markus Keller CLA 2011-03-24 06:59:42 EDT
Since we can report the modified elements only when listeners are registered with a new flag, it will be OK to reuse the existing F_CONTENT and F_FINE_GRAINED flags. The Javadoc just has to tell about the additional meaning of the reused flags for ElementChangedEvent#FINE_GRAINED_CONTENT_CHANGE listeners.

Since all changes below a CU currently have F_FINE_GRAINED set, I think it would be best to keep this. The Javadoc of F_FINE_GRAINED already tells that this flag doesn't indicate a change -- it just tells that the analysis has been made.

Setting F_CONTENT to an element delta that doesn't have F_CHILDREN set would be OK, but it's redundant: The absence of F_CHILDREN and the fact that the delta node exists already tell that. Every F_CHILDREN change is also a content change.