Community
Participate
Working Groups
In the following code import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.JPopupMenu; import javax.swing.JTable; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; public class Test { public void foo() { final JTable table = new JTable(); table.getSelectionModel().addListSelectionListener( new ListSelectionListener() { // <-- (2) public void valueChanged(ListSelectionEvent arg0) { } }); table.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { JPopupMenu popup = getPopup(); // <-- (1) } private JPopupMenu getPopup() { return null; } }); } } If you select the call to "getPopup()" on the line marked (1) and select "Open Declaration" from the context menu (or press F3, or Ctrl-Click) the editor positions on ListSelectionListener on the line marked (2).
Looks like a model bug: also source and hover are wrong probably because codeSelect returns the wrong element.
Problem is multiple consecutive anonymous classes. SelectionParser build only a partial AST but to build a JavaElement, all anonymous type are needed to compute the correct occurence count. Fixed and test added ResolveTest#testResolveLocalClass7() ResolveTest#testResolveLocalField2() ResolveTest#testResolveLocalMethod2() ResolveTest#testResolveLocalVariable() CompilationUnit#getElementAt() and ClassFile#getElementAtConsideringSibling() are used instead of HandleFactory.
Verified for 3.1 M3 with build I200411020800 + org.eclipse.jdt.core v_517.