| Summary: | [Viewers] Sort feature brings Outline and members view out of synch | ||
|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Dani Megert <daniel_megert> |
| Component: | UI | Assignee: | Nick Edgar <n.a.edgar> |
| Status: | RESOLVED DUPLICATE | QA Contact: | |
| Severity: | major | ||
| Priority: | P2 | CC: | jerome_lanneluc, martinae |
| Version: | 2.1 | ||
| Target Milestone: | 2.1 RC2 | ||
| Hardware: | PC | ||
| OS: | Windows 2000 | ||
| Whiteboard: | |||
|
Description
Dani Megert
Martin, I guess that someone has to do a reconcile on the CU. Is this us or Core ? I looked at the delta send by the sorter. the outliner doesn;t react to it, as there are no additions or deletions. The type is marked as changed - children changed The type's sorted elements are marked as changed - content changed So I think the outliner is correct, as the same delta would be send if in each of the members a whitespace would be added. A non-structural change where no refresh of the type is needed. There must be a way that the delta can signal that children changed but also the the type must refresh. Maybe the type could also have the F_MODIFIERS flag included? Moving to JCore The sort operation doesn't send any delta. It simply update the buffer of the working copy passed as an argument. Just to clarify. The sorting operation doesn't answer a custom delta, but
rather relies on working copy fine grain deltas (when buffer changes).
Actually, we reproduced the problem without using sort members.
- If you have unit with
class X {
void foo(){}
void bar(){}
}
- copy both method sources at once
- swap foo() and bar() in editor, observe that bar() is listed before foo() in
outliner.
- paste back the copied source, and notice that the outliner won't refresh
(order is now wrong).
Fine-grain deltas should be able to detect reordering scenario, based on
ordering of handles.
Added new flag to signal a change in the order of the element: F_REORDER. So when members are reordered, the affected members have a CHANGED delta with the F_REORDER flag positioned. Note this won't be in today's integration build, but in next integration build (20030218) Moving to JDT/UI to react to this new flag. I guess this affects all the content providers that deal with members (e.g package explorer, outliner and members view). Have to see if we have to do something in the UI. Note this is not an API change. If you choose not to change anything on the UI side, the behavior will be the same as before. However to fix this bug you will now need to check the F_REORDERED flag (and not F_REORDER as I previously indicated) Members view and package explorer updates correctly. So only the outliner is affected. Fixed by detecting the reorder case and executing a refresh. Build 2.1 RC1
Does not work for Members view.
Test Case
1. Open Java Browsing perspective
2. Add type T:
public class T {
int a;
int b;
}
3. From the editor's context menu: Source -> Sort Members
Note: Maybe this is a side-effect of using refresh(false). If this is the case
then this must not be fixed by reverting to refresh(true) since this would cause
lots of refreshes in the Java Browsing perspective and would invalidate PRs
fixed for RC1.
Daniel, can you look into the members view. You know the code better than I. If it is too tight move it back to me. Sure. OK. This is a result of misunderstood REORDER flag. I assumed that the reorder flag is set on the parent and not on each child. I have now reverted parts of my code to use refresh(Object, true). This can be
viewed as a workaround for a bigger problem:
The TreeViewer does not handle structural changes correctly if the updateLabels
flag is false. I assume that the children are ignored if the viewer's label
didn't change.
Small Test Case:
0. From your development workspace start an Eclipse target
1. In the target add the following CU and save it:
public class C {
int b;
int a;
public class Inner {
void foo() {
}
}
}
2. Source -> Sort Members
Observe: the Members view is OK
3. Exit target
4. In the development workspace open JavaBrowsingContentProvider.java and
replace the only occurrence of postRefresh(null, boolean) with postRefresh(null).
5. Start target
6. Open C
7. Source -> Sort Members
Observe: the Members view is totally corrupted. Clicking in the Members view
reveals the old elements
Probably a duplicate of bug 32414 I'm curious. In JavaBrowsingContentProvider.postRefresh(Object, boolean) you
have:
if (!updateLabels) {
postRefresh(root);
return;
}
Why do you need this test? You should be able to just pass the boolean to the
viewer refresh.
*** This bug has been marked as a duplicate of 32414 *** >Why do you need this test? You should be able to just pass the boolean to the >viewer refresh. Correct. I did it this way to see that it's a workaround for this bug. Normally postRefresh(Object) should be called. I added a new bug to revisit refresh calls in the JavaBrowsingContentProvider (bug 34260). |