示例#1
0
        internal bool TryExecuteCommand(Document document, int caretPosition, IEditorGoToDefinitionService goToDefinitionService)
        {
            string errorMessage = null;

            var result = _waitIndicator.Wait(
                title: EditorFeaturesResources.Go_to_Definition,
                message: EditorFeaturesResources.Navigating_to_definition,
                allowCancel: true,
                action: waitContext =>
            {
                if (goToDefinitionService != null &&
                    goToDefinitionService.TryGoToDefinition(document, caretPosition, waitContext.CancellationToken))
                {
                    return;
                }

                errorMessage = EditorFeaturesResources.Cannot_navigate_to_the_symbol_under_the_caret;
            });

            if (result == WaitIndicatorResult.Completed && errorMessage != null)
            {
                var workspace           = document.Workspace;
                var notificationService = workspace.Services.GetService <INotificationService>();
                notificationService.SendNotification(errorMessage, title: EditorFeaturesResources.Go_to_Definition, severity: NotificationSeverity.Information);
            }

            return(true);
        }
示例#2
0
        private bool TryExecuteCommand(Document document, int caretPosition, IEditorGoToDefinitionService goToDefinitionService, CommandExecutionContext context)
        {
            string errorMessage = null;

            using (context.OperationContext.AddScope(true, EditorFeaturesResources.Navigating_to_definition))
            {
                if (goToDefinitionService != null &&
                    goToDefinitionService.TryGoToDefinition(document, caretPosition, context.OperationContext.UserCancellationToken))
                {
                    return(true);
                }

                errorMessage = EditorFeaturesResources.Cannot_navigate_to_the_symbol_under_the_caret;
            }

            if (errorMessage != null)
            {
                context.OperationContext.TakeOwnership();
                var workspace           = document.Workspace;
                var notificationService = workspace.Services.GetService <INotificationService>();
                notificationService.SendNotification(errorMessage, title: EditorFeaturesResources.Go_to_Definition, severity: NotificationSeverity.Information);
            }

            return(true);
        }