Bug 431826 - [quick fix] No Quick fix for missing static import for annotation @Retention(RUNTIME)
Summary: [quick fix] No Quick fix for missing static import for annotation @Retention(...
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.3.2   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-02 14:11 EDT by Eric Peters CLA
Modified: 2014-06-17 14:56 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Peters CLA 2014-04-02 14:11:45 EDT
I've a Java project targeted Java 7 SDK, with code snippet like below and associated error in the Markers view (copied below). There is no Quick Fix available, but I expect I should minimally have quick fix 'Import static java.lang.annotation.RetentionPolicy.RUNTIME;'


package p;

import java.lang.annotation.Retention;

@Retention(RUNTIME)
public @interface CustomerQualifier {

}

Description	Resource	Path	Location	Type
RUNTIME cannot be resolved to a variable	CustomerQualifier.java	/Java/src/p	line 5	Java Problem
Comment 1 Srikanth Sankaran CLA 2014-04-07 02:28:04 EDT
Let us know if you need something from Core
Comment 2 Noopur Gupta CLA 2014-04-08 07:09:25 EDT
There is no quick fix provided for this at present.

However, you can just place the caret at RUNTIME (eg: RUNTIME|) and press Ctrl+space to invoke content assist. It will resolve the error and add the import. 

To convert that to a static import, press Ctrl+Shift+M (Add Import) with caret at RUNTIME (eg: RetentionPolicy.RUNTIME|).
Comment 3 Eric Peters CLA 2014-04-09 11:09:00 EDT
(In reply to Noopur Gupta from comment #2)
> There is no quick fix provided for this at present.
> 
> However, you can just place the caret at RUNTIME (eg: RUNTIME|) and press
> Ctrl+space to invoke content assist. It will resolve the error and add the
> import. 
> 
> To convert that to a static import, press Ctrl+Shift+M (Add Import) with
> caret at RUNTIME (eg: RetentionPolicy.RUNTIME|).

Thanks Noopur,

Can you point me to eclipse help that outlines content assist related key sequences like above?
Comment 4 Noopur Gupta CLA 2014-04-10 02:49:47 EDT
(In reply to Eric D. Peters from comment #3)
> Can you point me to eclipse help that outlines content assist related key
> sequences like above?

In Eclipse, Help > Tips and Tricks... > Eclipse Java Development Tools, will bring up the "Tips and Tricks (JDT)" page. You can refer "Editing" section for content assist and other sections for various other tips.

You can press Ctrl+Shift+L to get the list of all key sequences.
To set/change the key bindings, go to the preference page: Window > Preferences > General > Keys.