Skip to content

Commit 70820fc

Browse files
committed
Add regions
1 parent fb38a30 commit 70820fc

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

Flow.Launcher.Localization.Analyzers/Localize/ContextAvailabilityAnalyzerCodeFixProvider.cs

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ namespace Flow.Launcher.Localization.Analyzers.Localize
1717
[ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(ContextAvailabilityAnalyzerCodeFixProvider)), Shared]
1818
public class ContextAvailabilityAnalyzerCodeFixProvider : CodeFixProvider
1919
{
20+
#region CodeFixProvider
21+
2022
public sealed override ImmutableArray<string> FixableDiagnosticIds => ImmutableArray.Create(
2123
AnalyzerDiagnostics.ContextIsAField.Id,
2224
AnalyzerDiagnostics.ContextIsNotStatic.Id,
@@ -82,21 +84,9 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
8284
}
8385
}
8486

85-
private static MemberDeclarationSyntax GetStaticContextPropertyDeclaration(string propertyName = "Context") =>
86-
SyntaxFactory.ParseMemberDeclaration(
87-
$"internal static {Constants.PluginContextTypeName} {propertyName} {{ get; private set; }} = null!;"
88-
);
87+
#endregion
8988

90-
private static Document GetFormattedDocument(CodeFixContext context, SyntaxNode root)
91-
{
92-
var formattedRoot = Formatter.Format(
93-
root,
94-
Formatter.Annotation,
95-
context.Document.Project.Solution.Workspace
96-
);
97-
98-
return context.Document.WithSyntaxRoot(formattedRoot);
99-
}
89+
#region Fix Methods
10090

10191
private static Document FixContextNotDeclared(CodeFixContext context, SyntaxNode root, TextSpan diagnosticSpan)
10292
{
@@ -160,6 +150,24 @@ private static Document FixContextIsAFieldError(CodeFixContext context, SyntaxNo
160150
return GetFormattedDocument(context, newRoot);
161151
}
162152

153+
#region Utils
154+
155+
private static MemberDeclarationSyntax GetStaticContextPropertyDeclaration(string propertyName = "Context") =>
156+
SyntaxFactory.ParseMemberDeclaration(
157+
$"internal static {Constants.PluginContextTypeName} {propertyName} {{ get; private set; }} = null!;"
158+
);
159+
160+
private static Document GetFormattedDocument(CodeFixContext context, SyntaxNode root)
161+
{
162+
var formattedRoot = Formatter.Format(
163+
root,
164+
Formatter.Annotation,
165+
context.Document.Project.Solution.Workspace
166+
);
167+
168+
return context.Document.WithSyntaxRoot(formattedRoot);
169+
}
170+
163171
private static PropertyDeclarationSyntax FixRestrictivePropertyModifiers(PropertyDeclarationSyntax propertyDeclaration)
164172
{
165173
var newModifiers = SyntaxFactory.TokenList();
@@ -185,5 +193,9 @@ private static T GetDeclarationSyntax<T>(SyntaxNode root, TextSpan diagnosticSpa
185193
?.AncestorsAndSelf()
186194
.OfType<T>()
187195
.First();
196+
197+
#endregion
198+
199+
#endregion
188200
}
189201
}

0 commit comments

Comments
 (0)