コード例 #1
0
        public async Task <LineEvaluationResult> HandleAsync(Guid lineId, string text, IReplLogger logger)
        {
            // bail out if it's not a complete statement, but first try automatic completions
            var(success, newTree) = await scriptEvaluator.TryCompleteStatementAsync(text);

            if (!success)
            {
                return(LineEvaluationResult.IncompleteInput);
            }
            text = (await newTree.GetRootAsync())
                   .ToFullString();

            // track the submission in our workspace. We won't need the
            // result for script evaluation, but other roslyn APIs like
            // code completion and syntax highlighting will need it.
            var submission   = workspaceManager.CreateOrUpdateSubmission(lineId, text);
            var scriptResult = await scriptEvaluator.EvaluateAsync(text);

            var output = await prettyPrinter.FormatAsync(submission.Document, scriptResult);

            return(output);
        }