               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]



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