public void skipThrough(char[] in, int pos) throws IOException, BadLocationException { String origText = new String(in, offset, pos - offset); org.netbeans.api.java.source.ModificationResult.Difference diff = diffs.size() > 0 ? diffs.get(diffs.size() - 1) : null; if (diff != null && diff.getKind() == org.netbeans.api.java.source.ModificationResult.Difference.Kind.INSERT && diff.getStartPosition().getOffset() == offset) { diffs.remove(diffs.size() - 1); diffs.add(JavaSourceAccessor.getINSTANCE().createDifference(ModificationResult.Difference.Kind.CHANGE, diff.getStartPosition(), diff.getEndPosition(), origText, diff.getNewText(), diff.getDescription(), src)); } else { int off = converter != null ? converter.getOriginalPosition(offset) : offset; if (off >= 0) { diffs.add(JavaSourceAccessor.getINSTANCE().createDifference(ModificationResult.Difference.Kind.REMOVE, prp.createPosition(off, Bias.Forward), prp.createPosition(off + origText.length(), Bias.Backward), origText, null, userInfo.get(offset), src)); } } offset = pos; }
public void writeTo(String s) throws IOException, BadLocationException { ModificationResult.Difference diff = diffs.size() > 0 ? diffs.get(diffs.size() - 1) : null; if (diff != null && diff.getKind() == ModificationResult.Difference.Kind.REMOVE && diff.getEndPosition().getOffset() == offset) { diffs.remove(diffs.size() - 1); diffs.add(JavaSourceAccessor.getINSTANCE().createDifference(ModificationResult.Difference.Kind.CHANGE, diff.getStartPosition(), diff.getEndPosition(), diff.getOldText(), s, diff.getDescription(), src)); } else { int off = converter != null ? converter.getOriginalPosition(offset) : offset; if (off >= 0) { diffs.add(JavaSourceAccessor.getINSTANCE().createDifference(ModificationResult.Difference.Kind.INSERT, prp.createPosition(off, Bias.Forward), prp.createPosition(off, Bias.Backward), null, s, userInfo.get(offset), src)); } } }
private DiffElement(Difference diff, PositionBounds bounds, FileObject parentFile, ModificationResult modification) { this.bounds = bounds; this.displayText = diff.getDescription(); this.parentFile = parentFile; this.diff = diff; this.modification = modification; }