Skip to content

Commit 18be681

Browse files
committed
Perform initial abstraction of visitors to a base class
1 parent ef6f35a commit 18be681

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/PowerShellEditorServices/Services/TextDocument/RenameService.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,14 +283,18 @@ private async Task<RenameServiceOptions> GetScopedSettings(DocumentUri uri, Canc
283283
}
284284
}
285285

286+
internal abstract class RenameVisitorBase() : AstVisitor
287+
{
288+
internal List<TextEdit> Edits { get; } = new();
289+
}
290+
286291
/// <summary>
287292
/// A visitor that generates a list of TextEdits to a TextDocument to rename a PowerShell function
288293
/// You should use a new instance for each rename operation.
289294
/// Skipverify can be used as a performance optimization when you are sure you are in scope.
290295
/// </summary>
291-
internal class RenameFunctionVisitor(Ast target, string newName, bool skipVerify = false) : AstVisitor
296+
internal class RenameFunctionVisitor(Ast target, string newName, bool skipVerify = false) : RenameVisitorBase
292297
{
293-
internal List<TextEdit> Edits { get; } = new();
294298
private Ast? CurrentDocument;
295299
private FunctionDefinitionAst? FunctionToRename;
296300

@@ -399,12 +403,11 @@ internal TextEdit[] VisitAndGetEdits(Ast ast)
399403
}
400404

401405
#nullable disable
402-
internal class RenameVariableVisitor : AstVisitor
406+
internal class RenameVariableVisitor : RenameVisitorBase
403407
{
404408
private readonly string OldName;
405409
private readonly string NewName;
406410
internal bool ShouldRename;
407-
internal List<TextEdit> Edits = [];
408411
internal int StartLineNumber;
409412
internal int StartColumnNumber;
410413
internal VariableExpressionAst TargetVariableAst;

0 commit comments

Comments
 (0)