本文整理汇总了C#中Microsoft.CodeAnalysis.SolutionCrawler.InvocationReasons类的典型用法代码示例。如果您正苦于以下问题:C# InvocationReasons类的具体用法?C# InvocationReasons怎么用?C# InvocationReasons使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InvocationReasons类属于Microsoft.CodeAnalysis.SolutionCrawler命名空间,在下文中一共展示了InvocationReasons类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
}
}
}
开发者ID:jkotas,项目名称:roslyn,代码行数:35,代码来源:SolutionSizeTracker.cs
示例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);
}
}
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:7,代码来源:AggregateIncrementalAnalyzer.cs
示例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);
}
}
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:7,代码来源:AggregateIncrementalAnalyzer.cs
示例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);
}
}
开发者ID:RoryVL,项目名称:roslyn,代码行数:8,代码来源:AggregateIncrementalAnalyzer.cs
示例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)
{
}
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:8,代码来源:WorkCoordinator.WorkItem.cs
示例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);
}
}
开发者ID:orthoxerox,项目名称:roslyn,代码行数:50,代码来源:AbstractTodoCommentIncrementalAnalyzer.cs
示例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;
}
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:42,代码来源:DiagnosticIncrementalAnalyzer_IncrementalAnalyzer.cs
示例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);
}
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:20,代码来源:SemanticChangeNotificationService.cs
示例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);
}
}
开发者ID:GloryChou,项目名称:roslyn,代码行数:8,代码来源:WorkCoordinator.cs
示例10: AnalyzeProjectAsync
public override Task AnalyzeProjectAsync(Project project, bool semanticsChanged, InvocationReasons reasons, CancellationToken cancellationToken)
{
return Analyzer.AnalyzeProjectAsync(project, semanticsChanged, reasons, cancellationToken);
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:4,代码来源:DiagnosticAnalyzerService_IncrementalAnalyzer.cs
示例11: AnalyzeDocumentAsync
public override Task AnalyzeDocumentAsync(Document document, SyntaxNode bodyOpt, InvocationReasons reasons, CancellationToken cancellationToken)
{
return Analyzer.AnalyzeDocumentAsync(document, bodyOpt, reasons, cancellationToken);
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:4,代码来源:DiagnosticAnalyzerService_IncrementalAnalyzer.cs
示例12: DocumentDifferenceResult
public DocumentDifferenceResult(InvocationReasons changeType, SyntaxNode changedMember = null)
{
this.ChangeType = changeType;
this.ChangedMember = changedMember;
}
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:5,代码来源:IDocumentDifferenceService.cs
示例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);
开发者ID:XieShuquan,项目名称:roslyn,代码行数:10,代码来源:BaseDiagnosticIncrementalAnalyzer.cs
示例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);
开发者ID:XieShuquan,项目名称:roslyn,代码行数:11,代码来源:BaseDiagnosticIncrementalAnalyzer.cs
示例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);
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:17,代码来源:SymbolTreeInfoIncrementalAnalyzerProvider.cs
示例16: AnalyzeSyntaxAsync
public override Task AnalyzeSyntaxAsync(Document document, InvocationReasons reasons, CancellationToken cancellationToken)
{
return AnalyzeDocumentForKindAsync(document, AnalysisKind.Syntax, cancellationToken);
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:4,代码来源:DiagnosticIncrementalAnalyzer_IncrementalAnalyzer.cs
示例17: AnalyzeDocumentAsync
public Task AnalyzeDocumentAsync(Document document, SyntaxNode bodyOpt, InvocationReasons reasons, CancellationToken cancellationToken)
{
if (bodyOpt == null)
{
this.DocumentIds.Add(document.Id);
}
return SpecializedTasks.EmptyTask;
}
开发者ID:RoryVL,项目名称:roslyn,代码行数:9,代码来源:WorkCoordinatorTests.cs
示例18: TestAsync
private static async Task TestAsync(string codeWithMarker)
{
using (var workspace = await CSharpWorkspaceFactory.CreateWorkspaceFromLinesAsync(codeWithMarker))
{
var commentTokens = new TodoCommentTokens();
var provider = new TodoCommentIncrementalAnalyzerProvider(commentTokens);
var worker = (TodoCommentIncrementalAnalyzer)provider.CreateIncrementalAnalyzer(workspace);
var document = workspace.Documents.First();
var documentId = document.Id;
var reasons = new InvocationReasons(PredefinedInvocationReasons.DocumentAdded);
await worker.AnalyzeSyntaxAsync(workspace.CurrentSolution.GetDocument(documentId), CancellationToken.None);
var todoLists = worker.GetItems_TestingOnly(documentId);
var expectedLists = document.SelectedSpans;
Assert.Equal(todoLists.Length, expectedLists.Count);
for (int i = 0; i < todoLists.Length; i++)
{
var todo = todoLists[i];
var span = expectedLists[i];
var line = document.InitialTextSnapshot.GetLineFromPosition(span.Start);
var text = document.InitialTextSnapshot.GetText(span.ToSpan());
Assert.Equal(todo.MappedLine, line.LineNumber);
Assert.Equal(todo.MappedColumn, span.Start - line.Start);
Assert.Equal(todo.Message, text);
}
}
}
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:32,代码来源:TodoCommentTests.cs
示例19: EnqueueEvent
private void EnqueueEvent(Solution solution, DocumentId documentId, InvocationReasons invocationReasons, IAsyncToken asyncToken)
{
_eventProcessingQueue.ScheduleTask(
() => EnqueueWorkItemForDocumentAsync(solution, documentId, invocationReasons), _shutdownToken).CompletesAsyncOperation(asyncToken);
}
开发者ID:GloryChou,项目名称:roslyn,代码行数:5,代码来源:WorkCoordinator.cs
示例20: LogWorkItemEnqueue
public static void LogWorkItemEnqueue(
LogAggregator logAggregator, string language, DocumentId documentId, InvocationReasons reasons, bool lowPriority, SyntaxPath activeMember, bool added)
{
logAggregator.IncreaseCount(language);
logAggregator.IncreaseCount(added ? NewWorkItem : UpdateWorkItem);
if (documentId != null)
{
logAggregator.IncreaseCount(activeMember == null ? TopLevel : MemberLevel);
if (lowPriority)
{
logAggregator.IncreaseCount(LowerPriority);
logAggregator.IncreaseCount(ValueTuple.Create(LowerPriority, documentId.Id));
}
}
foreach (var reason in reasons)
{
logAggregator.IncreaseCount(reason);
}
}
开发者ID:daking2014,项目名称:roslyn,代码行数:22,代码来源:SolutionCrawlerLogger.cs
注:本文中的Microsoft.CodeAnalysis.SolutionCrawler.InvocationReasons类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论