Bug 153843 - [hierarchy] viewpane gets reloaded even if not needed
Summary: [hierarchy] viewpane gets reloaded even if not needed
Status: VERIFIED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Linux
: P3 normal with 1 vote (vote)
Target Milestone: 3.5 M2   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-08-14 20:23 EDT by Daniel Beck CLA
Modified: 2011-10-04 14:24 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Beck CLA 2006-08-14 20:23:09 EDT
I like to have the hierarchy pane open, since it helps me to understand how the Class hierarchy works. 
Every time I import a class or a package in my java source code, the type hierarchy is loaded again. This takes substantial time on my computer, then a lot of types are in the type hierarchy (~ 30/40 secondes).

I believe that should not happen, since there is no need to recreate the type hierarchy: The type hierarchy already contains the imported type, since it contains all classes/type from the project. (Correct me if I'm wrong)

Step to reproduce this:
1) Open a java file with the editor
2) Open the hierarchy pane on some type that have a lot of subtypes (e.g., "Object")
3) import a new package to the java source code (e.g., "import java.awt.*")

Then the type-hierarchy viewpane reloads.

As a side node, this behavior can really be disturbing then developing on OpenOffice.org plug-in. I like to open the type hierarchy of the "XEventListener" to have on overview on the list of possible events I can catch from OpenOffice.org, and they are quite a lot of them. It already takes a lot of time to load the type hierarchy the first time, but that would not be so disturbing, if eclipse wouldn't load it everytime again.
Comment 1 Maxime Daniel CLA 2006-08-22 05:16:21 EDT
Moving to JDT UI for comment.
Comment 2 Martin Aeschlimann CLA 2006-08-29 05:23:14 EDT
The type hierarchy listens to the ITypeHierarchyChangedListener and updates the hierarchy on notification. This listener should only report a change if a super type or subtype is added or a type in the hierarchy has changed or is updated.
Are you saying the imported types replace one of the types already in the hierarchy? That would explain the rebuilding of the hierarchy.
I couldn't reproduce any problems.
Comment 3 Daniel Beck CLA 2006-08-29 05:48:51 EDT
I uses eclipse 3.2 on Linux.
Every time I add a new import statement - even if the new type is used nowhere in the code - the TypeHierarchy is loaded again. The type  hierarchy Pane has to be open all the time. 

For example if I add "javax.swing.JPanel", the type hierarchy is loaded again and I have to wait half a minute, since my hierarchy is quite big.
Comment 4 Frederic Fusier CLA 2007-06-20 05:15:41 EDT
Reproduced with 3.3 RC4
Comment 5 Jerome Lanneluc CLA 2007-12-17 11:36:08 EST
It is expected that changing the import statements will force a refresh of the hierarchy as import statements may change how types are resolved.

For example, if you have p1/X.java and p2/X.java and Y.java defines as follows:
import p1.*;
public class Y extends X {
}
The hierarchy on Y is:
+ java.lang.Object
  + p1.X
    + Y
Now if you add an import statement as follows:
import p1.*;
import p2.X;
public class Y extends X {
}
then the hierarchy becomes:
+ java.lang.Object
  + p2.X
    + Y
Comment 6 Jerome Lanneluc CLA 2007-12-17 11:37:50 EST
Having the explanation from comment 5 in mind, do you have a specific test case where the refresh is still not necessary?
Comment 7 Jerome Lanneluc CLA 2008-09-08 09:40:44 EDT
Working as designed. Please reopen if you have an answer to comment 6.
Comment 8 Olivier Thomann CLA 2008-09-15 09:36:19 EDT
Verified for 3.5M2 using I20080914-2000
Comment 9 Byron Hawkins CLA 2011-10-04 14:24:44 EDT
I'm finding that all instances of ITypeHierarchy notify their listeners when an import is changed in any single source having a type in a single hierarchy. I have an Eclipse plugin with 400 ITypeHierarchy instances, and when I change one import in one file--which is a leaf in the hierarchy--then all 400 listeners are notified of a change. The contents of ChangeCollector.changes are identical for every ITypeHierarchy instance (though each does have its own separate ChangeCollector instance): the one import change is listed.

Is it possible to have each import change analyzed for significance, and if it can easily be determined irrelevant to a particular ITypeHierarchy, then discard it? Most import changes are in fact unrelated to the hierarchy. Alternatively, can more information be given to the listener, so that it has an opportunity to examine the changes and ignore the even when it constitutes a physical no-op in the hierarchy?

The reason I ask is that my workspace hangs for 10 seconds while refreshing all the type hierarchies, even though they have not changed at all. If it takes this long with Indigo on an Intel i7-940, my plugin will simply be unusable for commercial purposes. Please let me know if some optimization can be made; otherwise I will need to maintain the hierarchy within my plugin.