import { resolveTypeAtPosition } from "./typeResolution.js";
import { pathToUri } from "./uri.js";
export function handleTypeDefinition(params, doc, program, scopes, semanticIndex) {
    const varType = resolveTypeAtPosition(doc.getText(), params.position.line, params.position.character, program, scopes);
    if (!varType)
        return null;
    let typeName = null;
    if (varType.type === "typeAliasVariable") {
        typeName = varType.aliasName;
    }
    if (!typeName)
        return null;
    const symbol = semanticIndex[typeName];
    if (!symbol?.loc)
        return null;
    return {
        uri: pathToUri(symbol.filePath),
        range: {
            start: { line: symbol.loc.line, character: symbol.loc.col },
            end: { line: symbol.loc.line, character: symbol.loc.col },
        },
    };
}
