Community
Participate
Working Groups
Build 20030214 I get no code assist in the context of an inner class created in an instance variable declaration. My specific test case is trying to create a single inner class that can be reused by multiple widgets as a selection listener. So I have: private SelectionAdapter buttonListener= new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { if (event.widget == addButton) { addProperty(); } else if (event.widget == editButton) { edit(); } } } If I try to get code assist to see the fields/methods on event, for example, I get nothing.
Jared this works for me using the following example: import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; public class X { private SelectionAdapter buttonListener= new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { if (event.widget == null) { // addProperty(); } else if (event.widget == null) { // edit(); } } }; } Any additional steps to reproduce this ? Philippe, anything you can think of that can cause this behaviour.
I cannot reproduce the problem with your test case. Jared - Could you give me all the source of the compilation unit where the problem occur ?
Build 200303272130, jdk 1.4.1_02, win32. I just came across this bug while writing Swing code. The example code below is the minimum required to reproduce the problem for me. The bug shows up when you create an anonymous inner class in an instance variable declaration AFTER a method containing both an anonymous inner class declaration AND a method call. import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import javax.swing.Action; import javax.swing.JButton; public class CodeCompletionBug { private JButton button = new JButton(); // The anonymous class before the constructor class works. private Action action1 = new AbstractAction() { public void actionPerformed(ActionEvent e) { // Code completion works in here. } }; public void someInitMethod() { // Remove this and the broken completion below will work. button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // Code completion works in here. } }); // Or remove this. someMethod(); } // Code completion does not propose constructors after the "new" keyword. private Action action2; // = new // Did it manually but completion is broken inside the anonymous class. private Action action3 = new AbstractAction() { public void actionPerformed(ActionEvent e) { // Code completion does not work in here. //e. } }; private void someMethod() { } }
I can reproduce the bug with Dominic test case in build 20040422. The problem is inside AssistParser#recoveryTokenCheck(). K_TYPE_DELIMITER is not correctly remove from the element stack. Fixed and tests added CompletionParserTest2#138() CompletionParserTest2#139()
Verified in 200405180816.