Skip to content

Commit ee313bc

Browse files
author
Werner Randelshofer
committed
SourceLocator: Start line numbers with 1.
1 parent 77e7d82 commit ee313bc

3 files changed

Lines changed: 4 additions & 3 deletions

File tree

org.jhotdraw8.css/src/main/java/org.jhotdraw8.css/org/jhotdraw8/css/ast/SourceLocator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Indicates the position of a node in a source file, intended primarily for error reporting.
1414
*
1515
* @param characterOffset the character offset or -1 if unknown
16-
* @param lineNumber the line number or -1 if unknown
16+
* @param lineNumber the line number or -1 if unknown. A file starts with line number 1 (not with 0).
1717
* @param uri the source file URI or null if unknown
1818
*/
1919
public record SourceLocator(int characterOffset, int lineNumber,

org.jhotdraw8.css/src/main/java/org.jhotdraw8.css/org/jhotdraw8/css/ast/Stylesheet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class Stylesheet extends AbstractSyntaxTree {
2828
private final ImmutableList<StyleRule> styleRules;
2929

3030
public Stylesheet(@Nullable URI uri, List<Rule> rules) {
31-
super(new SourceLocator(0, 0, uri));
31+
super(new SourceLocator(0, 1, uri));
3232
this.uri = uri;
3333
this.rules = VectorList.copyOf(rules);
3434
this.styleRules = VectorList.copyOf(

org.jhotdraw8.css/src/main/java/org.jhotdraw8.css/org/jhotdraw8/css/parser/AbstractCssScanner.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ public abstract class AbstractCssScanner implements CssScanner {
1414
protected long position;
1515
/**
1616
* The current line number in the input stream.
17+
* An input stream starts with line number 1.
1718
*/
18-
protected long lineNumber;
19+
protected long lineNumber = 1;
1920

2021
/**
2122
* The current character.

0 commit comments

Comments
 (0)