-
Notifications
You must be signed in to change notification settings - Fork 511
🧹 Refactor classes that do not need a language client to not inherit from IFeature #2685
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
Merged
TylerLeonhardt
merged 8 commits into
PowerShell:master
from
bergmeister:refactor-IFeature
Jul 23, 2020
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4afcb90
Refactor classes that do not need a language client to not inherit fr…
95a7c29
Merge branch 'master' of https://github.com/PowerShell/vscode-powersh…
57b714b
Use base class LanguageClientConsumer
a50af97
Remove IFeature by making languageClientConsumer abstract
c8eedbb
Provide base implementation for setLanguageClient to remove repeated …
447c184
Merge branch 'master' of https://github.com/PowerShell/vscode-powersh…
1104820
Adapt ExternalApi.ts and PowerShellNotebooks.ts
5b9b99d
newline
TylerLeonhardt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not super crazy about having two different types of commands. What if rather than implementing
IFeature
, you create a base class called Feature (or another name if you can come up with something better). Then each subclass would useextends
instead ofimplements
. The base class would implement vscode.Disposable and would provide a protectedlanguageClient
property getter. Then we can treat each command/feature the same with respect to storing them in a single collection in main and a single loop to dispose of them.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree.
Having a separate list, means less work to do for the
SessionManager
, which only needs to manage classes, which require management therefore due to it depending on thelanguageClient
. The value of this PR is to decouple standalone and self-contained command registrations, whilst also removing boilerplate code in those classes.IFeature
could be called something likeILanguageClientConsumer
to better reflect what it does.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how I feel about this but I do like the idea of having a base class for
LanguageClientConsumer
that sets a propertylanguageClient
.This will stop so many issues that just have the unhelpful
Unable to instantiate; language client undefined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'm cool with some "features" just implementing Dispose and other "features" extending this
LanguageClientConsumer
.Did you want to make that change @bergmeister?
the if statement can just run:
or something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've just added a
LanguageClientConsumer
base class in 57b714bI couldn't remove the usage of
IFeature
yet because thedispose()
andsetLanguageClient
methods are still being used. Trying to get rid of that would be a bit more complicated and I wouldn't like to convolute this PR too much.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bergmeister any reason:
LanguageClientConsumer
can't inherit fromIFeature
instead of everything inheriting fromIFeature
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LanguageClientConsumer
could be abstract so each thing can implement their own dispose... but then you can remove all of the:and have just one of those in
LanguageClientConsumer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good idea. I made it an abstract class and
dispose()
an abstract method so that every implementation has to implement that one. I've also noticed thatExpandAlias
andShowHelpFeature
have thelogger
passed into the constructor but actually never use the loggers, should we remove those unnecessary references as well or do that in another follow up PR?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah let's leave those in for now. Really we should add logging ;)