Example #1
0
            /// <summary>
            /// Creates a tag provider for the specified view and buffer
            /// </summary>
            /// <typeparam name="T">The tag type</typeparam>
            /// <param name="textView">The text view</param>
            /// <param name="buffer">The text buffer</param>
            /// <returns>The tag provider for the specified view and buffer or null if the buffer is not editable
            /// or spell checking as you type is disabled.</returns>
            public ISuggestedActionsSource CreateSuggestedActionsSource(ITextView textView, ITextBuffer textBuffer)
            {
                // If this view isn't editable, then there isn't a good reason to be showing these
                if (textView == null || textBuffer == null ||
                    !textView.Roles.Contains(PredefinedTextViewRoles.Editable) ||
                    (!textView.Roles.Contains(PredefinedTextViewRoles.PrimaryDocument) &&
                     !textView.Roles.Contains(Utility.EmbeddedPeekTextView)))
                {
                    return(null);
                }

#pragma warning disable VSTHRD010
                // Getting the dictionary determines if spell checking is enabled for this file
                var dictionary = SpellingServiceProxy.GetDictionary(textBuffer);

                if (dictionary == null)
                {
                    return(null);
                }

                var config = SpellingServiceProxy.GetConfiguration(textBuffer);

#pragma warning restore VSTHRD010

                return(new SpellSuggestedActionSource(dictionary,
                                                      config?.IgnoredWordsFiles ?? Enumerable.Empty <(ConfigurationType ConfigType, string Filename)>(),
                                                      tagAggregatorFactory.CreateTagAggregator <MisspellingTag>(textView)));
            }
            /// <summary>
            /// Creates a tag provider for the specified buffer
            /// </summary>
            /// <typeparam name="T">The tag type</typeparam>
            /// <param name="buffer">The text buffer</param>
            /// <returns>The tag provider for the specified buffer or null if the buffer is null or the spelling
            /// service is unavailable.</returns>
            public ITagger <T> CreateTagger <T>(ITextBuffer buffer) where T : ITag
            {
                if (buffer == null || buffer.ContentType.IsOfType("R Markdown"))
                {
                    return(null);
                }

#pragma warning disable VSTHRD010
                var config = SpellingServiceProxy.GetConfiguration(buffer);
#pragma warning restore VSTHRD010

                if (config == null)
                {
                    return(null);
                }

                // Markdown has its own tagger
                if (buffer.ContentType.IsOfType("Markdown"))
                {
                    return(new MarkdownTextTagger(buffer, classifierAggregatorService.GetClassifier(buffer),
                                                  config.IgnoredClassificationsFor(buffer.ContentType.TypeName)) as ITagger <T>);
                }

                // Due to an issue with the built-in C# classifier, we avoid using it.  This also lets us provide
                // configuration options to exclude certain elements from being spell checked if not wanted.
                // Through the configuration options, we can also specify this tagger be used for all C-style
                // code.  Not all configuration options will apply but the structure is similar enough to make
                // most of them relevant.
                string filename = buffer.GetFilename();

                if (buffer.ContentType.IsOfType("csharp") || (config.CSharpOptions.ApplyToAllCStyleLanguages &&
                                                              ClassifierFactory.IsCStyleCode(filename)))
                {
                    // The C# options are passed to the tagger for local use since it tracks the state of the
                    // lines in the buffer.  Changing the global options will require that any open editors be
                    // closed and reopened for the changes to take effect.
                    return(new CSharpCommentTextTagger(buffer)
                    {
                        SupportsOldStyleXmlDocComments = ClassifierFactory.SupportsOldStyleXmlDocComments(filename),
                        IgnoreXmlDocComments = config.CSharpOptions.IgnoreXmlDocComments,
                        IgnoreDelimitedComments = config.CSharpOptions.IgnoreDelimitedComments,
                        IgnoreStandardSingleLineComments = config.CSharpOptions.IgnoreStandardSingleLineComments,
                        IgnoreQuadrupleSlashComments = config.CSharpOptions.IgnoreQuadrupleSlashComments,
                        IgnoreNormalStrings = config.CSharpOptions.IgnoreNormalStrings,
                        IgnoreVerbatimStrings = config.CSharpOptions.IgnoreVerbatimStrings,
                        IgnoreInterpolatedStrings = config.CSharpOptions.IgnoreInterpolatedStrings,
                        IgnoredXmlElements = config.IgnoredXmlElements,
                        SpellCheckedAttributes = config.SpellCheckedXmlAttributes
                    } as ITagger <T>);
                }

                return(new CommentTextTagger(buffer, classifierAggregatorService.GetClassifier(buffer),
                                             config.IgnoredXmlElements, config.SpellCheckedXmlAttributes,
                                             config.IgnoredClassificationsFor(buffer.ContentType.TypeName)) as ITagger <T>);
            }
Example #3
0
            /// <inheritdoc />
            public ITagger <T> CreateTagger <T>(ITextBuffer buffer) where T : ITag
            {
                var classifier = classifierAggregatorService.GetClassifier(buffer);

#pragma warning disable VSTHRD010
                var config = SpellingServiceProxy.GetConfiguration(buffer);
#pragma warning restore VSTHRD010

                if (config == null)
                {
                    return(new RMarkdownTextTagger(buffer, classifier, null) as ITagger <T>);
                }

                return(new RMarkdownTextTagger(buffer, classifier,
                                               config.IgnoredClassificationsFor(buffer.ContentType.TypeName)) as ITagger <T>);
            }
        /// <inheritdoc />
        public ITagger <T> CreateTagger <T>(ITextBuffer buffer) where T : ITag
        {
            var classifier = classifierAggregatorService.GetClassifier(buffer);

#pragma warning disable VSTHRD010
            var config = SpellingServiceProxy.GetConfiguration(buffer);
#pragma warning restore VSTHRD010

            // Use existing comment text tagger, it works well with PHP classifier
            if (config == null)
            {
                return(new CommentTextTagger(buffer, classifier, null, null, null) as ITagger <T>);
            }

            return(new CommentTextTagger(buffer, classifier, null, null,
                                         config.IgnoredClassificationsFor(buffer.ContentType.TypeName)) as ITagger <T>);
        }