1
1
using System . Collections . Immutable ;
2
2
using System . Linq ;
3
+ using Flow . Launcher . Localization . Shared ;
3
4
using Microsoft . CodeAnalysis ;
4
5
using Microsoft . CodeAnalysis . CSharp ;
5
6
using Microsoft . CodeAnalysis . CSharp . Syntax ;
@@ -10,14 +11,9 @@ namespace Flow.Launcher.Localization.Analyzers.Localize
10
11
[ DiagnosticAnalyzer ( LanguageNames . CSharp ) ]
11
12
public class OldGetTranslateAnalyzer : DiagnosticAnalyzer
12
13
{
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
+ ) ;
21
17
22
18
public override void Initialize ( AnalysisContext context )
23
19
{
@@ -75,20 +71,20 @@ private static bool IsFormatStringCall(SymbolInfo? symbolInfo) =>
75
71
symbolInfo is SymbolInfo info && IsFormatStringCall ( info . Symbol as IMethodSymbol ) ;
76
72
77
73
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 ;
80
76
81
77
private static InvocationExpressionSyntax GetFirstArgumentInvocationExpression ( InvocationExpressionSyntax invocationExpr ) =>
82
78
invocationExpr . ArgumentList . Arguments . FirstOrDefault ( ) ? . Expression as InvocationExpressionSyntax ;
83
79
84
80
private static bool IsTranslateCall ( SymbolInfo symbolInfo ) =>
85
81
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 ) ;
88
84
89
85
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 ) ;
92
88
93
89
private static string GetFirstArgumentStringValue ( InvocationExpressionSyntax invocationExpr )
94
90
{
0 commit comments