Bug 91938 - [ast rewrite] new API: move range of nodes and replace
Summary: [ast rewrite] new API: move range of nodes and replace
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P2 major (vote)
Target Milestone: 3.1 M7   Edit
Assignee: Martin Aeschlimann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 82494 82949 85950
  Show dependency tree
 
Reported: 2005-04-19 13:02 EDT by Martin Aeschlimann CLA
Modified: 2005-05-11 12:23 EDT (History)
2 users (show)

See Also:


Attachments
patch (38.85 KB, patch)
2005-04-19 13:04 EDT, Martin Aeschlimann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Aeschlimann CLA 2005-04-19 13:02:15 EDT
I20050419

The old ASTR rewrite had a feature that wasn't supported on the new
(non-modifiying) API anymore: Move a range of nodes and replace them with a node.
Usages are:
- Surround with
- inline method

-> additional API on org.eclipse.jdt.core.dom.rewrite.ListRewrite:

/**
 * Creates and returns a placeholder node for a move of a range of nodes of the
 * current list. The moved nodes can optionally be replaced by a specified node.
 * 
 * The placeholder node can either be inserted as new or used to replace an
 * existing node. When the document is rewritten, a copy of the source code 
 * for the given node range is inserted into the output document at the position
 * corresponding to the placeholder (indentation is adjusted).
 * 
 * @param first the node that starts the range
 * @param last the node that ends the range
 * @param replacingNode a node that is set at the location of the moved nodes
 * or <code>null</code> to remove all nodes
 * @param editGroup the edit group in which to collect the corresponding
 * text edits fro a replace, or <code>null</code> if ungrouped
 * @return the new placeholder node
 * @throws IllegalArgumentException An exception is thrown if the first or
 * last node are <code>null</code>, if a node is not a child of the current list or
 * if the first node is not before the last node. An <code>IllegalArgumentException
 * </code> is also thrown if the moved range is overlapping with an other moved
 * or copied range. 
 * 
 * @since 3.1
 */
public final ASTNode createMoveTarget(ASTNode first, ASTNode last, ASTNode
replacingNode, TextEditGroup editGroup) {
Comment 1 Martin Aeschlimann CLA 2005-04-19 13:04:37 EDT
Created attachment 20064 [details]
patch
Comment 2 Dirk Baeumer CLA 2005-04-27 07:09:53 EDT
Martin, both scenarios I have are fixed with the patch. 

Erich, can you please approve the API addition.
Comment 3 Erich Gamma CLA 2005-04-27 07:34:41 EDT
approved - having these problems fixed is important
Comment 4 Martin Aeschlimann CLA 2005-04-27 10:44:27 EDT
patch released > 20050427
Comment 5 Martin Aeschlimann CLA 2005-05-11 12:23:55 EDT
verified in 20050509-2010