Community
Participate
Working Groups
Using the ASTRewrite to remove an annotation causes the source code in the editor to appear to "jump" up. It is very brief and causes the source code to look like it has moved up a line then back down. This only occurs if the annotation is on a separate line from the field declaration. astRewrite.getListRewrite(fieldDeclaration, fieldDeclaration.getModifiersProperty()).remove(annotation, null); There is a blip while doing this on a TypeDeclaration, but it seems more obvious on a FieldDeclaration.
The AST rewriter just computes a text edit tree. The 'jumping' in the editor probably has to do how you apply the edit tree on the document. Wrap you edit.apply with a rewrite session: DocumentRewriteSession session= null; try { if (document instanceof IDocumentExtension4) { session= ((IDocumentExtension4)document).startRewriteSession( DocumentRewriteSessionType.UNRESTRICTED); } edit.apply(document); } finally { if (session != null) { ((IDocumentExtension4)document).stopRewriteSession(session); } } setting bug to REMIND. Reopen if this wasn't the problem
The "jumping" still occurs if I use a DocumentRewriteSession. It does not occur if the code formatter option 'Insert New lines after annotations' is set to false. But if that option is set to true, the problem occurs when removing as well as adding annotations via the ASTRewrite.
moving to jdt.text.
Martin, can you explain why it works when the formatter option is off?
I assume the text edit if first removing an existing line and then adding it again. I have't looked into this in detail.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.