private bool TryStartSyntaxAnalysis_NoLock(SourceOrAdditionalFile file, [NotNullWhen(returnValue: true)] out AnalyzerStateData?state) { Debug.Assert(_lazyFilesWithAnalysisData != null); if (_pendingSyntaxAnalysisFilesCount == 0) { state = null; return(false); } if (_lazyFilesWithAnalysisData.TryGetValue(file, out state)) { if (state.StateKind != StateKind.ReadyToProcess) { state = null; return(false); } } else { state = _analyzerStateDataPool.Allocate(); } state.SetStateKind(StateKind.InProcess); Debug.Assert(state.StateKind == StateKind.InProcess); _lazyFilesWithAnalysisData[file] = state; return(true); }
public void MarkSyntaxAnalysisComplete(SourceOrAdditionalFile file) { lock (_gate) { MarkSyntaxAnalysisComplete_NoLock(file); } }
private void MarkSyntaxAnalysisComplete_NoLock(SourceOrAdditionalFile file) { if (_pendingSyntaxAnalysisFilesCount == 0) { return; } Debug.Assert(_lazyFilesWithAnalysisData != null); var wasAlreadyFullyProcessed = false; if (_lazyFilesWithAnalysisData.TryGetValue(file, out var state)) { if (state.StateKind != StateKind.FullyProcessed) { FreeState_NoLock(state, _analyzerStateDataPool); } else { wasAlreadyFullyProcessed = true; } } if (!wasAlreadyFullyProcessed) { _pendingSyntaxAnalysisFilesCount--; } _lazyFilesWithAnalysisData[file] = AnalyzerStateData.FullyProcessedInstance; }
/// <summary> /// Marks the given file as fully syntactically analyzed for the given analyzers. /// </summary> public void MarkSyntaxAnalysisComplete(SourceOrAdditionalFile file, IEnumerable <DiagnosticAnalyzer> analyzers) { foreach (var analyzer in analyzers) { GetAnalyzerState(analyzer).MarkSyntaxAnalysisComplete(file); } }
public static AnalyzerDiagnosticReporter GetInstance( SourceOrAdditionalFile contextFile, TextSpan?span, Compilation compilation, DiagnosticAnalyzer analyzer, bool isSyntaxDiagnostic, Action <Diagnostic>?addNonCategorizedDiagnostic, Action <Diagnostic, DiagnosticAnalyzer, bool>?addCategorizedLocalDiagnostic, Action <Diagnostic, DiagnosticAnalyzer>?addCategorizedNonLocalDiagnostic, Func <Diagnostic, DiagnosticAnalyzer, Compilation, CancellationToken, bool> shouldSuppressGeneratedCodeDiagnostic, CancellationToken cancellationToken) { var item = s_objectPool.Allocate(); item._contextFile = contextFile; item._span = span; item._compilation = compilation; item._analyzer = analyzer; item._isSyntaxDiagnostic = isSyntaxDiagnostic; item._addNonCategorizedDiagnostic = addNonCategorizedDiagnostic; item._addCategorizedLocalDiagnostic = addCategorizedLocalDiagnostic; item._addCategorizedNonLocalDiagnostic = addCategorizedNonLocalDiagnostic; item._shouldSuppressGeneratedCodeDiagnostic = shouldSuppressGeneratedCodeDiagnostic; item._cancellationToken = cancellationToken; return(item); }
public AnalysisScope( ImmutableArray <DiagnosticAnalyzer> analyzers, SourceOrAdditionalFile filterFile, TextSpan?filterSpan, bool isSyntacticSingleFileAnalysis, bool concurrentAnalysis, bool categorizeDiagnostics ) : this( filterFile.SourceTree != null ? SpecializedCollections.SingletonEnumerable(filterFile.SourceTree) : SpecializedCollections.EmptyEnumerable <SyntaxTree>(), filterFile.AdditionalFile != null ? SpecializedCollections.SingletonEnumerable(filterFile.AdditionalFile) : SpecializedCollections.EmptyEnumerable <AdditionalText>(), analyzers, isPartialAnalysis : true, filterFile, filterSpan, isSyntacticSingleFileAnalysis, concurrentAnalysis, categorizeDiagnostics ) { }
public bool TryStartSyntaxAnalysis(SourceOrAdditionalFile tree, [NotNullWhen(returnValue: true)] out AnalyzerStateData?state) { lock (_gate) { Debug.Assert(_lazyFilesWithAnalysisData != null); return(TryStartSyntaxAnalysis_NoLock(tree, out state)); } }
public AnalysisContextInfo(Compilation compilation, SourceOrAdditionalFile file) : this(compilation : compilation, operation : null, symbol : null, file : file, node : null) { }
/// <summary> /// Marks the given file as fully syntactically analyzed for the unprocessed analyzers in the given analysisScope. /// </summary> public void MarkSyntaxAnalysisCompleteForUnprocessedAnalyzers( SourceOrAdditionalFile file, AnalysisScope analysisScope, HashSet <DiagnosticAnalyzer> processedAnalyzers) => MarkAnalysisCompleteForUnprocessedAnalyzers(analysisScope, processedAnalyzers, MarkSyntaxAnalysisComplete, file);
/// <summary> /// Marks the given file as fully syntactically analyzed for the given analyzer. /// </summary> public void MarkSyntaxAnalysisComplete(SourceOrAdditionalFile file, DiagnosticAnalyzer analyzer) { GetAnalyzerState(analyzer).MarkSyntaxAnalysisComplete(file); }
/// <summary> /// Attempts to start processing a syntax tree or additional file for the given analyzer's syntax tree or additional file actions respectively. /// </summary> /// <returns> /// Returns false if the file has already been processed for the analyzer OR is currently being processed by another task. /// If true, then it returns a non-null <paramref name="state"/> representing partial syntax analysis state for the given tree for the given analyzer. /// </returns> public bool TryStartSyntaxAnalysis(SourceOrAdditionalFile file, DiagnosticAnalyzer analyzer, out AnalyzerStateData state) { return(GetAnalyzerState(analyzer).TryStartSyntaxAnalysis(file, out state)); }