               let length = statement.length else {
             return nil
         }
-        let startLine = file.line(for: offset, startFrom: 0)
-        let endLine = file.line(for: offset + length, startFrom: startLine)
+        let startLine = file.line(byteOffset: offset, startFrom: 0)
+        let endLine = file.line(byteOffset: offset + length, startFrom: max(startLine, 0))
 
         return (startLine, endLine)
     }

}

private extension File {
    func line(for byteOffset: Int, startFrom: Int = 0) -> Int {
        for index in startFrom..<lines.count {
            let line = lines[index]


    // other than let/var
    private func attributeLineNumbers(file: File) -> Set<Int> {
        let matches = file.match(pattern: "[@a-z]+", with: [.attributeBuiltin])
        let matchLines = matches.map { file.line(offset: $0.location) }

        return Set<Int>(matchLines)
    }
