               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)
     }

    // 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(for:$0.location) }

        return Set<Int>(matchLines)
    }


        for token in syntaxMap.tokens where token.type == SyntaxKind.comment.rawValue ||
                                            token.type == SyntaxKind.docComment.rawValue {
            let startLine = file.line(byteOffset: token.offset, startFrom: 0)
            let endLine = file.line(byteOffset: token.offset + token.length, startFrom: startLine)

            if startLine <= endLine {
                result.formUnion(Set(startLine...endLine))
