1 11 package org.eclipse.jdt.internal.core.dom.rewrite; 12 13 import org.eclipse.text.edits.TextEdit; 14 import org.eclipse.text.edits.TextEditGroup; 15 16 import org.eclipse.jdt.core.dom.ASTNode; 17 import org.eclipse.jdt.core.dom.rewrite.ITrackedNodePosition; 18 import org.eclipse.jface.text.IRegion; 19 20 23 public class TrackedNodePosition implements ITrackedNodePosition { 24 25 private final TextEditGroup group; 26 private final ASTNode node; 27 28 public TrackedNodePosition(TextEditGroup group, ASTNode node) { 29 this.group= group; 30 this.node= node; 31 } 32 33 36 public int getStartPosition() { 37 if (this.group.isEmpty()) { 38 return this.node.getStartPosition(); 39 } 40 IRegion coverage= TextEdit.getCoverage(this.group.getTextEdits()); 41 if (coverage == null) { 42 return this.node.getStartPosition(); 43 } 44 return coverage.getOffset(); 45 } 46 47 50 public int getLength() { 51 if (this.group.isEmpty()) { 52 return this.node.getLength(); 53 } 54 IRegion coverage= TextEdit.getCoverage(this.group.getTextEdits()); 55 if (coverage == null) { 56 return this.node.getLength(); 57 } 58 return coverage.getLength(); 59 } 60 } 61 | Popular Tags |