Skip to content

Commit bca0702

Browse files
StartAutomatingStartAutomating
authored andcommitted
Formatting the AST (Fixes #166)
1 parent d490187 commit bca0702

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

PipeScript.types.ps1xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,26 @@ while ($thisParent) {
2424

2525
</Script>
2626
</ScriptMethod>
27+
<ScriptProperty>
28+
<Name>Tokens</Name>
29+
<GetScriptBlock>
30+
$text = $this.Extent.ToString()
31+
32+
$previousToken = $null
33+
$tokenCount = 0
34+
@(foreach ($token in [Management.Automation.PSParser]::Tokenize($text, [ref]$null)) {
35+
Add-Member NoteProperty Text $text -Force -InputObject $token
36+
Add-Member NoteProperty PreviousToken $previousToken -Force -InputObject $token
37+
if ($token.Type -in 'Variable', 'String') {
38+
$realContent = $text.Substring($token.Start, $token.Length)
39+
Add-Member NoteProperty Content $realContent -Force -InputObject $token
40+
}
41+
$previousToken = $token
42+
$tokenCount++
43+
$token
44+
})
45+
</GetScriptBlock>
46+
</ScriptProperty>
2747
</Members>
2848
</Type>
2949
<Type>

0 commit comments

Comments
 (0)