import { getWordAtPosition } from "../cli/definition.js";
import { findContainingScope } from "./scopeResolution.js";
import { offsetOfLine } from "./util.js";
export function resolveTypeAtPosition(source, line, character, program, scopes) {
    const word = getWordAtPosition(source, line, character);
    if (!word)
        return null;
    const cursorOffset = offsetOfLine(source, line) + character;
    const scope = findContainingScope(cursorOffset, scopes, program);
    if (!scope)
        return null;
    const resolved = scope.scope.lookup(word);
    if (!resolved || resolved === "any")
        return null;
    return resolved;
}
