Bug 40782 - Primary working copies: unnecessary deltas on save
Summary: Primary working copies: unnecessary deltas on save
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.0 M4   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-07-25 11:30 EDT by Martin Aeschlimann CLA
Modified: 2003-10-14 10:28 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Aeschlimann CLA 2003-07-25 11:30:55 EDT
M2

Change is to rename a field in the editor from 'x' to 'x1':
1. On the change a delta 'content | fine grained, field x removed, field x1
added' is sent.
2. On save, a delta 'content | fine grained, no affected children' is posted. 

The second delta is unnecessary, it contains no information.
The information that a save was done is interesting but probably can not be
detected from the current delta ('content | fine grained, no affected children')
Comment 1 Jerome Lanneluc CLA 2003-08-21 11:16:28 EDT
This delta indicates that a change to the content of the compilation unit was 
made (it could be a change in a comment) but no structural difference exist.
So I think this delta contains some information and should be kept as is.
Comment 2 Martin Aeschlimann CLA 2003-08-22 03:51:10 EDT
In step 2. the file is only saved: No change on the file not even a change in
the comment)
Comment 3 Jerome Lanneluc CLA 2003-08-22 05:29:08 EDT
OK, but the Java model doesn't keep the previous content of the file. It only 
keeps the structure of the cu. So it cannot know that absolutely no change was 
made.
Comment 4 Martin Aeschlimann CLA 2003-08-22 07:10:24 EDT
I don't understand that. The cu is in working copy mode and the delta listener
listens on document changes.  A IResource change can be ignored in this case, no?

The question of course it, what happens if somebody external makes a change on a
resource while the file is in working copy mode. But I think such changes on the
resource are ignored and overridden when the working copy is commited.

I think it's important to not send unnecessary deltas as it leads to unnecessary
refreshes in viewers and refreshes in caches ect.
Comment 5 Jerome Lanneluc CLA 2003-08-22 10:23:36 EDT
So are you saying that changes (including addition and deletion) should not be 
reported through a Java delta if the primary cu is in working copy mode?
Comment 6 Philipe Mulet CLA 2003-09-03 06:34:35 EDT
Problem is that if this delta is discarded, then type hierarchies will not get 
notified of possible need to refresh (hierarchies are not listening to working 
copy deltas currently for performance reason).

So either we keep a delta (with special flag?) or type hierarchies will get 
notified of intermediate deltas, and will refresh when it makes sense 
(performance), could be on save action only. The scenario which causes trouble 
in reconciler is the addition of an unterminated type comment  '/*' which 
immediately treats a significant portion of the unit as discarded.
Comment 7 Martin Aeschlimann CLA 2003-09-06 08:35:34 EDT
I would prefer the 'special flag' solution. In other words a delta simply 
reporting that a document has been saved (what only would be information, not a 
real delta)
Comment 8 Jerome Lanneluc CLA 2003-09-25 07:08:38 EDT
Committing a primary working copy should only force a reconcile, if it is 
already reconciled, this is a no-op: no delta.

As well we will filter them out in DeltaProcessor.

Type hierarchy should store fine-grained deltas and traverse the working copy 
on save to check if supertypes have changed.
We might want to use reconcile on save and use the resolution to find out what 
has changed in the working copy.
Known problem: move of a local type inside a method can change its hierarchy.
Comment 9 Jerome Lanneluc CLA 2003-09-26 10:38:54 EDT
Fixed commit operation and DeltaProcessor.
Added regression test WorkingCopyOwnerTests.testDeltaCommitPrimaryWorkingCopy1()

Problem with type hierarchy update is captured in bug 43294.
Comment 10 David Audel CLA 2003-10-14 10:28:42 EDT
Verified.