Skip to content

Code Action: Generate Interface #44645

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

Open
Tracked by #55825
FlagshipApps opened this issue Jan 12, 2021 · 2 comments
Open
Tracked by #55825

Code Action: Generate Interface #44645

FlagshipApps opened this issue Jan 12, 2021 · 2 comments
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. devexp-refactoring Issues with analysis server refactorings P4 type-enhancement A request for a change that isn't a bug

Comments

@FlagshipApps
Copy link

FlagshipApps commented Jan 12, 2021

  • Dart SDK Version (dart --version)
    2.12.0-133.2.beta on windows_x64

Problem
Oftentimes I write some kind of service and afterwards I want to create an abstract class from it, to implement dependency inversion. I always have to manually copy the whole class and delete the function bodies, which is annoying work.

Possible solution
A code action would be great. Like I can do "extract widget" in flutter, I'm thinking of a code action like "generate Abstract Class" or "generate Interface" when hovering over a dart class. The action should then create an abstract class (and maybe let me chose the name) which acts as an interface.

Example
existing class
class MyClass { void helloWorld(){ print("Hello"); } }
generated class after code action:
abstract class MyAbstractClass { void helloWorld(); }

@mraleph
Copy link
Member

mraleph commented Jan 12, 2021

FWIW every class is an interface in Dart so you don't need a separate abstract class to act as an interface for MyClass.

@FlagshipApps
Copy link
Author

FlagshipApps commented Jan 12, 2021

FWIW

Thanks for the hint! However, I think it does not change the benefit of the feature to generate a class without bodies to act as an interface, does it?

@vsmenon vsmenon added the legacy-area-analyzer Use area-devexp instead. label Jan 12, 2021
@srawlins srawlins added devexp-refactoring Issues with analysis server refactorings P4 labels Jan 12, 2021
@srawlins srawlins added the type-enhancement A request for a change that isn't a bug label Mar 13, 2024
@bwilkerson bwilkerson added area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. and removed legacy-area-analyzer Use area-devexp instead. labels Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. devexp-refactoring Issues with analysis server refactorings P4 type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants