Community
Participate
Working Groups
I20041208 I have started to get rid of the OldASTrewrite however the old version gave me some control over the extended source range used when replacing/deleting nodes. Some refactorings (extract method, surround with try catch) are selection based and the refactoring should honor the selection. For example if a user selects a bunch of method calls with comments and calls extract method all the methods including the comments should be move to the new method even if the extended source range for the call doesn't contain the comments. To achieve this I porpose the following: - the ASTRewrite allows me to set an IExtendedSourceRangeComputer - if present the computation is forwared to this instance - if null is returned the standard extended source range is used.
Created attachment 16946 [details] JDT Core patch Attaching a concrete proposal for how this could be done. Martin and Dirk, please review.
looks fine to me!
+1
Released API additions: ASTRewrite public final void setTargetSourceRangeCompute(TargetSourceRangeComputer computer); public class TargetSourceRangeComputer { public static final class SourceRange { public SourceRange(int startPosition, int length); public int getStartPosition(); public int getLength(); } public TargetSourceRangeComputer(); public SourceRange computeSourceRange(ASTNode node); } Martin, Please add "descriptive" rewrite tests for the new API.
Added a first test case ASTRewritingInsertBoundTest.testTargetSourceRangeComputer. Mark bug as fixed
Verified in I20050214-0927