microsoft / microsoft/language-server-protocol

Support refactors that require user input/options

Open
#1,164 26 comments 127 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

discussion feature-request new request
Dominant language
TypeScript
Stars
13k
Forks
1k
Avg merge
6d 1h
Merged PRs (30d)
10

Description

One common request of Dart is a refactor for "move to file" (either moving to an existing file, or a new one). Right now I don't think there's a great way to implement this as far as I can see there's no way to ask the user to pick a file (existing or not).

Slightly related, for Extract Method we would like to ask for a name (there's a related issue at https://github.com/microsoft/language-server-protocol/issues/764 suggesting instead allowing us to trigger a rename at the end, although asking for the name up-front would also work).

There are other refactors that Dart supports in other IDEs that have various other inputs/options (for example "inline method" lets you decide whether to keep or remove the method, and when extracting a method there's an option for whether to replace any other instances of the same statements in the file with a call to the new method).

I'm not sure of the best way to do this, but I thought it was worth starting a discussion (I couldn't find an existing one), but some possible ideas:

  • Metadata on code-actions that allow asking for input
  • Support for command variables in args of commands on code actions (and well-define input commands)
  • Server-to-client commands that allow taking input (similar to window/showMessageRequest)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with this issue's discussion and the related Language Server Protocol issue 764. Compare the proposed approaches for collecting refactor inputs, including code-action metadata, command variables, and server-to-client commands. Done would require an agreed protocol design for user-supplied options, rather than a narrowly scoped edit.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
developer-experience, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.