Bug 80839

Summary: [dom] Need API to control extended source range computation
Product: [Eclipse Project] JDT Reporter: Dirk Baeumer <dirk_baeumer>
Component: CoreAssignee: Martin Aeschlimann <martinae>
Status: VERIFIED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: jeem, martinae
Version: 3.1   
Target Milestone: 3.1 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on:    
Bug Blocks: 40243    
Attachments:
Description Flags
JDT Core patch none

Description Dirk Baeumer CLA 2004-12-13 12:47:10 EST
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.
Comment 1 Jim des Rivieres CLA 2005-01-05 11:51:22 EST
Created attachment 16946 [details]
JDT Core patch

Attaching a concrete proposal for how this could be done.
Martin and Dirk, please review.
Comment 2 Martin Aeschlimann CLA 2005-01-05 12:13:42 EST
looks fine to me!
Comment 3 Dirk Baeumer CLA 2005-01-05 12:24:13 EST
+1
Comment 4 Jim des Rivieres CLA 2005-01-05 12:55:50 EST
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.
Comment 5 Martin Aeschlimann CLA 2005-02-03 12:07:47 EST
Added a first test case ASTRewritingInsertBoundTest.testTargetSourceRangeComputer.

Mark bug as fixed
Comment 6 David Audel CLA 2005-02-15 12:34:19 EST
Verified in I20050214-0927