Bug 80839 - [dom] Need API to control extended source range computation
Summary: [dom] Need API to control extended source range computation
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: 3.1 M5   Edit
Assignee: Martin Aeschlimann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 40243
  Show dependency tree
 
Reported: 2004-12-13 12:47 EST by Dirk Baeumer CLA
Modified: 2005-02-15 12:34 EST (History)
2 users (show)

See Also:


Attachments
JDT Core patch (14.55 KB, patch)
2005-01-05 11:51 EST, Jim des Rivieres CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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