Community
Participate
Working Groups
I discovered an odd behaviour in a nested class: public class OuterPanel extends JPanel { public class InnerPanel extends JPanel { public InnerPanel() { setLayo <- code assist here } } } This brings up two setLayout() methods, though both provide the same identical piece of code. I verified this with other JPanel methods (setSize, setLocation) and they all appeared to be duplicated. On reflection, I think it was showing me both the inner and outer classes' methods. [I tested this theory out with a third nested inner class, and indeed in that inner class, it showed three methods, so this seems to be the right idea] However, it doesn't matter which one I pick since they all expand to setLayout(mgr) in the code itself. My thoughts are: A) This behaviour should display one method if all it's going to do is insert the same piece of code, or B) The methods showing calls to the outer class should be distinguished somehow in the method code assist area (such as setLayout(LayoutManager) - OuterPanel) and the code should generate the appropriate OuterPanel.setLayout call In this particular case, I wanted the internal method call, but there may be situations where a commonly-used name (like getName()) is desired to be called on the outer class whereas instead it will pick up the inner class' implementation. Eclipse 2.1RC1 Windows 2000/Mac OS X.2.4
Our intent is to provide all methods, and provide adequate qualification in case of conflict (if you mean the enclosing method). Need to investigate.
If i do code completion with your test case, there is two proposals. This proposals seems to be the same in the popup window. If i select the first proposal, the inserted text is "setLayout()", but if i select the other proposal, the inserted text is "OuterPanel.this.setLayout()". Alex - Do you see the same behavior ?
Both of the proposals return the same 'setLayout(mgr)' regardless of which one I select, on both Windows 2000 and Mac OS X.2.4 using Eclipse 2.1RC1 (200302211557) It's possible that this has been fixed by another patch elsewhere (for example, it might be an underlying issue in the SWT List that can't tell which of two identical entries are selected). However, IMHO it would still be useful for the drop-down list to distinguish between the two, possibly by changing the '- Component' to '- OuterPanel' or '- Component (OuterPanel)'
Alex - there are 2 things to consider: 1- what you see in the completion popup, 2- what gets inserted in the editor after picking one completion We know that (1) is confusing, this is a known JDT/UI limitation (they should disambiguate the presented information, but currently don't). However, on (2) we think we insert the various prefixes corresponding to what you select, on your exact test case. Can you confirm this ? There is no patch elsewhere that we know about which would alter this behavior.
To clarify: the behaviour described in the bug is the behaviour I see. I retested it and put comment #3 to clarify this. So, to be completely unambiguous, I have never seen the OuterPanel.this.setLayout() in 2.1RC1, regardless of which of the two proposals I choose. Have you tested this against 2.1RC1 or a more recent build? If it is more recent, then perhaps you could test against a fresh install of 2.1RC1 to see if this is an issue with 2.1RC1, or whether it's an install issue on my machine(s). FWIW One of them is an upgraded workspace from previous 2.1M builds, the other (Windows) is a fresh install of 2.1RC1.
If you have never seen "OuterPanel.this.setLayout()", there is bug. But i cannot reproduce it with 2.1M4, 2.1M5, 2.1RC1 , the latest integration build (I20030227)and and with a fresh workspace. What is your exact test case? The test case seems to be incomplete (import is missing). I tried to reproduce the problem with the following code. import javax.swing.JPanel; public class OuterPanel extends JPanel { public class InnerPanel extends JPanel { public InnerPanel() { setLayo<- code assist here } } }
I tried this on my M5 install with a clean workspace, and it worked correctly. It may be something that is just screwed up with my preferences in the more recent builds. I'd suggest filing this as RESOLVED/WORKSFORME and when RC2 comes out I'll zap my workspace and verify this.
I can reproduce the symptom with another test case but i don't think that is the same bug. import javax.swing.JPanel; public class X { void foo(){ new JPanel(){ class InnerPanel extends JPanel { public InnerPanel() { setLayout(<- code assist here } } }; } }
I filled a new bug report for this new test case (bug 35220).
Could not reproduce in I20040506 Closed.