X-Git-Url: http://secure.phpeclipse.com
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/textmanipulation/MoveTextEdit.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/textmanipulation/MoveTextEdit.java
index 77a8db5..d41ef60 100644
--- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/textmanipulation/MoveTextEdit.java
+++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/textmanipulation/MoveTextEdit.java
@@ -6,73 +6,87 @@ package net.sourceforge.phpdt.internal.corext.textmanipulation;
import org.eclipse.core.runtime.CoreException;
-
-//import org.eclipse.jdt.internal.corext.Assert;
+// import net.sourceforge.phpdt.internal.corext.Assert;
/**
* A text edit that moves text inside a text buffer.
*/
public final class MoveTextEdit extends TextEdit {
-
- /* package */ static class TargetMark extends NopTextEdit {
+
+ /* package */static class TargetMark extends NopTextEdit {
private MoveTextEdit fMoveTextEdit;
+
public TargetMark(TextRange range, MoveTextEdit edit) {
super(range);
- fMoveTextEdit= edit;
+ fMoveTextEdit = edit;
}
- /* package */ MoveTextEdit getMoveTextEdit() {
+
+ /* package */MoveTextEdit getMoveTextEdit() {
return fMoveTextEdit;
}
+
public TextEdit perform(TextBuffer buffer) throws CoreException {
fMoveTextEdit.internalPerform(buffer);
return super.perform(buffer);
}
+
public TextEdit copy() {
- // Assert.isTrue(false, "This should never happen"); //$NON-NLS-1$
+ // Assert.isTrue(false, "This should never happen"); //$NON-NLS-1$
return super.copy();
}
}
private TextRange fTarget;
+
private TextRange fSource;
+
private int fPerformCounter;
/**
* Creates a new MoveTextEdit
. The text edit doesn't support
- * overlapping moves. So for a MoveTextEdit
destination <= offset &&
- * offset + length - 1 <= destination
must be true
.
+ * overlapping moves. So for a
+ * MoveTextEdit
destination <= offset &&
+ * offset + length - 1 <= destination
+ * must be true
.
*
- * @param offset the offset of the text to be moved
- * @param length the text length to be moved
- * @param destination the destination offset
+ * @param offset
+ * the offset of the text to be moved
+ * @param length
+ * the text length to be moved
+ * @param destination
+ * the destination offset
*/
public MoveTextEdit(int offset, int length, int destination) {
- // Assert.isTrue(destination <= offset || offset + length <= destination);
- fSource= new TextRange(offset, length);
- fTarget= new TextRange(destination);
+ // Assert.isTrue(destination <= offset || offset + length <=
+ // destination);
+ fSource = new TextRange(offset, length);
+ fTarget = new TextRange(destination);
}
/**
- * Creates a new MoveTextEdit
with the given source and target range.
+ * Creates a new MoveTextEdit
with the given source and
+ * target range.
*
- * @param source the source
- * @param target the target
+ * @param source
+ * the source
+ * @param target
+ * the target
*/
- private MoveTextEdit(TextRange source,TextRange target) {
- fSource= source;
- fTarget= target;
+ private MoveTextEdit(TextRange source, TextRange target) {
+ fSource = source;
+ fTarget = target;
}
-
+
/**
- * Returns the move text edit's source range. This method returns the same range
- * as TextEdit#getTextRange()
+ * Returns the move text edit's source range. This method returns the same
+ * range as TextEdit#getTextRange()
*
* @return the edit's source range
*/
public TextRange getSourceRange() {
return fSource;
}
-
+
/**
* Returns the move text edit's target range.
*
@@ -81,22 +95,28 @@ public final class MoveTextEdit extends TextEdit {
public TextRange getTargetRange() {
return fTarget;
}
-
- /* non Java-doc
+
+ /*
+ * non Java-doc
+ *
* @see TextEdit#getTextRange()
*/
public TextRange getTextRange() {
return fSource;
}
- /* non Java-doc
+ /*
+ * non Java-doc
+ *
* @see TextEdit#connect(TextBufferEditor)
*/
public void connect(TextBufferEditor editor) throws CoreException {
editor.add(new TargetMark(fTarget, this));
}
-
- /* non Java-doc
+
+ /*
+ * non Java-doc
+ *
* @see TextEdit#perform(TextBuffer)
*/
public TextEdit perform(TextBuffer buffer) throws CoreException {
@@ -104,44 +124,46 @@ public final class MoveTextEdit extends TextEdit {
return new MoveTextEdit(fTarget, fSource);
}
- /* non Java-doc
+ /*
+ * non Java-doc
+ *
* @see TextEdit#copy()
*/
public TextEdit copy() {
- TextRange source= getSourceRange();
- TextRange target= getTargetRange();
+ TextRange source = getSourceRange();
+ TextRange target = getTargetRange();
return new MoveTextEdit(source.fOffset, source.fLength, target.fOffset);
}
-
- //---- Helper method ---------------------------------------------------------------------------------
-
+
+ // ---- Helper method
+ // ---------------------------------------------------------------------------------
+
private void internalPerform(TextBuffer buffer) throws CoreException {
-// Assert.isTrue(fPerformCounter < 2);
+ // Assert.isTrue(fPerformCounter < 2);
if (++fPerformCounter == 2) {
- TextRange source= getSourceRange();
- TextRange target= getTargetRange();
- String current= buffer.getContent(source.fOffset, source.fLength);
+ TextRange source = getSourceRange();
+ TextRange target = getTargetRange();
+ String current = buffer.getContent(source.fOffset, source.fLength);
buffer.replace(source, ""); //$NON-NLS-1$
buffer.replace(target, current);
}
}
-
- /* package */ boolean isUpMove() {
+
+ /* package */boolean isUpMove() {
return fSource.fOffset < fTarget.fOffset;
}
-
- /* package */ boolean isDownMove() {
+
+ /* package */boolean isDownMove() {
return fSource.fOffset > fTarget.fOffset;
}
-
- /* package */ TextRange getChildRange() {
- int offset= fSource.fOffset;
- int length= fSource.fLength;
- int destination= fTarget.fOffset;
+
+ /* package */TextRange getChildRange() {
+ int offset = fSource.fOffset;
+ int length = fSource.fLength;
+ int destination = fTarget.fOffset;
if (destination <= offset)
return new TextRange(destination, offset + length - destination);
else
return new TextRange(offset, destination - offset);
- }
+ }
}
-