Examples of ReplaceEdit


Examples of org.eclipse.jgit.diff.ReplaceEdit

    SafeHtmlBuilder buf = new SafeHtmlBuilder();

    int curIdx = 0;
    Edit curEdit = edits.get(curIdx);

    ReplaceEdit lastReplace = null;
    List<Edit> charEdits = null;
    int lastPos = 0;
    int lastIdx = 0;

    for (int index = src.first(); index < src.size(); index = src.next(index)) {
      int cmp = compare(index, curEdit);
      while (0 < cmp) {
        // The index is after the edit. Skip to the next edit.
        //
        curEdit = edits.get(curIdx++);
        cmp = compare(index, curEdit);
      }

      if (cmp < 0) {
        // index occurs before the edit. This is a line of context.
        //
        appendShowBareCR(buf, src.get(index), true);
        buf.append('\n');
        continue;
      }

      // index occurs within the edit. The line is a modification.
      //
      if (curEdit instanceof ReplaceEdit) {
        if (lastReplace != curEdit) {
          lastReplace = (ReplaceEdit) curEdit;
          charEdits = lastReplace.getInternalEdits();
          lastPos = 0;
          lastIdx = 0;
        }

        String line = src.get(index) + "\n";
View Full Code Here

Examples of org.eclipse.jgit.diff.ReplaceEdit

    writeVarInt32(out, edits.size());
    for (Edit e : edits) {
      writeEdit(out, e);

      if (e instanceof ReplaceEdit) {
        ReplaceEdit r = (ReplaceEdit) e;
        writeVarInt32(out, r.getInternalEdits().size());
        for (Edit i : r.getInternalEdits()) {
          writeEdit(out, i);
        }
      } else {
        writeVarInt32(out, 0);
      }
View Full Code Here

Examples of org.eclipse.jgit.diff.ReplaceEdit

      if (0 < innerCount) {
        Edit[] inner = new Edit[innerCount];
        for (int j = 0; j < innerCount; j++) {
          inner[j] = readEdit(in);
        }
        editArray[i] = new ReplaceEdit(editArray[i], toList(inner));
      }
    }
    edits = toList(editArray);
  }
View Full Code Here

Examples of org.eclipse.jgit.diff.ReplaceEdit

          }

          wordEdits.set(j, new Edit(ab, ae, bb, be));
        }

        edits.set(i, new ReplaceEdit(e, wordEdits));
      }
    }

    return new IntraLineDiff(edits);
  }
View Full Code Here

Examples of org.eclipse.php.formatter.core.ReplaceEdit

  }

  private String applyChanges(String content, List<?> changes) {
    StringBuffer result = new StringBuffer(content);
    for (int i = changes.size() - 1; i >= 0; i--) {
      ReplaceEdit replace = (ReplaceEdit) changes.get(i);
      result = result.replace(replace.offset, replace.getEnd(),
          replace.content);
    }
    return result.toString();
  }
View Full Code Here

Examples of org.eclipse.text.edits.ReplaceEdit

      FindReplaceDocumentAdapter find = new FindReplaceDocumentAdapter(doc);
      IRegion resultStart = find.find(0, "location\\s*=\\s*\"", true, true, false, true);
      IRegion resultStop = find.find(resultStart.getOffset() + resultStart.getLength(), "\"", true, true, false, false);
 
      String linkTarget = WGADesignStructureHelper.computeDirLinkTarget(info.getFile().getParent(), computeNewLinkTarget(info));
      TextEdit edit = new ReplaceEdit(resultStart.getLength() + resultStart.getOffset(), resultStop.getOffset() - (resultStart.getLength() + resultStart.getOffset()), linkTarget);
     
      change.setEdit(edit);
      return change;
      }else if (info.getArguments() instanceof DeleteArguments) {
        // check if resource to delete will still exists after parent deletion is performed - otherwise we can skip any change here
View Full Code Here

Examples of org.eclipse.text.edits.ReplaceEdit

      if(errors.isEmpty()) {
       
     
      ByteArrayOutputStream configContent = new ByteArrayOutputStream();   
      WGAConfiguration.write(config, configContent);
      change.setEdit(new ReplaceEdit(0, change.getCurrentDocument((new NullProgressMonitor())).getLength(), configContent.toString()))
      return change;
      } else {
        for(ValidationError current : errors){
          WGADesignerPlugin.getDefault().logError(current.getMessage());
        }
View Full Code Here

Examples of org.eclipse.text.edits.ReplaceEdit

      edit = new MultiTextEdit(this.textRegionStart, this.textRegionEnd - this.textRegionStart + 1);
    }
    for (int i= 0, max = this.editsIndex; i < max; i++) {
      OptimizedReplaceEdit currentEdit = edits[i];
      if (isValidEdit(currentEdit)) {
        edit.addChild(new ReplaceEdit(currentEdit.offset, currentEdit.length, currentEdit.replacement));
      }
    }
    this.edits = null;
    return edit;
  }
View Full Code Here

Examples of org.eclipse.text.edits.ReplaceEdit

 
     
  private static TextEdit shifEdit(TextEdit oldEdit, int diff) {
    TextEdit newEdit;
    if (oldEdit instanceof ReplaceEdit) {
      ReplaceEdit edit= (ReplaceEdit) oldEdit;
      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

Examples of org.eclipse.text.edits.ReplaceEdit

        IRegion region= tracker.getLineInformation(i);
        int offset= region.getOffset();
        String line= source.substring(offset, offset + region.getLength());
        int length= indexOfIndent(line, indentUnitsToRemove, tabWidth, indentWidth);
        if (length >= 0) {
          result.add(new ReplaceEdit(offset, length, newIndentString));
        } else {
          length= measureIndentUnits(line, tabWidth, indentWidth);
          result.add(new ReplaceEdit(offset, length, "")); //$NON-NLS-1$
        }
      }
    } catch (BadLocationException cannotHappen) {
      // can not happen
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.