Пример #1
0
        public static void UpdateAnalyzerTypeCount(DiagnosticAnalyzer analyzer, ActionCounts analyzerActions, Project projectOpt, DiagnosticLogAggregator logAggregator)
        {
            if (analyzerActions == null || analyzer == null || logAggregator == null)
            {
                return;
            }

            logAggregator.UpdateAnalyzerTypeCount(analyzer, analyzerActions, projectOpt);
        }
Пример #2
0
 public void SetAnalyzerTypeCount(ActionCounts analyzerActions)
 {
     Counts[0] = analyzerActions.CodeBlockActionsCount;
     Counts[1] = analyzerActions.CodeBlockEndActionsCount;
     Counts[2] = analyzerActions.CodeBlockStartActionsCount;
     Counts[3] = analyzerActions.CompilationActionsCount;
     Counts[4] = analyzerActions.CompilationEndActionsCount;
     Counts[5] = analyzerActions.CompilationStartActionsCount;
     Counts[6] = analyzerActions.SemanticModelActionsCount;
     Counts[7] = analyzerActions.SymbolActionsCount;
     Counts[8] = analyzerActions.SyntaxNodeActionsCount;
     Counts[9] = analyzerActions.SyntaxTreeActionsCount;
 }
Пример #3
0
 public void SetAnalyzerTypeCount(ActionCounts analyzerActions)
 {
     Counts[0] = analyzerActions.CodeBlockActionsCount;
     Counts[1] = analyzerActions.CodeBlockEndActionsCount;
     Counts[2] = analyzerActions.CodeBlockStartActionsCount;
     Counts[3] = analyzerActions.CompilationActionsCount;
     Counts[4] = analyzerActions.CompilationEndActionsCount;
     Counts[5] = analyzerActions.CompilationStartActionsCount;
     Counts[6] = analyzerActions.SemanticModelActionsCount;
     Counts[7] = analyzerActions.SymbolActionsCount;
     Counts[8] = analyzerActions.SyntaxNodeActionsCount;
     Counts[9] = analyzerActions.SyntaxTreeActionsCount;
 }
Пример #4
0
        public void UpdateAnalyzerTypeCount(DiagnosticAnalyzer analyzer, ActionCounts analyzerActions, Project projectOpt)
        {
            var telemetry = DiagnosticAnalyzerLogger.AllowsTelemetry(_owner, analyzer, projectOpt?.Id);

            ImmutableInterlocked.AddOrUpdate(
                ref _analyzerInfoMap,
                analyzer.GetType(),
                addValue: new AnalyzerInfo(analyzer, analyzerActions, telemetry),
                updateValueFactory: (k, ai) =>
                {
                    ai.SetAnalyzerTypeCount(analyzerActions);
                    return ai;
                });
        }
Пример #5
0
        public void UpdateAnalyzerTypeCount(DiagnosticAnalyzer analyzer, ActionCounts analyzerActions, Project projectOpt)
        {
            var telemetry = DiagnosticAnalyzerLogger.AllowsTelemetry(_owner, analyzer, projectOpt?.Id);

            ImmutableInterlocked.AddOrUpdate(
                ref _analyzerInfoMap,
                analyzer.GetType(),
                addValue: new AnalyzerInfo(analyzer, analyzerActions, telemetry),
                updateValueFactory: (k, ai) =>
            {
                ai.SetAnalyzerTypeCount(analyzerActions);
                return(ai);
            });
        }
Пример #6
0
            public AnalyzerInfo(DiagnosticAnalyzer analyzer, ActionCounts analyzerActions, bool telemetry)
            {
                CLRType = analyzer.GetType();
                Telemetry = telemetry;

                Counts[0] = analyzerActions.CodeBlockActionsCount;
                Counts[1] = analyzerActions.CodeBlockEndActionsCount;
                Counts[2] = analyzerActions.CodeBlockStartActionsCount;
                Counts[3] = analyzerActions.CompilationActionsCount;
                Counts[4] = analyzerActions.CompilationEndActionsCount;
                Counts[5] = analyzerActions.CompilationStartActionsCount;
                Counts[6] = analyzerActions.SemanticModelActionsCount;
                Counts[7] = analyzerActions.SymbolActionsCount;
                Counts[8] = analyzerActions.SyntaxNodeActionsCount;
                Counts[9] = analyzerActions.SyntaxTreeActionsCount;
            }
Пример #7
0
            public AnalyzerInfo(DiagnosticAnalyzer analyzer, ActionCounts analyzerActions, bool telemetry)
            {
                CLRType   = analyzer.GetType();
                Telemetry = telemetry;

                Counts[0] = analyzerActions.CodeBlockActionsCount;
                Counts[1] = analyzerActions.CodeBlockEndActionsCount;
                Counts[2] = analyzerActions.CodeBlockStartActionsCount;
                Counts[3] = analyzerActions.CompilationActionsCount;
                Counts[4] = analyzerActions.CompilationEndActionsCount;
                Counts[5] = analyzerActions.CompilationStartActionsCount;
                Counts[6] = analyzerActions.SemanticModelActionsCount;
                Counts[7] = analyzerActions.SymbolActionsCount;
                Counts[8] = analyzerActions.SyntaxNodeActionsCount;
                Counts[9] = analyzerActions.SyntaxTreeActionsCount;
            }
Пример #8
0
 private static bool HasActionsForEvent(CompilationEvent compilationEvent, ActionCounts actionCounts)
 {
     if (compilationEvent is CompilationStartedEvent)
     {
         return(actionCounts.CompilationActionsCount > 0 ||
                actionCounts.SyntaxTreeActionsCount > 0);
     }
     else if (compilationEvent is CompilationCompletedEvent)
     {
         return(actionCounts.CompilationEndActionsCount > 0);
     }
     else if (compilationEvent is SymbolDeclaredCompilationEvent)
     {
         return(actionCounts.CodeBlockActionsCount > 0 ||
                actionCounts.CodeBlockStartActionsCount > 0 ||
                actionCounts.SymbolActionsCount > 0 ||
                actionCounts.SyntaxNodeActionsCount > 0);
     }
     else
     {
         return(actionCounts.SemanticModelActionsCount > 0);
     }
 }
Пример #9
0
 private static bool HasActionsForEvent(CompilationEvent compilationEvent, ActionCounts actionCounts)
 {
     if (compilationEvent is CompilationStartedEvent)
     {
         return actionCounts.CompilationActionsCount > 0 ||
             actionCounts.SyntaxTreeActionsCount > 0;
     }
     else if (compilationEvent is CompilationCompletedEvent)
     {
         return actionCounts.CompilationEndActionsCount > 0;
     }
     else if (compilationEvent is SymbolDeclaredCompilationEvent)
     {
         return actionCounts.CodeBlockActionsCount > 0 ||
             actionCounts.CodeBlockStartActionsCount > 0 ||
             actionCounts.SymbolActionsCount > 0 ||
             actionCounts.SyntaxNodeActionsCount > 0;
     }
     else
     {
         return actionCounts.SemanticModelActionsCount > 0;
     }
 }
            public void OnCompilationEventGenerated(CompilationEvent compilationEvent, ActionCounts actionCounts)
            {
                lock (_gate)
                {
                    var symbolEvent = compilationEvent as SymbolDeclaredCompilationEvent;
                    if (symbolEvent != null)
                    {
                        var needsAnalysis = false;
                        var symbol        = symbolEvent.Symbol;
                        if (!AnalysisScope.ShouldSkipSymbolAnalysis(symbolEvent) && actionCounts.SymbolActionsCount > 0)
                        {
                            needsAnalysis           = true;
                            _pendingSymbols[symbol] = null;
                        }

                        if (!AnalysisScope.ShouldSkipDeclarationAnalysis(symbol) &&
                            (actionCounts.SyntaxNodeActionsCount > 0 ||
                             actionCounts.CodeBlockActionsCount > 0 ||
                             actionCounts.CodeBlockStartActionsCount > 0))
                        {
                            foreach (var syntaxRef in symbolEvent.DeclaringSyntaxReferences)
                            {
                                needsAnalysis = true;
                                _pendingDeclarations[syntaxRef.GetSyntax()] = null;
                            }
                        }

                        if (!needsAnalysis)
                        {
                            return;
                        }
                    }
                    else if (compilationEvent is CompilationStartedEvent)
                    {
                        if (actionCounts.SyntaxTreeActionsCount > 0)
                        {
                            var trees = compilationEvent.Compilation.SyntaxTrees;
                            var map   = new Dictionary <SyntaxTree, AnalyzerStateData>(trees.Count());
                            foreach (var tree in trees)
                            {
                                map[tree] = null;
                            }

                            _lazyPendingSyntaxAnalysisTrees = map;
                        }

                        if (actionCounts.CompilationActionsCount == 0)
                        {
                            return;
                        }
                    }

                    _pendingEvents[compilationEvent] = null;
                }
            }
Пример #11
0
        public static void UpdateAnalyzerTypeCount(DiagnosticAnalyzer analyzer, ActionCounts analyzerActions, Project projectOpt, DiagnosticLogAggregator logAggregator)
        {
            if (analyzerActions == null || analyzer == null || logAggregator == null)
            {
                return;
            }

            logAggregator.UpdateAnalyzerTypeCount(analyzer, analyzerActions, projectOpt);
        }