mirror of
https://github.com/Tyrrrz/CliFx.git
synced 2025-10-25 15:19:17 +00:00
Extract duplicated code in analyzers
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
using CliFx.Analyzers.ObjectModel;
|
||||
using CliFx.Analyzers.Utils.Extensions;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using Microsoft.CodeAnalysis.Diagnostics;
|
||||
|
||||
@@ -18,15 +17,11 @@ namespace CliFx.Analyzers
|
||||
{
|
||||
}
|
||||
|
||||
private void Analyze(SyntaxNodeAnalysisContext context)
|
||||
private void Analyze(
|
||||
SyntaxNodeAnalysisContext context,
|
||||
ClassDeclarationSyntax classDeclaration,
|
||||
ITypeSymbol type)
|
||||
{
|
||||
if (context.Node is not ClassDeclarationSyntax classDeclaration)
|
||||
return;
|
||||
|
||||
var type = context.SemanticModel.GetDeclaredSymbol(classDeclaration);
|
||||
if (type is null)
|
||||
return;
|
||||
|
||||
var hasCommandAttribute = type
|
||||
.GetAttributes()
|
||||
.Select(a => a.AttributeClass)
|
||||
@@ -47,7 +42,7 @@ namespace CliFx.Analyzers
|
||||
public override void Initialize(AnalysisContext context)
|
||||
{
|
||||
base.Initialize(context);
|
||||
context.RegisterSyntaxNodeAction(Analyze, SyntaxKind.ClassDeclaration);
|
||||
context.HandleClassDeclaration(Analyze);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user