zardoy / typescript-vscode-plugins

NO LIMITS FOR TS! Isn't this the most advanced TypeScript plugin as VS Code extension ever created?
https://marketplace.visualstudio.com/items?itemName=zardoy.ts-essential-plugins
MIT License
55 stars 5 forks source link

feat(refactoring): rename parameter to type name (#107) #166

Closed Ilanaya closed 1 year ago

Ilanaya commented 1 year ago

Resolves #107 @zardoy Is there a way to rename all param occurrences within a function body (like vscode's Rename symbol command works)?

I tested on this code:

type fnType = (name: number) => number;

const fn1: fnType = (arg): number => arg

const fn2: fnType = function fn2(arg: number): number {
  return arg
}
zardoy commented 1 year ago

Answering original question: I’m not sure for now, but I had the code snippet to apply code action with the same kind for each of selected regions. You can select all params with go to node by syntax kind within selection. I don’t think it’s worth adding another code action for renaming all params, though it is easy to do. You can implement it of course, but only if you really need it.

Ilanaya commented 1 year ago

Answering original question: I’m not sure for now, but I had the code snippet to apply code action with the same kind for each of selected regions. You can select all params with go to node by syntax kind within selection. I don’t think it’s worth adding another code action for renaming all params, though it is easy to do. You can implement it of course, but only if you really need it.

As I recall, special commands do not work in Volar's takeover mode, so there is a reason to implement

zardoy commented 1 year ago

As I recall, special commands do not work in Volar's takeover mode, so there is a reason to implement

This is not a special command, this is snippet for ide scripting extension as you can apply any code action using vscode api. I'll drop you the code. Anyway, I’m not against implementing it, you decide! Edit: sorry I forgot that go to syntax kind is a special command…

Ilanaya commented 1 year ago

I dunno why but my last two commits with fixes just don't display here https://github.com/zardoy/typescript-vscode-plugins/compare/107-rename-to-type-parameter

fixed by updating pr base 🤔