當前位置: 首頁>>代碼示例>>C#>>正文


C# SolutionCrawler.InvocationReasons類代碼示例

本文整理匯總了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;
                        }
                    }
                }
            }
開發者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


注:本文中的Microsoft.CodeAnalysis.SolutionCrawler.InvocationReasons類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。