// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Generic; using System.Collections.Immutable; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Text; namespace Microsoft.CodeAnalysis.Diagnostics { internal interface IDiagnosticAnalyzerService { /// /// re-analyze given projects and documents /// void Reanalyze(Workspace workspace, IEnumerable projectIds = null, IEnumerable documentIds = null, bool highPriority = false); /// /// get specific diagnostics currently stored in the source. returned diagnostic might be out-of-date if solution has changed but analyzer hasn't run for the new solution. /// Task> GetSpecificCachedDiagnosticsAsync(Workspace workspace, object id, bool includeSuppressedDiagnostics = false, CancellationToken cancellationToken = default(CancellationToken)); /// /// get diagnostics currently stored in the source. returned diagnostic might be out-of-date if solution has changed but analyzer hasn't run for the new solution. /// Task> GetCachedDiagnosticsAsync(Workspace workspace, ProjectId projectId = null, DocumentId documentId = null, bool includeSuppressedDiagnostics = false, CancellationToken cancellationToken = default(CancellationToken)); /// /// get specific diagnostics for the given solution. all diagnostics returned should be up-to-date with respect to the given solution. /// Task> GetSpecificDiagnosticsAsync(Solution solution, object id, bool includeSuppressedDiagnostics = false, CancellationToken cancellationToken = default(CancellationToken)); /// /// get diagnostics for the given solution. all diagnostics returned should be up-to-date with respect to the given solution. /// Task> GetDiagnosticsAsync(Solution solution, ProjectId projectId = null, DocumentId documentId = null, bool includeSuppressedDiagnostics = false, CancellationToken cancellationToken = default(CancellationToken)); /// /// true if given project has any diagnostics /// bool ContainsDiagnostics(Workspace workspace, ProjectId projectId); /// /// get diagnostics of the given diagnostic ids from the given solution. all diagnostics returned should be up-to-date with respect to the given solution. /// Note that for project case, this method returns diagnostics from all project documents as well. Use /// if you want to fetch only project diagnostics without source locations. /// Task> GetDiagnosticsForIdsAsync(Solution solution, ProjectId projectId = null, DocumentId documentId = null, ImmutableHashSet diagnosticIds = null, bool includeSuppressedDiagnostics = false, CancellationToken cancellationToken = default(CancellationToken)); /// /// get project diagnostics (diagnostics with no source location) of the given diagnostic ids from the given solution. all diagnostics returned should be up-to-date with respect to the given solution. /// Note that this method doesn't return any document diagnostics. Use to also fetch those. /// Task> GetProjectDiagnosticsForIdsAsync(Solution solution, ProjectId projectId = null, ImmutableHashSet diagnosticIds = null, bool includeSuppressedDiagnostics = false, CancellationToken cancellationToken = default(CancellationToken)); /// /// try to return up to date diagnostics for the given span for the document. /// /// it will return true if it was able to return all up-to-date diagnostics. /// otherwise, false indicating there are some missing diagnostics in the diagnostic list /// Task TryAppendDiagnosticsForSpanAsync(Document document, TextSpan range, List diagnostics, bool includeSuppressedDiagnostics = false, CancellationToken cancellationToken = default(CancellationToken)); /// /// return up to date diagnostics for the given span for the document /// /// this can be expensive since it is force analyzing diagnostics if it doesn't have up-to-date one yet. /// Task> GetDiagnosticsForSpanAsync(Document document, TextSpan range, bool includeSuppressedDiagnostics = false, CancellationToken cancellationToken = default(CancellationToken)); /// /// Gets a list of the diagnostics that are provided by this service. /// If the given is non-null, then gets the diagnostics for the project. /// Otherwise, returns the global set of diagnostics enabled for the workspace. /// /// A mapping from analyzer name to the diagnostics produced by that analyzer ImmutableDictionary> GetDiagnosticDescriptors(Project projectOpt); /// /// Gets a list of the diagnostics provided by the given . /// /// A list of the diagnostics produced by the given analyzer ImmutableArray GetDiagnosticDescriptors(DiagnosticAnalyzer analyzer); /// /// Check whether given diagnostic is compiler diagnostic or not /// bool IsCompilerDiagnostic(string language, DiagnosticData diagnostic); /// /// Get compiler analyzer for the given language /// DiagnosticAnalyzer GetCompilerDiagnosticAnalyzer(string language); /// /// Check whether given is compiler analyzer for the language or not. /// bool IsCompilerDiagnosticAnalyzer(string language, DiagnosticAnalyzer analyzer); /// /// Return host s. (ex, analyzers installed by vsix) /// IEnumerable GetHostAnalyzerReferences(); } }