Bug 186992 - [misc] Position of (Text)Marker not updated correctly after Refactoring "Rename Class"
Summary: [misc] Position of (Text)Marker not updated correctly after Refactoring "Rena...
Status: ASSIGNED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-05-15 08:24 EDT by Sebastian Schmidt CLA
Modified: 2019-09-06 16:13 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 Sebastian Schmidt CLA 2007-05-15 08:24:29 EDT
Build ID: I20070503-1400

Steps To Reproduce:
1. Create CompilationUnit with sourcecode:
public class MyClass {
    void method_one(){}
    void method_two(){}
         ^-marker-^
}

and set a Marker that subtypes textmarker to mark the name of the second method. I.E. set its Attributes CHAR_START = 56 and CHAR_END = 65

2. Use refactoring to rename "method_one" to "method_1". The File is not saved and the marker position is moved correctly to

public class MyClass {
    void method_1(){}
    void method_two(){}
         ^-marker-^
}
CHAR_START = 54.

3. Now use refactoring to rename the Class from "MyClass" to "MyRenamedClass". During refactoring the file is saved. Afterwards it looks like this:

public class MyRenamedClass {
    void method_1(){}
    void method_two(){}
    ^-marker-^
}
CHAR_START = 56.

The Marker is set to the last position that was persisted by the MarkerUpdater.

More information:
I discovered this behavour in Eclipse 3.2.2 M20070212-1330. In this build, the refactoring to rename the method also saved the file, but this doesn't happen anymore. During this save the MarkerUpdater was not called to persist the new position. In the example above, saving the file after renaming the method results in starting at Position 54 instead of 56 after renaming the class.

I assume, saving the file while renaming the Class is necessary because of renaming the .java file.

I would think, that calling the MarkerUpdater during the class renaming could solve the problem.
Comment 1 Martin Aeschlimann CLA 2007-05-15 09:20:31 EDT
reproduced in 20070515

- create 'MyClass' from comment 0
- create bookmark on method_two
- rename 'MyClass' in the package Explorer to MyClassXXXXX
- the bookmark location is wrong

It has to do with the rename of the compilation unit. 
The code that renames is in jdt.core:
CopyResourceElementsOperation.saveContent(PackageFragment, String, ASTRewrite, String, IFile)

My guess is that the destCU.save doesn't make it to the ResourceMarkerAnnotationModel. It seems to me that the ResourceMarkerAnnotationModel should also listen for moves and update the markers before this happens. (wild guess)




We need to make sure that the 
Comment 2 Dani Megert CLA 2007-05-15 09:35:43 EDT
Martin, some text seems to be missing from your last comment.
Comment 3 Martin Aeschlimann CLA 2007-05-15 11:36:32 EDT
The last sentence should have been deleted. Please ignore.
Comment 4 Eclipse Webmaster CLA 2019-09-06 16:13:04 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.