Bug 431826

Summary: [quick fix] No Quick fix for missing static import for annotation @Retention(RUNTIME)
Product: [Eclipse Project] JDT Reporter: Eric Peters <ericdp>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: ASSIGNED --- QA Contact:
Severity: enhancement    
Priority: P3 CC: ccc, noopur_gupta, srikanth_sankaran
Version: 4.3.2   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

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.