Package org.eclipse.text.edits

Examples of org.eclipse.text.edits.MultiTextEdit


      // AstyleLog.logInfo("result is " + target.toString());
      // TODO: format the who file in iteration 0 ;-)
   
      int textOffset = 0;
      int textLength = source.length();
      MultiTextEdit textEdit = new MultiTextEdit(textOffset, textLength);
      textEdit
          .addChild(new ReplaceEdit(textOffset, textLength, target));
      //     
      // File tempFile = File.createTempFile("indent", null);
      // //$NON-NLS-1$
      // FileOutputStream ostream = new FileOutputStream(tempFile);
View Full Code Here


        if (offset1 != -1 && oldName1 != null
            && oldName1.substring(1).equals(oldName)) {
          MovedTextFileChange change1 = new MovedTextFileChange(
              "Rename artifactId's value", newFile,
              deploymentPlanFile);
          MultiTextEdit rootEdit1 = new MultiTextEdit();
          ReplaceEdit edit1 = new ReplaceEdit(offset1, oldName1
              .length(), "/" + newName);
          rootEdit1.addChild(edit1);
          change1.setEdit(rootEdit1);
          result.add(change1);
        }
      }

      // create change for artifactId
      String oldName2 = editHelper
          .getNodeValue(DeploymentPlanTextNode.ARTIFACT_ID);
      int offset2 = editHelper
          .getNodeOffset(DeploymentPlanTextNode.ARTIFACT_ID);
      if (offset2 != -1 && oldName2 != null && oldName2.equals(oldName)) {
        MovedTextFileChange change2 = new MovedTextFileChange(
            "Rename context-root's value", newFile,
            deploymentPlanFile);
        MultiTextEdit rootEdit2 = new MultiTextEdit();
        ReplaceEdit edit2 = new ReplaceEdit(offset2, oldName2.length(),
            newName);
        rootEdit2.addChild(edit2);
        change2.setEdit(rootEdit2);
        result.add(change2);
      }

    } finally {
View Full Code Here

     * @return A text edit that when applied to the document, will format the jsni methods.
     */
    @SuppressWarnings("unchecked")
    public static TextEdit format(IDocument document, Map javaFormattingPrefs, Map javaScriptFormattingPrefs,
                                  Range range) {
        TextEdit combinedEdit = new MultiTextEdit();
        ITypedRegion[] regions = computePartitioning(document, range);

        // Format all JSNI blocks in the document
        int i = 0;
        for (ITypedRegion region : regions) {
            if (region.getType().equals(GWTPartitions.JSNI_METHOD)) {
                String originalJsniMethod = null;
                TextEdit edit = format(document, new TypedPosition(region), javaFormattingPrefs,
                        javaScriptFormattingPrefs, originalJsniMethod);
                if (edit != null) {
                    combinedEdit.addChild(edit);
                }
                i++;
            }
        }
        return combinedEdit;
View Full Code Here

    }
    return true;
  }

  private TextEdit format(IDocument document, Range range) {
    TextEdit combinedEdit = new MultiTextEdit();
    ITypedRegion[] regions = computePartitioning(document, range);

    // Format all JSNI blocks in the document
    int i = 0;
    for (ITypedRegion region : regions) {
      if (region.getType().equals(GWTPartitions.JSNI_METHOD)) {
        TextEdit edit = format(document, new TypedPosition(region));
        if (edit != null) {
          combinedEdit.addChild(edit);
        }
        i++;
      }
    }
    return combinedEdit;
View Full Code Here

      IDocument wodDocument = _cache.getWodEntry().getDocument();
      if (wodDocument != null) {
        IWodModel wodModel = _cache.getWodEntry().getModel();
        List<TextEdit> wodEdits = new LinkedList<TextEdit>();
        MultiTextEdit multiEdit = new MultiTextEdit();
        for (ElementRename rename : _renames) {
          IWodElement wodElement = wodModel.getElementNamed(rename.getOldName());
          wodEdits.add(new ReplaceEdit(wodElement.getElementNamePosition().getOffset(), wodElement.getElementNamePosition().getLength(), rename.getNewName()));
        }
        WodDocumentUtils.applyEdits(wodDocument, wodEdits);
View Full Code Here

public class WodDocumentUtils {
  public static void applyEdits(IDocument document, List<TextEdit> edits) throws MalformedTreeException, BadLocationException {
    IDocumentExtension4 doc4 = (IDocumentExtension4) document;
    DocumentRewriteSession rewriteSession = doc4.startRewriteSession(DocumentRewriteSessionType.UNRESTRICTED);
    try {
      MultiTextEdit multiEdit = new MultiTextEdit();
      for (TextEdit edit : edits) {
        multiEdit.addChild(edit);
      }
      multiEdit.apply(document);
    }
    finally {
      doc4.stopRewriteSession(rewriteSession);
    }
View Full Code Here

    if ( content == null ) {
        return null;
    }
   
    TextFileChange change = new TextFileChange(drlFile.getName(), drlFile);
    MultiTextEdit mte = new MultiTextEdit();
    change.setEdit(mte);
   
    boolean isImported = false;
    for (ImportDescr importDescr : drlInfo.getPackageDescr().getImports()) {
      isImported |= importDescr.getTarget().equals(className) || importDescr.getTarget().equals(packageName + ".*");
 
View Full Code Here

            Pattern pattern = Pattern.compile(toReplace);
            matcher = pattern.matcher(content);

            if (matcher.find()) {
                TextFileChange change = new TextFileChange(drlFile.getName(), drlFile);
                MultiTextEdit mte = new MultiTextEdit();
                change.setEdit(mte);
                ReplaceEdit replace = new ReplaceEdit(matcher.start(), toReplace.length(), replaceWith);
                mte.addChild(replace);
                changes.add(change);
                refactoringContent.updateContent(drlFile, content.replace(toReplace, replaceWith));
            }
        }
        return (changes.getChildren().length > 0)?changes:null;
View Full Code Here

    if (edit == null) {
        if (initialIndentationLevel > 0) {
            // at least correct the indent
            String indentString = createIndentString(initialIndentationLevel);
        ReplaceEdit[] edits = IndentManipulation.getChangeIndentEdits(unformatted, 0, this.tabWidth, this.indentWidth, indentString);
        edit= new MultiTextEdit();
        edit.addChild(new InsertEdit(0, indentString));
        edit.addChildren(edits);
        } else {
           return unformatted;
        }
View Full Code Here

      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
    }
    TextEdit[] children= oldEdit.getChildren();
    for (int i= 0; i < children.length; i++) {
View Full Code Here

TOP

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

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.