Exemple #1
0
        public static async Task <ImmutableArray <Diagnostic> > AnalyzeSpellingAsync(
            Project project,
            SpellingData spellingData,
            SpellingFixerOptions options        = null,
            CancellationToken cancellationToken = default)
        {
            ISpellingService service = MefWorkspaceServices.Default.GetService <ISpellingService>(project.Language);

            if (service == null)
            {
                return(ImmutableArray <Diagnostic> .Empty);
            }

            ImmutableArray <Diagnostic> .Builder diagnostics = ImmutableArray.CreateBuilder <Diagnostic>();

            foreach (Document document in project.Documents)
            {
                if (!document.SupportsSyntaxTree)
                {
                    continue;
                }

                ImmutableArray <Diagnostic> diagnostics2 = await AnalyzeSpellingAsync(
                    service,
                    document,
                    spellingData,
                    options,
                    cancellationToken)
                                                           .ConfigureAwait(false);

                diagnostics.AddRange(diagnostics2);
            }

            return(diagnostics.ToImmutableArray());
        }
Exemple #2
0
        public SpellingFixer(
            Solution solution,
            SpellingData spellingData,
            IFormatProvider formatProvider = null,
            SpellingFixerOptions options   = null)
        {
            Workspace = solution.Workspace;

            SpellingData   = spellingData;
            FormatProvider = formatProvider;
            Options        = options ?? SpellingFixerOptions.Default;
        }
Exemple #3
0
        public SpellingAnalysisContext(
            Action <Diagnostic> reportDiagnostic,
            SpellingData spellingData,
            SpellingFixerOptions options,
            CancellationToken cancellationToken)
        {
            SpellingData      = spellingData;
            Options           = options;
            CancellationToken = cancellationToken;

            _reportDiagnostic = reportDiagnostic;

            _spellchecker = new Spellchecker(spellingData, options: new SpellcheckerOptions(options.SplitMode, options.MinWordLength, options.MaxWordLength));
        }
Exemple #4
0
        public static async Task <ImmutableArray <Diagnostic> > AnalyzeSpellingAsync(
            ISpellingService service,
            Document document,
            SpellingData spellingData,
            SpellingFixerOptions options        = null,
            CancellationToken cancellationToken = default)
        {
            SyntaxTree tree = await document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);

            if (tree == null)
            {
                return(ImmutableArray <Diagnostic> .Empty);
            }

            if (!options.IncludeGeneratedCode &&
                GeneratedCodeUtility.IsGeneratedCode(tree, f => service.SyntaxFacts.IsComment(f), cancellationToken))
            {
                return(ImmutableArray <Diagnostic> .Empty);
            }

            SyntaxNode root = await tree.GetRootAsync(cancellationToken).ConfigureAwait(false);

            return(service.AnalyzeSpelling(root, spellingData, options, cancellationToken));
        }
Exemple #5
0
 public abstract ImmutableArray <Diagnostic> AnalyzeSpelling(
     SyntaxNode node,
     SpellingData spellingData,
     SpellingFixerOptions options,
     CancellationToken cancellationToken);
Exemple #6
0
 public abstract DiagnosticAnalyzer CreateAnalyzer(
     SpellingData spellingData,
     SpellingFixerOptions options);