"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExtensionDebugSessionFactory = exports.ExtensionDebugSession = void 0;
const ide_core_common_1 = require("@opensumi/ide-core-common");
const debug_session_1 = require("@opensumi/ide-debug/lib/browser/debug-session");
const debug_session_connection_1 = require("@opensumi/ide-debug/lib/browser/debug-session-connection");
const ext_types_1 = require("../../../../common/vscode/ext-types");
class ExtensionDebugSession extends debug_session_1.DebugSession {
    constructor(id, options, connection, terminalService, editorService, breakpointManager, modelManager, labelService, messageService, fileSystem, sessionManager, terminalOptionsExt) {
        super(id, options, connection, terminalService, editorService, breakpointManager, modelManager, labelService, messageService, fileSystem, sessionManager);
        this.id = id;
        this.options = options;
        this.connection = connection;
        this.terminalService = terminalService;
        this.editorService = editorService;
        this.breakpointManager = breakpointManager;
        this.modelManager = modelManager;
        this.labelService = labelService;
        this.messageService = messageService;
        this.fileSystem = fileSystem;
        this.sessionManager = sessionManager;
        this.terminalOptionsExt = terminalOptionsExt;
    }
    async doRunInTerminal(terminalOptions) {
        if (!terminalOptions.name) {
            terminalOptions.name = (0, ide_core_common_1.localize)('debug.terminal.title', 'Debug Process');
        }
        if (!terminalOptions.iconPath) {
            terminalOptions.iconPath = new ext_types_1.ThemeIcon('debug');
        }
        const terminalWidgetOptions = {
            ...terminalOptions,
            ...this.terminalOptionsExt,
        };
        return super.doRunInTerminal(terminalWidgetOptions);
    }
}
exports.ExtensionDebugSession = ExtensionDebugSession;
class ExtensionDebugSessionFactory {
    constructor(editorManager, breakpoints, modelManager, terminalService, labelService, messageService, debugPreferences, connectionFactory, fileSystem, terminalOptionsExt, debugPreference, outputService, injector, sessionManager) {
        this.editorManager = editorManager;
        this.breakpoints = breakpoints;
        this.modelManager = modelManager;
        this.terminalService = terminalService;
        this.labelService = labelService;
        this.messageService = messageService;
        this.debugPreferences = debugPreferences;
        this.connectionFactory = connectionFactory;
        this.fileSystem = fileSystem;
        this.terminalOptionsExt = terminalOptionsExt;
        this.debugPreference = debugPreference;
        this.outputService = outputService;
        this.injector = injector;
        this.sessionManager = sessionManager;
    }
    get(sessionId, options) {
        const connection = this.injector.get(debug_session_connection_1.DebugSessionConnection, [
            sessionId,
            this.connectionFactory,
            this.getTraceOutputChannel(),
        ]);
        return new ExtensionDebugSession(sessionId, options, connection, this.terminalService, this.editorManager, this.breakpoints, this.modelManager, this.labelService, this.messageService, this.fileSystem, this.sessionManager, this.terminalOptionsExt);
    }
    getTraceOutputChannel() {
        if (this.debugPreferences['debug.trace']) {
            return this.outputService.getChannel('Debug adapters');
        }
    }
}
exports.ExtensionDebugSessionFactory = ExtensionDebugSessionFactory;
//# sourceMappingURL=extension-debug-session-factory.js.map