Package org.eclipse.text.edits

Examples of org.eclipse.text.edits.DeleteEdit


   *
   * DeleteText
   */
  protected UndoEdit  DeleteText(IDocument doc2Alter, int offset, int length)
  {
    DeleteEdit charRemoval = new DeleteEdit(offset, length);
    UndoEdit removal = null;
    try {
      removal = charRemoval.apply(doc2Alter);
    } catch (BadLocationException e) {
      // Doing nowt right now. The Java editor doesn't, so should we?
    }
    return removal;
  }
View Full Code Here


    if ((offset == edit.getOffset()) && (length == edit.getLength())) {
      // InsertEdit always satisfies the above condition.
      return edit;
    }
    if (edit instanceof DeleteEdit) {
      return new DeleteEdit(offset, length);
    }
    if (edit instanceof ReplaceEdit) {
      final String replacement = ((ReplaceEdit) edit).getText();
      final int start = Math.max(offset - edit.getOffset(), 0);
      final int end = Math.min(endOffset(region) - offset, replacement.length());
      if (end <= start) {
        return new DeleteEdit(offset, length);
      }
      return new ReplaceEdit(offset, length, replacement.substring(start, end));
    } else {
      throw new IllegalArgumentException("Unexpected edit type: " + edit.getClass().getSimpleName()); //$NON-NLS-1$
    }
View Full Code Here

    final String code = writer.toString();
    if (!code.isEmpty()) {
      addChildEdit(new InsertEdit(insertPos, code));
    }
    if (length != 0) {
      addChildEdit(new DeleteEdit(insertPos, length));
    }
  }
View Full Code Here

      } else if (node.getParent() instanceof ICPPASTNamespaceDefinition) {
        writer.newLine();
      }
      final String code = writer.toString();
      if (endOffset > offset) {
        addChildEdit(new DeleteEdit(offset, endOffset - offset));
      }
      if (!code.isEmpty()) {
        addChildEdit(new InsertEdit(endOffset, code));
      }
    } else {
      node.accept(writer);
      String code = writer.toString();
      final int offset = fileLocation.getNodeOffset();
      final int endOffset = offset + fileLocation.getNodeLength();
      final String lineSeparator = writer.getScribe().getLineSeparator();
      if (code.endsWith(lineSeparator)) {
        code = code.substring(0, code.length() - lineSeparator.length());
      }
      addChildEdit(new ReplaceEdit(offset, endOffset - offset, code));
      if ((node instanceof IASTStatement) || (node instanceof IASTDeclaration)) {
        // Include trailing comments in the area to be replaced.
        final int commentEnd = getEndOffsetIncludingTrailingComments(node);
        if (commentEnd > endOffset) {
          addChildEdit(new DeleteEdit(endOffset, commentEnd - endOffset));
        }
      }
    }
  }
View Full Code Here

    final String code = writer.toString();
    if (!code.isEmpty()) {
      addChildEdit(new InsertEdit(offset, code));
    }
    if (endOffset > offset) {
      addChildEdit(new DeleteEdit(offset, endOffset - offset));
    }
  }
View Full Code Here

    private void formatFeature(MultiTextEdit allEdits) throws BadLocationException {
        int featureIndex = originalString.indexOf("Feature:");
        int lastValidChar = indexOfPreviousChar(originalString, featureIndex);

        if (featureIndex > lastValidChar && lastValidChar >= 0) {
            allEdits.addChild(new DeleteEdit(lastValidChar, featureIndex - lastValidChar));
        }
    }
View Full Code Here

        while ((scenarioIndex = originalString.indexOf("Scenario:", lastIndex + 1)) > -1) {
            lastIndex = scenarioIndex;
            int lastValidChar = indexOfPreviousChar(originalString, scenarioIndex);

            if (scenarioIndex > lastValidChar && lastValidChar >= 0) {
                allEdits.addChild(new DeleteEdit(lastValidChar, scenarioIndex - lastValidChar));
                allEdits.addChild(new InsertEdit(lastValidChar, SPACE));
            }
        }
    }
View Full Code Here

            while ((index = originalString.indexOf(annotation, lastIndex + 1)) > -1) {
                lastIndex = index;
                int lastValidChar = indexOfPreviousChar(originalString, index);

                if (index > lastValidChar && lastValidChar >= 0) {
                    allEdits.addChild(new DeleteEdit(lastValidChar, index - lastValidChar));
                }
                allEdits.addChild(new InsertEdit(lastValidChar, SPACE + SPACE));
            }
        }
    }
View Full Code Here

                if (columnSize > currentMax) {
                    columnNumberToMaxWidth.put(i, columnSize);
                }
            }

            allEdits.addChild(new DeleteEdit(originalString.indexOf(line), line.length()));
        }

        // Rebuild entire line from scratch with proper spacing
        StringBuilder formattedGrid = new StringBuilder();
        for (String line : foundGridLines) {
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.