diff --git a/snippets/PowerShell.json b/snippets/PowerShell.json index dd7317d89b..a7fffc4551 100644 --- a/snippets/PowerShell.json +++ b/snippets/PowerShell.json @@ -1019,5 +1019,62 @@ "}$0" ], "description": "Pester - It block" + }, + "ArgumentCompleterAttribute with ScriptBlock": { + "prefix": "completer-attribute", + "body": [ + "[ArgumentCompleter({", + "\t[OutputType([System.Management.Automation.CompletionResult])] # zero to many", + "\tparam(", + "\t\t[string] \\$CommandName,", + "\t\t[string] \\$ParameterName,", + "\t\t[string] \\$WordToComplete,", + "\t\t[System.Management.Automation.Language.CommandAst] \\$CommandAst,", + "\t\t[System.Collections.IDictionary] \\$FakeBoundParameters", + "\t)", + "\t", + "\t${0:$TM_SELECTED_TEXT}", + "})]" + ], + "description": "ArgumentCompleter parameter attribute with script block definition" + }, + "ArgumentCompleterAttribute ScriptBlock": { + "prefix": "completer-scriptblock", + "body": [ + "{", + "\t[OutputType([System.Management.Automation.CompletionResult])] # zero to many", + "\tparam(", + "\t\t[string] \\$CommandName,", + "\t\t[string] \\$ParameterName,", + "\t\t[string] \\$WordToComplete,", + "\t\t[System.Management.Automation.Language.CommandAst] \\$CommandAst,", + "\t\t[System.Collections.IDictionary] \\$FakeBoundParameters", + "\t)", + "\t", + "\t${0:$TM_SELECTED_TEXT}", + "}" + ], + "description": "ArgumentCompleter parameter attribute script block definition" + }, + "IArgumentCompleter Class": { + "prefix": "completer-class", + "body": [ + "class ${1:ArgumentCompleter} : System.Management.Automation.IArgumentCompleter {", + "\t[System.Collections.Generic.IEnumerable[System.Management.Automation.CompletionResult]] CompleteArgument(", + "\t\t[string] \\$CommandName,", + "\t\t[string] \\$ParameterName,", + "\t\t[string] \\$WordToComplete,", + "\t\t[System.Management.Automation.Language.CommandAst] \\$CommandAst,", + "\t\t[System.Collections.IDictionary] \\$FakeBoundParameters", + "\t) {", + "\t\t\\$CompletionResults = [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new()", + "\t\t", + "\t\t${0:$TM_SELECTED_TEXT}", + "\t\t", + "\t\treturn \\$CompletionResults", + "\t}", + "}" + ], + "description": "IArgumentCompleter implementation class definition" } }