Example #1
0
        public virtual async Task <ExecutionResult> InitializeAsync()
        {
            if (_commands != null)
            {
                // Already initialized
                return(ExecutionResult.Success);
            }

            var msg = Strings.ReplInitializationMessage.FormatUI(
                DisplayName,
                AssemblyVersionInfo.Version,
                AssemblyVersionInfo.VSVersion
                ).Replace("&#x1b;", "\x1b");

            WriteOutput(msg, addNewline: true);

            var langBuffer = _window.CurrentLanguageBuffer;

            if (langBuffer != null)
            {
                // Reinitializing, and our new language buffer does not automatically
                // get connected to the Intellisense controller. Let's fix that.
                var controller = IntellisenseControllerProvider.GetController(_window.TextView);
                controller?.ConnectSubjectBuffer(langBuffer);
            }

            _window.TextView.Options.SetOptionValue(InteractiveWindowOptions.SmartUpDown, UseSmartHistoryKeys);
            _commands = GetInteractiveCommands(_serviceProvider, _window, this);

            return(ExecutionResult.Success);
        }
Example #2
0
        public Task <ExecutionResult> InitializeAsync()
        {
            this.CurrentWindow.WriteLine(Resources.ReplInitializationMessage);

            this.CurrentWindow.TextView.Options.SetOptionValue(InteractiveWindowOptions.SmartUpDown, true);
            this.commands = GetInteractiveCommands();

            return(ExecutionResult.Succeeded);
        }
Example #3
0
        public Task <ExecutionResult> InitializeAsync()
        {
            _commands = PythonCommonInteractiveEvaluator.GetInteractiveCommands(_serviceProvider, CurrentWindow, this);

            CurrentWindow.TextView.Options.SetOptionValue(InteractiveWindowOptions.SmartUpDown, CurrentOptions.UseSmartHistory);
            CurrentWindow.WriteLine(Strings.DebugReplHelpMessage);

            CurrentWindow.ReadyForInput += OnReadyForInput;
            return(ExecutionResult.Succeeded);
        }
        public Task <ExecutionResult> InitializeAsync()
        {
            _commands = PythonInteractiveEvaluator.GetInteractiveCommands(_serviceProvider, CurrentWindow, this);

            CurrentWindow.TextView.Options.SetOptionValue(InteractiveWindowOptions.SmartUpDown, CurrentOptions.UseSmartHistory);
            CurrentWindow.WriteLine("Python debug interactive window. Type $help for a list of commands.");

            CurrentWindow.ReadyForInput += OnReadyForInput;
            return(ExecutionResult.Succeeded);
        }
        protected override async Task <IEnumerable <CompletionItem> > GetItemsWorkerAsync(
            Document document, int position, CompletionTriggerInfo triggerInfo, CancellationToken cancellationToken)
        {
            if (document != null && document.SourceCodeKind == SourceCodeKind.Interactive)
            {
                // the provider might be invoked in non-interactive context:
                Workspace ws;
                if (Workspace.TryGetWorkspace(document.GetTextAsync(cancellationToken).WaitAndGetResult(cancellationToken).Container, out ws))
                {
                    var workspace = ws as InteractiveWorkspace;
                    if (workspace != null)
                    {
                        var window = workspace.Engine.CurrentWindow;
                        var tree   = await document.GetCSharpSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);

                        if (tree.IsBeforeFirstToken(position, cancellationToken) &&
                            tree.IsPreProcessorKeywordContext(position, cancellationToken))
                        {
                            var textChangeSpan = await this.GetTextChangeSpanAsync(document, position, cancellationToken).ConfigureAwait(false);

                            var list = new List <CompletionItem>();

                            IInteractiveWindowCommands commands = window.GetInteractiveCommands();
                            if (commands != null)
                            {
                                foreach (var command in commands.GetCommands())
                                {
                                    foreach (var commandName in command.Names)
                                    {
                                        list.Add(new CSharpCompletionItem(
                                                     workspace, this, commandName, textChangeSpan, c => Task.FromResult(command.Description.ToSymbolDisplayParts()), glyph: Glyph.Intrinsic));
                                    }
                                }
                            }

                            return(list);
                        }
                    }
                }
            }

            return(SpecializedCollections.EmptyEnumerable <CompletionItem>());
        }
        public Task <ExecutionResult> InitializeAsync()
        {
            _commands = PythonInteractiveEvaluator.GetInteractiveCommands(_serviceProvider, CurrentWindow, this);

            var langBuffer = CurrentWindow.CurrentLanguageBuffer;

            if (langBuffer != null)
            {
                // Reinitializing, and our new language buffer does not automatically
                // get connected to the Intellisense controller. Let's fix that.
                var controller = IntellisenseControllerProvider.GetController(CurrentWindow.TextView);
                controller?.ConnectSubjectBuffer(langBuffer);
            }

            CurrentWindow.TextView.Options.SetOptionValue(InteractiveWindowOptions.SmartUpDown, CurrentOptions.UseSmartHistory);
            CurrentWindow.WriteLine(Strings.DebugReplHelpMessage);

            CurrentWindow.ReadyForInput += OnReadyForInput;
            return(ExecutionResult.Succeeded);
        }
Example #7
0
        public virtual async Task <ExecutionResult> InitializeAsync()
        {
            if (_commands != null)
            {
                // Already initialized
                return(ExecutionResult.Success);
            }

            var msg = Strings.ReplInitializationMessage.FormatUI(
                DisplayName,
                AssemblyVersionInfo.Version,
                AssemblyVersionInfo.VSVersion
                ).Replace("&#x1b;", "\x1b");

            WriteOutput(msg, addNewline: true);

            _window.TextView.Options.SetOptionValue(InteractiveWindowOptions.SmartUpDown, UseSmartHistoryKeys);
            _commands = GetInteractiveCommands(_serviceProvider, _window, this);

            return(ExecutionResult.Success);
        }
Example #8
0
        public override async Task ProduceCompletionListAsync(CompletionListContext context)
        {
            var document          = context.Document;
            var position          = context.Position;
            var cancellationToken = context.CancellationToken;

            if (document != null && document.SourceCodeKind == SourceCodeKind.Interactive)
            {
                // the provider might be invoked in non-interactive context:
                Workspace ws;
                if (Workspace.TryGetWorkspace(document.GetTextAsync(cancellationToken).WaitAndGetResult(cancellationToken).Container, out ws))
                {
                    var workspace = ws as InteractiveWorkspace;
                    if (workspace != null)
                    {
                        var window = workspace.Engine.CurrentWindow;
                        var tree   = await document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);

                        if (tree.IsBeforeFirstToken(position, cancellationToken) &&
                            tree.IsPreProcessorKeywordContext(position, cancellationToken))
                        {
                            var filterSpan = await this.GetTextChangeSpanAsync(document, position, cancellationToken).ConfigureAwait(false);

                            IInteractiveWindowCommands commands = window.GetInteractiveCommands();
                            if (commands != null)
                            {
                                foreach (var command in commands.GetCommands())
                                {
                                    foreach (var commandName in command.Names)
                                    {
                                        context.AddItem(new CompletionItem(
                                                            this, commandName, filterSpan, c => Task.FromResult(command.Description.ToSymbolDisplayParts()), glyph: Glyph.Intrinsic));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Example #9
0
        public override async Task ProduceCompletionListAsync(CompletionListContext context)
        {
            var document          = context.Document;
            var position          = context.Position;
            var cancellationToken = context.CancellationToken;

            // the provider might be invoked in non-interactive context:
            Workspace  ws;
            SourceText sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);

            if (Workspace.TryGetWorkspace(sourceText.Container, out ws))
            {
                var workspace = ws as InteractiveWorkspace;
                if (workspace != null)
                {
                    var window = workspace.Engine.CurrentWindow;
                    var tree   = await document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);

                    if (await ShouldDisplayCommandCompletionsAsync(tree, position, cancellationToken).ConfigureAwait(false))
                    {
                        var filterSpan = await this.GetTextChangeSpanAsync(document, position, cancellationToken).ConfigureAwait(false);

                        IInteractiveWindowCommands commands = window.GetInteractiveCommands();
                        if (commands != null)
                        {
                            foreach (var command in commands.GetCommands())
                            {
                                foreach (var commandName in command.Names)
                                {
                                    string completion = GetCompletionString(commandName);
                                    context.AddItem(new CompletionItem(
                                                        this, completion, filterSpan, c => Task.FromResult(command.Description.ToSymbolDisplayParts()), glyph: Glyph.Intrinsic));
                                }
                            }
                        }
                    }
                }
            }
        }
        public override async Task ProvideCompletionsAsync(CompletionContext context)
        {
            var document          = context.Document;
            var position          = context.Position;
            var cancellationToken = context.CancellationToken;

            // the provider might be invoked in non-interactive context:
            Workspace  ws;
            SourceText sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);

            if (Workspace.TryGetWorkspace(sourceText.Container, out ws))
            {
                var workspace = ws as InteractiveWorkspace;
                if (workspace != null)
                {
                    var window = workspace.Window;
                    var tree   = await document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);

                    if (await ShouldDisplayCommandCompletionsAsync(tree, position, cancellationToken).ConfigureAwait(false))
                    {
                        IInteractiveWindowCommands commands = window.GetInteractiveCommands();
                        if (commands != null)
                        {
                            foreach (var command in commands.GetCommands())
                            {
                                foreach (var commandName in command.Names)
                                {
                                    string completion = GetCompletionString(commandName);
                                    context.AddItem(CommonCompletionItem.Create(
                                                        completion, CompletionItemRules.Default, description: command.Description.ToSymbolDisplayParts(), glyph: Glyph.Intrinsic));
                                }
                            }
                        }
                    }
                }
            }
        }
Example #11
0
 public CommandClassifier(IStandardClassificationService registry, IInteractiveWindowCommands commands)
 {
     _registry = registry;
     _commands = commands;
 }
        public Task<ExecutionResult> InitializeAsync() {
            _commands = PythonInteractiveEvaluator.GetInteractiveCommands(_serviceProvider, CurrentWindow, this);

            CurrentWindow.TextView.Options.SetOptionValue(InteractiveWindowOptions.SmartUpDown, CurrentOptions.UseSmartHistory);
            CurrentWindow.WriteLine("Python debug interactive window. Type $help for a list of commands.");

            CurrentWindow.ReadyForInput += OnReadyForInput;
            return ExecutionResult.Succeeded;
        }
Example #13
0
 public CommandClassifier(IStandardClassificationService registry, IInteractiveWindowCommands commands)
 {
     this.registry = registry;
     this.commands = commands;
 }
Example #14
0
        public async Task<ExecutionResult> InitializeAsync() {
            if (_commands != null) {
                // Already initialized
                return ExecutionResult.Success;
            }

            var msg = Strings.ReplInitializationMessage.FormatUI(
                DisplayName,
                AssemblyVersionInfo.Version,
                AssemblyVersionInfo.VSVersion
            ).Replace("&#x1b;", "\x1b");

            WriteOutput(msg, addNewline: true);

            _window.TextView.Options.SetOptionValue(InteractiveWindowOptions.SmartUpDown, UseSmartHistoryKeys);
            _commands = GetInteractiveCommands(_serviceProvider, _window, this);

            return ExecutionResult.Success;
        }
Example #15
0
        public Task <ExecutionResult> InitializeAsync()
        {
            _commands = BasePythonReplEvaluator.GetInteractiveCommands(_serviceProvider, _window, this);

            return(Initialize(CurrentWindow));
        }
Example #16
0
        public Task<ExecutionResult> InitializeAsync() {
            WriteInitializationMessage();
            _window.TextView.BufferGraph.GraphBuffersChanged += BufferGraphGraphBuffersChanged;

            _window.SetSmartUpDown(CurrentOptions.ReplSmartHistory);

            _commands = GetInteractiveCommands(_serviceProvider, _window, this);

            return ExecutionResult.Succeeded;
        }
Example #17
0
        public Task<ExecutionResult> InitializeAsync() {
            _commands = BasePythonReplEvaluator.GetInteractiveCommands(_serviceProvider, _window, this);

            return Initialize(CurrentWindow);
        }