本文整理汇总了C#中Microsoft.CodeAnalysis.SolutionCrawler.InvocationReasons类的典型用法代码示例。如果您正苦于以下问题:C# InvocationReasons类的具体用法?C# InvocationReasons怎么用?C# InvocationReasons使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InvocationReasons类属于Microsoft.CodeAnalysis.SolutionCrawler命名空间,在下文中一共展示了InvocationReasons类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AnalyzeSyntaxAsync
public async Task AnalyzeSyntaxAsync(Document document, InvocationReasons reasons, CancellationToken cancellationToken)
{
if (!document.SupportsSyntaxTree)
{
return;
}
// getting tree is cheap since tree always stays in memory
var tree = await document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);
var length = tree.Length;
while (true)
{
if (_map.TryAdd(document.Id, length))
{
Interlocked.Add(ref _size, length);
return;
}
long size;
if (_map.TryGetValue(document.Id, out size))
{
if (size == length)
{
return;
}
if (_map.TryUpdate(document.Id, length, size))
{
Interlocked.Add(ref _size, length - size);
return;
}
}
}
}
示例2: AnalyzeProjectAsync
public async Task AnalyzeProjectAsync(Project project, bool semanticsChanged, InvocationReasons reasons, CancellationToken cancellationToken)
{
if (TryGetAnalyzer(project, out var analyzer))
{
await analyzer.AnalyzeProjectAsync(project, semanticsChanged, reasons, cancellationToken).ConfigureAwait(false);
}
}
示例3: AnalyzeDocumentAsync
public async Task AnalyzeDocumentAsync(Document document, SyntaxNode bodyOpt, InvocationReasons reasons, CancellationToken cancellationToken)
{
if (TryGetAnalyzer(document.Project, out var analyzer))
{
await analyzer.AnalyzeDocumentAsync(document, bodyOpt, reasons, cancellationToken).ConfigureAwait(false);
}
}
示例4: AnalyzeSyntaxAsync
public async Task AnalyzeSyntaxAsync(Document document, InvocationReasons reasons, CancellationToken cancellationToken)
{
IIncrementalAnalyzer analyzer;
if (TryGetAnalyzer(document.Project, out analyzer))
{
await analyzer.AnalyzeSyntaxAsync(document, reasons, cancellationToken).ConfigureAwait(false);
}
}
示例5: WorkItem
public WorkItem(
DocumentId documentId, string language, InvocationReasons invocationReasons, bool isLowPriority,
SyntaxPath activeMember, IAsyncToken asyncToken)
: this(documentId, documentId.ProjectId, language, invocationReasons, isLowPriority,
activeMember, ImmutableHashSet.Create<IIncrementalAnalyzer>(),
false, asyncToken)
{
}
示例6: AnalyzeSyntaxAsync
public async Task AnalyzeSyntaxAsync(Document document, InvocationReasons reasons, CancellationToken cancellationToken)
{
// it has an assumption that this will not be called concurrently for same document.
// in fact, in current design, it won't be even called concurrently for different documents.
// but, can be called concurrently for different documents in future if we choose to.
Contract.ThrowIfFalse(document.IsFromPrimaryBranch());
var documentOptions = await document.GetOptionsAsync(cancellationToken).ConfigureAwait(false);
if (!documentOptions.GetOption(InternalFeatureOnOffOptions.TodoComments))
{
return;
}
// use tree version so that things like compiler option changes are considered
var textVersion = await document.GetTextVersionAsync(cancellationToken).ConfigureAwait(false);
var syntaxVersion = await document.GetSyntaxVersionAsync(cancellationToken).ConfigureAwait(false);
var existingData = await _state.TryGetExistingDataAsync(document, cancellationToken).ConfigureAwait(false);
if (existingData != null)
{
// check whether we can use the data as it is (can happen when re-using persisted data from previous VS session)
if (CheckVersions(document, textVersion, syntaxVersion, existingData))
{
Contract.Requires(_workspace == document.Project.Solution.Workspace);
RaiseTaskListUpdated(_workspace, document.Project.Solution, document.Id, existingData.Items);
return;
}
}
var service = document.GetLanguageService<ITodoCommentService>();
if (service == null)
{
return;
}
var tokens = await _todoCommentTokens.GetTokensAsync(document, cancellationToken).ConfigureAwait(false);
var comments = await service.GetTodoCommentsAsync(document, tokens, cancellationToken).ConfigureAwait(false);
var items = await CreateItemsAsync(document, comments, cancellationToken).ConfigureAwait(false);
var data = new Data(textVersion, syntaxVersion, items);
await _state.PersistAsync(document, data, cancellationToken).ConfigureAwait(false);
// * NOTE * cancellation can't throw after this point.
if (existingData == null || existingData.Items.Length > 0 || data.Items.Length > 0)
{
Contract.Requires(_workspace == document.Project.Solution.Workspace);
RaiseTaskListUpdated(_workspace, document.Project.Solution, document.Id, data.Items);
}
}
示例7: AnalyzeProjectAsync
public override async Task AnalyzeProjectAsync(Project project, bool semanticsChanged, InvocationReasons reasons, CancellationToken cancellationToken)
{
try
{
var stateSets = GetStateSetsForFullSolutionAnalysis(_stateManager.GetOrUpdateStateSets(project), project).ToList();
// PERF: get analyzers that are not suppressed and marked as open file only
// this is perf optimization. we cache these result since we know the result. (no diagnostics)
// REVIEW: IsAnalyzerSuppressed call seems can be quite expensive in certain condition. is there any other way to do this?
var activeAnalyzers = stateSets
.Select(s => s.Analyzer)
.Where(a => !Owner.IsAnalyzerSuppressed(a, project) &&
!a.IsOpenFileOnly(project.Solution.Workspace));
// get driver only with active analyzers.
var includeSuppressedDiagnostics = true;
var analyzerDriverOpt = await _compilationManager.CreateAnalyzerDriverAsync(project, activeAnalyzers, includeSuppressedDiagnostics, cancellationToken).ConfigureAwait(false);
var ignoreFullAnalysisOptions = false;
var result = await _executor.GetProjectAnalysisDataAsync(analyzerDriverOpt, project, stateSets, ignoreFullAnalysisOptions, cancellationToken).ConfigureAwait(false);
if (result.FromCache)
{
RaiseProjectDiagnosticsIfNeeded(project, stateSets, result.Result);
return;
}
// no cancellation after this point.
// any analyzer that doesn't have result will be treated as returned empty set
// which means we will remove those from error list
foreach (var stateSet in stateSets)
{
var state = stateSet.GetProjectState(project.Id);
await state.SaveAsync(project, result.GetResult(stateSet.Analyzer)).ConfigureAwait(false);
}
RaiseProjectDiagnosticsIfNeeded(project, stateSets, result.OldResult, result.Result);
}
catch (Exception e) when (FatalError.ReportUnlessCanceled(e))
{
throw ExceptionUtilities.Unreachable;
}
}
示例8: AnalyzeDocumentAsync
public async Task AnalyzeDocumentAsync(Document document, SyntaxNode bodyOpt, InvocationReasons reasons, CancellationToken cancellationToken)
{
// method body change
if (bodyOpt != null || !document.IsOpen())
{
return;
}
// get semantic version for the project this document belongs to
var newVersion = await document.Project.GetDependentSemanticVersionAsync(cancellationToken).ConfigureAwait(false);
// check whether we already saw semantic version change
if (_map.TryGetValue(document.Id, out var oldVersion) && oldVersion == newVersion)
{
return;
}
// update to new version
_map[document.Id] = newVersion;
_owner.RaiseOpenDocumentSemanticChangedEvent(document);
}
示例9: EnqueueWorkItemAsync
private async Task EnqueueWorkItemAsync(Project project, InvocationReasons invocationReasons)
{
foreach (var documentId in project.DocumentIds)
{
var document = project.GetDocument(documentId);
await EnqueueWorkItemAsync(document, invocationReasons).ConfigureAwait(false);
}
}
示例10: AnalyzeProjectAsync
public override Task AnalyzeProjectAsync(Project project, bool semanticsChanged, InvocationReasons reasons, CancellationToken cancellationToken)
{
return Analyzer.AnalyzeProjectAsync(project, semanticsChanged, reasons, cancellationToken);
}
示例11: AnalyzeDocumentAsync
public override Task AnalyzeDocumentAsync(Document document, SyntaxNode bodyOpt, InvocationReasons reasons, CancellationToken cancellationToken)
{
return Analyzer.AnalyzeDocumentAsync(document, bodyOpt, reasons, cancellationToken);
}
示例12: DocumentDifferenceResult
public DocumentDifferenceResult(InvocationReasons changeType, SyntaxNode changedMember = null)
{
this.ChangeType = changeType;
this.ChangedMember = changedMember;
}
示例13: AnalyzeSyntaxAsync
/// <summary>
/// Apply syntax tree actions (that have not already been applied) to a document.
/// Calls <see cref="DiagnosticAnalyzerService.RaiseDiagnosticsUpdated(DiagnosticsUpdatedArgs)"/> for each
/// unique group of diagnostics, where a group is identified by analysis classification (syntax), document, and analyzer.
/// </summary>
/// <param name="document">The document to analyze.</param>
/// <param name="reasons">The reason(s) this analysis was triggered.</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public abstract Task AnalyzeSyntaxAsync(Document document, InvocationReasons reasons, CancellationToken cancellationToken);
示例14: AnalyzeProjectAsync
/// <summary>
/// Analyze a single project such that diagnostics for the entire project become available.
/// Calls <see cref="DiagnosticAnalyzerService.RaiseDiagnosticsUpdated(DiagnosticsUpdatedArgs)"/> for each
/// unique group of diagnostics, where a group is identified by analysis classification (project), project, and analyzer.
/// </summary>
/// <param name="project">The project to analyze.</param>
/// <param name="semanticsChanged">Indicates a change to the declarative semantics of the project.</param>
/// <param name="reasons">The reason(s) this analysis was triggered.</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public abstract Task AnalyzeProjectAsync(Project project, bool semanticsChanged, InvocationReasons reasons, CancellationToken cancellationToken);
示例15: AnalyzeDocumentAsync
public override Task AnalyzeDocumentAsync(Document document, SyntaxNode bodyOpt, InvocationReasons reasons, CancellationToken cancellationToken)
{
if (!document.SupportsSyntaxTree)
{
// Not a language we can produce indices for (i.e. TypeScript). Bail immediately.
return SpecializedTasks.EmptyTask;
}
if (bodyOpt != null)
{
// This was a method level edit. This can't change the symbol tree info
// for this project. Bail immediately.
return SpecializedTasks.EmptyTask;
}
return UpdateSymbolTreeInfoAsync(document.Project, cancellationToken);
}