public abstract static class DiffPrint.Base
extends java.lang.Object
Diff
class. This class divides the change list
into "hunks", and calls printHunk(org.jeditor.diff.Diff.change)
for each hunk. Various utility methods
are provided as well.Modifier and Type | Field and Description |
---|---|
protected int |
deletes |
protected java.lang.Object[] |
file0
Set to the lines of the files being compared.
|
protected java.lang.Object[] |
file1
Set to the lines of the files being compared.
|
protected int |
first0 |
protected int |
first1 |
protected UnaryPredicate |
ignore
Set to ignore certain kinds of lines when printing an edit script.
|
protected int |
inserts |
protected int |
last0 |
protected int |
last1 |
protected java.io.PrintWriter |
outfile |
Modifier | Constructor and Description |
---|---|
protected |
Base(java.lang.Object[] a,
java.lang.Object[] b) |
Modifier and Type | Method and Description |
---|---|
protected void |
analyzeHunk(Diff.change hunk)
Look at a hunk of edit script and report the range of lines in each file that it applies to.
|
static char |
changeLetter(int inserts,
int deletes) |
protected Diff.change |
hunkfun(Diff.change hunk)
Called with the tail of the script and returns the last link that belongs together with the start
of the tail.
|
protected abstract void |
printHunk(Diff.change hunk) |
protected void |
printNumberRange(char sepchar,
int a,
int b)
Print a pair of line numbers with
sepchar , translated for file FILE. |
protected void |
printOneLine(java.lang.String pre,
java.lang.Object linbuf) |
void |
printScript(Diff.change script)
Divide a script into pieces by calling
hunkfun(org.jeditor.diff.Diff.change) and print each piece with
printHunk(org.jeditor.diff.Diff.change) . |
protected UnaryPredicate ignore
protected java.lang.Object[] file0
protected java.lang.Object[] file1
protected int first0
protected int last0
protected int first1
protected int last1
protected int deletes
protected int inserts
protected java.io.PrintWriter outfile
public void printScript(Diff.change script)
hunkfun(org.jeditor.diff.Diff.change)
and print each piece with
printHunk(org.jeditor.diff.Diff.change)
.
Both functions take one arg, an edit script.
printHunk(org.jeditor.diff.Diff.change)
takes a subscript which belongs together (with a null link
at the end) and prints it.script
- the change scriptprotected Diff.change hunkfun(Diff.change hunk)
hunk
- the hunkprotected void analyzeHunk(Diff.change hunk)
hunk
is the start of the hunk, which is a chain of `struct change'. The first and last line numbers
of file0
are stored in first0
and last0
, and likewise for file1
in first1
and last1
. Note that these are internal line numbers that count from 0.
If no lines from file 0 are deleted, then first0
is last0
+ 1.
Also set deletes
nonzero if any lines of file0
are deleted and set inserts
nonzero
if any lines of file 1 are inserted. If only ignorable lines are inserted or deleted, both are set to 0.hunk
- the start of the hunkprotected abstract void printHunk(Diff.change hunk)
protected void printOneLine(java.lang.String pre, java.lang.Object linbuf)
protected void printNumberRange(char sepchar, int a, int b)
sepchar
, translated for file FILE.
If the two numbers are identical, print just one number.
We print the translated (real) line numbers.sepchar
- the character separatora
- the first line numberb
- the second line numberpublic static char changeLetter(int inserts, int deletes)
Copyright © 2016, 2017, 2018, 2019, 2023 Herve Girod. All Rights Reserved. Documentation and source under the MIT licence