Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 331139

Summary: PushIn refactoring support for field annotation removal
Product: [Tools] AJDT Reporter: Andrew Clement <aclement>
Component: CoreAssignee: Andrew Eisenberg <andrew.eisenberg>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: andrew.eisenberg
Version: 2.1.1   
Target Milestone: 2.2.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Andrew Clement CLA 2010-11-25 11:38:16 EST
The latest AJ in AJDT supports:

declare @field: int A.i: -@Foo

to remove annotations.  The push in refactoring should be able to apply it.
Comment 1 Andrew Eisenberg CLA 2010-11-25 11:59:56 EST
Before this can be implemented, there needs to be a way of determining what has been removed.  There would probably need to be some extra API on IProgramElement.

I'm thinking something like:

boolean IProgramElement.removesElement();  // quick check to see if this program element performs any removals

String[] IProgramElement.getRemovedAnnotations();  // returns array of fully qualified annotation types that have been removed from the target

Before we decide on something like this, we should also think about what kind of API would be required for augmenting and replacing annotations.
Comment 2 Andrew Clement CLA 2010-11-25 16:25:01 EST
What do you call for push in of a declare @field right now, to determine what fully qualified annotations are added?
Comment 3 Andrew Clement CLA 2010-11-25 16:32:09 EST
i presume it is getAnnotationType()

Let's not tackle annotation augment/replace, that isn't as urgent.
Comment 4 Andrew Clement CLA 2010-11-25 16:56:36 EST
API is in:

boolean isAnnotationRemover()

String[] getRemovedAnnotationTypes()

Note: I went with the suggestion of String[] return value there, but the corresponding one for 'regular' declare @field just returns a String.  The construct itself (declare @field) can take multiple annotations but I guess no-one is using that capability and doing a push in.  When there is time I'll make the other one String[] too.
Comment 5 Andrew Eisenberg CLA 2010-11-25 17:00:10 EST
Actually, for PushIn, I use IProgramElement.getDetails().  This provides the entire annotation including the annotation fields.  Imports are handled separately.
Comment 6 Andrew Eisenberg CLA 2010-11-25 17:00:32 EST
Thanks.  For getting the API in.
Comment 7 Andrew Eisenberg CLA 2011-09-26 17:30:36 EDT
Now available.