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)
51
51
: Enumerable . Empty < SymbolReference > ( ) ;
52
52
}
53
53
54
+ // Gets symbol whose name contains the position
54
55
internal SymbolReference ? TryGetSymbolAtPosition ( int line , int column ) => GetAllReferences ( )
55
56
. FirstOrDefault ( i => i . NameRegion . ContainsPosition ( line , column ) ) ;
56
57
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
+
57
62
internal IEnumerable < SymbolReference > GetAllReferences ( )
58
63
{
59
64
EnsureInitialized ( ) ;
Original file line number Diff line number Diff line change @@ -231,7 +231,9 @@ public static IEnumerable<SymbolReference> FindOccurrencesInFile(
231
231
public async Task < ParameterSetSignatures ? > FindParameterSetsInFileAsync (
232
232
ScriptFile scriptFile , int line , int column )
233
233
{
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 ) ;
235
237
236
238
// If we are not possibly looking at a Function, we don't
237
239
// need to continue because we won't be able to get the
@@ -255,6 +257,7 @@ await CommandHelpers.GetCommandInfoAsync(
255
257
256
258
try
257
259
{
260
+ // TODO: We should probably look at 'Parameters' instead of 'ParameterSets'
258
261
IEnumerable < CommandParameterSetInfo > commandParamSets = commandInfo . ParameterSets ;
259
262
return new ParameterSetSignatures ( commandParamSets , symbol ) ;
260
263
}
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ public PsesSignatureHelpHandler(
34
34
protected override SignatureHelpRegistrationOptions CreateRegistrationOptions ( SignatureHelpCapability capability , ClientCapabilities clientCapabilities ) => new ( )
35
35
{
36
36
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?)
38
38
TriggerCharacters = new Container < string > ( " " )
39
39
} ;
40
40
@@ -54,7 +54,7 @@ await _symbolsService.FindParameterSetsInFileAsync(
54
54
request . Position . Line + 1 ,
55
55
request . Position . Character + 1 ) . ConfigureAwait ( false ) ;
56
56
57
- if ( parameterSets == null )
57
+ if ( parameterSets is null )
58
58
{
59
59
return new SignatureHelp ( ) ;
60
60
}
@@ -89,7 +89,7 @@ private static ParameterInformation CreateParameterInfo(ParameterInfo parameterI
89
89
return new ParameterInformation
90
90
{
91
91
Label = parameterInfo . Name ,
92
- Documentation = string . Empty
92
+ Documentation = parameterInfo . HelpMessage
93
93
} ;
94
94
}
95
95
}
Original file line number Diff line number Diff line change @@ -125,11 +125,17 @@ private IReadOnlyList<SymbolReference> GetOccurrences(ScriptRegion scriptRegion)
125
125
. ToArray ( ) ;
126
126
}
127
127
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
+ }
129
134
130
135
[ Fact ]
131
136
public async Task FindsParameterHintsOnCommand ( )
132
137
{
138
+ // TODO: Fix signatures to use parameters, not sets.
133
139
ParameterSetSignatures signatures = await GetParamSetSignatures ( FindsParameterSetsOnCommandData . SourceDetails ) . ConfigureAwait ( true ) ;
134
140
Assert . NotNull ( signatures ) ;
135
141
Assert . Equal ( "Get-Process" , signatures . CommandName ) ;
You can’t perform that action at this time.
0 commit comments