Examples of RangeDifference


Examples of com.alkacon.diff.rangedifferencer.RangeDifference

        BlockComparator leftBlockComparator = new BlockComparator(block1);
        BlockComparator rightBlockComparator = new BlockComparator(block2);
        RangeDifference[] lineDiffs = RangeDifferencer.findDifferences(leftBlockComparator, rightBlockComparator);

        int pos = 0;
        RangeDifference diff = null;
        output.startLine(diffLineType);

        for (int i = 0; i < lineDiffs.length; i++) {
            diff = lineDiffs[i];

            int left = diff.leftStart();
            if (pos < left) {
                String[] strings = leftBlockComparator.substringSplitted(pos, left);
                for (int d = 0; d < strings.length; d++) {
                    if (strings[d].equals("\n")) {
                        output.endLine();
                        output.startLine(diffLineType);
                    } else {
                        output.addUnchangedText(strings[d]);
                    }
                }
            }

            if (diff.leftLength() > 0) {
                String[] strings = leftBlockComparator.substringSplitted(left, diff.leftEnd());
                for (int d = 0; d < strings.length; d++) {
                    if (strings[d].equals("\n")) {
                        output.endLine();
                        output.startLine(diffLineType);
                    } else {
                        output.addChangedText(strings[d]);
                    }
                }
            }

            pos = diff.leftEnd();
        }

        if ((diff == null) || (diff.leftEnd() < leftBlockComparator.getRangeCount())) {
            int start = 0;
            if (diff != null) {
                start = diff.leftEnd();
            }
            String[] strings = leftBlockComparator.substringSplitted(start);
            for (int d = 0; d < strings.length; d++) {
                if (strings[d].equals("\n")) {
                    output.endLine();
View Full Code Here

Examples of com.alkacon.diff.rangedifferencer.RangeDifference

        if (differences.length > 0) {
            int diffIndex = 0;

            int leftLineCount = leftComparator.getRangeCount();
            do {
                RangeDifference diff = differences[diffIndex];

                if (diff.kind() == RangeDifference.CHANGE) {
                    int nextChangedLine = diff.leftStart();

                    // output contextLineCount number of lines (if available) or all lines if contextLineCount == -1
                    if (pos != 0) { // at start of file, skip immediately to first changes
                        int beginContextEndPos = pos + config.getLinesBeforeSkip();
                        while (((pos < beginContextEndPos) || (config.getLinesBeforeSkip() == -1))
                            && (pos + MIN_EQUAL_LINES < nextChangedLine)) {
                            output.startLine(DiffLineType.UNCHANGED);
                            output.addUnchangedText(leftComparator.getLine(pos));
                            output.endLine();
                            pos++;
                        }
                    }

                    // skip a number of lines
                    if (config.getLinesBeforeSkip() >= 0) {
                        int endContextStartPos = nextChangedLine - config.getLinesBeforeSkip();
                        if (endContextStartPos >= pos + MIN_EQUAL_LINES) {
                            output.skippedLines(endContextStartPos - pos);
                            pos = endContextStartPos;
                        }
                    }

                    // output contextLineCount number of lines
                    while (pos < nextChangedLine) {
                        output.startLine(DiffLineType.UNCHANGED);
                        output.addUnchangedText(leftComparator.getLine(pos));
                        output.endLine();
                        pos++;
                    }

                    StringBuffer leftBlock = null;
                    StringBuffer rightBlock = null;
                    if ((diff.leftLength() > 0) && (diff.rightLength() > 0)) {
                        leftBlock = concatLines(leftComparator, diff.leftStart(), diff.leftLength());
                        rightBlock = concatLines(rightComparator, diff.rightStart(), diff.rightLength());
                    }

                    if (leftBlock == null) {
                        for (int i = 0; i < diff.leftLength(); i++) {
                            int currentLine = diff.leftStart() + i;
                            output.startLine(DiffLineType.REMOVED);
                            output.addUnchangedText(leftComparator.getLine(currentLine));
                            output.endLine();
                        }
                    } else {
                        diffBlock(leftBlock, rightBlock, output, DiffLineType.REMOVED);
                    }

                    if (leftBlock == null) {
                        for (int i = 0; i < diff.rightLength(); i++) {
                            int currentLine = diff.rightStart() + i;
                            output.startLine(DiffLineType.ADDED);
                            output.addUnchangedText(rightComparator.getLine(currentLine));
                            output.endLine();
                        }
                    } else {
View Full Code Here

Examples of com.dotcms.repackage.org.eclipse.compare.rangedifferencer.RangeDifference

                            throw new IllegalStateException(
                                    "space found aiaiai");
                    }
                }
            }
            newRanges.add(new RangeDifference(kind, rightStart, rightEnd
                    - rightStart, leftStart, leftEnd - leftStart));
        }

        return newRanges;
    }
View Full Code Here

Examples of com.dotcms.repackage.org.eclipse.compare.rangedifferencer.RangeDifference

                leftEnd = differences[i + 1].leftEnd();
                rightEnd = differences[i + 1].rightEnd();
                i++;
            }

            newRanges.add(new RangeDifference(kind, rightStart, rightEnd
                    - rightStart, leftStart, leftEnd - leftStart));
        }

        return newRanges;
    }
View Full Code Here

Examples of com.dotcms.repackage.org.eclipse.compare.rangedifferencer.RangeDifference

                leftLength = leftEnd - leftStart;
                rightLength = rightEnd - rightStart;
                i++;
            }

            newRanges.add(new RangeDifference(kind, rightStart, rightLength, leftStart, leftLength));
        }

        return newRanges;
    }
View Full Code Here

Examples of com.dotcms.repackage.org.eclipse.compare.rangedifferencer.RangeDifference

            rootlistopened = true;
        }

        for (int j = 0; j < differences.length; j++) {

            RangeDifference d = differences[j];

            boolean lvl1listopened = false;

            if (rootlistopened) {
                txt.addHtml("<li>");
            }

            if (d.leftLength() + d.rightLength() > 1) {
                txt.addHtml("<ul class='changelist'>");
                lvl1listopened = true;
            }

            // left are the old ones
            for (int i = d.leftStart(); i < d.leftEnd(); i++) {
                if (lvl1listopened)
                    txt.addHtml("<li>");

                // add a bullet for a old tag
                addTagOld(txt, other.getAncestor(i));

                if (lvl1listopened)
                    txt.addHtml("</li>");

            }

            // right are the new ones
            for (int i = d.rightStart(); i < d.rightEnd(); i++) {
                if (lvl1listopened)
                    txt.addHtml("<li>");

                // add a bullet for a new tag
                addTagNew(txt, this.getAncestor(i));
View Full Code Here

Examples of org.eclipse.compare.rangedifferencer.RangeDifference

        return;
      }

      // Debug: Raw output
      for (int i=0; i<rd.length; i++ ) {
        RangeDifference rdi = rd[i];
        log( rdi.kindString() + " left " + rdi.leftStart() + "," + rdi.leftLength()
            + " right " + rdi.rightStart() + "," + rdi.rightLength() );
      }

      log("top level LCS done; now performing child actions ...");


      int leftIdx = 0;
      for (int i=0; i<rd.length; i++ ) {

        RangeDifference rdi = rd[i];

        // No change
        if (rdi.leftStart() > leftIdx) {

          for (int k = leftIdx ; k< rdi.leftStart() ; k++) {
            // This just goes straight into the output,
            // since it is the same on the left and the right.
            // Since it is the same on both side, we handle
            // it here (on the left side), and
            // ignore it on the right
            //out.append("\n<!-- Adding same -->\n");
            addComment("Adding same", formatter);
              formatter.declarePrefixMapping(leftESC.getItem(k).getPrefixMapping());
            formatEventSequence(leftESC.getItem(k), formatter);
            //out.append("\n<!-- .. Adding same done -->");
            addComment(".. Adding same done ", formatter);

            // If we wanted to difference sdt's which
            // were treated the as the same (via their id)
            // this is where we'd have to change
            // (in addition to changing EventSequence for
            //  such things so that hashcode returned their
            //  id!)
          }
          leftIdx = rdi.leftStart();
        }

        EventSequence seq1 = new EventSequence();
        // Evil hack - doesn't work
        // seq1.mapPrefix("http://schemas.openxmlformats.org/wordprocessingml/2006/main", "w");

        for (int k = rdi.leftStart() ; k< rdi.leftEnd() ; k++) {

          if (rdi.kind()==rdi.CHANGE) {
            // This we need to diff
            //leftReport.append( "#" );
            seq1.addSequence(leftESC.getItem(k));

            // Don't forget our existing prefix mappings!
            PrefixMapping existingPM = leftESC.getItem(k).getPrefixMapping();
            addToPrefixMapping(seq1.getPrefixMapping(), existingPM);
          } else {
            // Does this happen?
            // This just goes straight into the output,
              formatter.declarePrefixMapping(leftESC.getItem(k).getPrefixMapping());
            //out.append("\n<!-- Adding same II -->\n");
            addComment("Adding same II", formatter);
            formatEventSequence(leftESC.getItem(k), formatter);
            //out.append("\n<!-- .. Adding same done -->");
            addComment(".. Adding same done", formatter);
          }
        }


        EventSequence seq2 = new EventSequence();
        // Evil hack - doesn't work
        //seq2.mapPrefix("http://schemas.openxmlformats.org/wordprocessingml/2006/main", "w");
        for (int k = rdi.rightStart() ; k< rdi.rightEnd() ; k++) {
          if (rdi.kind()==rdi.CHANGE) {
            // This is the RHS of the diff
            //rightReport.append( "#" );
            seq2.addSequence(rightESC.getItem(k));

            // Don't forget our existing prefix mappings!
            PrefixMapping existingPM = rightESC.getItem(k).getPrefixMapping();
            addToPrefixMapping(seq2.getPrefixMapping(), existingPM);

          }
        }

        leftIdx = rdi.leftEnd();

        // ok, now perform this diff
        //log("performing diff");
        //out.append("\n<!-- Differencing -->\n");
        addComment("Differencing", formatter);
View Full Code Here

Examples of org.eclipse.compare.rangedifferencer.RangeDifference

        //2. Successive changed lines are merged into on RangeDifference
        //     forAll r1,r2 element differences: r1.rightStart()<r2.rightStart() -> r1.rightEnd()<r2.rightStart

        ArrayList<Integer> regions = new ArrayList<Integer>();
        for (int i = 0; i < differences.length; i++) {
            RangeDifference curr = differences[i];
            if (curr.kind() == RangeDifference.CHANGE && curr.rightLength() > 0) {
                int startLine = curr.rightStart();
                int endLine = curr.rightEnd() - 1;

                if (startLine == endLine) {
                    regions.add(startLine);
                } else {
                    for (int iLine = startLine; iLine <= endLine; iLine++) {
View Full Code Here

Examples of org.eclipse.compare.rangedifferencer.RangeDifference

      rootlistopened = true;
    }

    for (int j = 0; j < differences.length; j++) {

      RangeDifference d = differences[j];

      boolean lvl1listopened = false;

      if (rootlistopened) {
        txt.addHtml("<li>");
      }

      if (d.leftLength() + d.rightLength() > 1) {
        txt.addHtml("<ul class='changelist'>");
        lvl1listopened = true;
      }

      // left are the old ones
      for (int i = d.leftStart(); i < d.leftEnd(); i++) {
        if (lvl1listopened)
          txt.addHtml("<li>");

        // add a bullet for a old tag
        addTagOld(txt, other.getAncestor(i));

        if (lvl1listopened)
          txt.addHtml("</li>");

      }

      // right are the new ones
      for (int i = d.rightStart(); i < d.rightEnd(); i++) {
        if (lvl1listopened)
          txt.addHtml("<li>");

        // add a bullet for a new tag
        addTagNew(txt, this.getAncestor(i));
View Full Code Here

Examples of org.eclipse.compare.rangedifferencer.RangeDifference

        leftLength = leftEnd - leftStart;
        rightLength = rightEnd - rightStart;
        i++;
      }

      newRanges.add(new RangeDifference(kind, rightStart, rightLength,
          leftStart, leftLength));
    }

    return newRanges;
  }
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.