File tree Expand file tree Collapse file tree 4 files changed +19
-5
lines changed
src/PowerShellEditorServices/Services
test/PowerShellEditorServices.Test/Language Expand file tree Collapse file tree 4 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -51,9 +51,14 @@ internal IEnumerable<SymbolReference> TryGetReferences(SymbolReference? symbol)
5151 : Enumerable . Empty < SymbolReference > ( ) ;
5252 }
5353
54+ // Gets symbol whose name contains the position
5455 internal SymbolReference ? TryGetSymbolAtPosition ( int line , int column ) => GetAllReferences ( )
5556 . FirstOrDefault ( i => i . NameRegion . ContainsPosition ( line , column ) ) ;
5657
58+ // Gets symbol whose whole extent contains the position
59+ internal SymbolReference ? TryGetSymbolContainingPosition ( int line , int column ) => GetAllReferences ( )
60+ . FirstOrDefault ( i => i . ScriptRegion . ContainsPosition ( line , column ) ) ;
61+
5762 internal IEnumerable < SymbolReference > GetAllReferences ( )
5863 {
5964 EnsureInitialized ( ) ;
Original file line number Diff line number Diff line change @@ -231,7 +231,9 @@ public static IEnumerable<SymbolReference> FindOccurrencesInFile(
231231 public async Task < ParameterSetSignatures ? > FindParameterSetsInFileAsync (
232232 ScriptFile scriptFile , int line , int column )
233233 {
234- SymbolReference ? symbol = FindSymbolAtLocation ( scriptFile , line , column ) ;
234+ // This needs to get by whole extent, not just the name, as it completes e.g.
235+ // `Get-Process -` (after the dash) and so also needs to look backwards a column.
236+ SymbolReference ? symbol = scriptFile . References . TryGetSymbolContainingPosition ( line , column - 1 ) ;
235237
236238 // If we are not possibly looking at a Function, we don't
237239 // need to continue because we won't be able to get the
@@ -255,6 +257,7 @@ await CommandHelpers.GetCommandInfoAsync(
255257
256258 try
257259 {
260+ // TODO: We should probably look at 'Parameters' instead of 'ParameterSets'
258261 IEnumerable < CommandParameterSetInfo > commandParamSets = commandInfo . ParameterSets ;
259262 return new ParameterSetSignatures ( commandParamSets , symbol ) ;
260263 }
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ public PsesSignatureHelpHandler(
3434 protected override SignatureHelpRegistrationOptions CreateRegistrationOptions ( SignatureHelpCapability capability , ClientCapabilities clientCapabilities ) => new ( )
3535 {
3636 DocumentSelector = LspUtils . PowerShellDocumentSelector ,
37- // A sane default of " ". We may be able to include others like "-".
37+ // TODO: We should evaluate what triggers (and re-triggers) signature help ( like dash?)
3838 TriggerCharacters = new Container < string > ( " " )
3939 } ;
4040
@@ -54,7 +54,7 @@ await _symbolsService.FindParameterSetsInFileAsync(
5454 request . Position . Line + 1 ,
5555 request . Position . Character + 1 ) . ConfigureAwait ( false ) ;
5656
57- if ( parameterSets == null )
57+ if ( parameterSets is null )
5858 {
5959 return new SignatureHelp ( ) ;
6060 }
@@ -89,7 +89,7 @@ private static ParameterInformation CreateParameterInfo(ParameterInfo parameterI
8989 return new ParameterInformation
9090 {
9191 Label = parameterInfo . Name ,
92- Documentation = string . Empty
92+ Documentation = parameterInfo . HelpMessage
9393 } ;
9494 }
9595 }
Original file line number Diff line number Diff line change @@ -125,11 +125,17 @@ private IReadOnlyList<SymbolReference> GetOccurrences(ScriptRegion scriptRegion)
125125 . ToArray ( ) ;
126126 }
127127
128- private IEnumerable < SymbolReference > FindSymbolsInFile ( ScriptRegion scriptRegion ) => symbolsService . FindSymbolsInFile ( GetScriptFile ( scriptRegion ) ) . OrderBy ( symbol => symbol . ScriptRegion . ToRange ( ) . Start ) ;
128+ private IEnumerable < SymbolReference > FindSymbolsInFile ( ScriptRegion scriptRegion )
129+ {
130+ return symbolsService
131+ . FindSymbolsInFile ( GetScriptFile ( scriptRegion ) )
132+ . OrderBy ( symbol => symbol . ScriptRegion . ToRange ( ) . Start ) ;
133+ }
129134
130135 [ Fact ]
131136 public async Task FindsParameterHintsOnCommand ( )
132137 {
138+ // TODO: Fix signatures to use parameters, not sets.
133139 ParameterSetSignatures signatures = await GetParamSetSignatures ( FindsParameterSetsOnCommandData . SourceDetails ) . ConfigureAwait ( true ) ;
134140 Assert . NotNull ( signatures ) ;
135141 Assert . Equal ( "Get-Process" , signatures . CommandName ) ;
You can’t perform that action at this time.
0 commit comments