Package org.aspectj.org.eclipse.jdt.internal.core.dom.rewrite

Source Code of org.aspectj.org.eclipse.jdt.internal.core.dom.rewrite.TrackedNodePosition

/*******************************************************************************
* Copyright (c) 2000, 2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
*     IBM Corporation - initial API and implementation
*******************************************************************************/
package org.aspectj.org.eclipse.jdt.internal.core.dom.rewrite;

import org.eclipse.text.edits.TextEdit;
import org.eclipse.text.edits.TextEditGroup;

import org.aspectj.org.eclipse.jdt.core.dom.ASTNode;
import org.aspectj.org.eclipse.jdt.core.dom.rewrite.ITrackedNodePosition;
import org.eclipse.jface.text.IRegion;

/**
*
*/
public class TrackedNodePosition implements ITrackedNodePosition {

  private final TextEditGroup group;
  private final ASTNode node;
 
  public TrackedNodePosition(TextEditGroup group, ASTNode node) {
    this.group= group;
    this.node= node;
  }

  /* (non-Javadoc)
   * @see org.aspectj.org.eclipse.jdt.internal.corext.dom.ITrackedNodePosition#getStartPosition()
   */
  public int getStartPosition() {
    if (this.group.isEmpty()) {
      return this.node.getStartPosition();
    }
    IRegion coverage= TextEdit.getCoverage(this.group.getTextEdits());
    if (coverage == null) {
      return this.node.getStartPosition();
    }
    return coverage.getOffset();
  }

  /* (non-Javadoc)
   * @see org.aspectj.org.eclipse.jdt.internal.corext.dom.ITrackedNodePosition#getLength()
   */
  public int getLength() {
    if (this.group.isEmpty()) {
      return this.node.getLength();
    }
    IRegion coverage= TextEdit.getCoverage(this.group.getTextEdits());
    if (coverage == null) {
      return this.node.getLength();
    }
    return coverage.getLength();
  }
}
TOP

Related Classes of org.aspectj.org.eclipse.jdt.internal.core.dom.rewrite.TrackedNodePosition

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.