Bug 107096 - [navigation] Quick Outline doesn't show inherited members for inner classes
Summary: [navigation] Quick Outline doesn't show inherited members for inner classes
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 minor with 1 vote (vote)
Target Milestone: 3.7 M5   Edit
Assignee: Markus Keller CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 333701 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-08-16 05:31 EDT by Jörg von Frantzius CLA
Modified: 2011-01-25 07:11 EST (History)
5 users (show)

See Also:


Attachments
Fix (2.56 KB, patch)
2011-01-07 11:15 EST, Markus Keller CLA
no flags Details | Diff
Fix 2 (adds focus indicator) (8.37 KB, patch)
2011-01-11 08:50 EST, Markus Keller CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jörg von Frantzius CLA 2005-08-16 05:31:42 EDT
If you put the following classes A and TestHierachy into separate files, place
the cursor within the body of TestHierachy.B.test(), press Ctrl+O twice, you
don't get to see A's member a. It works as expected if you place B into a file
of it's own.

// file A.java
class A {
	int a;
}

// file TestHierarchy.java
public class TestHierarchy {
	class B extends A {
		int b;
		void test() {
			// press Ctrl+O twice in the following line
			// and you won't see A.a

		}
	}
}
Comment 1 Markus Keller CLA 2008-12-08 12:09:35 EST
+1. I would expect that the hierarchy is built for the enclosing type at the caret location (or for the main type if there is no enclosing type).
Comment 2 Markus Keller CLA 2011-01-07 05:46:03 EST
*** Bug 333701 has been marked as a duplicate of this bug. ***
Comment 3 Markus Keller CLA 2011-01-07 06:07:12 EST
Not showing the inherited members from the top-level type any more would mean a loss of functionality. The best solution I see is to show the inherited members of the type that encloses the selection, and also show the inherited members of all enclosing types up to top-level. That solution would also scale in examples where a CU contains a lot of nested classes (e.g. the JavaEditor class).
Comment 4 Rostislav Krasny CLA 2011-01-07 10:47:28 EST
Please increase the importance of this bug. From my point of view this is not a minor but rather a major bug. As Markus has mentioned previously this is a loss of functionality.
Comment 5 Markus Keller CLA 2011-01-07 11:15:27 EST
Created attachment 186283 [details]
Fix
Comment 6 Markus Keller CLA 2011-01-07 11:20:05 EST
Fixed in HEAD. We now show inherited members of top-level types (old behavior) and inherited members of the initially selected type.

(In reply to comment #3)
> show the inherited members of all enclosing types up to top-level
I didn't implement that.
Comment 7 Rostislav Krasny CLA 2011-01-07 14:31:50 EST
(In reply to comment #6)
> Fixed in HEAD. We now show inherited members of top-level types (old behavior)
> and inherited members of the initially selected type.

Do you mean the Quick Outline of currently selected type, shown after pressing Ctrl+F3 instead of Ctrl+O?

> (In reply to comment #3)
> > show the inherited members of all enclosing types up to top-level
> I didn't implement that.

Why not?


P.S. The "Java development user guide > Getting Started > Basic tutorial > Editing Java elements > Using quick views" help section has following note:

Ctrl+O always opens the outline for the current Java editor. Press Ctrl+F3 to open the quick outline for the currently selected type.

I think this note is confusing and it's better to be written a little differently:

Ctrl+O always opens the outline for the current Java file. Press Ctrl+F3 to open the quick outline for the Java file of the currently selected type.
Comment 8 Dani Megert CLA 2011-01-10 03:56:00 EST
This makes Ctrl+O unpredictable as it only adds the inherited members for the nested type at the editor's caret location and when I then expand another type in Ctrl+O Ctrl+O mode I don't see its inherited members. It also means that I can't select a type in the Quick Outline and then get its inherited members with the second Ctrl+O.

Please either revert the change or make sure that in Ctrl+O Ctrl+O mode all expanded types show its inherited members.
Comment 9 Markus Keller CLA 2011-01-10 06:53:40 EST
(In reply to comment #7)
> > and inherited members of the initially selected type.
> 
> Do you mean the Quick Outline of currently selected type, shown after pressing
> Ctrl+F3 instead of Ctrl+O?

No, this doesn't depend on how you opened a Quick Outline. It only depends on the type on/in which the caret was placed before the dialog was opened. That type is already used to improve the filtering experience (bug 88195).

> > > show the inherited members of all enclosing types up to top-level
> > I didn't implement that.
> 
> Why not?

Because it would make the tree too big and show too many less interesting elements. In a class with many nested types (e.g. AbstractTextEditor), a query like "getC" would show a getClass() method inherited from Object for each and every type.


(In reply to comment #8)
> This makes Ctrl+O unpredictable as it only adds the inherited members for the
> nested type at the editor's caret location

That's fully predictable.

> and when I then expand another type
> in Ctrl+O Ctrl+O mode I don't see its inherited members.

We have to find a balance between supporting the primary use case well and showing too much information (which reduces usability for the primary use case). As I said above, we can't show inherited members for all types in the tree.

Using the initially selected element to show additional inherited members is fully predictable and supports the primary use case (seeing the inherited members at the caret location, like it already works when you're in a top level type).

Using the element that is selected when Ctrl+O is pressed a second time would support a theoretical workflow where a user selects another type and then wants to see the inherited members of that type. This is less common. And since the Quick Outline immediately selects items under the mouse and opens them on single click, it's harder to achieve. Furthermore, it happens often that the selection has no meaning at all, because the user just wanted to move the mouse away from the tree, which as a side effect selects an arbitrary element.

Please work with the feature and only reopen if you find this to be a problem in real life and have a better solution.
Comment 10 Dani Megert CLA 2011-01-11 08:39:56 EST
Markus and I had a longer discussion about this today. We both agreed (and verified) that showing all inherited members causes performance issues. We also concluded that the current solution is confusing for users because they don't have an indication which type(s) show the inherited members and hence also don't understand why it's working for some but not for others. Finally, we found a good solution to this problem: we will decorate those types with the "focus" decorator that we already use in the [Quick] Type Hierarchy. That way, the behavior is again predictable for the user.
Comment 11 Markus Keller CLA 2011-01-11 08:50:58 EST
Created attachment 186489 [details]
Fix 2 (adds focus indicator)
Comment 12 Markus Keller CLA 2011-01-11 08:51:49 EST
Fixed in HEAD.
Comment 13 Deepak Azad CLA 2011-01-25 03:31:50 EST
Verified for 3.7M5 on Mac with I20110124-1800.
Comment 14 Raksha Vasisht CLA 2011-01-25 07:11:31 EST
Verified for 3.7 M5 with I20110124-1800.