Class LogicalLine
java.lang.Object
org.variantsync.diffdetective.variation.diff.parse.LogicalLine
A logical line consisting of multiple physical lines of a text file joined by line continuations.
The concept of a logical line is used by the C11 standard to refer to one source code line of a
source file after all line continuations have been eliminated. Essentially a logical line is a
string matched by the regex
([^\n]|\\\n)*
where \n
represents the platform
dependent line delimiter. In contrast, a physical line is matched by the regex [^\n]*
.- Author:
- Benjamin Moosherr
-
Field Summary
Modifier and TypeFieldDescriptionprivate boolean
private boolean
private static final Pattern
private List<DiffLinesLabel.Line>
private DiffLineNumber
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
consume
(String line, DiffLineNumber lineNumber) Adds the physical lineline
with the line numberlineNumber
to this logical line.getLines()
Returns all physical linesconsume(java.lang.String,org.variantsync.diffdetective.diff.text.DiffLineNumber)
d for the current logical line.Returns the line number of the firstconsume(java.lang.String,org.variantsync.diffdetective.diff.text.DiffLineNumber)
d physical line of the current physical line.boolean
Returnstrue
iff at least one physical line wasconsume(java.lang.String,org.variantsync.diffdetective.diff.text.DiffLineNumber)
d.boolean
Returnstrue
iff the current logical is complete and the next physical line belongs to a new logical line.void
reset()
Starts a new, empty logical line.toString()
Returns this line without line continuations.
-
Field Details
-
lines
-
isContinued
private boolean isContinued -
inComment
private boolean inComment -
startLineNumber
-
LINE_COMMENT
-
-
Constructor Details
-
LogicalLine
public LogicalLine()Constructs an empty logical line.
-
-
Method Details
-
reset
public void reset()Starts a new, empty logical line. This especially ensureshasStarted() == false
andisComplete() == false
. -
consume
Adds the physical lineline
with the line numberlineNumber
to this logical line. This must not be called whileisComplete()
returnstrue
. There must be no new line inside ofline
. -
hasStarted
public boolean hasStarted()Returnstrue
iff at least one physical line wasconsume(java.lang.String,org.variantsync.diffdetective.diff.text.DiffLineNumber)
d. -
isComplete
public boolean isComplete()Returnstrue
iff the current logical is complete and the next physical line belongs to a new logical line. -
getStartLineNumber
Returns the line number of the firstconsume(java.lang.String,org.variantsync.diffdetective.diff.text.DiffLineNumber)
d physical line of the current physical line. -
getLines
Returns all physical linesconsume(java.lang.String,org.variantsync.diffdetective.diff.text.DiffLineNumber)
d for the current logical line. The backslashes of line continuations are still part of the strings. -
toString
Returns this line without line continuations.
-