nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
grammar: add bitwise operators `|`, `^`, `&`, and `~`
[nit.git]
/
src
/
location.nit
diff --git
a/src/location.nit
b/src/location.nit
index
d7154ca
..
b65511d
100644
(file)
--- a/
src/location.nit
+++ b/
src/location.nit
@@
-26,7
+26,7
@@
class SourceFile
var string: String is noinit
# The original stream used to initialize `string`
var string: String is noinit
# The original stream used to initialize `string`
- var stream: IStream
+ var stream: Reader
init
do
init
do
@@
-55,6
+55,8
@@
class Location
var file: nullable SourceFile
# The starting line number (starting from 1)
var file: nullable SourceFile
# The starting line number (starting from 1)
+ #
+ # If `line_start==0` then the whole file is considered
var line_start: Int
# The stopping line number (starting from 1)
var line_start: Int
# The stopping line number (starting from 1)
@@
-129,9
+131,12
@@
class Location
var file_part = ""
if file != null then
file_part = file.filename
var file_part = ""
if file != null then
file_part = file.filename
- if file.filename.length > 0 then file_part += ":"
end
end
+ if line_start <= 0 then return file_part
+
+ if file != null and file.filename.length > 0 then file_part += ":"
+
if line_start == line_end then
if column_start == column_end then
return "{file_part}{line_start},{column_start}"
if line_start == line_end then
if column_start == column_end then
return "{file_part}{line_start},{column_start}"
@@
-181,6
+186,8
@@
class Location
var l = self
var i = l.line_start
var l = self
var i = l.line_start
+ if i <= 0 then return ""
+
var line_start = l.file.line_starts[i-1]
var line_end = line_start
var string = l.file.string
var line_start = l.file.line_starts[i-1]
var line_end = line_start
var string = l.file.string