completionresolve support#1009
Conversation
SeeminglyScience
left a comment
There was a problem hiding this comment.
Awesome job 🙂
Got some comments/requests, none blocking though.
| // s_completionHandle.Release(); | ||
| // } | ||
| // } | ||
| static public async Task<CommandCompletion> GetCompletionsAsync( |
There was a problem hiding this comment.
| static public async Task<CommandCompletion> GetCompletionsAsync( | |
| public static async Task<CommandCompletion> GetCompletionsAsync( |
| { | ||
| IEnumerable<CompletionDetails> completionList = | ||
| commandCompletion.CompletionMatches.Select( | ||
| CompletionDetails.Create); |
There was a problem hiding this comment.
Since this delegate doesn't need a closure can we save it statically?
| this.CompletionType == otherDetails.CompletionType && | ||
| string.Equals(this.ToolTipText, otherDetails.ToolTipText) && | ||
| string.Equals(this.SymbolTypeName, otherDetails.SymbolTypeName); | ||
| } |
There was a problem hiding this comment.
Can you have this implement IEquatable<CompletionDetails> to better telegraph that it has custom comparisons? Also == and != operators.
| this.CompletionType, | ||
| this.ListItemText, | ||
| this.ToolTipText, | ||
| this.SymbolTypeName).GetHashCode(); |
There was a problem hiding this comment.
What about case sensitivity? Also ideally this wouldn't create an extra string. Here's the template I usually go with:
unchecked
{
int hash = 17;
hash = hash * 23 + CompletionText.GetHashCode();
hash = hash * 23 + CompletionType.GetHashCode();
hash = hash * 23 + ListItemText.GetHashCode();
hash = hash * 23 + ToolTipText.GetHashCode();
// If one can be null:
hash = hash * 23 + SymbolTypeName?.GetHashCode() ?? 0;
return hash;
}(Taken from https://stackoverflow.com/a/263416)
|
|
||
| default: | ||
| // TODO: Trace the unsupported CompletionResultType | ||
| return CompletionType.Unknown; |
There was a problem hiding this comment.
How do we feel about making LangVersion preview?
return completionResultType switch
{
CompletionResultType.Command => CompletionType.Command,
CompletionResultType.Method => CompletionType.Method,
CompletionResultType.ParameterName => CompletionType.ParameterName,
CompletionResultType.ParameterValue => CompletionType.ParameterValue,
CompletionResultType.Property => CompletionType.Property,
CompletionResultType.Variable => CompletionType.Variable,
CompletionResultType.Namespace => CompletionType.Namespace,
CompletionResultType.Type => CompletionType.Type,
CompletionResultType.Keyword => CompletionType.Keyword,
CompletionResultType.DynamicKeyword => CompletionType.Keyword,
CompletionResultType.ProviderContainer => CompletionType.Folder,
CompletionResultType.ProviderItem => CompletionType.File,
// TODO: Trace the unsupported CompletionResultType
_ => CompletionType.Unknown,
};Alternatively since it's mostly one to one you could have a map array, e.g.
private static readonly s_completionTypeMap =
{
CompletionType.Command,
// etc
};
void Access(CompletionResultType resultType) => s_completionTypeMap[(int)resultType];| { | ||
| return new CompletionRegistrationOptions | ||
| { | ||
| DocumentSelector = new DocumentSelector(new DocumentFilter { Pattern = "**/*.ps*1" }), |
There was a problem hiding this comment.
Does this effect untitled files?
There was a problem hiding this comment.
Good catch, I can change this to apply to only powershell files
| return value.Kind == CompletionItemKind.Function; | ||
| } | ||
|
|
||
| public async Task<CompletionItem> Handle(CompletionItem request, CancellationToken cancellationToken) |
There was a problem hiding this comment.
When is this called? Just on select? Or for every completion item?
There was a problem hiding this comment.
It's called when a completion item is highlighted in the completion list
| // Look for type encoded in the tooltip for parameters and variables. | ||
| // Display PowerShell type names in [] to be consistent with PowerShell syntax | ||
| // and now the debugger displays type names. | ||
| var matches = Regex.Matches(completionDetails.ToolTipText, @"^(\[.+\])"); |
There was a problem hiding this comment.
re: the CompletionDetails.ExtractSymbolTypeNameFromToolTip comment
| } | ||
| } | ||
| else if ((completionDetails.CompletionType == CompletionType.Folder) && | ||
| (completionText.EndsWith("\"", StringComparison.OrdinalIgnoreCase) || completionText.EndsWith("'", StringComparison.OrdinalIgnoreCase))) |
There was a problem hiding this comment.
Not sure if EndsWith optimizes this, but maybe better to have a static method like:
bool EndsWithQuote(string text)
{
if (string.IsNullOrEmpty(text))
{
return false;
}
char lastChar = text[text.Length - 1];
return lastChar == '"' || lastChar == '\'';
}| return CompletionItemKind.Folder; | ||
|
|
||
| default: | ||
| return CompletionItemKind.Text; |
There was a problem hiding this comment.
re: expression switch/array map
| /// </summary> | ||
| public static class CommandHelpers | ||
| { | ||
| private static readonly HashSet<string> NounBlackList = |
There was a problem hiding this comment.
I suspect this isn't threadsafe and should be a ConcurrentDictionary<string, bool> or something, where the value is never used
There was a problem hiding this comment.
We should also change blacklist to exclusionlist
b0aec47 to
0ad5d6b
Compare
|
@SeeminglyScience a few of your comments were really towards #1007 and that's merged in so I'm gonna skip them for now. |
| new DocumentFilter() | ||
| { | ||
| Pattern = "**/*.ps*1" | ||
| Language = "powershell" |
There was a problem hiding this comment.
I'm planning on factoring this out into an abstract class or interface... just haven't gotten around to it.
* handle log messages * switch to using xUnit output helper * Add completionItem/resolve request * feedback * update build to run update-help for signature help test * removing scope hoping it works in CI * setting to EA silentlycontinue * change to language=powershell
* Add starting point * x * More work * Make integration tests pass for omnisharp * Changes * add dummy workspace symbols handler * use LoggerFactory * A working WorkspaceSymbolsHandler * working text document syncer * needed document selector and getVersion handler to work with vscode * Added Diagnostics * didChangeConfiguration message and general settings support * Add diagnostics (#18) * initial folding support * added test for folding * Add setting support (#19) * Added Diagnostics * didChangeConfiguration message and general settings support * Apply suggestions from code review Co-Authored-By: Robert Holt <rjmholt@gmail.com> * Folding support (#20) * Added Diagnostics * didChangeConfiguration message and general settings support * initial folding support * log level trace * folding works with latest omnisharp version * comment typo * added test for folding * formatting support * remove merge conflict * add formatting tests * DocumentSymbols and References support (#997) * working formatting * add tests * delete commented out code * [Omnisharp-LSP] textDocument/documentHighlight support (#999) * Add handler scaffold * More stuff * Make handler work * Add copyright * Add tests, fix bugs * Fix small issues * codelens support (#1001) * codelens support * address rob's feedback * powerShell/getPSHostProcesses and powerShell/getRunspace (#1002) * Test only pester for now (#1003) * Implement textDocument/codeAction (#1004) * Add initial handler * Add working codeAction implementation * Crash * Make tests work * Fix issues * Make tests work in WinPS * Add powershellcontext (#1005) * Add powershellcontext * using file sink now instead * all the newlines * support $psEditor (#1006) * support $psEditor * deleted commented out code * fix initial build failures due to lack of certain assemblies * use different RootPath * wait an extra 5 seconds just in case * refactor initialize script * Re-add Stdio option and replace Pester tests with xunit tests. (#1008) * Completion Support (#1007) * completion support * misc codacy fixes * use BUILD_ARTIFACTSTAGINGDIRECTORY so logs can be uploaded * publish artifacts even if build fails * handle log messages * give PSES a chance to run what it needs to run * switch to using xUnit output helper * treat DynamicKeywords as Keyword * completionresolve support (#1009) * handle log messages * switch to using xUnit output helper * Add completionItem/resolve request * feedback * update build to run update-help for signature help test * removing scope hoping it works in CI * setting to EA silentlycontinue * change to language=powershell * hover support (#1010) * handle log messages * switch to using xUnit output helper * add hover handler * move to language=powershell * refactoring for feedback * codacy * Omni signaturehelp (#1011) * handle log messages * switch to using xUnit output helper * Support SignatureHelp * concurrentdict * Add definition handler (#1013) * add definition handler * codacy * sneak in powerShell/executionStatusChanged * codacy * Add Plaster messages (#1014) * Comment Help and Evaluate (#1015) * Support for Comment Help generator * add evaluate handler * Last LSP messages (#1016) * support CommandExporer commands and powerShell/runspaceChanged * expand alias * refactor server setup (#1018) * rename namespaces (#1019) * The entire Debug Adapter moved over... (#1043) * initial non-working dap * working launch but not attach * working attach handler * update namespaces * Disconnect support and handling of JsonRpcServer teardown * Add foundation for debug tests - stdio and fixures * all handlers * remote file manager working * rest of debug adapter * use actual release * Apply suggestions from code review Co-Authored-By: Robert Holt <rjmholt@gmail.com> * Delete projects we wont be keeping around and get pses.vscode working again (#1046) * delete other folders and tweak build script for BuildInfo * working PowerShellEditorServices.VSCode now a binary module! * some typo * Apply suggestions from code review Co-Authored-By: Patrick Meinecke <SeeminglyScience@users.noreply.github.com> * address additional comments * don't checkin maml * add error handling * deleted buildinfo and address rob's comments * Remove engine from files and namespaces (#1048) * apply apt state for PS7 (#1051) * delete buildinfo * implement powerShell/startDebugger (#1049) * implement powerShell/startDebugger * add line Co-Authored-By: Patrick Meinecke <SeeminglyScience@users.noreply.github.com> * Enable alias corrections (#1053) * Codacy comments
Comes after #1007
This adds support for
completionItem/resolve