コード例 #1
0
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            IWpfTextView view = AdaptersFactory.GetWpfTextView(textViewAdapter);

            Debug.Assert(view != null);

            ITextDocument document;

            if (!TextDocumentFactoryService.TryGetTextDocument(view.TextDataModel.DocumentBuffer, out document))
            {
                return;
            }

            TextType type = RobotsTxtClassifierProvider.GetTextType(document.FilePath);

            if (type != TextType.Robots)
            {
                return;
            }

            CommandFilter filter = new CommandFilter(view, CompletionBroker);

            IOleCommandTarget next;

            ErrorHandler.ThrowOnFailure(textViewAdapter.AddCommandFilter(filter, out next));
            filter.Next = next;
        }
コード例 #2
0
        public ICompletionSource TryCreateCompletionSource(ITextBuffer textBuffer)
        {
            string filename = System.IO.Path.GetFileName(textBuffer.GetFileName());
            var    textType = RobotsTxtClassifierProvider.GetTextType(filename);

            if (textType == TextType.Robots || textType == TextType.Humans)
            {
                return(new RobotsTxtCompletionSource(textBuffer));
            }
            return(null);
        }