Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre Weinand2002-03-12 10:51:24 +0000
committerAndre Weinand2002-03-12 10:51:24 +0000
commit86a6d867816054d2220b7f69825449db5b54e35d (patch)
tree918bc07db428a47ed5d1c4c1ff0f14ee14ac3a4c /bundles/org.eclipse.compare/compare/org/eclipse/compare
parent96b384230e61513f7e2678e63b9d950c0fc292f2 (diff)
downloadeclipse.platform.team-86a6d867816054d2220b7f69825449db5b54e35d.tar.gz
eclipse.platform.team-86a6d867816054d2220b7f69825449db5b54e35d.tar.xz
eclipse.platform.team-86a6d867816054d2220b7f69825449db5b54e35d.zip
version obeying exact input regions
Diffstat (limited to 'bundles/org.eclipse.compare/compare/org/eclipse/compare')
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DocLineComparator.java26
1 files changed, 21 insertions, 5 deletions
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DocLineComparator.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DocLineComparator.java
index 97239ac81..5d64f1f83 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DocLineComparator.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DocLineComparator.java
@@ -24,6 +24,7 @@ public class DocLineComparator implements ITokenComparator {
private int fLineCount;
private int fLength;
private boolean fIgnoreWhiteSpace;
+ private IRegion fRegion;
/**
* Creates a <code>DocLineComparator</code> for the given document range.
@@ -40,6 +41,7 @@ public class DocLineComparator implements ITokenComparator {
fIgnoreWhiteSpace= ignoreWhiteSpace;
fLineOffset= 0;
+ fRegion= region;
if (region != null) {
fLength= region.getLength();
int start= region.getOffset();
@@ -91,7 +93,13 @@ public class DocLineComparator implements ITokenComparator {
* see ITokenComparator.getTokenLength
*/
public int getTokenLength(int line) {
- return getTokenStart(line+1) - getTokenStart(line);
+ int s= getTokenStart(line);
+ int e= getTokenStart(line+1);
+ if (fRegion != null) {
+ if (e > fRegion.getOffset()+fRegion.getLength())
+ e= fRegion.getOffset()+fRegion.getLength();
+ }
+ return e - s;
// try {
// IRegion r= fDocument.getLineInformation(fLineOffset + line);
// return r.getLength();
@@ -137,9 +145,6 @@ public class DocLineComparator implements ITokenComparator {
* @return <code>true</code> to abort a token comparison
*/
public boolean skipRangeComparison(int length, int max, IRangeComparator other) {
-
-// if (max > 10000)
-// return true;
return false;
}
@@ -155,7 +160,18 @@ public class DocLineComparator implements ITokenComparator {
if (line < fLineCount) {
try {
IRegion r= fDocument.getLineInformation(fLineOffset + line);
- return fDocument.get(r.getOffset(), r.getLength());
+ int s= r.getOffset();
+ int l= r.getLength();
+ if (fRegion != null) {
+ int e= s+l;
+ int ee= fRegion.getOffset()+fRegion.getLength();
+ if (e > ee) {
+ System.out.println("********** extract");
+ e= ee;
+ l= e-s;
+ }
+ }
+ return fDocument.get(s, l);
} catch(BadLocationException e) {
}
}

Back to the top