@@ -13,14 +13,14 @@ public class LJDiagnostic extends RuntimeException {
1313 private final String accentColor ;
1414 private final String customMessage ;
1515 private String file ;
16- private ErrorPosition position ;
16+ private SourcePosition position ;
1717 private static final String PIPE = " | " ;
1818
1919 public LJDiagnostic (String title , String message , SourcePosition pos , String accentColor , String customMessage ) {
2020 this .title = title ;
2121 this .message = message ;
2222 this .file = (pos != null && pos .getFile () != null ) ? pos .getFile ().getPath () : null ;
23- this .position = ErrorPosition . fromSpoonPosition ( pos ) ;
23+ this .position = pos ;
2424 this .accentColor = accentColor ;
2525 this .customMessage = customMessage ;
2626 }
@@ -41,14 +41,14 @@ public String getDetails() {
4141 return "" ; // to be overridden by subclasses
4242 }
4343
44- public ErrorPosition getPosition () {
44+ public SourcePosition getPosition () {
4545 return position ;
4646 }
4747
4848 public void setPosition (SourcePosition pos ) {
4949 if (pos == null )
5050 return ;
51- this .position = ErrorPosition . fromSpoonPosition ( pos ) ;
51+ this .position = pos ;
5252 this .file = pos .getFile ().getPath ();
5353 }
5454
@@ -82,7 +82,7 @@ public String toString() {
8282
8383 // location
8484 if (file != null && position != null ) {
85- sb .append ("\n " ).append (file ).append (":" ).append (position .lineStart ()).append (Colors .RESET ).append ("\n " );
85+ sb .append ("\n " ).append (file ).append (":" ).append (position .getLine ()).append (Colors .RESET ).append ("\n " );
8686 }
8787
8888 return sb .toString ();
@@ -100,8 +100,8 @@ public String getSnippet() {
100100 // before and after lines for context
101101 int contextBefore = 2 ;
102102 int contextAfter = 2 ;
103- int startLine = Math .max (1 , position .lineStart () - contextBefore );
104- int endLine = Math .min (lines .size (), position .lineEnd () + contextAfter );
103+ int startLine = Math .max (1 , position .getLine () - contextBefore );
104+ int endLine = Math .min (lines .size (), position .getEndLine () + contextAfter );
105105
106106 // calculate padding for line numbers
107107 int padding = String .valueOf (endLine ).length ();
@@ -115,9 +115,9 @@ public String getSnippet() {
115115 sb .append (Colors .GREY ).append (lineNumStr ).append (PIPE ).append (line ).append (Colors .RESET ).append ("\n " );
116116
117117 // add error markers on the line(s) with the error
118- if (i >= position .lineStart () && i <= position .lineEnd ()) {
119- int colStart = (i == position .lineStart ()) ? position .colStart () : 1 ;
120- int colEnd = (i == position .lineEnd ()) ? position .colEnd () : rawLine .length ();
118+ if (i >= position .getLine () && i <= position .getEndLine ()) {
119+ int colStart = (i == position .getLine ()) ? position .getColumn () : 1 ;
120+ int colEnd = (i == position .getEndLine ()) ? position .getEndColumn () : rawLine .length ();
121121
122122 if (colStart > 0 && colEnd > 0 ) {
123123 int tabsBeforeStart = (int ) rawLine .substring (0 , Math .max (0 , colStart - 1 )).chars ()
0 commit comments