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

Signaturehelp cancellation and some caching #1251

Conversation

TylerLeonhardt
Copy link
Member

  • SignatureHelp request is now cancellable - I saw this request a bunch in a user's log
  • SignatureHelp request cleaned up a bit
  • Cache CmdletInfo's and synopsis' of CmdletInfos.
  • Renamed NounExclusionList to s_nounExclusionList

@TylerLeonhardt TylerLeonhardt requested a review from rjmholt as a code owner April 7, 2020 22:23
@TylerLeonhardt
Copy link
Member Author

I could add logging when it reads from the cache but then I'd need to pass in the logger.

s_nounExclusionList.TryAdd("InstalledModule", true);
s_nounExclusionList.TryAdd("InstalledScript", true);
s_nounExclusionList.TryAdd("ScriptFileInfo", true);
s_nounExclusionList.TryAdd("PSRepository", true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the comment on line 62, shouldn't PowerShellGet be in this list?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah nevermind, this is the noun list, duh. Not the package name list.

Copy link
Contributor

@rkeithhill rkeithhill Apr 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That said, I see more nouns from PowerShellGet 2.2.3 than appear in the list above. gcm -m PowerShellGet | % Noun | % Sort -uniq Is that a problem? For instance, there is a Find-Command function in PowerShellGet.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I just renamed the variable. We should have a better check for verb-noun when PSGet uses the same noun as an inbox module Module as an example.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a s_cmdletExclusionList now which will handle that ^

Copy link
Collaborator

@SeeminglyScience SeeminglyScience left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM!

One thing in existing code to consider, definitely not blocking.

{
signatures = new SignatureInformation[parameterSets.Signatures.Length];
for (int i = 0; i < signatures.Length; i++)
var parameters = new ParameterInformation[parameterSets.Signatures[i].Parameters.Count()];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know why Parameters is typed as IEnumerable<>? I know this is existing code, but while you're here it might be worth changing that to an array and use Length here instead of Count().

If it's IEnumerable<> because it's a yield enumerator or LINQ then Count() should be skipped and a List<> with a best estimate capacity should be used.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really sure what the best estimate could be here... so I'll just leave it empty.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added!

@@ -71,15 +70,13 @@ public async Task<SignatureHelp> Handle(SignatureHelpParams request, Cancellatio
return new SignatureHelp();
}

SignatureInformation[] signatures = new SignatureInformation[parameterSets.Signatures.Length];
var signatures = new SignatureInformation[parameterSets.Signatures.Length];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

@rkeithhill rkeithhill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@TylerLeonhardt
Copy link
Member Author

Codacy Here is an overview of what got changed by this pull request:

Issues
======
+ Solved 1
           

Complexity increasing per file
==============================
- src/PowerShellEditorServices/Services/TextDocument/Handlers/SignatureHelpHandler.cs  1
- src/PowerShellEditorServices/Services/PowerShellContext/Utilities/CommandHelpers.cs  2
         

Clones added
============
- src/PowerShellEditorServices/Services/TextDocument/Handlers/SignatureHelpHandler.cs  1
         

See the complete overview on Codacy

@TylerLeonhardt TylerLeonhardt merged commit 0e9b982 into PowerShell:master Apr 8, 2020
@TylerLeonhardt TylerLeonhardt deleted the signaturehelp-cancellation-and-some-caching branch April 8, 2020 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants