Package org.eclipse.text.edits

Examples of org.eclipse.text.edits.ReplaceEdit


          }
          change = new TextFileChange(file.getName(), file);
          change.setEdit(new MultiTextEdit());
          changes.put(file, change);
        }
        final ReplaceEdit edit = new ReplaceEdit(matchAccess.getMatchOffset(), matchAccess.getMatchLength(), replacement);
        change.addEdit(edit);
        change.addTextEditGroup(new TextEditGroup("Update " + QWickieActivator.WICKET_ID, edit));
        return true;
      }
    };
View Full Code Here


          }
          change = new TextFileChange(file.getName(), file);
          change.setEdit(new MultiTextEdit());
          changes.put(file, change);
        }
        final ReplaceEdit edit = new ReplaceEdit(matchAccess.getMatchOffset(), matchAccess.getMatchLength(), replacement);
        change.addEdit(edit);
        change.addTextEditGroup(new TextEditGroup("Update " + QWickieActivator.WICKET_ID, edit));
        return true;
      }
    };
View Full Code Here

            compositeChange.add(filechange);
           
            for (Pair pair : targets.get(pack))
            {
                // edit object for the text replacement in the file, this is the only child
                ReplaceEdit rEdit = new ReplaceEdit(
                        (int) pair.first,
                        (int) pair.second,
                        "");
                InsertEdit iEdit = new InsertEdit(
                        (int) pair.first,
View Full Code Here

          // get rid of pre and post white space or fine tuned
          // adjustment later.
          // fix text here...
          replaceText = fixJspReplaceText(replaceText, jspPos);
          if (!(replaceText.length() == 0 && jspPos.length == 0))//Unwanted TextEdit can lead to MalformedTreeException.See: Bug 321977
              jspEdits.add(new ReplaceEdit(jspPos.offset, jspPos.length, replaceText));
        }
        if (DEBUG)
          debugReplace(deltas, jspPos, replaceText, i);
      }
      else {
View Full Code Here

    else if (textEdit instanceof ReplaceEdit) {
      if (jspOffset == -1)
        return null;

      if (!getTranslation().javaSpansMultipleJspPartitions(javaOffset, length))
        translatedTextEdit = new ReplaceEdit(jspOffset, length, ((ReplaceEdit) textEdit).getText());
    }
    else if (textEdit instanceof InsertEdit) {
      translatedTextEdit = new InsertEdit(jspOffset, ((InsertEdit) textEdit).getText());
    }
    else if (textEdit instanceof DeleteEdit) {
View Full Code Here

          // get rid of pre and post white space or fine tuned
          // adjustment later.
          // fix text here...
          replaceText = fixJspReplaceText(replaceText, jspPos.offset);

          jspEdits.add(new ReplaceEdit(jspPos.offset, jspPos.length, replaceText));
        }
        if (DEBUG)
          debugReplace(deltas, jspPos, replaceText, i);
      }
      else {
View Full Code Here

      String renameText = getRenameText((JavaSearchDocumentDelegate)searchDoc, javaMatch);
     
      //if rename text is null then don't create an edit for it
      if(renameText != null) {
        // add it for the correct document
        addJavaEdit(searchDoc.getPath(), new ReplaceEdit(javaMatch.getOffset(), javaMatch.getLength(), renameText));
      }
    }
  }
View Full Code Here

    for(int i = 0; i < buff.length(); i++) {
      buff.setCharAt(i, ' '); //$NON-NLS-1$
    }
    String replacementString = buff.toString();
    if (!replacementString.equals(whitespaceRun)) {
      ReplaceEdit replaceEdit = new ReplaceEdit(spaceStartOffset, whitespaceRun.length(), replacementString);
      textEdit.addChild(replaceEdit);
    }
    return availableLineWidth;
  }
View Full Code Here

    String lineDelimiters = null;
    if (!getFormattingPreferences().getClearAllBlankLines()) {
      lineDelimiters = extractLineDelimiters(whitespaceRun, currentRegion);
      String formattedLine = lineDelimiters + getIndentString(indentLevel);
      if(lineDelimiters.length() > 0 && !formattedLine.equals(whitespaceRun)) {
        textEdit.addChild(new ReplaceEdit(spaceStartOffset, whitespaceRun.length(), formattedLine));
        availableLineWidth = getFormattingPreferences().getMaxLineWidth() - indentLevel;
      }
    }
    if (lineDelimiters == null || lineDelimiters.length() == 0) {
      availableLineWidth = collapseSpaces(textEdit, spaceStartOffset, availableLineWidth, whitespaceRun);
View Full Code Here

          onOwnLine = true;

          // Compress any whitespace before the line delimiter
          if (start != end) {
            int replaceLength = end - start;
            textEdit.addChild(new ReplaceEdit(start + startOffset, replaceLength, EMPTY));
            start = end = i;
          }
        }
      }
      else {
        // Transitioned to a new word
        if (start != end) {
          int replaceLength = end - start;
          if (onOwnLine) {
            // If content is on its own line, replace leading whitespace with proper indent
            textEdit.addChild(new ReplaceEdit(start + startOffset, replaceLength, indent));
            resultLength -= (replaceLength - indent.length());
            onOwnLine = false;
          }
          else if (!(replaceLength == 1 && text.charAt(start) == ' ')) {
            textEdit.addChild(new ReplaceEdit(start + startOffset, replaceLength, SPACE));
            resultLength -= (replaceLength - 1);
          }
          start = end = i;
          // Make sure the word starts on a new line
          if (resultLength > lineWidth) {
            lineWidth = fPreferences.getMaxLineWidth();
            resultLength = 0;
            textEdit.addChild(new InsertEdit(start + startOffset, getLineDelimiter(region) + indent));
          }
        }
        // Word is immediately after line delimiters, indent appropriately
        if (onOwnLine) {
          textEdit.addChild(new InsertEdit(i + startOffset, indent));
          onOwnLine = false;
        }
        resultLength++;
      }
    }

    // Clean up any dangling whitespace
    int replaceLength = end - start;
    indent = getIndentString(indentLevel);
    if (replaceLength == 0) { // No trailing whitespace
      textEdit.addChild(new InsertEdit(length + startOffset, (onOwnLine) ? indent : SPACE));
    }
    else {
      String whitespace = text.substring(start);
      String replacement = (onOwnLine) ? indent : SPACE;
      if (!whitespace.equals(replacement)) {
        textEdit.addChild(new ReplaceEdit(start + startOffset, replaceLength, replacement));
      }
    }
  }
View Full Code Here

TOP

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

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.