Skip to content

Commit 9208207

Browse files
authored
Fix incorrect positions in imported files (#691)
1 parent fc5c95d commit 9208207

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

src/main/scala/viper/silver/parser/FastParser.scala

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -126,19 +126,6 @@ class FastParser {
126126
var _file: Path = null
127127

128128
def parse(s: String, f: Path, plugins: Option[SilverPluginManager] = None) = {
129-
_file = f.toAbsolutePath
130-
131-
// Add an empty line at the end to make `computeFrom(s.length)` return `(lines.length, 1)`, as the old
132-
// implementation of `computeFrom` used to do.
133-
val lines = s.linesWithSeparators
134-
_line_offset = (lines.map(_.length) ++ Seq(0)).toArray
135-
var offset = 0
136-
for (i <- _line_offset.indices) {
137-
val line_length = _line_offset(i)
138-
_line_offset(i) = offset
139-
offset += line_length
140-
}
141-
142129
// Strategy to handle imports
143130
// Idea: Import every import reference and merge imported methods, functions, imports, .. into current program
144131
// iterate until no new imports are present.
@@ -260,6 +247,19 @@ class FastParser {
260247
case class RecParser(file: Path) {
261248

262249
def parses(s: String) = {
250+
_file = file.toAbsolutePath
251+
252+
// Add an empty line at the end to make `computeFrom(s.length)` return `(lines.length, 1)`, as the old
253+
// implementation of `computeFrom` used to do.
254+
val lines = s.linesWithSeparators
255+
_line_offset = (lines.map(_.length) ++ Seq(0)).toArray
256+
var offset = 0
257+
for (i <- _line_offset.indices) {
258+
val line_length = _line_offset(i)
259+
_line_offset(i) = offset
260+
offset += line_length
261+
}
262+
263263
fastparse.parse(s, entireProgram(_))
264264
}
265265
}

0 commit comments

Comments
 (0)