Package org.eclipse.text.edits

Examples of org.eclipse.text.edits.DeleteEdit


      // or if something was added into java that was not originally in
      // JSP (like a new import...)

      if (jspPos != null) {
        if (deltas[i].isDeleted) {
          jspEdits.add(new DeleteEdit(jspPos.offset, jspPos.length));
        }
        else {
          replaceText = newJavaText.substring(deltas[i].postOffset, deltas[i].postOffset + deltas[i].postLength);

          // get rid of pre and post white space or fine tuned
View Full Code Here


    }
    else if (textEdit instanceof InsertEdit) {
      translatedTextEdit = new InsertEdit(jspOffset, ((InsertEdit) textEdit).getText());
    }
    else if (textEdit instanceof DeleteEdit) {
      translatedTextEdit = new DeleteEdit(jspOffset, length);
      TextEdit[] children = ((DeleteEdit) textEdit).getChildren();
      for (int i = 0; i < children.length; i++) {
        TextEdit translatedChildTextEdit = translateTextEdit(children[i]);
        if (translatedChildTextEdit != null)
          ((DeleteEdit) translatedTextEdit).addChild(translatedChildTextEdit);
View Full Code Here

      // or if something was added into java that was not originally in
      // JSP (like a new import...)

      if (jspPos != null) {
        if (deltas[i].isDeleted) {
          jspEdits.add(new DeleteEdit(jspPos.offset, jspPos.length));
        }
        else {
          replaceText = newJavaText.substring(deltas[i].postOffset, deltas[i].postOffset + deltas[i].postLength);

          // get rid of pre and post white space or fine tuned
View Full Code Here

    // prefer to use use existing whitespace
    int existingWhitespaceOffset = whitespaceRun.indexOf(' ');
    if (existingWhitespaceOffset > -1) {
      // delete whitespaces before and after existing whitespace
      if (existingWhitespaceOffset > 0) {
        DeleteEdit deleteEdit = new DeleteEdit(spaceStartOffset, existingWhitespaceOffset);
        textEdit.addChild(deleteEdit);
      }
      if (existingWhitespaceOffset < whitespaceRun.length() - 1) {
        int nextOffset = existingWhitespaceOffset + 1;
        DeleteEdit deleteEdit = new DeleteEdit(spaceStartOffset + nextOffset, whitespaceRun.length() - nextOffset);
        textEdit.addChild(deleteEdit);
      }
    }
    else {
      // delete all whitespace and insert new one
      // collapse whitespace by deleting whitespace
      DeleteEdit deleteEdit = new DeleteEdit(spaceStartOffset, whitespaceRun.length());
      textEdit.addChild(deleteEdit);
      // then insert one space
      InsertEdit insertEdit = new InsertEdit(spaceStartOffset, SPACE);
      textEdit.addChild(insertEdit);
    }
View Full Code Here

  private void deleteTrailingSpaces(TextEdit textEdit, ITextRegion currentTextRegion, IStructuredDocumentRegion currentDocumentRegion) {
    int textEnd = currentTextRegion.getTextEnd();
    int textEndOffset = currentDocumentRegion.getStartOffset() + textEnd;
    int difference = currentTextRegion.getEnd() - textEnd;
    DeleteEdit deleteEdit = new DeleteEdit(textEndOffset, difference);
    textEdit.addChild(deleteEdit);
  }
View Full Code Here

          }
          else {
            // just collapse spaces, but adjust for any indenting that may result from preserving line delimiters
            if (whitespaceStart == 0 && XMLFormattingConstraints.IGNOREANDTRIM.equals(whitespaceMode)) {
              // if ignore, trim
              DeleteEdit deleteTrailing = new DeleteEdit(startOffset, whitespaceRun.length());
              textEdit.addChild(deleteTrailing);
            }
            else if(XMLFormattingConstraints.REPLACE.equals(whitespaceMode))
              availableLineWidth = replaceSpaces(textEdit, startOffset, availableLineWidth, whitespaceRun);
            else
              availableLineWidth = collapseAndIndent(textEdit, startOffset, availableLineWidth, indentLevel, whitespaceRun, currentRegion);
          }

          fullTextOffset += characterRunLength;
        }
        else {
          // handle trailing whitespace
          int whitespaceOffset = currentRegion.getStartOffset() + whitespaceStart;
          if (XMLFormattingConstraints.REPLACE.equals(whitespaceMode))
            availableLineWidth = replaceSpaces(textEdit, whitespaceOffset, availableLineWidth, whitespaceRun);
          else if (XMLFormattingConstraints.IGNOREANDTRIM.equals(whitespaceMode)) {
            // always trim
            DeleteEdit deleteTrailing = new DeleteEdit(whitespaceOffset, whitespaceRun.length());
            textEdit.addChild(deleteTrailing);
          }
          else if(getFormattingPreferences().getClearAllBlankLines()) {
            if (XMLFormattingConstraints.IGNORE.equals(whitespaceMode)) {
              // if ignore, trim
              DeleteEdit deleteTrailing = new DeleteEdit(whitespaceOffset, whitespaceRun.length());
              textEdit.addChild(deleteTrailing);
            }
            else {
              // if collapse, leave a space. but what if end up
              // wanting to add indent? then need to delete space
View Full Code Here

    int endTagOffset = ((Integer) ((Object[]) fAdditionalFixInfo)[2]).intValue();
    int endTagLength = ((Integer) ((Object[]) fAdditionalFixInfo)[3]).intValue();

    MultiTextEdit multiTextEdit = new MultiTextEdit();
    if (endTagOffset != -1) {
      multiTextEdit.addChild(new DeleteEdit(endTagOffset, endTagLength));
      fSelection = new Point(endTagOffset, 0);
    }
    if (startTagOffset != -1) {
      multiTextEdit.addChild(new DeleteEdit(startTagOffset, startTagLength));
      fSelection = new Point(startTagOffset, 0);
    }

    try {
      multiTextEdit.apply(viewer.getDocument());
View Full Code Here

    int pureTypePos =
        StringUtils.indexOfAny(
            source,
            new String[]{"public ", "protected ", "class ", "interface "});
    if (pureTypePos != -1 && pureTypePos != typePos) {
      edits.addChild(new DeleteEdit(typePos, pureTypePos - typePos));
    }
  }
View Full Code Here

        int endOffset = _binding.getEndOffset();
        if (_element.isInline()) {
          IDocument htmlDocument = _cache.getHtmlEntry().getDocument();
          if (htmlDocument != null) {
            List<TextEdit> htmlEdits = new LinkedList<TextEdit>();
            htmlEdits.add(new DeleteEdit(startOffset - 1, endOffset - startOffset + 2));
            WodDocumentUtils.applyEdits(htmlDocument, htmlEdits);
          }
        }
        else {
          IDocument wodDocument = _cache.getWodEntry().getDocument();
          if (wodDocument != null) {
            List<TextEdit> wodEdits = new LinkedList<TextEdit>();
            wodEdits.add(new DeleteEdit(startOffset, endOffset - startOffset + 1));
            WodDocumentUtils.applyEdits(wodDocument, wodEdits);
          }
        }
      }
    }
View Full Code Here

      IDocument htmlDocument = _cache.getHtmlEntry().getDocument();
      if (htmlDocument != null) {
        List<TextEdit> htmlEdits = new LinkedList<TextEdit>();
        if (_unwrap && _element.hasCloseTag()) {
          htmlEdits.add(new DeleteEdit(_element.getCloseTagOffset(), _element.getCloseTagLength() + 2));
          htmlEdits.add(new DeleteEdit(_element.getOffset(), _element.getOpenTagLength() + 2));
        }
        else {
          htmlEdits.add(new DeleteEdit(_element.getOffset(), _element.getLength()));
        }
        WodDocumentUtils.applyEdits(htmlDocument, htmlEdits);
      }
    }
    catch (Exception e) {
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.