Skip to content

Commit 1bc41ec

Browse files
pavel-mikula-sonarsourcesonartech
authored andcommitted
NET-1034 AnalysisContext: Cleanup SonarAnalysisContext
1 parent 08e8ad7 commit 1bc41ec

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

analyzers/src/SonarAnalyzer.Core/AnalysisContext/SonarAnalysisContext.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ namespace SonarAnalyzer.Core.AnalysisContext;
2121

2222
public class SonarAnalysisContext
2323
{
24-
internal ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }
25-
2624
private readonly RoslynAnalysisContext analysisContext;
2725

2826
/// <summary>
@@ -54,6 +52,8 @@ public class SonarAnalysisContext
5452
/// </remarks>
5553
public static Action<IReportingContext> ReportDiagnostic { get; set; }
5654

55+
internal ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }
56+
5757
internal SonarAnalysisContext(RoslynAnalysisContext analysisContext, ImmutableArray<DiagnosticDescriptor> supportedDiagnostics)
5858
{
5959
this.analysisContext = analysisContext ?? throw new ArgumentNullException(nameof(analysisContext));
@@ -65,18 +65,6 @@ private protected SonarAnalysisContext(SonarAnalysisContext context) : this(cont
6565
public bool TryGetValue<TValue>(SourceText text, SourceTextValueProvider<TValue> valueProvider, out TValue value) =>
6666
analysisContext.TryGetValue(text, valueProvider, out value);
6767

68-
/// <summary>
69-
/// Legacy API for backward compatibility with SonarLint v4.0 - v5.5. See <see cref="ShouldExecuteRegisteredAction"/>.
70-
/// </summary>
71-
internal static bool LegacyIsRegisteredActionEnabled(IEnumerable<DiagnosticDescriptor> diagnostics, SyntaxTree tree) =>
72-
ShouldExecuteRegisteredAction == null || tree == null || ShouldExecuteRegisteredAction(diagnostics, tree);
73-
74-
/// <summary>
75-
/// Legacy API for backward compatibility with SonarLint v4.0 - v5.5. See <see cref="ShouldExecuteRegisteredAction"/>.
76-
/// </summary>
77-
internal static bool LegacyIsRegisteredActionEnabled(DiagnosticDescriptor diagnostic, SyntaxTree tree) =>
78-
ShouldExecuteRegisteredAction == null || tree == null || ShouldExecuteRegisteredAction(new[] { diagnostic }, tree);
79-
8068
public void RegisterCodeBlockStartAction<TSyntaxKind>(GeneratedCodeRecognizer generatedCodeRecognizer, Action<SonarCodeBlockStartAnalysisContext<TSyntaxKind>> action)
8169
where TSyntaxKind : struct =>
8270
RegisterCompilationStartAction(
@@ -115,7 +103,19 @@ public void RegisterTreeAction(GeneratedCodeRecognizer generatedCodeRecognizer,
115103
/// This should NOT be used for actions that report issues.
116104
/// </summary>
117105
public void RegisterNodeActionInAllFiles<TSyntaxKind>(Action<SonarSyntaxNodeReportingContext> action, params TSyntaxKind[] syntaxKinds) where TSyntaxKind : struct =>
118-
analysisContext.RegisterSyntaxNodeAction(c => action(new(this, c)), syntaxKinds);
106+
analysisContext.RegisterSyntaxNodeAction(x => action(new(this, x)), syntaxKinds);
107+
108+
/// <summary>
109+
/// Legacy API for backward compatibility with SonarLint v4.0 - v5.5. See <see cref="ShouldExecuteRegisteredAction"/>.
110+
/// </summary>
111+
internal static bool LegacyIsRegisteredActionEnabled(IEnumerable<DiagnosticDescriptor> diagnostics, SyntaxTree tree) =>
112+
ShouldExecuteRegisteredAction is null || tree is null || ShouldExecuteRegisteredAction(diagnostics, tree);
113+
114+
/// <summary>
115+
/// Legacy API for backward compatibility with SonarLint v4.0 - v5.5. See <see cref="ShouldExecuteRegisteredAction"/>.
116+
/// </summary>
117+
internal static bool LegacyIsRegisteredActionEnabled(DiagnosticDescriptor diagnostic, SyntaxTree tree) =>
118+
ShouldExecuteRegisteredAction is null || tree is null || ShouldExecuteRegisteredAction(new[] { diagnostic }, tree);
119119

120120
private void Execute<TSonarContext>(TSonarContext context, Action<TSonarContext> action)
121121
where TSonarContext : IAnalysisContext

0 commit comments

Comments
 (0)