Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement "Extract type alias" assist #8210

Merged
merged 6 commits into from Mar 31, 2021
Merged

Implement "Extract type alias" assist #8210

merged 6 commits into from Mar 31, 2021

Conversation

jonas-schievink
Copy link
Contributor

No description provided.

Jonas Schievink and others added 4 commits March 26, 2021 19:39
crates/ide_assists/src/handlers/extract_type_alias.rs Outdated Show resolved Hide resolved
Comment on lines 61 to 66
builder.replace_snippet(cap, target, "${0:Type}");
builder.insert_snippet(
cap,
insert,
format!("type ${{0:Type}} = {};\n\n", node),
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔

Three separate thoughts:

  1. the snippet's ${0} feels like a wrong tool here: it can't express the fact that the second position should be focused (primary).
  2. Our "extract variable" works differently as well, it just foceses the new name (so that it's possible to rename it later)
  3. I've noticed that type-script applies rename automatically. I think they just set the command to rename?

So, let's implement the same logic as extract variable now, and then add something like

	/**
	 * A command this code action executes. If a code action
	 * provides an edit and a command, first the edit is
	 * executed and then the command.
	 */
	command?: Command;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see, that does seem better!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll implement this part later

@jonas-schievink
Copy link
Contributor Author

bors r+

@bors
Copy link
Contributor

bors bot commented Mar 31, 2021

@bors bors bot merged commit 75011bb into rust-lang:master Mar 31, 2021
@lnicola
Copy link
Member

lnicola commented Mar 31, 2021

changelog feature

@jonas-schievink jonas-schievink deleted the extract-type-alias branch March 31, 2021 12:39
@lnicola
Copy link
Member

lnicola commented Apr 5, 2021

extract_type_alias

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants