Summary: | [refactoring] Comment deleted on 'Move type to new file' refactoring | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Deepak Azad <deepakazad> | ||||||
Component: | UI | Assignee: | Raksha Vasisht <raksha.vasisht> | ||||||
Status: | VERIFIED FIXED | QA Contact: | |||||||
Severity: | major | ||||||||
Priority: | P3 | CC: | daniel_megert, markus.kell.r | ||||||
Version: | 3.6 | ||||||||
Target Milestone: | 3.7 M1 | ||||||||
Hardware: | PC | ||||||||
OS: | Windows XP | ||||||||
Whiteboard: | |||||||||
Bug Depends on: | 306524 | ||||||||
Bug Blocks: | |||||||||
Attachments: |
|
Description
Deepak Azad
2010-03-09 01:21:28 EST
I don't think that's new (same problem in old refactoring). Raksha, can you please have a look? Maybe we should set a NoCommentSourceRangeComputer or another source range computer to the AST rewrite. Yes the problem exists in 3.5 as well. Also the problem is with Secondary types as well. For instance, moving X in the following also deletes the comment. package p; class A { } /* * A very important comment. */ class X { } Probably not for 3.6, waiting on decision in bug 306524. Created attachment 172314 [details]
Fix for the new CU
Markus, how about using a source range computer even for computing the new source range for the moved CU? This takes the extended range of the declaration node into account rather than just the simple range which helps in copying the comments which belong to the extended range of the node along with the declaration to the new CU. Since deleting the comments from the old CU which belong to the new CU in ASTRewriteAnalyzer is also done using the same source range computer, there wont be any inconsistencies.
I tried this approach:
ASTNodes.getNodeSource(declaration, true, false), but that returns null in this case
ASTNode root= node.getRoot();
if (root instanceof CompilationUnit) {
CompilationUnit astRoot= (CompilationUnit) root;
ITypeRoot typeRoot= astRoot.getTypeRoot();
since the java type root of the astRoot is null.
(In reply to comment #4) +1, makes sense. Created attachment 175427 [details] Fix + tests Added some tests and adjusted some for the changes in JDT-Core(bug 306524) and UI. (In reply to comment #6) > Created an attachment (id=175427) [details] [diff] > Fix + tests Committed to HEAD after Ayush committed the fix for bug 306524. Verified in I20100802-1800. |