Ejemplo n.º 1
0
        private async void OnLanguageServiceClientConnect(
            object sender,
            TcpSocketServerChannel serverChannel)
        {
            MessageDispatcher messageDispatcher = new MessageDispatcher(this.logger);

            ProtocolEndpoint protocolEndpoint =
                new ProtocolEndpoint(
                    serverChannel,
                    messageDispatcher,
                    this.logger);

            this.editorSession =
                CreateSession(
                    this.hostDetails,
                    this.profilePaths,
                    protocolEndpoint,
                    messageDispatcher,
                    this.enableConsoleRepl);

            this.languageServer =
                new LanguageServer(
                    this.editorSession,
                    messageDispatcher,
                    protocolEndpoint,
                    this.logger);

            await this.editorSession.PowerShellContext.ImportCommandsModule(
                Path.Combine(
                    Path.GetDirectoryName(this.GetType().GetTypeInfo().Assembly.Location),
                    @"..\..\Commands"));

            this.languageServer.Start();
            protocolEndpoint.Start();
        }
Ejemplo n.º 2
0
        private void OnDebugServiceClientConnect(object sender, TcpSocketServerChannel serverChannel)
        {
            MessageDispatcher messageDispatcher = new MessageDispatcher(this.logger);

            ProtocolEndpoint protocolEndpoint =
                new ProtocolEndpoint(
                    serverChannel,
                    messageDispatcher,
                    this.logger);

            protocolEndpoint.UnhandledException += ProtocolEndpoint_UnhandledException;

            bool ownsEditorSession = this.editorSession == null;

            if (ownsEditorSession)
            {
                this.editorSession =
                    this.CreateDebugSession(
                        this.hostDetails,
                        profilePaths,
                        protocolEndpoint,
                        messageDispatcher,
                        this.languageServer?.EditorOperations,
                        this.enableConsoleRepl);
            }

            this.debugAdapter =
                new DebugAdapter(
                    this.editorSession,
                    ownsEditorSession,
                    messageDispatcher,
                    protocolEndpoint,
                    this.logger);

            this.debugAdapter.SessionEnded +=
                (obj, args) =>
            {
                if (!ownsEditorSession)
                {
                    this.logger.Write(
                        LogLevel.Normal,
                        "Previous debug session ended, restarting debug service listener...");

                    this.debugServiceListener.Start();
                }
                else
                {
                    // Exit the host process
                    this.serverCompletedTask.SetResult(true);
                }
            };

            this.debugAdapter.Start();
            protocolEndpoint.Start();
        }
Ejemplo n.º 3
0
        private void OnDebugServiceClientConnect(object sender, TcpSocketServerChannel serverChannel)
        {
            MessageDispatcher messageDispatcher = new MessageDispatcher(this.logger);

            ProtocolEndpoint protocolEndpoint =
                new ProtocolEndpoint(
                    serverChannel,
                    messageDispatcher,
                    this.logger);

            if (this.enableConsoleRepl)
            {
                this.debugAdapter =
                    new DebugAdapter(
                        this.editorSession,
                        false,
                        messageDispatcher,
                        protocolEndpoint,
                        this.logger);
            }
            else
            {
                EditorSession debugSession =
                    this.CreateDebugSession(
                        this.hostDetails,
                        profilePaths,
                        protocolEndpoint,
                        messageDispatcher,
                        this.languageServer?.EditorOperations,
                        false);

                this.debugAdapter =
                    new DebugAdapter(
                        debugSession,
                        true,
                        messageDispatcher,
                        protocolEndpoint,
                        this.logger);
            }

            this.debugAdapter.SessionEnded +=
                (obj, args) =>
            {
                this.logger.Write(
                    LogLevel.Normal,
                    "Previous debug session ended, restarting debug service listener...");

                this.debugServiceListener.Start();
            };

            this.debugAdapter.Start();
            protocolEndpoint.Start();
        }
        private async void OnLanguageServiceClientConnect(
            object sender,
            TcpSocketServerChannel serverChannel)
        {
            MessageDispatcher messageDispatcher = new MessageDispatcher(this.logger);

            ProtocolEndpoint protocolEndpoint =
                new ProtocolEndpoint(
                    serverChannel,
                    messageDispatcher,
                    this.logger);

            protocolEndpoint.UnhandledException += ProtocolEndpoint_UnhandledException;

            this.editorSession =
                CreateSession(
                    this.hostDetails,
                    this.profilePaths,
                    protocolEndpoint,
                    messageDispatcher,
                    this.enableConsoleRepl);

            this.languageServer =
                new LanguageServer(
                    this.editorSession,
                    messageDispatcher,
                    protocolEndpoint,
                    this.logger);

            await this.editorSession.PowerShellContext.ImportCommandsModule(
                Path.Combine(
                    Path.GetDirectoryName(this.GetType().GetTypeInfo().Assembly.Location),
                    @"..\..\Commands"));

            this.languageServer.Start();

            // TODO: This can be moved to the point after the $psEditor object
            // gets initialized when that is done earlier than LanguageServer.Initialize
            foreach (string module in this.additionalModules)
            {
                await this.editorSession.PowerShellContext.ExecuteCommand <System.Management.Automation.PSObject>(
                    new System.Management.Automation.PSCommand().AddCommand("Import-Module").AddArgument(module),
                    false,
                    true);
            }

            protocolEndpoint.Start();
        }