11using System . Collections . Immutable ;
22using System . Linq ;
3+ using Flow . Launcher . Localization . Shared ;
34using Microsoft . CodeAnalysis ;
45using Microsoft . CodeAnalysis . CSharp ;
56using Microsoft . CodeAnalysis . CSharp . Syntax ;
@@ -10,14 +11,9 @@ namespace Flow.Launcher.Localization.Analyzers.Localize
1011 [ DiagnosticAnalyzer ( LanguageNames . CSharp ) ]
1112 public class OldGetTranslateAnalyzer : DiagnosticAnalyzer
1213 {
13- public override ImmutableArray < DiagnosticDescriptor > SupportedDiagnostics =>
14- ImmutableArray . Create ( AnalyzerDiagnostics . OldLocalizationApiUsed ) ;
15-
16- private static readonly string [ ] oldLocalizationClasses = { "IPublicAPI" , "Internationalization" } ;
17- private const string OldLocalizationMethodName = "GetTranslation" ;
18-
19- private const string StringFormatMethodName = "Format" ;
20- private const string StringFormatTypeName = "string" ;
14+ public override ImmutableArray < DiagnosticDescriptor > SupportedDiagnostics => ImmutableArray . Create (
15+ AnalyzerDiagnostics . OldLocalizationApiUsed
16+ ) ;
2117
2218 public override void Initialize ( AnalysisContext context )
2319 {
@@ -75,20 +71,20 @@ private static bool IsFormatStringCall(SymbolInfo? symbolInfo) =>
7571 symbolInfo is SymbolInfo info && IsFormatStringCall ( info . Symbol as IMethodSymbol ) ;
7672
7773 private static bool IsFormatStringCall ( IMethodSymbol methodSymbol ) =>
78- methodSymbol ? . Name is StringFormatMethodName &&
79- methodSymbol . ContainingType . ToDisplayString ( ) is StringFormatTypeName ;
74+ methodSymbol ? . Name is Constants . StringFormatMethodName &&
75+ methodSymbol . ContainingType . ToDisplayString ( ) is Constants . StringFormatTypeName ;
8076
8177 private static InvocationExpressionSyntax GetFirstArgumentInvocationExpression ( InvocationExpressionSyntax invocationExpr ) =>
8278 invocationExpr . ArgumentList . Arguments . FirstOrDefault ( ) ? . Expression as InvocationExpressionSyntax ;
8379
8480 private static bool IsTranslateCall ( SymbolInfo symbolInfo ) =>
8581 symbolInfo . Symbol is IMethodSymbol innerMethodSymbol &&
86- innerMethodSymbol . Name is OldLocalizationMethodName &&
87- oldLocalizationClasses . Contains ( innerMethodSymbol . ContainingType . Name ) ;
82+ innerMethodSymbol . Name is Constants . OldLocalizationMethodName &&
83+ Constants . OldLocalizationClasses . Contains ( innerMethodSymbol . ContainingType . Name ) ;
8884
8985 private static bool IsTranslateCall ( IMethodSymbol methodSymbol ) =>
90- methodSymbol ? . Name is OldLocalizationMethodName &&
91- oldLocalizationClasses . Contains ( methodSymbol . ContainingType . Name ) ;
86+ methodSymbol ? . Name is Constants . OldLocalizationMethodName &&
87+ Constants . OldLocalizationClasses . Contains ( methodSymbol . ContainingType . Name ) ;
9288
9389 private static string GetFirstArgumentStringValue ( InvocationExpressionSyntax invocationExpr )
9490 {
0 commit comments