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

Move TS/JS to use organize imports codeAction instead of command #47850

Merged
merged 4 commits into from
Apr 18, 2018

Conversation

mjbvz
Copy link
Contributor

@mjbvz mjbvz commented Apr 13, 2018

Fixes #47845
Fixes #46647

  • Defines a new standard SourceOrganizeImports CodeActionKind to be used to implement organize imports in a consistent way.
  • Add a new Organize imports command and keybinding that executes these actions.
  • Move over the existing js/ts organize imports command to use the new code action kind

@mjbvz mjbvz self-assigned this Apr 13, 2018
@mjbvz mjbvz requested a review from jrieken April 13, 2018 21:09
@@ -19,6 +19,7 @@ import { CodeActionKind, CodeActionTrigger } from './codeActionTrigger';

export const HAS_REFACTOR_PROVIDER = new RawContextKey<boolean>('hasRefactorProvider', false);
export const HAS_SOURCE_ACTION_PROVIDER = new RawContextKey<boolean>('hasSourceActionProvider', false);
export const HAS_ORGANIZE_IMPORTS_PROVIDER = new RawContextKey<boolean>('hasOrganizeImportsActionProvider', false);
Copy link
Member

Choose a reason for hiding this comment

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

Can we have a more generic context key? We could use equality or the regex support. Something like supportedCodeAction ~= /source\.organizeImports.*/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. supportedCodeAction is a space separated list of provided kinds. The regexp you use will typically look like:

/\bsource\.organizeImports(\b|\.)/

Which will match source.organizeImports as well as source.organizeImports.alphabetically

@@ -1942,6 +1942,11 @@ declare module 'vscode' {
*/
static readonly Source: CodeActionKind;

/**
* Base kind for an organize imports source action.
Copy link
Member

Choose a reason for hiding this comment

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

Please document the actual value

@mjbvz mjbvz force-pushed the organize-imports-codeaction-kind branch from 555413d to fc0c499 Compare April 17, 2018 18:02
Fixes microsoft#47845
Fixes microsoft#46647

- Defines a new standard `SourceOrganizeImports` `CodeActionKind` to be used to implement organize imports in a consistent way.
- Add a new `Organize imports` command and keybinding that executes these actions.
- Move over the existing js/ts organize imports command to use the new code action kind
@mjbvz mjbvz force-pushed the organize-imports-codeaction-kind branch from 3b97519 to 378c760 Compare April 17, 2018 23:32
Copy link
Member

@jrieken jrieken left a comment

Choose a reason for hiding this comment

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

lgtm

Make sure we only match whole scopes and not `unicorn.source.organizeImports`
@mjbvz mjbvz added this to the April 2018 milestone Apr 18, 2018
@mjbvz mjbvz merged commit 2fadb90 into microsoft:master Apr 18, 2018
@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Define standard OrganizeImports CodeActionKind Organise imports should be a refactoring/code action
2 participants