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:
@@ -1,7 +1,7 @@
|
||||
using System.Linq;
|
||||
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;
|
||||
|
||||
@@ -17,15 +17,11 @@ namespace CliFx.Analyzers
|
||||
{
|
||||
}
|
||||
|
||||
private void Analyze(SyntaxNodeAnalysisContext context)
|
||||
private void Analyze(
|
||||
SyntaxNodeAnalysisContext context,
|
||||
PropertyDeclarationSyntax propertyDeclaration,
|
||||
IPropertySymbol property)
|
||||
{
|
||||
if (context.Node is not PropertyDeclarationSyntax propertyDeclaration)
|
||||
return;
|
||||
|
||||
var property = context.SemanticModel.GetDeclaredSymbol(propertyDeclaration);
|
||||
if (property is null)
|
||||
return;
|
||||
|
||||
var parameter = CommandParameterSymbol.TryResolve(property);
|
||||
if (parameter is null)
|
||||
return;
|
||||
@@ -53,7 +49,7 @@ namespace CliFx.Analyzers
|
||||
public override void Initialize(AnalysisContext context)
|
||||
{
|
||||
base.Initialize(context);
|
||||
context.RegisterSyntaxNodeAction(Analyze, SyntaxKind.PropertyDeclaration);
|
||||
context.HandlePropertyDeclaration(Analyze);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user