Class CopySourceEdit

java.lang.Object
org.eclipse.text.edits.TextEdit
org.eclipse.text.edits.CopySourceEdit

public final class CopySourceEdit extends TextEdit
A copy source edit denotes the source of a copy operation. Copy source edits are only valid inside an edit tree if they have a corresponding target edit. Furthermore the corresponding target edit can't be a direct or indirect child of the source edit. Violating one of two requirements will result in a MalformedTreeException when executing the edit tree.

A copy source edit can manage an optional source modifier. A source modifier can provide a set of replace edits which will to applied to the source before it gets inserted at the target position.

Since:
3.0
See Also:
  • Constructor Details

    • CopySourceEdit

      public CopySourceEdit(int offset, int length)
      Constructs a new copy source edit.
      Parameters:
      offset - the edit's offset
      length - the edit's length
    • CopySourceEdit

      public CopySourceEdit(int offset, int length, CopyTargetEdit target)
      Constructs a new copy source edit.
      Parameters:
      offset - the edit's offset
      length - the edit's length
      target - the edit's target
  • Method Details

    • getTargetEdit

      public CopyTargetEdit getTargetEdit()
      Returns the associated target edit or null if no target edit is associated yet.
      Returns:
      the target edit or null
    • setTargetEdit

      public void setTargetEdit(CopyTargetEdit edit) throws MalformedTreeException
      Sets the target edit.
      Parameters:
      edit - the new target edit.
      Throws:
      MalformedTreeException - is thrown if the target edit is a direct or indirect child of the source edit
    • getSourceModifier

      public ISourceModifier getSourceModifier()
      Returns the current source modifier or null if no source modifier is set.
      Returns:
      the source modifier
    • setSourceModifier

      public void setSourceModifier(ISourceModifier modifier)
      Sets the optional source modifier.
      Parameters:
      modifier - the source modifier or null if no source modification is need.
    • doCopy

      protected TextEdit doCopy()
      Description copied from class: TextEdit
      Creates and returns a copy of this edit. The copy method should be implemented in a way so that the copy can executed without causing any harm to the original edit. Implementors of this method are responsible for creating deep or shallow copies of referenced object to fulfill this requirement.

      Implementers of this method should use the copy constructor Edit#Edit(Edit source) to initialize the edit part of the copy. Implementors aren't responsible to actually copy the children or to set the right parent.

      This method should not be called from outside the framework. Please use copy to create a copy of a edit tree.
      Specified by:
      doCopy in class TextEdit
      Returns:
      a copy of this edit.
      See Also:
    • accept0

      protected void accept0(TextEditVisitor visitor)
      Description copied from class: TextEdit
      Accepts the given visitor on a type-specific visit of the current edit. This method must be implemented in all concrete text edits.

      General template for implementation on each concrete TextEdit class:

       
       boolean visitChildren= visitor.visit(this);
       if (visitChildren) {
          acceptChildren(visitor);
       }
       
       
      Note that the caller (accept) takes care of invoking visitor.preVisit(this) and visitor.postVisit(this).
      Specified by:
      accept0 in class TextEdit
      Parameters:
      visitor - the visitor object
    • postProcessCopy

      protected void postProcessCopy(TextEditCopier copier)
      Description copied from class: TextEdit
      This method is called on every edit of the copied tree to do some post-processing like connected an edit to a different edit in the tree.

      This default implementation does nothing

      Overrides:
      postProcessCopy in class TextEdit
      Parameters:
      copier - the copier that manages a map between original and copied edit.
      See Also: