PowerShell / PowerShell/PowerShellEditorServices

Have `expandAlias` emit `TextEdit`s like the rename handler instead of a custom request

Abierto
#2,315 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Area-Language Server Issue-Enhancement
Lenguaje dominante
C#
Estrellas
767
Forks
266
Merge medio
3 d 16 h
PR fusionados (30 d)
1

Descripción

Follow-on from @JustinGrote's review on #2312: https://github.com/PowerShell/PowerShellEditorServices/pull/2312#pullrequestreview-4521187389

Yeah looks fine to me. As a follow-on issue we should probably update the rename handler to use this same code path if it isn't already.

The rename handler (RenameService) is already on the modern path — it uses System.Management.Automation.Language.Parser.ParseInput plus AST visitors and never used the legacy PsParser, so there's nothing to migrate there. #2312 brought ExpandAliasHandler onto the same modern parser.

The remaining divergence is in output shape, and the reusable direction is the reverse of "rename adopts expand-alias": expand-alias should adopt rename's edit model.

  • ExpandAliasHandler resolves aliases, then returns a single wholesale-rewritten string over the custom powerShell/expandAlias JSON-RPC request.
  • RenameService walks AST extents and returns TextEdit[] over standard textDocument/rename, using ScriptExtentAdapter to map PowerShell 1-based extents to LSP 0-based ranges.

This is also what #2108 itself anticipated: "return a proper edit (potentially deprecating the need for an entirely separate custom request)."

Proposed work:

  • Rework alias expansion to emit TextEdits (reusing ScriptExtentAdapter) covering each command-name token's extent, instead of returning a rewritten document.
  • Investigate folding it into a standard LSP surface (e.g. a code action) and deprecating the custom powerShell/expandAlias request + its client plumbing in vscode-powershell.

Note this changes the client contract, so it needs coordination with the extension — which is why #2312 was scoped to just the parser swap.

Drafted by Copilot (Claude Opus 4.8).

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza con ExpandAliasHandler, RenameService y ScriptExtentAdapter, usando #2312 y #2108 como contexto. Sigue el flujo existente de la solicitud powerShell/expandAlias y la infraestructura del cliente vscode-powershell; después compara la salida TextEdit del controlador de renombrado. Se considera terminado cuando la expansión de alias emite edits para los command-name extents y el contrato del cliente se actualiza o la solicitud personalizada queda obsoleta.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
csharp, powershell
Área
api, tooling
Tipo de issue
Nueva funcionalidad
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Tranquilo
Claridad
Bastante claro
Aptitud para principiantes
48/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.