Package org.eclipse.text.edits

Examples of org.eclipse.text.edits.DeleteEdit


 
  public static void deleteWodElement(WodParserCache _cache, IWodElement wodElement) throws MalformedTreeException, BadLocationException {
    IDocument wodDocument = _cache.getWodEntry().getDocument();
    if (wodDocument != null) {
      List<TextEdit> wodEdits = new LinkedList<TextEdit>();
      wodEdits.add(new DeleteEdit(wodElement.getStartOffset(), wodElement.getEndOffset() - wodElement.getStartOffset() + 1));
      WodDocumentUtils.applyEdits(wodDocument, wodEdits);
    }
  }
View Full Code Here


      newEdit= new ReplaceEdit(edit.getOffset() - diff, edit.getLength(), edit.getText());
    } else if (oldEdit instanceof InsertEdit) {
      InsertEdit edit= (InsertEdit) oldEdit;
      newEdit= new InsertEdit(edit.getOffset() - diff,  edit.getText());
    } else if (oldEdit instanceof DeleteEdit) {
      DeleteEdit edit= (DeleteEdit) oldEdit;
      newEdit= new DeleteEdit(edit.getOffset() - diff,  edit.getLength());
    } else if (oldEdit instanceof MultiTextEdit) {
      newEdit= new MultiTextEdit();
    } else {
      return null; // not supported
    }
View Full Code Here

  final TextEdit doTextRemove(int offset, int len, TextEditGroup editGroup) {
    if (len == 0) {
      return null;
    }
    TextEdit edit= new DeleteEdit(offset, len);
    addEdit(edit);
    if (editGroup != null) {
      addEditGroup(editGroup, edit);
    }
    return edit;
View Full Code Here

    for (int i= 0; i < stringsToInsert.size(); i++) {
      String curr= (String) stringsToInsert.get(i);
      int idx= findInBuffer(buffer, curr, pos, contentEnd);
      if (idx != -1) {
        if (idx != pos) {
          resEdit.addChild(new DeleteEdit(pos, idx - pos));
        }
        pos= idx + curr.length();
      } else {
        resEdit.addChild(new InsertEdit(pos, curr));
      }
    }
    if (pos < contentEnd) {
      resEdit.addChild(new DeleteEdit(pos, contentEnd - pos));
    }
  }
View Full Code Here

      newEdit= new ReplaceEdit(edit.getOffset() - diff, edit.getLength(), edit.getText());
    } else if (oldEdit instanceof InsertEdit) {
      InsertEdit edit= (InsertEdit) oldEdit;
      newEdit= new InsertEdit(edit.getOffset() - diff,  edit.getText());
    } else if (oldEdit instanceof DeleteEdit) {
      DeleteEdit edit= (DeleteEdit) oldEdit;
      newEdit= new DeleteEdit(edit.getOffset() - diff,  edit.getLength());
    } else if (oldEdit instanceof MultiTextEdit) {
      newEdit= new MultiTextEdit();
    } else {
      return null; // not supported
    }
View Full Code Here

    for (int i= 0; i < stringsToInsert.size(); i++) {
      String curr= (String) stringsToInsert.get(i);
      int idx= findInBuffer(buffer, curr, pos, contentEnd);
      if (idx != -1) {
        if (idx != pos) {
          resEdit.addChild(new DeleteEdit(pos, idx - pos));
        }
        pos= idx + curr.length();
      } else {
        resEdit.addChild(new InsertEdit(pos, curr));
      }
    }
    if (pos < contentEnd) {
      resEdit.addChild(new DeleteEdit(pos, contentEnd - pos));
    }
  }
View Full Code Here

  final TextEdit doTextRemove(int offset, int len, TextEditGroup editGroup) {
    if (len == 0) {
      return null;
    }
    TextEdit edit= new DeleteEdit(offset, len);
    addEdit(edit);
    if (editGroup != null) {
      addEditGroup(editGroup, edit);
    }
    return edit;
View Full Code Here

          // A flag for skipping empty lines, if required
          if (fIgnoreEmptyLines && j == lineStart) {
            continue;
          }
          if (j < lineExclusiveEnd) {
            multiEdit.addChild(new DeleteEdit(j, lineExclusiveEnd
                - j));
          }
          progressMonitor.worked(1);
        }
View Full Code Here

              ';');
          int length = sourceRange.getLength() + suffixLength;
          if (sourceRange.getOffset() + length > document.getLength()) {
            length = document.getLength() - sourceRange.getOffset();
          }
          DeleteEdit edit = new DeleteEdit(sourceRange.getOffset(),
              length);

          fileChangeRootEdit.addChild(edit);
          if (cu.isWorkingCopy()) {
            textFileChange.setSaveMode(TextFileChange.LEAVE_DIRTY);
View Full Code Here

        int offset = lineInfo.getOffset();
        String str = doc.get(offset, lineInfo.getLength());
        if (Strings.containsOnlyWhitespaces(str) && nLines > line + 1
            && removedLines.add(Integer.valueOf(line))) {
          int nextStart = doc.getLineOffset(line + 1);
          edit.addChild(new DeleteEdit(offset, nextStart - offset));
        }
      }
    }
    edit.apply(doc, 0);
    return doc.get();
View Full Code Here

TOP

Related Classes of org.eclipse.text.edits.DeleteEdit

Copyright © 2018 www.massapicom. 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.