@@ -5989,12 +5989,13 @@ private static List<CompletionResult> CompleteRequires(CompletionContext context
5989
5989
5990
5990
// Produce completions for all parameters that begin with the prefix we've found,
5991
5991
// but which haven't already been specified in the line we need to complete
5992
- foreach ( KeyValuePair < string , string > parameter in s_requiresParameters )
5992
+ foreach ( string parameter in s_requiresParameters )
5993
5993
{
5994
- if ( parameter . Key . StartsWith ( currentParameterPrefix , StringComparison . OrdinalIgnoreCase )
5995
- && ! context . CursorPosition . Line . Contains ( $ " -{ parameter . Key } ", StringComparison . OrdinalIgnoreCase ) )
5994
+ if ( parameter . StartsWith ( currentParameterPrefix , StringComparison . OrdinalIgnoreCase )
5995
+ && ! context . CursorPosition . Line . Contains ( $ " -{ parameter } ", StringComparison . OrdinalIgnoreCase ) )
5996
5996
{
5997
- results . Add ( new CompletionResult ( parameter . Key , parameter . Key , CompletionResultType . ParameterName , parameter . Value ) ) ;
5997
+ string toolTip = GetRequiresParametersToolTip ( parameter ) ;
5998
+ results . Add ( new CompletionResult ( parameter , parameter , CompletionResultType . ParameterName , toolTip ) ) ;
5998
5999
}
5999
6000
}
6000
6001
@@ -6019,11 +6020,12 @@ private static List<CompletionResult> CompleteRequires(CompletionContext context
6019
6020
// Complete PSEdition parameter values
6020
6021
if ( currentParameterMatch . Value . Equals ( "PSEdition" , StringComparison . OrdinalIgnoreCase ) )
6021
6022
{
6022
- foreach ( KeyValuePair < string , string > psEditionEntry in s_requiresPSEditions )
6023
+ foreach ( string psEditionEntry in s_requiresPSEditions )
6023
6024
{
6024
- if ( psEditionEntry . Key . StartsWith ( currentValue , StringComparison . OrdinalIgnoreCase ) )
6025
+ if ( psEditionEntry . StartsWith ( currentValue , StringComparison . OrdinalIgnoreCase ) )
6025
6026
{
6026
- results . Add ( new CompletionResult ( psEditionEntry . Key , psEditionEntry . Key , CompletionResultType . ParameterValue , psEditionEntry . Value ) ) ;
6027
+ string toolTip = GetRequiresPsEditionsToolTip ( psEditionEntry ) ;
6028
+ results . Add ( new CompletionResult ( psEditionEntry , psEditionEntry , CompletionResultType . ParameterValue , toolTip ) ) ;
6027
6029
}
6028
6030
}
6029
6031
@@ -6051,7 +6053,7 @@ private static List<CompletionResult> CompleteRequires(CompletionContext context
6051
6053
hashtableKeyMatches = Regex . Matches ( hashtableString , @"(@{|;)\s*(?:'|\""|\w*)\w*" ) ;
6052
6054
6053
6055
// Build the list of keys we might want to complete, based on what's already been provided
6054
- var moduleSpecKeysToComplete = new HashSet < string > ( s_requiresModuleSpecKeys . Keys ) ;
6056
+ var moduleSpecKeysToComplete = new HashSet < string > ( s_requiresModuleSpecKeys ) ;
6055
6057
bool sawModuleNameLast = false ;
6056
6058
foreach ( Match existingHashtableKeyMatch in hashtableKeyMatches )
6057
6059
{
@@ -6107,35 +6109,62 @@ private static List<CompletionResult> CompleteRequires(CompletionContext context
6107
6109
{
6108
6110
if ( moduleSpecKey . StartsWith ( currentValue , StringComparison . OrdinalIgnoreCase ) )
6109
6111
{
6110
- results . Add ( new CompletionResult ( moduleSpecKey , moduleSpecKey , CompletionResultType . ParameterValue , s_requiresModuleSpecKeys [ moduleSpecKey ] ) ) ;
6112
+ string toolTip = GetRequiresModuleSpecKeysToolTip ( moduleSpecKey ) ;
6113
+ results . Add ( new CompletionResult ( moduleSpecKey , moduleSpecKey , CompletionResultType . ParameterValue , toolTip ) ) ;
6111
6114
}
6112
6115
}
6113
6116
}
6114
6117
6115
6118
return results ;
6116
6119
}
6117
6120
6118
- private static readonly IReadOnlyDictionary < string , string > s_requiresParameters = new SortedList < string , string > ( StringComparer . OrdinalIgnoreCase )
6121
+ private static readonly string [ ] s_requiresParameters = new string [ ]
6119
6122
{
6120
- { "Modules" , "Specifies PowerShell modules that the script requires." } ,
6121
- { "PSEdition" , "Specifies a PowerShell edition that the script requires." } ,
6122
- { "RunAsAdministrator" , "Specifies that PowerShell must be running as administrator on Windows." } ,
6123
- { "Version" , "Specifies the minimum version of PowerShell that the script requires." } ,
6123
+ "Modules" ,
6124
+ "PSEdition" ,
6125
+ "RunAsAdministrator" ,
6126
+ "Version"
6124
6127
} ;
6125
6128
6126
- private static readonly IReadOnlyDictionary < string , string > s_requiresPSEditions = new SortedList < string , string > ( StringComparer . OrdinalIgnoreCase )
6129
+ private static string GetRequiresParametersToolTip ( string name ) => name switch
6127
6130
{
6128
- { "Core" , "Specifies that the script requires PowerShell Core to run." } ,
6129
- { "Desktop" , "Specifies that the script requires Windows PowerShell to run." } ,
6131
+ "Modules" => TabCompletionStrings . RequiresModulesParameterDescription ,
6132
+ "PSEdition" => TabCompletionStrings . RequiresPSEditionParameterDescription ,
6133
+ "RunAsAdministrator" => TabCompletionStrings . RequiresRunAsAdministratorParameterDescription ,
6134
+ "Version" => TabCompletionStrings . RequiresVersionParameterDescription ,
6135
+ _ => string . Empty
6130
6136
} ;
6131
6137
6132
- private static readonly IReadOnlyDictionary < string , string > s_requiresModuleSpecKeys = new SortedList < string , string > ( StringComparer . OrdinalIgnoreCase )
6138
+ private static readonly string [ ] s_requiresPSEditions = new string [ ]
6133
6139
{
6134
- { "ModuleName" , "Required. Specifies the module name." } ,
6135
- { "GUID" , "Optional. Specifies the GUID of the module." } ,
6136
- { "ModuleVersion" , "Specifies a minimum acceptable version of the module." } ,
6137
- { "RequiredVersion" , "Specifies an exact, required version of the module." } ,
6138
- { "MaximumVersion" , "Specifies the maximum acceptable version of the module." } ,
6140
+ "Core" ,
6141
+ "Desktop"
6142
+ } ;
6143
+
6144
+ private static string GetRequiresPsEditionsToolTip ( string name ) => name switch
6145
+ {
6146
+ "Core" => TabCompletionStrings . RequiresPsEditionCoreDescription ,
6147
+ "Desktop" => TabCompletionStrings . RequiresPsEditionDesktopDescription ,
6148
+ _ => string . Empty
6149
+ } ;
6150
+
6151
+ private static readonly string [ ] s_requiresModuleSpecKeys = new string [ ]
6152
+ {
6153
+ "GUID" ,
6154
+ "MaximumVersion" ,
6155
+ "ModuleName" ,
6156
+ "ModuleVersion" ,
6157
+ "RequiredVersion"
6158
+ } ;
6159
+
6160
+ private static string GetRequiresModuleSpecKeysToolTip ( string name ) => name switch
6161
+ {
6162
+ "GUID" => TabCompletionStrings . RequiresModuleSpecGUIDDescription ,
6163
+ "MaximumVersion" => TabCompletionStrings . RequiresModuleSpecMaximumVersionDescription ,
6164
+ "ModuleName" => TabCompletionStrings . RequiresModuleSpecModuleNameDescription ,
6165
+ "ModuleVersion" => TabCompletionStrings . RequiresModuleSpecModuleVersionDescription ,
6166
+ "RequiredVersion" => TabCompletionStrings . RequiresModuleSpecRequiredVersionDescription ,
6167
+ _ => string . Empty
6139
6168
} ;
6140
6169
6141
6170
private static readonly char [ ] s_hashtableKeyPrefixes = new [ ]
@@ -6180,7 +6209,7 @@ private static List<CompletionResult> CompleteCommentHelp(CompletionContext cont
6180
6209
replacementIndex = context . TokenAtCursor . Extent . StartOffset + lineKeyword . Index ;
6181
6210
replacementLength = lineKeyword . Value . Length ;
6182
6211
6183
- var validKeywords = new HashSet < String > ( s_commentHelpKeywords . Keys , StringComparer . OrdinalIgnoreCase ) ;
6212
+ var validKeywords = new HashSet < string > ( s_commentHelpKeywords , StringComparer . OrdinalIgnoreCase ) ;
6184
6213
foreach ( Match keyword in usedKeywords )
6185
6214
{
6186
6215
if ( keyword == lineKeyword || s_commentHelpAllowedDuplicateKeywords . Contains ( keyword . Value ) )
@@ -6196,7 +6225,8 @@ private static List<CompletionResult> CompleteCommentHelp(CompletionContext cont
6196
6225
{
6197
6226
if ( keyword . StartsWith ( lineKeyword . Value , StringComparison . OrdinalIgnoreCase ) )
6198
6227
{
6199
- result . Add ( new CompletionResult ( keyword , keyword , CompletionResultType . Keyword , s_commentHelpKeywords [ keyword ] ) ) ;
6228
+ string toolTip = GetCommentHelpKeywordsToolTip ( keyword ) ;
6229
+ result . Add ( new CompletionResult ( keyword , keyword , CompletionResultType . Keyword , toolTip ) ) ;
6200
6230
}
6201
6231
}
6202
6232
@@ -6256,46 +6286,66 @@ private static List<CompletionResult> CompleteCommentHelp(CompletionContext cont
6256
6286
return null ;
6257
6287
}
6258
6288
6259
- private static readonly IReadOnlyDictionary < string , string > s_commentHelpKeywords = new SortedList < string , string > ( StringComparer . OrdinalIgnoreCase )
6260
- {
6261
- { "SYNOPSIS" , "A brief description of the function or script. This keyword can be used only once in each topic." } ,
6262
- { "DESCRIPTION" , "A detailed description of the function or script. This keyword can be used only once in each topic." } ,
6263
- { "PARAMETER" , ".PARAMETER <Parameter-Name>\n The description of a parameter. Add a .PARAMETER keyword for each parameter in the function or script syntax." } ,
6264
- { "EXAMPLE" , "A sample command that uses the function or script, optionally followed by sample output and a description. Repeat this keyword for each example." } ,
6265
- { "INPUTS" , "The .NET types of objects that can be piped to the function or script. You can also include a description of the input objects." } ,
6266
- { "OUTPUTS" , "The .NET type of the objects that the cmdlet returns. You can also include a description of the returned objects." } ,
6267
- { "NOTES" , "Additional information about the function or script." } ,
6268
- { "LINK" , "The name of a related topic. Repeat the .LINK keyword for each related topic. The .Link keyword content can also include a URI to an online version of the same help topic." } ,
6269
- { "COMPONENT" , "The name of the technology or feature that the function or script uses, or to which it is related." } ,
6270
- { "ROLE" , "The name of the user role for the help topic." } ,
6271
- { "FUNCTIONALITY" , "The keywords that describe the intended use of the function." } ,
6272
- { "FORWARDHELPTARGETNAME" , ".FORWARDHELPTARGETNAME <Command-Name>\n Redirects to the help topic for the specified command." } ,
6273
- { "FORWARDHELPCATEGORY" , ".FORWARDHELPCATEGORY <Category>\n Specifies the help category of the item in .ForwardHelpTargetName" } ,
6274
- { "REMOTEHELPRUNSPACE" , ".REMOTEHELPRUNSPACE <PSSession-variable>\n Specifies a session that contains the help topic. Enter a variable that contains a PSSession object." } ,
6275
- { "EXTERNALHELP" , ".EXTERNALHELP <XML Help File>\n The .ExternalHelp keyword is required when a function or script is documented in XML files." }
6289
+ private static readonly string [ ] s_commentHelpKeywords = new string [ ]
6290
+ {
6291
+ "COMPONENT" ,
6292
+ "DESCRIPTION" ,
6293
+ "EXAMPLE" ,
6294
+ "EXTERNALHELP" ,
6295
+ "FORWARDHELPCATEGORY" ,
6296
+ "FORWARDHELPTARGETNAME" ,
6297
+ "FUNCTIONALITY" ,
6298
+ "INPUTS" ,
6299
+ "LINK" ,
6300
+ "NOTES" ,
6301
+ "OUTPUTS" ,
6302
+ "PARAMETER" ,
6303
+ "REMOTEHELPRUNSPACE" ,
6304
+ "ROLE" ,
6305
+ "SYNOPSIS"
6306
+ } ;
6307
+
6308
+ private static string GetCommentHelpKeywordsToolTip ( string name ) => name switch
6309
+ {
6310
+ "COMPONENT" => TabCompletionStrings . CommentHelpCOMPONENTKeywordDescription ,
6311
+ "DESCRIPTION" => TabCompletionStrings . CommentHelpDESCRIPTIONKeywordDescription ,
6312
+ "EXAMPLE" => TabCompletionStrings . CommentHelpEXAMPLEKeywordDescription ,
6313
+ "EXTERNALHELP" => TabCompletionStrings . CommentHelpEXTERNALHELPKeywordDescription ,
6314
+ "FORWARDHELPCATEGORY" => TabCompletionStrings . CommentHelpFORWARDHELPCATEGORYKeywordDescription ,
6315
+ "FORWARDHELPTARGETNAME" => TabCompletionStrings . CommentHelpFORWARDHELPTARGETNAMEKeywordDescription ,
6316
+ "FUNCTIONALITY" => TabCompletionStrings . CommentHelpFUNCTIONALITYKeywordDescription ,
6317
+ "INPUTS" => TabCompletionStrings . CommentHelpINPUTSKeywordDescription ,
6318
+ "LINK" => TabCompletionStrings . CommentHelpLINKKeywordDescription ,
6319
+ "NOTES" => TabCompletionStrings . CommentHelpNOTESKeywordDescription ,
6320
+ "OUTPUTS" => TabCompletionStrings . CommentHelpOUTPUTSKeywordDescription ,
6321
+ "PARAMETER" => TabCompletionStrings . CommentHelpPARAMETERKeywordDescription ,
6322
+ "REMOTEHELPRUNSPACE" => TabCompletionStrings . CommentHelpREMOTEHELPRUNSPACEKeywordDescription ,
6323
+ "ROLE" => TabCompletionStrings . CommentHelpROLEKeywordDescription ,
6324
+ "SYNOPSIS" => TabCompletionStrings . CommentHelpSYNOPSISKeywordDescription ,
6325
+ _ => string . Empty
6276
6326
} ;
6277
6327
6278
6328
private static readonly HashSet < string > s_commentHelpAllowedDuplicateKeywords = new ( StringComparer . OrdinalIgnoreCase )
6279
6329
{
6280
- "PARAMETER" ,
6281
6330
"EXAMPLE" ,
6282
- "LINK"
6331
+ "LINK" ,
6332
+ "PARAMETER"
6283
6333
} ;
6284
6334
6285
6335
private static readonly string [ ] s_commentHelpForwardCategories = new string [ ]
6286
6336
{
6287
6337
"Alias" ,
6338
+ "All" ,
6288
6339
"Cmdlet" ,
6289
- "HelpFile" ,
6340
+ "ExternalScript" ,
6341
+ "FAQ" ,
6342
+ "Filter" ,
6290
6343
"Function" ,
6291
- "Provider" ,
6292
6344
"General" ,
6293
- "FAQ" ,
6294
6345
"Glossary" ,
6295
- "ScriptCommand" ,
6296
- "ExternalScript" ,
6297
- "Filter" ,
6298
- "All"
6346
+ "HelpFile" ,
6347
+ "Provider" ,
6348
+ "ScriptCommand"
6299
6349
} ;
6300
6350
6301
6351
private static FunctionDefinitionAst GetCommentHelpFunctionTarget ( CompletionContext context )
@@ -8066,7 +8116,7 @@ internal static List<CompletionResult> CompleteHashtableKey(CompletionContext co
8066
8116
}
8067
8117
8068
8118
var result = new List < CompletionResult > ( ) ;
8069
- foreach ( var key in s_requiresModuleSpecKeys . Keys )
8119
+ foreach ( string key in s_requiresModuleSpecKeys )
8070
8120
{
8071
8121
if ( excludedKeys . Contains ( key )
8072
8122
|| ( wordToComplete is not null && ! key . StartsWith ( wordToComplete , StringComparison . OrdinalIgnoreCase ) )
@@ -8075,7 +8125,10 @@ internal static List<CompletionResult> CompleteHashtableKey(CompletionContext co
8075
8125
{
8076
8126
continue ;
8077
8127
}
8078
- result . Add ( new CompletionResult ( key , key , CompletionResultType . Property , s_requiresModuleSpecKeys [ key ] ) ) ;
8128
+
8129
+ string toolTip = GetRequiresModuleSpecKeysToolTip ( key ) ;
8130
+
8131
+ result . Add ( new CompletionResult ( key , key , CompletionResultType . Property , toolTip ) ) ;
8079
8132
}
8080
8133
8081
8134
return result ;
@@ -8327,7 +8380,9 @@ private static List<CompletionResult> GetSpecialHashTableKeyMembers(HashSet<stri
8327
8380
{
<
341A
div aria-hidden="true" style="left:-2px" class="position-absolute top-0 d-flex user-select-none DiffLineTableCellParts-module__in-progress-comment-indicator--hx3m3">8328
8381
if ( ( string . IsNullOrEmpty ( wordToComplete ) || key . StartsWith ( wordToComplete , StringComparison . OrdinalIgnoreCase ) ) && ! excludedKeys . Contains ( key ) )
8329
8382
{
8330
- result . Add ( new CompletionResult ( key , key , CompletionResultType . Property , key ) ) ;
8383
+ string toolTip = GetHashtableKeyDescriptionToolTip ( key ) ;
8384
+
8385
+ result . Add ( new CompletionResult ( key , key , CompletionResultType . Property , toolTip ) ) ;
8331
8386
}
8332
8387
}
8333
8388
@@ -8339,6 +8394,31 @@ private static List<CompletionResult> GetSpecialHashTableKeyMembers(HashSet<stri
8339
8394
return result ;
8340
8395
}
8341
8396
8397
+ private static string GetHashtableKeyDescriptionToolTip ( string name ) => name switch
8398
+ {
8399
+ "Alignment" => TabCompletionStrings . AlignmentHashtableKeyDescription ,
8400
+ "Ascending" => TabCompletionStrings . AscendingHashtableKeyDescription ,
8401
+ "Data" => TabCompletionStrings . DataHashtableKeyDescription ,
8402
+ "Depth" => TabCompletionStrings . DepthHashtableKeyDescription ,
8403
+ "Descending" => TabCompletionStrings . DescendingHashtableKeyDescription ,
8404
+ "EndTime" => TabCompletionStrings . EndTimeHashtableKeyDescription ,
8405
+ "Expression" => TabCompletionStrings . ExpressionHashtableKeyDescription ,
8406
+ "FormatString" => TabCompletionStrings . FormatStringHashtableKeyDescription ,
8407
+ "ID" => TabCompletionStrings . IDHashtableKeyDescription ,
8408
+ "Keywords" => TabCompletionStrings . KeywordsHashtableKeyDescription ,
8409
+ "Label" => TabCompletionStrings . LabelHashtableKeyDescription ,
8410
+ "Level" => TabCompletionStrings . LevelHashtableKeyDescription ,
8411
+ "LogName" => TabCompletionStrings . LogNameHashtableKeyDescription ,
8412
+ "Name" => TabCompletionStrings . NameHashtableKeyDescription ,
8413
+ "Path" => TabCompletionStrings . PathHashtableKeyDescription ,
8414
+ "ProviderName" => TabCompletionStrings . ProviderNameHashtableKeyDescription ,
8415
+ "StartTime" => TabCompletionStrings . StartTimeHashtableKeyDescription ,
8416
+ "SuppressHashFilter" => TabCompletionStrings . SuppressHashFilterHashtableKeyDescription ,
8417
+ "UserID" => TabCompletionStrings . UserIDHashtableKeyDescription ,
8418
+ "Width" => TabCompletionStrings . WidthHashtableKeyDescription ,
8419
+ _ => string . Empty
8420
+ } ;
8421
+
8342
8422
#endregion Hashtable Keys
8343
8423
8344
8424
#region Helpers
0 commit comments