本文整理汇总了C#中StateSet.GetActiveFileState方法的典型用法代码示例。如果您正苦于以下问题:C# StateSet.GetActiveFileState方法的具体用法?C# StateSet.GetActiveFileState怎么用?C# StateSet.GetActiveFileState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StateSet
的用法示例。
在下文中一共展示了StateSet.GetActiveFileState方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDocumentAnalysisDataAsync
/// <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)
{
try
{
var version = await GetDiagnosticVersionAsync(document.Project, cancellationToken).ConfigureAwait(false);
var state = stateSet.GetActiveFileState(document.Id);
var existingData = state.GetAnalysisData(kind);
if (existingData.Version == version)
{
return existingData;
}
// perf optimization. check whether analyzer is suppressed and avoid getting diagnostics if suppressed.
// REVIEW: IsAnalyzerSuppressed call seems can be quite expensive in certain condition. is there any other way to do this?
if (_owner.Owner.IsAnalyzerSuppressed(stateSet.Analyzer, document.Project))
{
return new DocumentAnalysisData(version, existingData.Items, ImmutableArray<DiagnosticData>.Empty);
}
var nullFilterSpan = (TextSpan?)null;
var diagnostics = await ComputeDiagnosticsAsync(analyzerDriverOpt, document, stateSet.Analyzer, kind, nullFilterSpan, cancellationToken).ConfigureAwait(false);
// we only care about local diagnostics
return new DocumentAnalysisData(version, existingData.Items, diagnostics.ToImmutableArrayOrEmpty());
}
catch (Exception e) when (FatalError.ReportUnlessCanceled(e))
{
throw ExceptionUtilities.Unreachable;
}
}