Bug 228845 - [hierarchy] Type hierarchy should include subtypes in primary working copies
Summary: [hierarchy] Type hierarchy should include subtypes in primary working copies
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M4   Edit
Assignee: Srikanth Sankaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-04-25 05:18 EDT by Markus Keller CLA
Modified: 2014-03-01 04:26 EST (History)
3 users (show)

See Also:


Attachments
Patch with code changes and test (3.01 KB, patch)
2008-11-20 10:38 EST, Srikanth Sankaran CLA
no flags Details | Diff
Patch incorporating review comments (6.18 KB, patch)
2008-11-25 06:04 EST, Srikanth Sankaran CLA
jerome_lanneluc: iplog+
jerome_lanneluc: review+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2008-04-25 05:18:25 EDT
N20080423-2000

- paste to Package Explorer:
package xy;
public interface I { }

package xy;
public class C /*implements I*/ { }

- in C.java, remove the /* and */ around "implements I"
- do NOT save
- select I
- F4
=> type hierarchy on I, no subtypes
=> I thought the TH works on working copies, but working on saved state is also acceptable

- Ctrl+S
=> type hierarchy not updated (should show C as child of I)

- F4 on I does not refresh the hierarchy. Need to open hierarchy on another type first or press F5 in Hierarchy view to get correct hierarchy.
Comment 1 Markus Keller CLA 2008-04-25 05:33:47 EDT
Already broken in 3.3.2.
Comment 2 Jerome Lanneluc CLA 2008-09-26 11:57:22 EDT
Actually the problem comes from the fact that the primary working copies are not taken into account when building the hierarchy, i.e. the hierarchy notification assumes that the working copies were taken into account, and thus save will not notify a need to refresh the hierarchy since it is not needed.

Changing the title to better reflect the issue.
Comment 3 Jerome Lanneluc CLA 2008-10-31 08:30:53 EDT
Srikanth, please have a look at this issue. To debug it, I would start by putting a breakpoint in org.eclipse.jdt.internal.core.CreateTypeHierarchyOperation.executeOperation() and debug from there.
Comment 4 Srikanth Sankaran CLA 2008-11-19 08:00:02 EST
1. When the type hierarchy browser is opened while there are some pertinent unsaved changes to the editor's working copy, then those changes don't appear upon the type hierarchy being opened up. (as reported in the bug)

2. A subsequent save also doesn't refresh the view (also as reported in the bug)

In addition, 

3. Reconcilation strategy driven changes never seem to be taken into account w.r.t type hierarchy. i.e, while the TH window is open, making any changes to the working copy don't show up at all in TH. (until you save the changes)

It appears the latter behavior is a conscious design choice (from a performance p.o.v) - In browsing the change history of TypeHierarchy.isAffectedByOpenable() one see comments to the effect either that (a) working copy changes are altogether ignored in type hierarchy browser or (b) that we don't immediately act on them and instead batch up the changes (in the latter case, I couldn't see how/when the batched up changes get acted upon (other than a resource change triggered by ctrl-s) - they seem to be dropped otherwise)
 
Discussion with team members with more history, confirms this intent (that changes to working copy are not intended to be reflected spontaneously.)

So the one thing that is broken and needs fixing is the lack of refresh upon ctrl-s.

I have a fix for this that is under test - stay tuned.
Comment 5 Srikanth Sankaran CLA 2008-11-20 10:38:59 EST
Created attachment 118370 [details]
Patch with code changes and test


Type hierarchy *creation* now takes into account any changes that may exist in primary working copies.

However, once a type hierarchy window is open, changes to working copies will
not automatically reflect spontaneously - A user will have to use ctrl-s or F5
to have the view refresh itself. As discussed earlier, this has always been
the intent.

Jerome, Please review the changes and help take to this to commit, Thanks.
Comment 6 Jerome Lanneluc CLA 2008-11-20 12:16:19 EST
Fix and test are good. However we should have the same fix (and a corresponding test) for BinaryType (that also implements IType).
Comment 7 Srikanth Sankaran CLA 2008-11-25 06:04:10 EST
Created attachment 118648 [details]
Patch incorporating review comments

Now we take primary working copies into consideration while a type hierarchy view is created out of a binary type.
Comment 8 Jerome Lanneluc CLA 2008-11-25 13:09:25 EST
Comment on attachment 118648 [details]
Patch incorporating review comments

Fixes and tests are good
Comment 9 Jerome Lanneluc CLA 2008-11-25 13:10:03 EST
Fixes and tests released for 3.5M4
Comment 10 Olivier Thomann CLA 2008-12-09 13:02:34 EST
Verified for 3.5M4 using I20081208-1800
Comment 11 Srikanth Sankaran CLA 2014-03-01 04:26:34 EST
I raised a follow up fix here: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?h=BETA_JAVA8&id=76226936180e26d9e682e909ba765fff61d327d9

that covers local types from working copy not showing up in hierarchy.