Пример #1
0
 public void OnEvent(DocumentViewerEventArgs e)
 {
     if (e.EventType == DocumentViewerEvent.Added)
     {
         DocumentViewerHighlightReferencesTagger.OnDocumentViewerCreated(e.DocumentViewer, documentViewerReferenceEnablerProviders);
     }
 }
Пример #2
0
        public CommandTargetStatus Execute(Guid group, int cmdId, object args, ref object result)
        {
            var documentViewer = TryGetInstance();

            if (documentViewer == null)
            {
                return(CommandTargetStatus.NotHandled);
            }

            if (group == CommandConstants.TextEditorGroup)
            {
                switch ((TextEditorIds)cmdId)
                {
                case TextEditorIds.CANCEL:
                    DocumentViewerHighlightReferencesTagger.ClearMarkedReferences(documentViewer.TextView);
                    documentViewer.TextView.Selection.Clear();
                    return(CommandTargetStatus.Handled);
                }
            }
            else if (group == CommandConstants.TextReferenceGroup)
            {
                switch ((TextReferenceIds)cmdId)
                {
                case TextReferenceIds.MoveToNextReference:
                    documentViewer.MoveReference(true);
                    return(CommandTargetStatus.Handled);

                case TextReferenceIds.MoveToPreviousReference:
                    documentViewer.MoveReference(false);
                    return(CommandTargetStatus.Handled);

                case TextReferenceIds.MoveToNextDefinition:
                    documentViewer.MoveToNextDefinition(true);
                    return(CommandTargetStatus.Handled);

                case TextReferenceIds.MoveToPreviousDefinition:
                    documentViewer.MoveToNextDefinition(false);
                    return(CommandTargetStatus.Handled);

                case TextReferenceIds.FollowReference:
                    documentViewer.FollowReference();
                    return(CommandTargetStatus.Handled);

                case TextReferenceIds.FollowReferenceNewTab:
                    documentViewer.FollowReferenceNewTab();
                    return(CommandTargetStatus.Handled);

                default:
                    Debug.Fail($"Unknown {nameof(TextReferenceIds)} id: {(TextReferenceIds)cmdId}");
                    return(CommandTargetStatus.NotHandled);
                }
            }
            return(CommandTargetStatus.NotHandled);
        }
Пример #3
0
 public ITagger <T>?CreateTagger <T>(ITextView textView, ITextBuffer buffer) where T : ITag
 {
     if (textView is null)
     {
         throw new ArgumentNullException(nameof(textView));
     }
     if (buffer is null)
     {
         throw new ArgumentNullException(nameof(buffer));
     }
     if (textView.TextBuffer != buffer)
     {
         return(null);
     }
     if (!textView.Roles.Contains(PredefinedTextViewRoles.Interactive))
     {
         return(null);
     }
     return(DocumentViewerHighlightReferencesTagger.GetOrCreate(textView) as ITagger <T>);
 }