Skip to content

Commit

Permalink
fix: add kinds to refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy committed Feb 17, 2023
1 parent 2ef7de5 commit 19c0a03
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const nodeToSpan = (node: ts.Node): ts.TextSpan => {
export default {
id: 'changeStringReplaceToRegex',
name: 'Change to Regex',
kind: 'refactor.rewrite.stringToRegex',
tryToApply(sourceFile, position, _range, node) {
if (!node || !position) return
// requires full explicit object selection (be aware of comma) to not be annoying with suggestion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const printNodeForObjectKey = (node: ts.Node) => {
export default {
id: 'objectSwapKeysAndValues',
name: 'Swap Keys and Values in Object',
kind: 'refactor.rewrite.object.swapKeysAndValues',
tryToApply(sourceFile, _position, range, node) {
if (!range || !node) return
// requires full explicit object selection (be aware of comma) to not be annoying with suggestion
Expand Down
5 changes: 4 additions & 1 deletion typescript/src/codeActions/getCodeActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export type ApplyCodeAction = (
export type CodeAction = {
name: string
id: string
/** Base kind https://github.com/microsoft/vscode/blob/main/src/vscode-dts/vscode.d.ts#L2236 */
kind: string
tryToApply: ApplyCodeAction
}

Expand Down Expand Up @@ -72,8 +74,9 @@ export default (
return {
info:
(appliableCodeActions.length && {
actions: appliableCodeActions.map(({ id, name }) => ({
actions: appliableCodeActions.map(({ id, name, kind }) => ({
description: name,
kind,
name: id,
})),
// anyway not visible in ui
Expand Down

0 comments on commit 19c0a03

Please sign in to comment.