本文整理汇总了C#中Microsoft.CodeAnalysis.Diagnostics.EngineV1.DiagnosticAnalyzerDriver类的典型用法代码示例。如果您正苦于以下问题:C# DiagnosticAnalyzerDriver类的具体用法?C# DiagnosticAnalyzerDriver怎么用?C# DiagnosticAnalyzerDriver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DiagnosticAnalyzerDriver类属于Microsoft.CodeAnalysis.Diagnostics.EngineV1命名空间,在下文中一共展示了DiagnosticAnalyzerDriver类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetDocumentBodyAnalysisDataAsync
public async Task<AnalysisData> GetDocumentBodyAnalysisDataAsync(
StateSet stateSet, VersionArgument versions, DiagnosticAnalyzerDriver analyzerDriver,
SyntaxNode root, SyntaxNode member, int memberId, bool supportsSemanticInSpan, MemberRangeMap.MemberRanges ranges)
{
try
{
var document = analyzerDriver.Document;
var cancellationToken = analyzerDriver.CancellationToken;
var state = stateSet.GetState(StateType.Document);
var existingData = await state.TryGetExistingDataAsync(document, cancellationToken).ConfigureAwait(false);
ImmutableArray<DiagnosticData> diagnosticData;
if (supportsSemanticInSpan && CanUseRange(memberId, ranges.Ranges) && CanUseDocumentState(existingData, ranges.TextVersion, versions.DataVersion))
{
var memberDxData = await GetSemanticDiagnosticsAsync(analyzerDriver, stateSet.Analyzer).ConfigureAwait(false);
diagnosticData = _owner.UpdateDocumentDiagnostics(existingData, ranges.Ranges, memberDxData.AsImmutableOrEmpty(), root.SyntaxTree, member, memberId);
ValidateMemberDiagnostics(stateSet.Analyzer, document, root, diagnosticData);
}
else
{
// if we can't re-use existing document state, only option we have is updating whole document state here.
var dx = await GetSemanticDiagnosticsAsync(analyzerDriver, stateSet.Analyzer).ConfigureAwait(false);
diagnosticData = dx.AsImmutableOrEmpty();
}
return new AnalysisData(versions.TextVersion, versions.DataVersion, GetExistingItems(existingData), diagnosticData);
}
catch (Exception e) when (FatalError.ReportUnlessCanceled(e))
{
throw ExceptionUtilities.Unreachable;
}
}
开发者ID:noahfalk,项目名称:roslyn,代码行数:33,代码来源:DiagnosticIncrementalAnalyzer.AnalyzerExecutor.cs
示例2: LatestDiagnosticsForSpanGetter
public LatestDiagnosticsForSpanGetter(
DiagnosticIncrementalAnalyzer owner, Document document, SyntaxNode root, TextSpan range, bool blockForData, List<DiagnosticData> diagnostics, CancellationToken cancellationToken)
{
_owner = owner;
_document = document;
_range = range;
_blockForData = blockForData;
_cancellationToken = cancellationToken;
Diagnostics = diagnostics;
// Share the diagnostic analyzer driver across all analyzers.
var fullSpan = root?.FullSpan;
_spanBasedDriver = new DiagnosticAnalyzerDriver(_document, _range, root, _owner, _cancellationToken);
_documentBasedDriver = new DiagnosticAnalyzerDriver(_document, fullSpan, root, _owner, _cancellationToken);
_projectDriver = new DiagnosticAnalyzerDriver(_document.Project, _owner, _cancellationToken);
}
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:19,代码来源:DiagnosticIncrementalAnalyzer_GetLatestDiagnosticsForSpan.cs
示例3: GetDocumentAnalysisDataAsync
public async Task<AnalysisData> GetDocumentAnalysisDataAsync(DiagnosticAnalyzerDriver analyzerDriver, StateSet stateSet, VersionArgument versions)
{
try
{
var document = analyzerDriver.Document;
var cancellationToken = analyzerDriver.CancellationToken;
var state = stateSet.GetState(StateType.Document);
var existingData = await state.TryGetExistingDataAsync(document, cancellationToken).ConfigureAwait(false);
if (CheckSemanticVersions(document, existingData, versions))
{
return existingData;
}
var diagnosticData = await GetSemanticDiagnosticsAsync(analyzerDriver, stateSet.Analyzer).ConfigureAwait(false);
return new AnalysisData(versions.TextVersion, versions.DataVersion, GetExistingItems(existingData), diagnosticData.AsImmutableOrEmpty());
}
catch (Exception e) when (FatalError.ReportUnlessCanceled(e))
{
throw ExceptionUtilities.Unreachable;
}
}
开发者ID:noahfalk,项目名称:roslyn,代码行数:23,代码来源:DiagnosticIncrementalAnalyzer.AnalyzerExecutor.cs
示例4: GetSyntaxAnalysisDataAsync
public async Task<AnalysisData> GetSyntaxAnalysisDataAsync(
DiagnosticAnalyzer provider, ProviderId providerId, VersionArgument versions, DiagnosticAnalyzerDriver analyzerDriver)
{
try
{
var document = analyzerDriver.Document;
var cancellationToken = analyzerDriver.CancellationToken;
var state = AnalyzersAndState.GetOrCreateDiagnosticState(StateType.Syntax, providerId, provider, document.Project.Id, document.Project.Language);
var existingData = await state.TryGetExistingDataAsync(document, cancellationToken).ConfigureAwait(false);
if (CheckSyntaxVersions(document, existingData, versions))
{
return existingData;
}
var diagnosticData = await GetSyntaxDiagnosticsAsync(providerId, provider, analyzerDriver).ConfigureAwait(false);
return new AnalysisData(versions.TextVersion, versions.DataVersion, GetExistingItems(existingData), diagnosticData.AsImmutableOrEmpty());
}
catch (Exception e) when (FatalError.ReportUnlessCanceled(e))
{
throw ExceptionUtilities.Unreachable;
}
}
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:24,代码来源:DiagnosticIncrementalAnalyzer.IncrementalAnalyzer.AnalyzerExecutor.cs
示例5: GetDiagnosticAnalysisDataAsync
protected abstract Task<AnalysisData> GetDiagnosticAnalysisDataAsync(Solution solution, DiagnosticAnalyzerDriver analyzerDriver, StateSet stateSet, StateType stateType, VersionArgument versions);
开发者ID:nileshjagtap,项目名称:roslyn,代码行数:1,代码来源:DiagnosticIncrementalAnalyzer_GetDiagnostics.cs
示例6: SkipRunningAnalyzer
private bool SkipRunningAnalyzer(
CompilationOptions compilationOptions,
DiagnosticAnalyzerDriver userDiagnosticDriver,
bool openedDocument,
bool skipClosedFileChecks,
StateSet stateSet)
{
if (Owner.IsAnalyzerSuppressed(stateSet.Analyzer, userDiagnosticDriver.Project))
{
return true;
}
if (skipClosedFileChecks)
{
return false;
}
if (ShouldRunAnalyzerForClosedFile(compilationOptions, openedDocument, stateSet.Analyzer))
{
return false;
}
return true;
}
开发者ID:nevinclement,项目名称:roslyn,代码行数:24,代码来源:DiagnosticIncrementalAnalyzer.cs
示例7: AnalyzeDocumentAsync
private async Task AnalyzeDocumentAsync(Document document, VersionArgument versions, ImmutableHashSet<string> diagnosticIds, bool skipClosedFileChecks, CancellationToken cancellationToken)
{
try
{
var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
var fullSpan = root == null ? null : (TextSpan?)root.FullSpan;
var userDiagnosticDriver = new DiagnosticAnalyzerDriver(document, fullSpan, root, this, cancellationToken);
bool openedDocument = document.IsOpen();
foreach (var stateSet in _stateManager.GetOrUpdateStateSets(document.Project))
{
if (SkipRunningAnalyzer(document.Project.CompilationOptions, userDiagnosticDriver, openedDocument, skipClosedFileChecks, stateSet))
{
await ClearExistingDiagnostics(document, stateSet, StateType.Document, cancellationToken).ConfigureAwait(false);
continue;
}
if (ShouldRunAnalyzerForStateType(stateSet.Analyzer, StateType.Document, diagnosticIds))
{
var data = await _executor.GetDocumentAnalysisDataAsync(userDiagnosticDriver, stateSet, versions).ConfigureAwait(false);
if (data.FromCache)
{
RaiseDiagnosticsUpdated(StateType.Document, document.Id, stateSet, new SolutionArgument(document), data.Items);
continue;
}
if (openedDocument)
{
_memberRangeMap.Touch(stateSet.Analyzer, document, versions.TextVersion);
}
var state = stateSet.GetState(StateType.Document);
await state.PersistAsync(document, data.ToPersistData(), cancellationToken).ConfigureAwait(false);
RaiseDocumentDiagnosticsUpdatedIfNeeded(StateType.Document, document, stateSet, data.OldItems, data.Items);
}
}
_solutionCrawlerAnalysisState.OnDocumentAnalyzed(document);
}
catch (Exception e) when (FatalError.ReportUnlessCanceled(e))
{
throw ExceptionUtilities.Unreachable;
}
}
开发者ID:nevinclement,项目名称:roslyn,代码行数:46,代码来源:DiagnosticIncrementalAnalyzer.cs
示例8: AnalyzeProjectAsync
private async Task AnalyzeProjectAsync(Project project, CancellationToken cancellationToken)
{
try
{
if (!CheckOptions(project, forceAnalysis: false))
{
return;
}
var projectTextVersion = await project.GetLatestDocumentVersionAsync(cancellationToken).ConfigureAwait(false);
var semanticVersion = await project.GetDependentSemanticVersionAsync(cancellationToken).ConfigureAwait(false);
var projectVersion = await project.GetDependentVersionAsync(cancellationToken).ConfigureAwait(false);
var versions = new VersionArgument(projectTextVersion, semanticVersion, projectVersion);
var stateSets = _stateManager.GetOrUpdateStateSets(project);
var analyzers = stateSets.Select(s => s.Analyzer);
var analyzerDriver = new DiagnosticAnalyzerDriver(project, this, analyzers, ConcurrentAnalysis, ReportSuppressedDiagnostics, cancellationToken);
foreach (var stateSet in stateSets)
{
// Compilation actions can report diagnostics on open files, so we skipClosedFileChecks.
if (await SkipRunningAnalyzerAsync(project, stateSet.Analyzer, openedDocument: false, skipClosedFileCheck: true, cancellationToken: cancellationToken).ConfigureAwait(false))
{
await ClearExistingDiagnostics(project, stateSet, cancellationToken).ConfigureAwait(false);
continue;
}
if (ShouldRunAnalyzerForStateType(stateSet.Analyzer, StateType.Project, diagnosticIds: null))
{
var data = await _executor.GetProjectAnalysisDataAsync(analyzerDriver, stateSet, versions).ConfigureAwait(false);
if (data.FromCache)
{
RaiseProjectDiagnosticsUpdatedIfNeeded(project, stateSet, ImmutableArray<DiagnosticData>.Empty, data.Items);
continue;
}
var state = stateSet.GetState(StateType.Project);
await PersistProjectData(project, state, data).ConfigureAwait(false);
RaiseProjectDiagnosticsUpdatedIfNeeded(project, stateSet, data.OldItems, data.Items);
}
}
}
catch (Exception e) when (FatalError.ReportUnlessCanceled(e))
{
throw ExceptionUtilities.Unreachable;
}
}
开发者ID:vcsjones,项目名称:roslyn,代码行数:49,代码来源:DiagnosticIncrementalAnalyzer.cs
示例9: TryGetDocumentDiagnosticsAsync
private async Task<bool> TryGetDocumentDiagnosticsAsync(
StateSet stateSet, StateType stateType, bool supportsSemanticInSpan,
Func<VersionStamp, VersionStamp, bool> versionCheck,
Func<DiagnosticAnalyzerDriver, DiagnosticAnalyzer, Task<IEnumerable<DiagnosticData>>> getDiagnostics,
DiagnosticAnalyzerDriver analyzerDriverOpt = null)
{
Func<DiagnosticData, bool> shouldInclude = d =>
d.DocumentId == _document.Id &&
_range.IntersectsWith(d.TextSpan) &&
(_includeSuppressedDiagnostics || !d.IsSuppressed);
// make sure we get state even when none of our analyzer has ran yet.
// but this shouldn't create analyzer that doesn't belong to this project (language)
var state = stateSet.GetState(stateType);
// see whether we can use existing info
var existingData = await state.TryGetExistingDataAsync(_document, _cancellationToken).ConfigureAwait(false);
if (existingData != null && versionCheck(existingData.TextVersion, existingData.DataVersion))
{
if (existingData.Items == null || existingData.Items.Length == 0)
{
return true;
}
Diagnostics.AddRange(existingData.Items.Where(shouldInclude));
return true;
}
// check whether we want up-to-date document wide diagnostics
if (!BlockForData(stateType, supportsSemanticInSpan))
{
return false;
}
var dx = await getDiagnostics(analyzerDriverOpt, stateSet.Analyzer).ConfigureAwait(false);
if (dx != null)
{
// no state yet
Diagnostics.AddRange(dx.Where(shouldInclude));
}
return true;
}
开发者ID:nemec,项目名称:roslyn,代码行数:43,代码来源:DiagnosticIncrementalAnalyzer_GetLatestDiagnosticsForSpan.cs
示例10: GetDiagnosticAnalysisDataAsync
protected override async Task<AnalysisData> GetDiagnosticAnalysisDataAsync(
Solution solution, DiagnosticAnalyzerDriver analyzerDriver, StateSet stateSet, StateType stateType, VersionArgument versions)
{
// we don't care about result
switch (stateType)
{
case StateType.Syntax:
await GetSyntaxDiagnosticsAsync(analyzerDriver, _analyzer).ConfigureAwait(false);
break;
case StateType.Document:
await GetSemanticDiagnosticsAsync(analyzerDriver, _analyzer).ConfigureAwait(false);
break;
case StateType.Project:
default:
return Contract.FailWithReturn<AnalysisData>("Can't reach here");
}
return AnalysisData.Empty;
}
开发者ID:daking2014,项目名称:roslyn,代码行数:19,代码来源:DiagnosticIncrementalAnalyzer_GetDiagnostics.cs
示例11: ValidateMemberDiagnostics
private void ValidateMemberDiagnostics(DiagnosticAnalyzer analyzer, Document document, SyntaxNode root, ImmutableArray<DiagnosticData> diagnostics)
{
#if RANGE
var documentBasedDriver = new DiagnosticAnalyzerDriver(document, root.FullSpan, root, this, CancellationToken.None);
var expected = GetSemanticDiagnosticsAsync(documentBasedDriver, analyzer).WaitAndGetResult(documentBasedDriver.CancellationToken) ?? SpecializedCollections.EmptyEnumerable<DiagnosticData>();
Contract.Requires(diagnostics.SetEquals(expected));
#endif
}
开发者ID:noahfalk,项目名称:roslyn,代码行数:8,代码来源:DiagnosticIncrementalAnalyzer.AnalyzerExecutor.cs
示例12: UpdateAllSemanticDiagnosticsAsync
private static async Task<ImmutableArray<DiagnosticData>> UpdateAllSemanticDiagnosticsAsync(
StateSet stateSet, DiagnosticAnalyzerDriver analyzerDriver, ImmutableArray<DiagnosticData> diagnosticData)
{
var dx = await GetSemanticDiagnosticsAsync(analyzerDriver, stateSet.Analyzer).ConfigureAwait(false);
diagnosticData = dx.AsImmutableOrEmpty();
return diagnosticData;
}
开发者ID:RoryVL,项目名称:roslyn,代码行数:7,代码来源:DiagnosticIncrementalAnalyzer.AnalyzerExecutor.cs
示例13: GetSpecificDiagnosticsAsync
protected abstract Task<AnalysisData> GetSpecificDiagnosticsAsync(Solution solution, DiagnosticAnalyzer provider, ProviderId providerId, StateType stateType, VersionArgument versions, DiagnosticAnalyzerDriver analyzerDriver);
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:1,代码来源:DiagnosticIncrementalAnalyzer_GetDiagnostics.cs
示例14: ShouldRunAnalyzerForStateTypeAsync
private static async Task<bool> ShouldRunAnalyzerForStateTypeAsync(DiagnosticAnalyzerDriver driver, DiagnosticAnalyzer analyzer, StateType stateTypeId,
ImmutableHashSet<string> diagnosticIds = null, Func<DiagnosticAnalyzer, ImmutableArray<DiagnosticDescriptor>> getDescriptors = null)
{
Debug.Assert(!driver.IsAnalyzerSuppressed(analyzer));
if (diagnosticIds != null && getDescriptors(analyzer).All(d => !diagnosticIds.Contains(d.Id)))
{
return false;
}
switch (stateTypeId)
{
case StateType.Syntax:
return await analyzer.SupportsSyntaxDiagnosticAnalysisAsync(driver).ConfigureAwait(false);
case StateType.Document:
return await analyzer.SupportsSemanticDiagnosticAnalysisAsync(driver).ConfigureAwait(false);
case StateType.Project:
return await analyzer.SupportsProjectDiagnosticAnalysisAsync(driver).ConfigureAwait(false);
default:
throw ExceptionUtilities.Unreachable;
}
}
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:25,代码来源:DiagnosticIncrementalAnalyzer.cs
示例15: IsAnalyzerSuppressed
private static bool IsAnalyzerSuppressed(DiagnosticAnalyzer provider, CompilationOptions options, DiagnosticAnalyzerDriver driver)
{
if (options != null && CompilationWithAnalyzers.IsDiagnosticAnalyzerSuppressed(provider, options, driver.CatchAnalyzerExceptionHandler))
{
// All diagnostics that are generated by this DiagnosticAnalyzer will be suppressed, so we need not run the analyzer.
return true;
}
return false;
}
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:10,代码来源:DiagnosticIncrementalAnalyzer.cs
示例16: AnalyzeSyntaxAsync
private async Task AnalyzeSyntaxAsync(Document document, ImmutableHashSet<string> diagnosticIds, bool skipClosedFileChecks, CancellationToken cancellationToken)
{
try
{
if (!skipClosedFileChecks && !CheckOption(document.Project.Solution.Workspace, document.Project.Language, document.IsOpen()))
{
return;
}
var textVersion = await document.GetTextVersionAsync(cancellationToken).ConfigureAwait(false);
var dataVersion = await document.GetSyntaxVersionAsync(cancellationToken).ConfigureAwait(false);
var versions = new VersionArgument(textVersion, dataVersion);
var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
var fullSpan = root == null ? null : (TextSpan?)root.FullSpan;
var userDiagnosticDriver = new DiagnosticAnalyzerDriver(document, fullSpan, root, _diagnosticLogAggregator, cancellationToken);
var options = document.Project.CompilationOptions;
var openedDocument = document.IsOpen();
foreach (var providerAndId in await _analyzersAndState.GetAllProviderAndIdsAsync(document.Project, cancellationToken).ConfigureAwait(false))
{
var provider = providerAndId.Key;
var providerId = providerAndId.Value;
if (IsAnalyzerSuppressed(provider, options, userDiagnosticDriver))
{
await HandleSuppressedAnalyzerAsync(document, StateType.Syntax, providerId, provider, cancellationToken).ConfigureAwait(false);
}
else if (ShouldRunProviderForStateType(StateType.Syntax, provider, userDiagnosticDriver, diagnosticIds) &&
(skipClosedFileChecks || ShouldRunProviderForClosedFile(openedDocument, provider)))
{
var data = await _executor.GetSyntaxAnalysisDataAsync(provider, providerId, versions, userDiagnosticDriver).ConfigureAwait(false);
if (data.FromCache)
{
RaiseDiagnosticsUpdated(StateType.Syntax, document.Id, providerId, new SolutionArgument(document), data.Items);
continue;
}
var state = _analyzersAndState.GetOrCreateDiagnosticState(StateType.Syntax, providerId, provider, document.Project.Id, document.Project.Language);
await state.PersistAsync(document, data.ToPersistData(), cancellationToken).ConfigureAwait(false);
RaiseDiagnosticsUpdatedIfNeeded(StateType.Syntax, document, providerId, data.OldItems, data.Items);
}
}
}
catch (Exception e) when (FatalError.ReportUnlessCanceled(e))
{
throw ExceptionUtilities.Unreachable;
}
}
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:51,代码来源:DiagnosticIncrementalAnalyzer.cs
示例17: AnalyzeBodyDocumentAsync
private async Task AnalyzeBodyDocumentAsync(Document document, SyntaxNode member, VersionArgument versions, CancellationToken cancellationToken)
{
try
{
// syntax facts service must exist, otherwise, this method won't have called.
var syntaxFacts = document.Project.LanguageServices.GetService<ISyntaxFactsService>();
var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
var memberId = syntaxFacts.GetMethodLevelMemberId(root, member);
var spanBasedDriver = new DiagnosticAnalyzerDriver(document, member.FullSpan, root, _diagnosticLogAggregator, cancellationToken);
var documentBasedDriver = new DiagnosticAnalyzerDriver(document, root.FullSpan, root, _diagnosticLogAggregator, cancellationToken);
var options = document.Project.CompilationOptions;
foreach (var providerAndId in await _analyzersAndState.GetAllProviderAndIdsAsync(document.Project, cancellationToken).ConfigureAwait(false))
{
var provider = providerAndId.Key;
var providerId = providerAndId.Value;
bool supportsSemanticInSpan;
if (IsAnalyzerSuppressed(provider, options, spanBasedDriver))
{
await HandleSuppressedAnalyzerAsync(document, StateType.Document, providerId, provider, cancellationToken).ConfigureAwait(false);
}
else if (ShouldRunProviderForStateType(StateType.Document, provider, spanBasedDriver, out supportsSemanticInSpan))
{
var userDiagnosticDriver = supportsSemanticInSpan ? spanBasedDriver : documentBasedDriver;
var ranges = _memberRangeMap.GetSavedMemberRange(providerId, document);
var data = await _executor.GetDocumentBodyAnalysisDataAsync(
provider, providerId, versions, userDiagnosticDriver, root, member, memberId, supportsSemanticInSpan, ranges).ConfigureAwait(false);
_memberRangeMap.UpdateMemberRange(providerId, document, versions.TextVersion, memberId, member.FullSpan, ranges);
var state = _analyzersAndState.GetOrCreateDiagnosticState(StateType.Document, providerId, provider, document.Project.Id, document.Project.Language);
await state.PersistAsync(document, data.ToPersistData(), cancellationToken).ConfigureAwait(false);
if (data.FromCache)
{
RaiseDiagnosticsUpdated(StateType.Document, document.Id, providerId, new SolutionArgument(document), data.Items);
continue;
}
RaiseDiagnosticsUpdatedIfNeeded(StateType.Document, document, providerId, data.OldItems, data.Items);
}
}
}
catch (Exception e) when (FatalError.ReportUnlessCanceled(e))
{
throw ExceptionUtilities.Unreachable;
}
}
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:51,代码来源:DiagnosticIncrementalAnalyzer.cs
示例18: GetProjectDiagnosticsWorkerAsync
private Task<IEnumerable<DiagnosticData>> GetProjectDiagnosticsWorkerAsync(DiagnosticAnalyzerDriver driver, DiagnosticAnalyzer analyzer)
{
return GetProjectDiagnosticsAsync(driver, analyzer, _owner.ForceAnalyzeAllDocuments);
}
开发者ID:hvanbakel,项目名称:roslyn,代码行数:4,代码来源:DiagnosticIncrementalAnalyzer_GetLatestDiagnosticsForSpan.cs
示例19: AnalyzeProjectAsync
private async Task AnalyzeProjectAsync(Project project, ImmutableHashSet<string> diagnosticIds, bool skipClosedFileChecks, CancellationToken cancellationToken)
{
try
{
if (!skipClosedFileChecks && !CheckOption(project.Solution.Workspace, project.Language, documentOpened: project.Documents.Any(d => d.IsOpen())))
{
return;
}
var projectVersion = await project.GetDependentVersionAsync(cancellationToken).ConfigureAwait(false);
var semanticVersion = await project.GetDependentSemanticVersionAsync(cancellationToken).ConfigureAwait(false);
var userDiagnosticDriver = new DiagnosticAnalyzerDriver(project, _diagnosticLogAggregator, cancellationToken);
var options = project.CompilationOptions;
var versions = new VersionArgument(VersionStamp.Default, semanticVersion, projectVersion);
foreach (var providerAndId in await _analyzersAndState.GetAllProviderAndIdsAsync(project, cancellationToken).ConfigureAwait(false))
{
var provider = providerAndId.Key;
var providerId = providerAndId.Value;
if (IsAnalyzerSuppressed(provider, options, userDiagnosticDriver))
{
await HandleSuppressedAnalyzerAsync(project, providerId, provider, cancellationToken).ConfigureAwait(false);
}
else if (ShouldRunProviderForStateType(StateType.Project, provider, userDiagnosticDriver, diagnosticIds) &&
(skipClosedFileChecks || ShouldRunProviderForClosedFile(openedDocument: false, provider: provider)))
{
var data = await _executor.GetProjectAnalysisDataAsync(provider, providerId, versions, userDiagnosticDriver).ConfigureAwait(false);
if (data.FromCache)
{
RaiseDiagnosticsUpdated(StateType.Project, project.Id, providerId, new SolutionArgument(project), data.Items);
continue;
}
var state = _analyzersAndState.GetOrCreateDiagnosticState(StateType.Project, providerId, provider, project.Id, project.Language);
await state.PersistAsync(project, data.ToPersistData(), cancellationToken).ConfigureAwait(false);
RaiseDiagnosticsUpdatedIfNeeded(project, providerId, data.OldItems, data.Items);
}
}
}
catch (Exception e) when (FatalError.ReportUnlessCanceled(e))
{
throw ExceptionUtilities.Unreachable;
}
}
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:46,代码来源:DiagnosticIncrementalAnalyzer.cs
示例20: AnalyzeSyntaxAsync
private async Task AnalyzeSyntaxAsync(Document document, ImmutableHashSet<string> diagnosticIds, CancellationToken cancellationToken)
{
try
{
if (!CheckOptions(document.Project, document.IsOpen()))
{
return;
}
var textVersion = await document.GetTextVersionAsync(cancellationToken).ConfigureAwait(false);
var dataVersion = await document.GetSyntaxVersionAsync(cancellationToken).ConfigureAwait(false);
var versions = new VersionArgument(textVersion, dataVersion);
var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
var fullSpan = root == null ? null : (TextSpan?)root.FullSpan;
var openedDocument = document.IsOpen();
var stateSets = _stateManager.GetOrUpdateStateSets(document.Project);
var analyzers = stateSets.Select(s => s.Analyzer);
var userDiagnosticDriver = new DiagnosticAnalyzerDriver(
document, fullSpan, root, this, analyzers, ConcurrentAnalysis, ReportSuppressedDiagnostics, cancellationToken);
foreach (var stateSet in stateSets)
{
if (await SkipRunningAnalyzerAsync(document.Project, stateSet.Analyzer, openedDocument, skipClosedFileCheck: false, cancellationToken: cancellationToken).ConfigureAwait(false))
{
await ClearExistingDiagnostics(document, stateSet, StateType.Syntax, cancellationToken).ConfigureAwait(false);
continue;
}
if (ShouldRunAnalyzerForStateType(stateSet.Analyzer, StateType.Syntax, diagnosticIds))
{
var data = await _executor.GetSyntaxAnalysisDataAsync(userDiagnosticDriver, stateSet, versions).ConfigureAwait(false);
if (data.FromCache)
{
RaiseDiagnosticsCreatedFromCacheIfNeeded(StateType.Syntax, document, stateSet, data.Items);
continue;
}
var state = stateSet.GetState(StateType.Syntax);
await state.PersistAsync(document, data.ToPersistData(), cancellationToken).ConfigureAwait(false);
RaiseDocumentDiagnosticsUpdatedIfNeeded(StateType.Syntax, document, stateSet, data.OldItems, data.Items);
}
}
}
catch (Exception e) when (FatalError.ReportUnlessCanceled(e))
{
throw ExceptionUtilities.Unreachable;
}
}
开发者ID:vcsjones,项目名称:roslyn,代码行数:53,代码来源:DiagnosticIncrementalAnalyzer.cs
注:本文中的Microsoft.CodeAnalysis.Diagnostics.EngineV1.DiagnosticAnalyzerDriver类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论