Skip to content

Commit

Permalink
Compare completions for splatted variable examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ninmonkey committed Feb 26, 2024
1 parent b2e382e commit c8c73f1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
$src = @'
Import-Module DbaTools -passthru
$splatExport = @{
# comment
}
Export-DbaLogin @splatExport
'@

$Tokens = $null
$AstErrors = $Null
$Doc = [Parser]::ParseInput(
<# input : #> $src,
<# tokens : #> [ref] $tokens,
<# errors : #> [ref] $AstErrors )

$find_splats =
$doc.FindAll( {
param( $Inp )
return $Inp -is [VariableExpressionAst] -and
$Inp.Splatted
}, $true )

$find_splats | Ft

<#
outputs:
VariablePath Splatted StaticType Extent Parent
------------ -------- ---------- ------ ------
splatExport True System.Object @splatExport Export-DbaLogin @splatExport
#>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
$src = @'
# About: tab expansion version
$src = @'
Import-Module DbaTools -passthru
$splatExport = @{
# comment
Expand Down

0 comments on commit c8c73f1

Please sign in to comment.