protected Task HandleEvaluateRequest(
            DebugAdapterMessages.EvaluateRequestArguments evaluateParams,
            RequestContext <DebugAdapterMessages.EvaluateResponseBody> requestContext)
        {
            // We don't await the result of the execution here because we want
            // to be able to receive further messages while the current script
            // is executing.  This important in cases where the pipeline thread
            // gets blocked by something in the script like a prompt to the user.
            var executeTask =
                this.editorSession.PowerShellContext.ExecuteScriptString(
                    evaluateParams.Expression,
                    true,
                    true);

            // Return the execution result after the task completes so that the
            // caller knows when command execution completed.
            executeTask.ContinueWith(
                (task) =>
            {
                // Return an empty result since the result value is irrelevant
                // for this request in the LanguageServer
                return
                (requestContext.SendResult(
                     new DebugAdapterMessages.EvaluateResponseBody
                {
                    Result = "",
                    VariablesReference = 0
                }));
            });

            return(Task.FromResult(true));
        }
예제 #2
0
        protected async Task HandleEvaluateRequest(
            DebugAdapterMessages.EvaluateRequestArguments evaluateParams,
            EditorSession editorSession,
            RequestContext <DebugAdapterMessages.EvaluateResponseBody, object> requestContext)
        {
            VariableDetails result =
                await editorSession.DebugService.EvaluateExpression(
                    evaluateParams.Expression,
                    evaluateParams.FrameId);

            string valueString = null;
            int    variableId  = 0;

            if (result != null)
            {
                valueString = result.ValueString;
                variableId  =
                    result.IsExpandable ?
                    result.Id : 0;
            }

            await requestContext.SendResult(
                new DebugAdapterMessages.EvaluateResponseBody
            {
                Result             = valueString,
                VariablesReference = variableId
            });
        }
        protected async Task HandleEvaluateRequest(
            EvaluateRequestArguments evaluateParams,
            RequestContext<EvaluateResponseBody> requestContext)
        {
            bool isFromRepl =
                string.Equals(
                    evaluateParams.Context,
                    "repl",
                    StringComparison.InvariantCultureIgnoreCase);

            VariableDetails result =
                await editorSession.DebugService.EvaluateExpression(
                    evaluateParams.Expression,
                    evaluateParams.FrameId,
                    isFromRepl);

            string valueString = null;
            int variableId = 0;

            if (result != null)
            {
                valueString = result.ValueString;
                variableId =
                    result.IsExpandable ?
                        result.Id : 0;
            }

            await requestContext.SendResult(
                new EvaluateResponseBody
                {
                    Result = valueString,
                    VariablesReference = variableId
                });
        }