Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 


Eclipse JDT
Release 3.5

org.eclipse.jdt.core.dom.rewrite
Class TargetSourceRangeComputer

java.lang.Object
  extended by 
org.eclipse.jdt.core.dom.rewrite.TargetSourceRangeComputer

public class TargetSourceRangeComputer
extends Object

An object for computing adjusted source ranges for AST nodes that are being replaced or deleted.

For example, a refactoring like inline method may choose to replace calls to the method but leave intact any comments immediately preceding the calls. On the other hand, a refactoring like extract method may choose to extract not only the nodes for the selected code but also any comments preceding or following them.

Clients should subclass if they need to influence the the source range to be affected when replacing or deleting a particular node. An instance of the subclass should be registered with ASTRewrite.setTargetSourceRangeComputer(TargetSourceRangeComputer). During a call to ASTRewrite.rewriteAST(org.eclipse.jface.text.IDocument, java.util.Map), the computeSourceRange(ASTNode) method on this object will be used to compute the source range for a node being deleted or replaced.

Since:
3.1

Nested Class Summary
static class TargetSourceRangeComputer.SourceRange
          Reified source range.
 
Constructor Summary
TargetSourceRangeComputer ()
          Creates a new target source range computer.
 
Method Summary
  TargetSourceRangeComputer.SourceRange computeSourceRange ( ASTNode node)
          Returns the target source range of the given node.
 
Methods inherited from class java.lang. Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TargetSourceRangeComputer

public TargetSourceRangeComputer()
Creates a new target source range computer.

Method Detail

computeSourceRange

public 
TargetSourceRangeComputer.SourceRange computeSourceRange(
ASTNode node)
Returns the target source range of the given node. Unlike ASTNode.getStartPosition() and ASTNode.getLength(), the extended source range may include comments and whitespace immediately before or after the normal source range for the node.

The returned source ranges must satisfy the following conditions:

  • no two source ranges in an AST may be overlapping
  • a source range of a parent node must fully cover the source ranges of its children
  • The default implementation uses CompilationUnit.getExtendedStartPosition(ASTNode) and CompilationUnit.getExtendedLength(ASTNode) to compute the target source range. Clients may override or extend this method to expand or contract the source range of the given node. The resulting source range must cover at least the original source range of the node.

    Parameters:
    node - the node with a known source range in the compilation unit being rewritten
    Returns:
    the exact source range in the compilation unit being rewritten that should be replaced (or deleted)

    Eclipse JDT
    Release 3.5

    Copyright (c) IBM Corp. and others 2000, 2008. All Rights Reserved.

     
     
      Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire