|
7 | 7 | using System.Management.Automation.Language;
|
8 | 8 | using System.Threading;
|
9 | 9 | using System.Threading.Tasks;
|
10 |
| -using MediatR; |
11 | 10 | using Microsoft.PowerShell.EditorServices.Services;
|
12 | 11 | using Microsoft.PowerShell.EditorServices.Services.TextDocument;
|
13 | 12 | using Microsoft.PowerShell.EditorServices.Refactoring;
|
|
19 | 18 |
|
20 | 19 | namespace Microsoft.PowerShell.EditorServices.Handlers;
|
21 | 20 |
|
22 |
| - |
23 | 21 | /// <summary>
|
24 | 22 | /// A handler for <a href="https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_prepareRename">textDocument/prepareRename</a>
|
25 | 23 | /// LSP Ref: <see cref="PrepareRename()"/>
|
@@ -83,15 +81,6 @@ private static ScriptExtentAdapter GetFunctionNameExtent(FunctionDefinitionAst a
|
83 | 81 | };
|
84 | 82 | }
|
85 | 83 |
|
86 |
| - /// <summary> |
87 |
| - /// Finds a renamable symbol at a given position in a script file using 1-based row/column references |
88 |
| - /// <param name="scriptFile"/> |
89 |
| - /// <param name="line">1-based line number</param> |
90 |
| - /// <param name="column">1-based column number</param> |
91 |
| - /// </summary> |
92 |
| - internal static Ast FindRenamableSymbol(ScriptFile scriptFile, int line, int column) => |
93 |
| - FindRenamableSymbol(scriptFile, new ScriptPositionAdapter(line, column)); |
94 |
| - |
95 | 84 | /// <summary>
|
96 | 85 | /// Finds a renamable symbol at a given position in a script file.
|
97 | 86 | /// </summary>
|
@@ -204,22 +193,15 @@ internal static TextEdit[] RenameFunction(Ast token, Ast scriptAst, RenameParams
|
204 | 193 |
|
205 | 194 | internal static TextEdit[] RenameVariable(Ast symbol, Ast scriptAst, RenameParams requestParams)
|
206 | 195 | {
|
207 |
| - RenameSymbolParams request = new() |
208 |
| - { |
209 |
| - FileName = requestParams.TextDocument.Uri.ToString(), |
210 |
| - Line = requestParams.Position.Line, |
211 |
| - Column = requestParams.Position.Character, |
212 |
| - RenameTo = requestParams.NewName |
213 |
| - }; |
214 | 196 | if (symbol is VariableExpressionAst or ParameterAst or CommandParameterAst or StringConstantExpressionAst)
|
215 | 197 | {
|
216 | 198 |
|
217 | 199 | IterativeVariableRename visitor = new(
|
218 |
| - request.RenameTo, |
| 200 | + requestParams.NewName, |
219 | 201 | symbol.Extent.StartLineNumber,
|
220 | 202 | symbol.Extent.StartColumnNumber,
|
221 | 203 | scriptAst,
|
222 |
| - request.Options ?? null |
| 204 | + null //FIXME: Pass through Alias config |
223 | 205 | );
|
224 | 206 | visitor.Visit(scriptAst);
|
225 | 207 | return visitor.Modifications.ToArray();
|
@@ -322,18 +304,3 @@ internal record ScriptExtentAdapter(IScriptExtent extent) : IScriptExtent
|
322 | 304 | public bool Contains(Position position) => ContainsPosition(this, position);
|
323 | 305 | public static bool ContainsPosition(ScriptExtentAdapter range, ScriptPositionAdapter position) => Range.ContainsPosition(range, position);
|
324 | 306 | }
|
325 |
| - |
326 |
| -public class RenameSymbolParams : IRequest<RenameSymbolResult> |
327 |
| -{ |
328 |
| - public string? FileName { get; set; } |
329 |
| - public int Line { get; set; } |
330 |
| - public int Column { get; set; } |
331 |
| - public string? RenameTo { get; set; } |
332 |
| - public RenameSymbolOptions? Options { get; set; } |
333 |
| -} |
334 |
| - |
335 |
| -public class RenameSymbolResult |
336 |
| -{ |
337 |
| - public RenameSymbolResult() => Changes = new List<TextEdit>(); |
338 |
| - public List<TextEdit> Changes { get; set; } |
339 |
| -} |
0 commit comments