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

'declare method' quick fix for adding a private method #37782

Open
mjbvz opened this issue Apr 3, 2020 · 14 comments · Fixed by #37806
Open

'declare method' quick fix for adding a private method #37782

mjbvz opened this issue Apr 3, 2020 · 14 comments · Fixed by #37806
Labels
Good First Issue Well scoped, documented and has the green light Help Wanted You can do this Suggestion An idea for TypeScript

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Apr 3, 2020

From microsoft/vscode#94118

TypeScript Version: 3.9.0-dev.20200330

Search terms

  • quick fix
  • declare method
  • private

Repro
For ts file:

index.ts

class Bar {
    bar() {
         this._baz(123)
    }
}
  1. Trigger quick fixes on _baz

Feature request:
#36249 added a quick fix for adding private properties. However there is no quick fix for adding a private method

Playground Link:

Related Issues:

@bpasero
Copy link
Member

bpasero commented Apr 10, 2020

I am the original one complaining about this: what I expect is NOT having 1 code action per visibility, but rather ONE code action (as today) with a tab-stop at the visibility that I can flip the various visibilities. I realise this may need support from VSCode too. Here is how it would work:

  • you trigger the code action
  • you get into a mode like snippets where certain places are stops you can cycle through with Tab key
  • each method or property has a tab stop where you can navigate to and once you are there, be able to select a modifier private, protected, public etc.

@a-tarasyuk
Copy link
Contributor

@DanielRosenwasser Is there a way to have a sub action to handle tab-stop? Or need to generate all possible actions for various methods/properties and VSCode should resolve tab-stop? Do I need to close #37806, and revert #36249?

@DanielRosenwasser
Copy link
Member

Could you explain what you mean by tab-stop? I feel like I have an idea, but I might be out of the loop on something.

@a-tarasyuk
Copy link
Contributor

@bpasero

Could you explain what you mean by tab-stop?

@mjbvz
Copy link
Contributor Author

mjbvz commented Apr 13, 2020

Tabstops are from VS Code's snippets: https://code.visualstudio.com/docs/editor/userdefinedsnippets#_tabstops

There is no concept of tabstops in the TS Server api today since it only talks about text. I've opened #25207 which proposes adding the idea of snippets to typescript

@a-tarasyuk
Copy link
Contributor

Right now I see two ways for this issue

  1. Resolve this issue based on the original requirements
  2. Close feat(37782): 'declare method' quick fix for adding a private method #37806 revert Declare property quick fix should add private properties (or be configurable)  #36249 and add tab-stop for modifiers after TSServer: snippet completions #25207 will be implemented

I feel like I have an idea

@DanielRosenwasser Maybe you have a better idea :)

@DanielRosenwasser
Copy link
Member

Hah, I meant like "I might have an idea of what you mean by tab stops". I think the weird thing is that the rename location already allows you to make something #-private, but it's not clear whether we could make a conditional tabstop location for when the declaration isn't #-private

@bpasero
Copy link
Member

bpasero commented May 9, 2020

To demonstrate what I expect to happen, here is what Eclipse does:

recording

Notice how some tab-stops are linked, so renaming the method actually also renames the call!

And what VSCode does:

kap

Paper cuts:

  • method is added above constructor???
  • no way to change anything after the method was inserted

Can we reopen this or reconsider this?

@sandersn
Copy link
Member

Yeah, #37806 partially fixes this but doesn't address the full issue. I'll re-open that so we can unify the two fixes when post-codefix rename locations are available.

@sandersn sandersn reopened this May 11, 2020
@asd34-45

This comment was marked as spam.

@asd34-45

This comment was marked as spam.

@asd34-45

This comment was marked as spam.

@arvind-nikam-halodoc
Copy link

From microsoft/vscode#94118

TypeScript Version: 3.9.0-dev.20200330

Search terms

  • quick fix
  • declare method
  • private

Repro
For ts file:

index.ts

class Bar {
    bar() {
         this._baz(123)
    }
}
  1. Trigger quick fixes on _baz

Feature request:
#36249 added a quick fix for adding private properties. However there is no quick fix for adding a private method

Playground Link:

Related Issues:

It’s fixed i guess.
Screenshot 2021-03-10 at 11 26 37 AM

@NsdHSO
Copy link

NsdHSO commented Jul 23, 2024

@DanielRosenwasser is it still open?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good First Issue Well scoped, documented and has the green light Help Wanted You can do this Suggestion An idea for TypeScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants