Skip to content

Quickfix for interface method stubs #867

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

Closed
bali182 opened this issue Feb 27, 2016 · 8 comments
Closed

Quickfix for interface method stubs #867

bali182 opened this issue Feb 27, 2016 · 8 comments
Labels

Comments

@bali182
Copy link

bali182 commented Feb 27, 2016

I find this a very useful feature, mostly for compiled languages like java or scala.

Let's say you have an interface:

interface IFoo {
  foo(): number
  bar(): string
}

Now when you start writing an implementation, and you have this:

class FooImpl implements IFoo {
}

It would be really helpful to have a quickfix, that is able to generate for you something like this:

class FooImpl implements IFoo {
  foo(): number {
    return undefined;
  }
  bar(): string {
    return undefined;
  }
}

Because otherwise you have to go to the interface, copy-paste the methods, ... I don't have to explain the process.

Do you consider implementing this? If not, would you consider accepting a PR if I were to implement it?

@nycdotnet
Copy link
Contributor

Would absolutely accept a PR. Thank you.

@karlkras
Copy link

@nycdotnet , was there any traction on this feature add request?

@nycdotnet
Copy link
Contributor

I haven't seen any, but would still love a PR for it.

@bali182
Copy link
Author

bali182 commented Apr 27, 2016

I started looking at how this could be done, when I found this: https://github.com/TypeStrong/atom-typescript/blob/master/lib/main/lang/fixmyts/quickFixes/implementInterface.ts (which is I guess what this issue is about), but unfortunately I didn't go any further and forgot about it 😢

@kyasbal
Copy link
Contributor

kyasbal commented Nov 26, 2016

Is there any plan to be implemented? As long as I see the code of quick fix, the quick fix code wouldn't do anything. The quickfix just shows implement interface suggestion.
I the quickfix should be removed if the feature is not implemented. I thought that was bug first time but actually that is only not implemented.

@p-bakker
Copy link

p-bakker commented Mar 6, 2017

I've implemented this today locally, using the TypeScript Language Service getCodeFixesAtPosition API, which seems to do exactly what this Quickfix is supposed to do.

Any thoughts as to why the LanguageService API wasn't used before or why it doesn't seem to be used for any of the other Quickfixes (afaics from a quick look through the code)

The only problem I have is that the formatting is off. Anyone knows how to fix the formatting? I would've thought the LangaugeService would return me the code fixes properly formatted, but that doesn't seem to be the case.

If I can get this formatting resolved, I can make a Pull Request out of this

@guncha
Copy link
Contributor

guncha commented Mar 6, 2017

Quickfixes were only recently added to the Typescript API while atom-typescript has had them for a while. It's a similar story with a few other features like glob support in tsconfig.json. Now that the compiler has these, it doesn't make sense to use the custom versions. There's a rewrite of the plugin to only use official APIs in #1166 and I intend to deprecate the current master once that beta gets some testing in the trenches.

One thing it is currently lacking is Codefix support and I would be extremely happy if some enterprising soul would add that.

@github-actions
Copy link

github-actions bot commented Jan 2, 2020

This issue has been marked as stale because it did not have any activity for the last 90 days or more. Remove the stale label or comment or this will be closed in 14 days

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

No branches or pull requests

6 participants