コード例 #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);

                case TextReferenceIds.MoveToMatchingBrace:
                case TextReferenceIds.MoveToMatchingBraceSelect:
                    return(CommandTargetStatus.NotHandled);

                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 == null)
     {
         throw new ArgumentNullException(nameof(textView));
     }
     if (buffer == 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>);
 }