protected void VerifyInsertCommentCommand(
            string initialMarkup,
            string expectedMarkup,
            bool useTabs = false,
            bool autoGenerateXmlDocComments = true
            )
        {
            Verify(
                initialMarkup,
                expectedMarkup,
                useTabs,
                autoGenerateXmlDocComments,
                execute: (workspace, view, editorOperationsFactoryService) =>
            {
                var commandHandler = CreateCommandHandler(workspace);

                var commandArgs    = new InsertCommentCommandArgs(view, view.TextBuffer);
                Action nextHandler = delegate { };

                commandHandler.ExecuteCommand(
                    commandArgs,
                    nextHandler,
                    TestCommandExecutionContext.Create()
                    );
            }
                );
        }
Exemplo n.º 2
0
        public CommandState GetCommandState(InsertCommentCommandArgs args, Func <CommandState> nextHandler)
        {
            var caretPosition = args.TextView.GetCaretPoint(args.SubjectBuffer) ?? -1;

            if (caretPosition < 0)
            {
                return(CommandState.Unavailable);
            }

            var document = args.SubjectBuffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges();

            if (document == null)
            {
                return(CommandState.Unavailable);
            }

            TMemberNode targetMember = null;

            _waitIndicator.Wait("IntelliSense", allowCancel: true, action: c =>
            {
                var syntaxTree = document.GetSyntaxTreeSynchronously(c.CancellationToken);
                var text       = syntaxTree.GetText(c.CancellationToken);
                targetMember   = GetTargetMember(syntaxTree, text, caretPosition, c.CancellationToken);
            });

            return(targetMember != null
                ? CommandState.Available
                : CommandState.Unavailable);
        }
Exemplo n.º 3
0
 public bool ExecuteCommand(InsertCommentCommandArgs args, CommandExecutionContext context)
 {
     using (context.OperationContext.AddScope(allowCancellation: true, EditorFeaturesResources.Inserting_documentation_comment))
     {
         return(CompleteComment(args.SubjectBuffer, args.TextView, InsertOnCommandInvoke, context.OperationContext.UserCancellationToken));
     }
 }
        public bool ExecuteCommand(InsertCommentCommandArgs args, CommandExecutionContext context)
        {
            var originalCaretPosition = args.TextView.GetCaretPoint(args.SubjectBuffer) ?? -1;

            using (context.WaitContext.AddScope(allowCancellation: true, EditorFeaturesResources.Inserting_documentation_comment))
            {
                return(CompleteComment(args.SubjectBuffer, args.TextView, originalCaretPosition, InsertOnCommandInvoke, context.WaitContext.UserCancellationToken));
            }
        }
        protected void VerifyInsertCommentCommand(string initialMarkup, string expectedMarkup)
        {
            Verify(initialMarkup, expectedMarkup, (view, undoHistoryRegistry, editorOperationsFactoryService, completionService) =>
            {
                var commandHandler = CreateCommandHandler(TestWaitIndicator.Default, undoHistoryRegistry, editorOperationsFactoryService, completionService) as ICommandHandler<InsertCommentCommandArgs>;

                var commandArgs = new InsertCommentCommandArgs(view, view.TextBuffer);
                Action nextHandler = delegate { };

                commandHandler.ExecuteCommand(commandArgs, nextHandler);
            });
        }
        protected void VerifyInsertCommentCommand(string initialMarkup, string expectedMarkup)
        {
            Verify(initialMarkup, expectedMarkup, (view, undoHistoryRegistry, editorOperationsFactoryService, completionService) =>
            {
                var commandHandler = CreateCommandHandler(TestWaitIndicator.Default, undoHistoryRegistry, editorOperationsFactoryService, completionService) as ICommandHandler <InsertCommentCommandArgs>;

                var commandArgs    = new InsertCommentCommandArgs(view, view.TextBuffer);
                Action nextHandler = delegate { };

                commandHandler.ExecuteCommand(commandArgs, nextHandler);
            });
        }
        protected async Task VerifyInsertCommentCommandAsync(string initialMarkup, string expectedMarkup, bool useTabs = false, bool autoGenerateXmlDocComments = true)
        {
            await VerifyAsync(initialMarkup, expectedMarkup, useTabs, autoGenerateXmlDocComments,
                              execute : (view, undoHistoryRegistry, editorOperationsFactoryService, completionService) =>
            {
                var commandHandler = CreateCommandHandler(TestWaitIndicator.Default, undoHistoryRegistry, editorOperationsFactoryService) as ICommandHandler <InsertCommentCommandArgs>;

                var commandArgs    = new InsertCommentCommandArgs(view, view.TextBuffer);
                Action nextHandler = delegate { };

                commandHandler.ExecuteCommand(commandArgs, nextHandler);
            });
        }
        protected async Task VerifyInsertCommentCommandAsync(string initialMarkup, string expectedMarkup, bool useTabs = false, bool autoGenerateXmlDocComments = true)
        {
            await VerifyAsync(initialMarkup, expectedMarkup, useTabs, autoGenerateXmlDocComments,
                execute: (view, undoHistoryRegistry, editorOperationsFactoryService, completionService) =>
                {
                    var commandHandler = CreateCommandHandler(TestWaitIndicator.Default, undoHistoryRegistry, editorOperationsFactoryService) as ICommandHandler<InsertCommentCommandArgs>;

                    var commandArgs = new InsertCommentCommandArgs(view, view.TextBuffer);
                    Action nextHandler = delegate { };

                    commandHandler.ExecuteCommand(commandArgs, nextHandler);
                });
        }
        internal void VerifyInsertCommentCommand(string initialMarkup, string expectedMarkup, bool useTabs = false, string newLine = "\r\n", bool trimTrailingWhiteSpace = false, OptionsCollection globalOptions = null)
        {
            Verify(initialMarkup, expectedMarkup,
                   execute: (workspace, view, editorOperationsFactoryService) =>
            {
                var commandHandler = CreateCommandHandler(workspace);

                var commandArgs    = new InsertCommentCommandArgs(view, view.TextBuffer);
                Action nextHandler = delegate { };

                commandHandler.ExecuteCommand(commandArgs, nextHandler, TestCommandExecutionContext.Create());
            },
                   useTabs, newLine, trimTrailingWhiteSpace, globalOptions);
        }
Exemplo n.º 10
0
        public void ExecuteCommand(InsertCommentCommandArgs args, Action nextHandler)
        {
            var originalCaretPosition = args.TextView.GetCaretPoint(args.SubjectBuffer) ?? -1;

            _waitIndicator.Wait(
                title: EditorFeaturesResources.Documentation_Comment,
                message: EditorFeaturesResources.Inserting_documentation_comment,
                allowCancel: true,
                action: w =>
            {
                if (!CompleteComment(args.SubjectBuffer, args.TextView, originalCaretPosition, InsertOnCommandInvoke, w.CancellationToken))
                {
                    nextHandler();
                }
            });
        }