|
Re: Annotation insert location [message #206563 is a reply to message #206531] |
Mon, 13 June 2005 15:47 |
Markus Keller Messages: 294 Registered: July 2009 |
Senior Member |
|
|
There was a discussion about annotation placement in bug 82461, and a code
formatter option was introduced. If the current options don't fit your
needs, please file an enhancement request for JDT/Core.
If you think the ASTRewrite does not produce properly formatted code
according to the code formatting options, please file a bug for JDT/Core.
If the behavior is really different depending on existing modifiers, I'd say
that's a bug.
Markus
Karen Moore wrote:
> I am programmatically adding an annotation to a FieldDeclaration. I see
> inconsisitent behavior depending on whether the field has existing
> modifiers. If the field is defined as private String foo then the
> annotation is placed on the line above the field like this:
>
> @MyAnnotation
> private String foo
>
> If the field is defined as just String foo, then the annotation is
> placed like this:
>
> @MyAnnotation String foo
>
>
> Here is some of my code used to do this:
>
> AST ast = astRewrite.getAST();
> NormalAnnotation annotation = ast.newNormalAnnotation();
> annotation.setTypeName(ast.newSimpleName("MyAnnotation"));
>
> astRewrite.getListRewrite(bodyDeclaration,
> bodyDeclaration.getModifiersProperty()).insertAt(annotation, 0, null);
>
>
> The same thing occurs with other BodyDeclarations such as a
> TypeDeclaration. Is there a better way to go about this or is this a bug?
>
>
> thanks,
> Karen
>
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03867 seconds