/**
 * Diagnostic types for Tsonic compiler
 */
export const createDiagnostic = (code, severity, message, location, hint, relatedLocations) => ({
    code,
    severity,
    message,
    location,
    hint,
    relatedLocations,
});
export const isError = (diagnostic) => diagnostic.severity === "error" || diagnostic.severity === "fatal";
export const isFatal = (diagnostic) => diagnostic.severity === "fatal";
export const formatDiagnostic = (diagnostic) => {
    const parts = [];
    if (diagnostic.location) {
        parts.push(`${diagnostic.location.file}:${diagnostic.location.line}:${diagnostic.location.column}`);
    }
    parts.push(`${diagnostic.severity} ${diagnostic.code}:`);
    parts.push(diagnostic.message);
    if (diagnostic.hint) {
        parts.push(`Hint: ${diagnostic.hint}`);
    }
    return parts.join(" ");
};
export const createDiagnosticsCollector = () => ({
    diagnostics: [],
    hasErrors: false,
    hasFatalErrors: false,
});
export const addDiagnostic = (collector, diagnostic) => ({
    diagnostics: [...collector.diagnostics, diagnostic],
    hasErrors: collector.hasErrors || isError(diagnostic),
    hasFatalErrors: collector.hasFatalErrors || isFatal(diagnostic),
});
export const mergeDiagnostics = (collector1, collector2) => ({
    diagnostics: [...collector1.diagnostics, ...collector2.diagnostics],
    hasErrors: collector1.hasErrors || collector2.hasErrors,
    hasFatalErrors: collector1.hasFatalErrors || collector2.hasFatalErrors,
});
//# sourceMappingURL=diagnostic.js.map