Bug 68710 - Open Declaration opens wrong target
Summary: Open Declaration opens wrong target
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M3   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-27 15:23 EDT by Nico Seessle CLA
Modified: 2004-11-02 10:58 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nico Seessle CLA 2004-06-27 15:23:58 EDT
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).
Comment 1 Dani Megert CLA 2004-07-06 10:19:27 EDT
Looks like a model bug: also source and hover are wrong probably because
codeSelect returns the wrong element.
Comment 2 David Audel CLA 2004-10-29 05:33:45 EDT
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.
Comment 3 Frederic Fusier CLA 2004-11-02 10:58:32 EST
Verified for 3.1 M3 with build I200411020800 + org.eclipse.jdt.core v_517.