提交 60e41b21 编写于 作者: H Heejae Chang

added comment based on PR.

上级 2920c155
......@@ -41,6 +41,9 @@ public IEnumerable<DiagnosticData> ConvertToLocalDiagnostics(Document targetDocu
return ConvertToLocalDiagnosticsWithoutCompilation(targetDocument, diagnostics, span);
}
/// <summary>
/// Return all local diagnostics (syntax, semantic) that belong to given document for the given StateSet (analyzer) either from cache or by calculating them
/// </summary>
public async Task<DocumentAnalysisData> GetDocumentAnalysisDataAsync(
CompilationWithAnalyzers analyzerDriverOpt, Document document, StateSet stateSet, AnalysisKind kind, CancellationToken cancellationToken)
{
......@@ -74,6 +77,9 @@ public IEnumerable<DiagnosticData> ConvertToLocalDiagnostics(Document targetDocu
}
}
/// <summary>
/// Return all diagnostics that belong to given project for the given StateSets (analyzers) either from cache or by calculating them
/// </summary>
public async Task<ProjectAnalysisData> GetProjectAnalysisDataAsync(
CompilationWithAnalyzers analyzerDriverOpt, Project project, IEnumerable<StateSet> stateSets, CancellationToken cancellationToken)
{
......@@ -105,6 +111,9 @@ public IEnumerable<DiagnosticData> ConvertToLocalDiagnostics(Document targetDocu
}
}
/// <summary>
/// Return all local diagnostics (syntax, semantic) that belong to given document for the given StateSet (analyzer) by calculating them
/// </summary>
public async Task<IEnumerable<DiagnosticData>> ComputeDiagnosticsAsync(
CompilationWithAnalyzers analyzerDriverOpt, Document document, DiagnosticAnalyzer analyzer, AnalysisKind kind, TextSpan? spanOpt, CancellationToken cancellationToken)
{
......@@ -119,6 +128,9 @@ public IEnumerable<DiagnosticData> ConvertToLocalDiagnostics(Document targetDocu
return ConvertToLocalDiagnostics(document, documentDiagnostics);
}
/// <summary>
/// Return all diagnostics that belong to given project for the given StateSets (analyzers) by calculating them
/// </summary>
public async Task<ImmutableDictionary<DiagnosticAnalyzer, AnalysisResult>> ComputeDiagnosticsAsync(
CompilationWithAnalyzers analyzerDriverOpt, Project project, IEnumerable<StateSet> stateSets, CancellationToken cancellationToken)
{
......
......@@ -42,6 +42,9 @@ public bool IsEmpty(DocumentId documentId)
return IsEmpty(_lastResult, documentId);
}
/// <summary>
/// Return all diagnostics for the given project stored in this state
/// </summary>
public async Task<AnalysisResult> GetAnalysisDataAsync(Project project, bool avoidLoadingData, CancellationToken cancellationToken)
{
// make a copy of last result.
......@@ -54,14 +57,14 @@ public async Task<AnalysisResult> GetAnalysisDataAsync(Project project, bool avo
}
// PERF: avoid loading data if version is not right one.
// avoid loading data flag is there as a strickly perf optimization.
// avoid loading data flag is there as a strictly perf optimization.
var version = await GetDiagnosticVersionAsync(project, cancellationToken).ConfigureAwait(false);
if (avoidLoadingData && lastResult.Version != version)
{
return lastResult;
}
// if given document doesnt have any diagnostics, return empty.
// if given project doesnt have any diagnostics, return empty.
if (lastResult.IsEmpty)
{
return new AnalysisResult(lastResult.ProjectId, lastResult.Version);
......@@ -73,6 +76,8 @@ public async Task<AnalysisResult> GetAnalysisDataAsync(Project project, bool avo
foreach (var documentId in lastResult.DocumentIds)
{
cancellationToken.ThrowIfCancellationRequested();
var document = project.GetDocument(documentId);
if (document == null)
{
......@@ -94,6 +99,9 @@ public async Task<AnalysisResult> GetAnalysisDataAsync(Project project, bool avo
return builder.ToResult();
}
/// <summary>
/// Return all diagnostics for the given document stored in this state including non local diagnostics for this document
/// </summary>
public async Task<AnalysisResult> GetAnalysisDataAsync(Document document, bool avoidLoadingData, CancellationToken cancellationToken)
{
// make a copy of last result.
......@@ -129,6 +137,9 @@ public async Task<AnalysisResult> GetAnalysisDataAsync(Document document, bool a
return builder.ToResult();
}
/// <summary>
/// Return all no location diagnostics for the given project stored in this state
/// </summary>
public async Task<AnalysisResult> GetProjectAnalysisDataAsync(Project project, bool avoidLoadingData, CancellationToken cancellationToken)
{
// make a copy of last result.
......@@ -209,6 +220,8 @@ private async Task<AnalysisResult> LoadInitialAnalysisDataAsync(Project project,
foreach (var document in project.Documents)
{
cancellationToken.ThrowIfCancellationRequested();
if (!await TryDeserializeDocumentAsync(serializer, document, builder, cancellationToken).ConfigureAwait(false))
{
continue;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册