#!/usr/bin/env npx tsx
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
const diagnostics_1 = require("../../../src/agents/tools/ycmd/tools/diagnostics");
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
async function testDiagnosticsFix() {
    console.log('🧪 Testing Diagnostics Fix...\n');
    const testFilePath = path.join(__dirname, 'fixtures', 'test_diagnostics_fix.ts');
    const testContent = `
interface User {
  name: string;
  age: number;
}

// Error 1: Missing required property 'age'
const user1: User = {
  name: "John"
};

// Error 2: Undefined variable
console.log(undefinedVariable);

// Error 3: Type mismatch
const user2: User = {
  name: "Jane",
  age: "not a number" // Should be number, not string
};
`;
    await fs.promises.writeFile(testFilePath, testContent, 'utf8');
    console.log(`📝 Created test file: ${testFilePath}`);
    console.log(`📄 Test file content:\n${testContent}`);
    try {
        console.log('🔍 Running diagnostics...');
        const result = await (0, diagnostics_1.ycmdDiagnostics)({
            filepath: testFilePath,
            fileContents: testContent
        });
        console.log('\n📊 Diagnostics Result:');
        console.log(`Success: ${result.success}`);
        console.log(`Message: ${result.message}`);
        if (result.diagnostics) {
            console.log(`\n🔎 Found ${result.diagnostics.length} diagnostic(s):`);
            result.diagnostics.forEach((diag, index) => {
                console.log(`\n${index + 1}. ${diag.kind}: ${diag.text}`);
                console.log(`   Location: Line ${diag.location.line}, Column ${diag.location.column}`);
                if (diag.fixit_available) {
                    console.log(`   ✨ Fix available`);
                }
            });
            if (result.diagnostics.length > 0) {
                console.log('\n✅ SUCCESS: Diagnostics are now working!');
                const errors = result.diagnostics.filter(d => d.kind === 'ERROR');
                const warnings = result.diagnostics.filter(d => d.kind === 'WARNING');
                const infos = result.diagnostics.filter(d => d.kind === 'INFO');
                console.log(`\n📈 Summary:`);
                console.log(`   - Errors: ${errors.length}`);
                console.log(`   - Warnings: ${warnings.length}`);
                console.log(`   - Info: ${infos.length}`);
            }
            else {
                console.log('\n❌ ISSUE: Still no diagnostics found');
            }
        }
        else {
            console.log('\n❌ ISSUE: No diagnostics returned');
        }
    }
    catch (error) {
        console.error('\n💥 Error during diagnostics test:', error);
    }
    finally {
        try {
            await fs.promises.unlink(testFilePath);
            console.log(`\n🧹 Cleaned up test file: ${testFilePath}`);
        }
        catch (error) {
            console.warn(`⚠️  Failed to clean up test file: ${error}`);
        }
    }
}
testDiagnosticsFix().catch(console.error);
//# sourceMappingURL=test_diagnostics_fix.js.map