Skip to content

Commit 2143656

Browse files
committed
Move all the IDE (Features layer) analyzer to the new options and code style API
1 parent e182acd commit 2143656

File tree

47 files changed

+129
-126
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+129
-126
lines changed

src/Features/CSharp/Portable/AddAccessibilityModifiers/CSharpAddAccessibilityModifiersDiagnosticAnalyzer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ public CSharpAddAccessibilityModifiersDiagnosticAnalyzer()
2222

2323
protected override void ProcessCompilationUnit(
2424
SyntaxTreeAnalysisContext context, SyntaxGenerator generator,
25-
CodeStyleOption<AccessibilityModifiersRequired> option, CompilationUnitSyntax compilationUnit)
25+
CodeStyleOption2<AccessibilityModifiersRequired> option, CompilationUnitSyntax compilationUnit)
2626
{
2727
ProcessMembers(context, generator, option, compilationUnit.Members);
2828
}
2929

3030
private void ProcessMembers(
3131
SyntaxTreeAnalysisContext context, SyntaxGenerator generator,
32-
CodeStyleOption<AccessibilityModifiersRequired> option,
32+
CodeStyleOption2<AccessibilityModifiersRequired> option,
3333
SyntaxList<MemberDeclarationSyntax> members)
3434
{
3535
foreach (var memberDeclaration in members)
@@ -40,7 +40,7 @@ private void ProcessMembers(
4040

4141
private void ProcessMemberDeclaration(
4242
SyntaxTreeAnalysisContext context, SyntaxGenerator generator,
43-
CodeStyleOption<AccessibilityModifiersRequired> option, MemberDeclarationSyntax member)
43+
CodeStyleOption2<AccessibilityModifiersRequired> option, MemberDeclarationSyntax member)
4444
{
4545
if (member.IsKind(SyntaxKind.NamespaceDeclaration, out NamespaceDeclarationSyntax namespaceDeclaration))
4646
{

src/Features/CSharp/Portable/Diagnostics/Analyzers/CSharpSimplifyTypeNamesDiagnosticAnalyzer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,12 @@ internal override bool CanSimplifyTypeNameExpression(
124124
}
125125

126126
// set proper diagnostic ids.
127-
if (replacementSyntax.HasAnnotations(nameof(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration)))
127+
if (replacementSyntax.HasAnnotations(nameof(CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInDeclaration)))
128128
{
129129
inDeclaration = true;
130130
diagnosticId = IDEDiagnosticIds.PreferBuiltInOrFrameworkTypeDiagnosticId;
131131
}
132-
else if (replacementSyntax.HasAnnotations(nameof(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess)))
132+
else if (replacementSyntax.HasAnnotations(nameof(CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInMemberAccess)))
133133
{
134134
inDeclaration = false;
135135
diagnosticId = IDEDiagnosticIds.PreferBuiltInOrFrameworkTypeDiagnosticId;

src/Features/CSharp/Portable/MisplacedUsingDirectives/MisplacedUsingDirectivesDiagnosticAnalyzer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ private static bool ShouldSuppressDiagnostic(CompilationUnitSyntax compilationUn
8989

9090
private static void ReportDiagnostics(
9191
SyntaxNodeAnalysisContext context, DiagnosticDescriptor descriptor,
92-
IEnumerable<UsingDirectiveSyntax> usingDirectives, CodeStyleOption<AddImportPlacement> option)
92+
IEnumerable<UsingDirectiveSyntax> usingDirectives, CodeStyleOption2<AddImportPlacement> option)
9393
{
9494
foreach (var usingDirective in usingDirectives)
9595
{

src/Features/CSharp/Portable/UseExpressionBody/Helpers/UseExpressionBodyHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.CSharp.UseExpressionBody
1111
{
1212
internal abstract class UseExpressionBodyHelper
1313
{
14-
public abstract Option<CodeStyleOption<ExpressionBodyPreference>> Option { get; }
14+
public abstract Option2<CodeStyleOption2<ExpressionBodyPreference>> Option { get; }
1515
public abstract LocalizableString UseExpressionBodyTitle { get; }
1616
public abstract LocalizableString UseBlockBodyTitle { get; }
1717
public abstract string DiagnosticId { get; }

src/Features/CSharp/Portable/UseExpressionBody/Helpers/UseExpressionBodyHelper`1.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace Microsoft.CodeAnalysis.CSharp.UseExpressionBody
2222
internal abstract class UseExpressionBodyHelper<TDeclaration> : UseExpressionBodyHelper
2323
where TDeclaration : SyntaxNode
2424
{
25-
public override Option<CodeStyleOption<ExpressionBodyPreference>> Option { get; }
25+
public override Option2<CodeStyleOption2<ExpressionBodyPreference>> Option { get; }
2626
public override LocalizableString UseExpressionBodyTitle { get; }
2727
public override LocalizableString UseBlockBodyTitle { get; }
2828
public override string DiagnosticId { get; }
@@ -32,7 +32,7 @@ protected UseExpressionBodyHelper(
3232
string diagnosticId,
3333
LocalizableString useExpressionBodyTitle,
3434
LocalizableString useBlockBodyTitle,
35-
Option<CodeStyleOption<ExpressionBodyPreference>> option,
35+
Option2<CodeStyleOption2<ExpressionBodyPreference>> option,
3636
ImmutableArray<SyntaxKind> syntaxKinds)
3737
{
3838
DiagnosticId = diagnosticId;
@@ -55,7 +55,6 @@ protected static AccessorDeclarationSyntax GetSingleGetAccessor(AccessorListSynt
5555
return null;
5656
}
5757

58-
5958
protected static BlockSyntax GetBodyFromSingleGetAccessor(AccessorListSyntax accessorList)
6059
=> GetSingleGetAccessor(accessorList)?.Body;
6160

src/Features/CSharp/Portable/UseExpressionBodyForLambda/UseExpressionBodyForLambdaCodeStyleProvider_Analysis.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ protected override void DiagnosticAnalyzerInitialize(AnalysisContext context)
2222
protected override DiagnosticAnalyzerCategory GetAnalyzerCategory()
2323
=> DiagnosticAnalyzerCategory.SemanticSpanAnalysis;
2424

25-
private void AnalyzeSyntax(SyntaxNodeAnalysisContext context, CodeStyleOption<ExpressionBodyPreference> option)
25+
private void AnalyzeSyntax(SyntaxNodeAnalysisContext context, CodeStyleOption2<ExpressionBodyPreference> option)
2626
{
2727
var declaration = (LambdaExpressionSyntax)context.Node;
2828
var diagnostic = AnalyzeSyntax(context.SemanticModel, option, declaration, context.CancellationToken);
@@ -33,7 +33,7 @@ private void AnalyzeSyntax(SyntaxNodeAnalysisContext context, CodeStyleOption<Ex
3333
}
3434

3535
private Diagnostic AnalyzeSyntax(
36-
SemanticModel semanticModel, CodeStyleOption<ExpressionBodyPreference> option,
36+
SemanticModel semanticModel, CodeStyleOption2<ExpressionBodyPreference> option,
3737
LambdaExpressionSyntax declaration, CancellationToken cancellationToken)
3838
{
3939
if (CanOfferUseExpressionBody(option.Value, declaration))

src/Features/CSharp/Portable/UseIndexOrRangeOperator/CSharpUseRangeOperatorDiagnosticAnalyzer.Result.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public enum ResultKind
2222
public readonly struct Result
2323
{
2424
public readonly ResultKind Kind;
25-
public readonly CodeStyleOption<bool> Option;
25+
public readonly CodeStyleOption2<bool> Option;
2626
public readonly IInvocationOperation InvocationOperation;
2727
public readonly InvocationExpressionSyntax Invocation;
2828
public readonly IMethodSymbol SliceLikeMethod;
@@ -31,7 +31,7 @@ public readonly struct Result
3131
public readonly IOperation Op2;
3232

3333
public Result(
34-
ResultKind kind, CodeStyleOption<bool> option,
34+
ResultKind kind, CodeStyleOption2<bool> option,
3535
IInvocationOperation invocationOperation, InvocationExpressionSyntax invocation,
3636
IMethodSymbol sliceLikeMethod, MemberInfo memberInfo,
3737
IOperation op1, IOperation op2)

src/Features/CSharp/Portable/UseIndexOrRangeOperator/CSharpUseRangeOperatorDiagnosticAnalyzer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ private void AnalyzeInvocation(
9292
return default;
9393
}
9494

95-
CodeStyleOption<bool> option = null;
95+
CodeStyleOption2<bool> option = null;
9696
if (analyzerOptionsOpt != null)
9797
{
9898
// Check if we're at least on C# 8, and that the user wants these operators.

src/Features/CSharp/Portable/UseInferredMemberName/CSharpUseInferredMemberNameDiagnosticAnalyzer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ private void ReportDiagnosticsIfNeeded(NameColonSyntax nameColon, SyntaxNodeAnal
4545

4646
var parseOptions = (CSharpParseOptions)syntaxTree.Options;
4747
var preference = options.GetOption(
48-
CodeStyleOptions.PreferInferredTupleNames, context.Compilation.Language, syntaxTree, cancellationToken);
48+
CodeStyleOptions2.PreferInferredTupleNames, context.Compilation.Language, syntaxTree, cancellationToken);
4949
if (!preference.Value ||
5050
!CSharpInferredMemberNameReducer.CanSimplifyTupleElementName(argument, parseOptions))
5151
{
@@ -78,7 +78,7 @@ private void ReportDiagnosticsIfNeeded(NameEqualsSyntax nameEquals, SyntaxNodeAn
7878
}
7979

8080
var preference = options.GetOption(
81-
CodeStyleOptions.PreferInferredAnonymousTypeMemberNames, context.Compilation.Language, syntaxTree, cancellationToken);
81+
CodeStyleOptions2.PreferInferredAnonymousTypeMemberNames, context.Compilation.Language, syntaxTree, cancellationToken);
8282
if (!preference.Value ||
8383
!CSharpInferredMemberNameReducer.CanSimplifyAnonymousTypeMemberName(anonCtor))
8484
{

src/Features/CSharp/Portable/UseIsNullCheck/CSharpUseIsNullCheckForCastAndEqualityOperatorDiagnosticAnalyzer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ internal class CSharpUseIsNullCheckForCastAndEqualityOperatorDiagnosticAnalyzer
1919

2020
public CSharpUseIsNullCheckForCastAndEqualityOperatorDiagnosticAnalyzer()
2121
: base(IDEDiagnosticIds.UseIsNullCheckDiagnosticId,
22-
CodeStyleOptions.PreferIsNullCheckOverReferenceEqualityMethod,
22+
CodeStyleOptions2.PreferIsNullCheckOverReferenceEqualityMethod,
2323
CSharpFeaturesResources.Use_is_null_check,
2424
new LocalizableResourceString(nameof(FeaturesResources.Null_check_can_be_simplified), FeaturesResources.ResourceManager, typeof(FeaturesResources)))
2525
{
@@ -43,7 +43,7 @@ private void AnalyzeSyntax(SyntaxNodeAnalysisContext context)
4343
return;
4444
}
4545

46-
var option = context.Options.GetOption(CodeStyleOptions.PreferIsNullCheckOverReferenceEqualityMethod, semanticModel.Language, syntaxTree, cancellationToken);
46+
var option = context.Options.GetOption(CodeStyleOptions2.PreferIsNullCheckOverReferenceEqualityMethod, semanticModel.Language, syntaxTree, cancellationToken);
4747
if (!option.Value)
4848
{
4949
return;

0 commit comments

Comments
 (0)