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
FieldsModifier and TypeFieldDescriptionprivate booleanprivate booleanprivate static final Patternprivate List<DiffLinesLabel.Line> private DiffLineNumber -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidconsume(String line, DiffLineNumber lineNumber) Adds the physical linelinewith the line numberlineNumberto 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.booleanReturnstrueiff at least one physical line wasconsume(java.lang.String,org.variantsync.diffdetective.diff.text.DiffLineNumber)d.booleanReturnstrueiff the current logical is complete and the next physical line belongs to a new logical line.voidreset()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() == falseandisComplete() == false. -
consume
Adds the physical linelinewith the line numberlineNumberto this logical line. This must not be called whileisComplete()returnstrue. There must be no new line inside ofline. -
hasStarted
public boolean hasStarted()Returnstrueiff at least one physical line wasconsume(java.lang.String,org.variantsync.diffdetective.diff.text.DiffLineNumber)d. -
isComplete
public boolean isComplete()Returnstrueiff 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.
-