Bug 502847 - Provide Quickfix to change a qualified static method call to a static import
Summary: Provide Quickfix to change a qualified static method call to a static import
Status: CLOSED DUPLICATE of bug 197850
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.6   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-30 06:47 EDT by Lars Vogel CLA
Modified: 2016-09-30 07:15 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lars Vogel CLA 2016-09-30 06:47:41 EDT
Would be nice to have a quickfix to change a static method call to a static import:

Button ok = new Button (shell, SWT.PUSH);
ok.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> System.out.println("OK")));

Quickfix should be able to covert to:

import static org.eclipse.swt.events.SelectionListener.*;
ok.addSelectionListener(widgetSelectedAdapter(e -> System.out.println("OK")));
Comment 1 Noopur Gupta CLA 2016-09-30 07:07:55 EDT
We already have the "Add Import" action for this.

- Place the caret on a static member in your code: "widgetSelectedAdapter".
- Press: Ctrl+Shift+M
Or, click Source > Add Import.

It will add the static import:
import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter;

and convert the code to:
ok.addSelectionListener(widgetSelectedAdapter(e -> System.out.println("OK")));
Comment 2 Lars Vogel CLA 2016-09-30 07:11:54 EDT
Good you offer the same as Ctrl+1 Quickfix? 

As IDE user, I find the usage of "Add Import" surprising here, as I'm not missing an import. It is great that this works but I think a Quickfix is more fitting here.
Comment 3 Noopur Gupta CLA 2016-09-30 07:15:43 EDT

*** This bug has been marked as a duplicate of bug 197850 ***