"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExtensionDebugAdapterSession = void 0;
const abstract_debug_adapter_session_1 = require("./abstract-debug-adapter-session");
class ExtensionDebugAdapterSession extends abstract_debug_adapter_session_1.StreamDebugAdapter {
    constructor(communicationProvider, tracker, debugSession) {
        super(debugSession.id, communicationProvider);
        this.communicationProvider = communicationProvider;
        this.tracker = tracker;
        this.debugSession = debugSession;
        this.type = debugSession.type;
        this.name = debugSession.name;
        this.workspaceFolder = debugSession.workspaceFolder;
        this.configuration = debugSession.configuration;
    }
    get parentSession() {
        return this.debugSession.parentSession;
    }
    async start(connection) {
        if (this.tracker.onWillStartSession) {
            this.tracker.onWillStartSession();
        }
        await super.start(connection);
    }
    async stop() {
        if (this.tracker.onWillStopSession) {
            this.tracker.onWillStopSession();
        }
        await super.stop();
    }
    async customRequest(command, args) {
        return this.debugSession.customRequest(command, args);
    }
    async getDebugProtocolBreakpoint(breakpoint) {
        return this.debugSession.getDebugProtocolBreakpoint(breakpoint);
    }
    onDebugAdapterError(error) {
        if (this.tracker.onError) {
            this.tracker.onError(error);
        }
        super.onDebugAdapterError(error);
    }
    sendToFrontend(message) {
        try {
            super.sendToFrontend(message);
        }
        finally {
            if (this.tracker.onDidSendMessage) {
                this.tracker.onDidSendMessage(message);
            }
        }
    }
    write(message) {
        if (this.tracker.onWillReceiveMessage) {
            this.tracker.onWillReceiveMessage(message);
        }
        super.write(message);
    }
    onDebugAdapterExit(exitCode, signal) {
        if (this.tracker.onExit) {
            this.tracker.onExit(exitCode, signal);
        }
        super.onDebugAdapterExit(exitCode, signal);
    }
}
exports.ExtensionDebugAdapterSession = ExtensionDebugAdapterSession;
//# sourceMappingURL=extension-debug-adapter-session.js.map