Bug 101102 - [misc] removing annotations from AST causes source code to "jump"
Summary: [misc] removing annotations from AST causes source code to "jump"
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 minor with 7 votes (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-21 14:19 EDT by Karen Butzke CLA
Modified: 2022-09-16 17:58 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Karen Butzke CLA 2005-06-21 14:19:04 EDT
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.
Comment 1 Martin Aeschlimann CLA 2005-06-22 03:54:02 EDT
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
Comment 2 Karen Butzke CLA 2005-06-22 08:59:36 EDT
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.
Comment 3 Martin Aeschlimann CLA 2005-06-22 09:18:06 EDT
moving to jdt.text.
Comment 4 Dani Megert CLA 2005-06-22 10:05:18 EDT
Martin, can you explain why it works when the formatter option is off?
Comment 5 Martin Aeschlimann CLA 2005-06-22 10:21:43 EDT
I assume the text edit if first removing an existing line and then adding it again.
I have't looked into this in detail.
Comment 6 Eclipse Genie CLA 2020-06-13 15:38:46 EDT
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.
Comment 7 Eclipse Genie CLA 2022-09-16 17:58:26 EDT
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.