Skip to content

Commit 0324cb0

Browse files
committed
Actually fix tests (missing some pattern matching on AST types)
1 parent b3f8a7c commit 0324cb0

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/PowerShellEditorServices/Services/TextDocument/RenameService.cs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,14 @@ private async Task<RenameServiceOptions> GetScopedSettings(DocumentUri uri, Canc
9797
// TODO: Potentially future cross-file support
9898
TextEdit[] changes = tokenToRename switch
9999
{
100-
FunctionDefinitionAst or CommandAst => RenameFunction(tokenToRename, scriptFile.ScriptAst, request),
101-
VariableExpressionAst => RenameVariable(tokenToRename, scriptFile.ScriptAst, request, options.createVariableAlias),
102-
// FIXME: Only throw if capability is not prepareprovider
100+
FunctionDefinitionAst
101+
or CommandAst => RenameFunction(tokenToRename, scriptFile.ScriptAst, request),
102+
103+
VariableExpressionAst
104+
or ParameterAst
105+
or CommandParameterAst
106+
or AssignmentStatementAst => RenameVariable(tokenToRename, scriptFile.ScriptAst, request, options.createVariableAlias),
107+
103108
_ => throw new InvalidOperationException("This should not happen as PrepareRename should have already checked for viability. File an issue if you see this.")
104109
};
105110

@@ -150,10 +155,15 @@ internal static TextEdit[] RenameVariable(Ast symbol, Ast scriptAst, RenameParam
150155
{
151156
Ast? ast = scriptFile.ScriptAst.FindAtPosition(position,
152157
[
153-
// Filters just the ASTs that are candidates for rename
158+
// Functions
154159
typeof(FunctionDefinitionAst),
160+
typeof(CommandAst),
161+
162+
// Variables
155163
typeof(VariableExpressionAst),
156-
typeof(CommandAst)
164+
typeof(ParameterAst),
165+
typeof(CommandParameterAst),
166+
typeof(AssignmentStatementAst),
157167
]);
158168

159169
// Only the function name is valid for rename, not other components

0 commit comments

Comments
 (0)