@Override public int getTokenLength(int line) { return getTokenStart(line+1) - getTokenStart(line); }
/** * Returns <code>true</code> if a line given by the first index * matches a line specified by the other <code>IRangeComparator</code> and index. * * @param thisIndex the number of the line within this range comparator * @param otherComparator the range comparator to compare this with * @param otherIndex the number of the line within the other comparator * @return <code>true</code> if the lines are equal */ public boolean rangesEqual(int thisIndex, IRangeComparator otherComparator, int otherIndex) { if (otherComparator != null && otherComparator.getClass() == getClass()) { DocLineComparator other= (DocLineComparator) otherComparator; if (fIgnoreWhiteSpace) { String s1= extract(thisIndex); String s2= other.extract(otherIndex); //return s1.trim().equals(s2.trim()); return compare(s1, s2); } int tlen= getTokenLength(thisIndex); int olen= other.getTokenLength(otherIndex); if (tlen == olen) { String s1= extract(thisIndex); String s2= other.extract(otherIndex); return s1.equals(s2); } } return false; }
private boolean isCapped(DocLineComparator ancestor, DocLineComparator left, DocLineComparator right) { if (isCappingDisabled()) return false; int aLength = ancestor == null? 0 : ancestor.getRangeCount(); int lLength = left.getRangeCount(); int rLength = right.getRangeCount(); if ((double) aLength * (double) lLength > LCS.TOO_LONG || (double) aLength * (double) rLength > LCS.TOO_LONG || (double) lLength * (double) rLength > LCS.TOO_LONG) return true; return false; }
continue; DocLineComparator sleft = new DocLineComparator(lDoc, null, shouldIgnoreWhitespace()); DocLineComparator sright = new DocLineComparator(rDoc, null, shouldIgnoreWhitespace()); int leftEnd = sleft.getTokenStart(diff.leftStart() + diff.leftLength()); String left = lDoc.get(lRegion.getOffset(), leftEnd - lRegion.getOffset()); IRegion rRegion = rDoc.getLineInformation(diff.rightStart()); int rightEnd = sright.getTokenStart(diff.rightStart() + diff.rightLength()); String right = rDoc.get(rRegion.getOffset(),
private boolean compareStrings(String left, String right, IProgressMonitor monitor) { IDocument lDoc = new Document(left); IDocument rDoc = new Document(right); DocLineComparator sleft = new DocLineComparator(lDoc, new Region(0, lDoc.getLength()), shouldIgnoreWhitespace()); DocLineComparator sright = new DocLineComparator(rDoc, new Region(0, rDoc.getLength()), shouldIgnoreWhitespace()); final DocLineComparator sl = sleft, sr = sright; RangeDifference[] ranges = RangeDifferencer.findRanges(monitor, sl, sr); return compareRangeDifferences(ranges, lDoc, rDoc); } }
if (extracts[0] == null) { extracts[0] = Utilities.applyCompareFilters( extract(thisIndex, includeSeparator), fContributor, other.extract(otherIndex, includeSeparator), other.fContributor, fCompareFilters); fCompareFilterCache if (extracts[1] == null) { extracts[1] = Utilities.applyCompareFilters( other.extract(otherIndex, includeSeparator), other.fContributor, extract(thisIndex, includeSeparator), fContributor, fCompareFilters); other.fCompareFilterCache.put(Integer.valueOf(otherIndex), extracts[1]); String thisLine = extract(thisIndex, includeSeparator); String otherLine = other.extract(otherIndex, includeSeparator); extracts = new String[] { Utilities.applyCompareFilters(thisLine, fContributor, extracts = new String[] { extract(thisIndex, includeSeparator), other.extract(otherIndex, includeSeparator) };
ICompareFilter[] compareFilters = getCompareFilters(); DocLineComparator sright= new DocLineComparator(rDoc, toRegion(rRegion), ignoreWhiteSpace, compareFilters, MergeViewerContentProvider.RIGHT_CONTRIBUTOR); DocLineComparator sleft= new DocLineComparator(lDoc, toRegion(lRegion), ignoreWhiteSpace, compareFilters, MergeViewerContentProvider.LEFT_CONTRIBUTOR); DocLineComparator sancestor= null; if (aDoc != null) sancestor= new DocLineComparator(aDoc, toRegion(aRegion), ignoreWhiteSpace, compareFilters, MergeViewerContentProvider.ANCESTOR_CONTRIBUTOR); int ancestorEnd= 0; if (sancestor != null) { ancestorStart= sancestor.getTokenStart(es.ancestorStart()); ancestorEnd= getTokenEnd2(sancestor, es.ancestorStart(), es.ancestorLength()); int leftStart= sleft.getTokenStart(es.leftStart()); int leftEnd= getTokenEnd2(sleft, es.leftStart(), es.leftLength()); int rightStart= sright.getTokenStart(es.rightStart()); int rightEnd= getTokenEnd2(sright, es.rightStart(), es.rightLength());
ICompareFilter[] compareFilters = getCompareFilters(); DocLineComparator sright = new DocLineComparator(rDoc, toRegion(rRegion), ignoreWhiteSpace, compareFilters, MergeViewerContentProvider.RIGHT_CONTRIBUTOR); DocLineComparator sleft = new DocLineComparator(lDoc, toRegion(lRegion), ignoreWhiteSpace, compareFilters, MergeViewerContentProvider.LEFT_CONTRIBUTOR); DocLineComparator sancestor = null; if (aDoc != null) { sancestor = new DocLineComparator(aDoc, toRegion(aRegion), ignoreWhiteSpace, compareFilters, MergeViewerContentProvider.ANCESTOR_CONTRIBUTOR); int ancestorEnd= 0; if (sancestor != null) { ancestorStart= sancestor.getTokenStart(es.ancestorStart()); ancestorEnd= getTokenEnd2(sancestor, es.ancestorStart(), es.ancestorLength()); int leftStart= sleft.getTokenStart(es.leftStart()); int leftEnd= getTokenEnd2(sleft, es.leftStart(), es.leftLength()); int rightStart= sright.getTokenStart(es.rightStart()); int rightEnd= getTokenEnd2(sright, es.rightStart(), es.rightLength());
/** * Returns <code>true</code> if a line given by the first index * matches a line specified by the other <code>IRangeComparator</code> and index. * * @param thisIndex the number of the line within this range comparator * @param otherComparator the range comparator to compare this with * @param otherIndex the number of the line within the other comparator * @return <code>true</code> if the lines are equal */ @Override public boolean rangesEqual(int thisIndex, IRangeComparator otherComparator, int otherIndex) { if (otherComparator != null && otherComparator.getClass() == getClass()) { DocLineComparator other= (DocLineComparator) otherComparator; if (fIgnoreWhiteSpace) { String[] linesToCompare = extract(thisIndex, otherIndex, other, false); return compare(linesToCompare[0], linesToCompare[1]); } int tlen= getTokenLength(thisIndex); int olen= other.getTokenLength(otherIndex); if (fCompareFilters != null && fCompareFilters.length > 0) { String[] linesToCompare = extract(thisIndex, otherIndex, other, true); return linesToCompare[0].equals(linesToCompare[1]); } else if (tlen == olen) { String[] linesToCompare = extract(thisIndex, otherIndex, other, false); return linesToCompare[0].equals(linesToCompare[1]); } } return false; }
public int getTokenLength(int line) { return getTokenStart(line+1) - getTokenStart(line); }
DocLineComparator sright= new DocLineComparator(rDoc, toRegion(rRegion), ignoreWhiteSpace); DocLineComparator sleft= new DocLineComparator(lDoc, toRegion(lRegion), ignoreWhiteSpace); DocLineComparator sancestor= null; if (aDoc != null) sancestor= new DocLineComparator(aDoc, toRegion(aRegion), ignoreWhiteSpace); int ancestorEnd= 0; if (sancestor != null) { ancestorStart= sancestor.getTokenStart(es.ancestorStart()); ancestorEnd= getTokenEnd2(sancestor, es.ancestorStart(), es.ancestorLength()); int leftStart= sleft.getTokenStart(es.leftStart()); int leftEnd= getTokenEnd2(sleft, es.leftStart(), es.leftLength()); int rightStart= sright.getTokenStart(es.rightStart()); int rightEnd= getTokenEnd2(sright, es.rightStart(), es.rightLength());
DocLineComparator sright= new DocLineComparator(rDoc, toRegion(rRegion), ignoreWhiteSpace); DocLineComparator sleft= new DocLineComparator(lDoc, toRegion(lRegion), ignoreWhiteSpace); DocLineComparator sancestor= null; boolean isRight = true; if (aDoc != null) { sancestor= new DocLineComparator(aDoc, toRegion(aRegion), ignoreWhiteSpace); if (isPatchHunk()) { ITypedElement right = ((ICompareInput)getInput()).getRight(); isRight = right != null && Utilities.getAdapter(right, IHunk.class) != null; if (isRight) { sleft= new DocLineComparator(aDoc, toRegion(aRegion), ignoreWhiteSpace); } else { sright= new DocLineComparator(aDoc, toRegion(aRegion), ignoreWhiteSpace); int ancestorEnd= 0; if (sancestor != null) { ancestorStart= sancestor.getTokenStart(es.ancestorStart()); ancestorEnd= getTokenEnd2(sancestor, es.ancestorStart(), es.ancestorLength()); int leftStart= sleft.getTokenStart(es.leftStart()); int leftEnd= getTokenEnd2(sleft, es.leftStart(), es.leftLength()); int rightStart= sright.getTokenStart(es.rightStart()); int rightEnd= getTokenEnd2(sright, es.rightStart(), es.rightLength());