File tree 1 file changed +11
-7
lines changed 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -103,15 +103,19 @@ public Optional<Integer> offset() {
103
103
return Optional .of (pos .point ());
104
104
}
105
105
public Optional <Integer > pointer () {
106
- return Optional .of (pos .point () - src .startOfLine (pos .point ()));
106
+ if (!pos .source ().exists ()) return Optional .empty ();
107
+ else return Optional .of (pos .point () - src .startOfLine (pos .point ()));
107
108
}
108
109
public Optional <String > pointerSpace () {
109
- String lineContent = this .lineContent ();
110
- int pointer = this .pointer ().get ();
111
- StringBuilder result = new StringBuilder ();
112
- for (int i = 0 ; i < pointer ; i ++)
113
- result .append (lineContent .charAt (i ) == '\t' ? '\t' : ' ' );
114
- return Optional .of (result .toString ());
110
+ if (!pos .source ().exists ()) return Optional .empty ();
111
+ else {
112
+ String lineContent = this .lineContent ();
113
+ int pointer = this .pointer ().get ();
114
+ StringBuilder result = new StringBuilder ();
115
+ for (int i = 0 ; i < pointer ; i ++)
116
+ result .append (lineContent .charAt (i ) == '\t' ? '\t' : ' ' );
117
+ return Optional .of (result .toString ());
118
+ }
115
119
}
116
120
};
117
121
} else {
You can’t perform that action at this time.
0 commit comments