mirror of
https://github.com/alecthomas/chroma.git
synced 2025-03-17 20:58:08 +02:00
More improvements to PowerShell lexer (#708)
This commit is contained in:
parent
94d785889c
commit
f07788e465
@ -6,6 +6,7 @@
|
||||
<alias>ps1</alias>
|
||||
<alias>psm1</alias>
|
||||
<alias>psd1</alias>
|
||||
<alias>pwsh</alias>
|
||||
<filename>*.ps1</filename>
|
||||
<filename>*.psm1</filename>
|
||||
<filename>*.psd1</filename>
|
||||
@ -22,6 +23,15 @@
|
||||
<rule pattern="\s+">
|
||||
<token type="Text"/>
|
||||
</rule>
|
||||
<rule pattern="(\s*)(#)(requires)(\s+)">
|
||||
<bygroups>
|
||||
<token type="TextWhitespace"/>
|
||||
<token type="Comment"/>
|
||||
<token type="Keyword"/>
|
||||
<token type="TextWhitespace"/>
|
||||
</bygroups>
|
||||
<push state="requires"/>
|
||||
</rule>
|
||||
<rule pattern="^(\s*#[#\s]*)(\.(?:component|description|example|externalhelp|forwardhelpcategory|forwardhelptargetname|functionality|inputs|link|notes|outputs|parameter|remotehelprunspace|role|synopsis))([^\n]*$)">
|
||||
<bygroups>
|
||||
<token type="Comment"/>
|
||||
@ -46,6 +56,9 @@
|
||||
<rule pattern="@'\n.*?\n'@">
|
||||
<token type="LiteralStringHeredoc"/>
|
||||
</rule>
|
||||
<rule pattern="@(?=\(|{)|\$(?=\()">
|
||||
<token type="NameVariableMagic"/>
|
||||
</rule>
|
||||
<rule pattern="`[\'"$@-]">
|
||||
<token type="Punctuation"/>
|
||||
</rule>
|
||||
@ -56,13 +69,42 @@
|
||||
<rule pattern="'([^']|'')*'">
|
||||
<token type="LiteralStringSingle"/>
|
||||
</rule>
|
||||
<rule pattern="(?<!\S)(function|filter|workflow)(\s*)(global:|script:|private:|env:)?(\w\S*\b)">
|
||||
<bygroups>
|
||||
<token type="KeywordDeclaration"/>
|
||||
<token type="TextWhitespace"/>
|
||||
<token type="NameVariableMagic"/>
|
||||
<token type="NameBuiltin"/>
|
||||
</bygroups>
|
||||
</rule>
|
||||
<rule pattern="(?<!\S)(class|configuration)(\s+)(\w\S*)(\s*)(:*)">
|
||||
<bygroups>
|
||||
<token type="KeywordDeclaration"/>
|
||||
<token type="TextWhitespace"/>
|
||||
<token type="NameBuiltin"/>
|
||||
<token type="NameBuiltin"/>
|
||||
<token type="NameBuiltin"/>
|
||||
</bygroups>
|
||||
</rule>
|
||||
<rule pattern="\$false|\$null|\$true(?=\b)">
|
||||
<token type="NameVariableMagic"/>
|
||||
</rule>
|
||||
<rule pattern="(\$|@@|@)((global|script|private|env):)?\w+">
|
||||
<token type="NameVariable"/>
|
||||
</rule>
|
||||
<rule pattern="(parameter|validatenotnullorempty|validatescript|validaterange|validateset|validaterange|validatepattern|validatelength|validatecount|validatenotnullorempty|validatescript|cmdletbinding|alias)\b">
|
||||
<token type="NameBuiltin"/>
|
||||
</rule>
|
||||
<rule pattern="[a-z]\w*-[a-z]\w*\b">
|
||||
<token type="NameBuiltin"/>
|
||||
</rule>
|
||||
<rule pattern="(while|validateset|validaterange|validatepattern|validatelength|validatecount|until|trap|switch|return|ref|process|param|parameter|in|if|global:|function|foreach|for|finally|filter|end|elseif|else|dynamicparam|do|default|continue|cmdletbinding|break|begin|alias|\?|%|#script|#private|#local|#global|mandatory|parametersetname|position|valuefrompipeline|valuefrompipelinebypropertyname|valuefromremainingarguments|helpmessage|try|catch|throw)\b">
|
||||
<rule pattern="(mandatory|parametersetname|position|helpmessage|valuefrompipeline|valuefrompipelinebypropertyname|valuefromremainingarguments|dontshow)\b">
|
||||
<token type="NameAttribute"/>
|
||||
</rule>
|
||||
<rule pattern="(confirmimpact|defaultparametersetname|helpuri|supportspaging|supportsshouldprocess|positionalbinding)\b">
|
||||
<token type="NameAttribute"/>
|
||||
</rule>
|
||||
<rule pattern="(while|until|trap|switch|return|ref|process|param|parameter|in|if|global:|foreach|for|finally|filter|end|elseif|else|dynamicparam|do|default|continue|break|begin|\?|%|#script|#private|#local|#global|try|catch|throw)\b">
|
||||
<token type="Keyword"/>
|
||||
</rule>
|
||||
<rule pattern="-(and|as|band|bnot|bor|bxor|casesensitive|ccontains|ceq|cge|cgt|cle|clike|clt|cmatch|cne|cnotcontains|cnotlike|cnotmatch|contains|creplace|eq|exact|f|file|ge|gt|icontains|ieq|ige|igt|ile|ilike|ilt|imatch|ine|inotcontains|inotlike|inotmatch|ireplace|is|isnot|le|like|lt|match|ne|not|notcontains|notlike|notmatch|or|regex|replace|wildcard)\b">
|
||||
@ -71,19 +113,47 @@
|
||||
<rule pattern="(ac|asnp|cat|cd|cfs|chdir|clc|clear|clhy|cli|clp|cls|clv|cnsn|compare|copy|cp|cpi|cpp|curl|cvpa|dbp|del|diff|dir|dnsn|ebp|echo|epal|epcsv|epsn|erase|etsn|exsn|fc|fhx|fl|foreach|ft|fw|gal|gbp|gc|gci|gcm|gcs|gdr|ghy|gi|gjb|gl|gm|gmo|gp|gps|gpv|group|gsn|gsnp|gsv|gu|gv|gwmi|h|history|icm|iex|ihy|ii|ipal|ipcsv|ipmo|ipsn|irm|ise|iwmi|iwr|kill|lp|ls|man|md|measure|mi|mount|move|mp|mv|nal|ndr|ni|nmo|npssc|nsn|nv|ogv|oh|popd|ps|pushd|pwd|r|rbp|rcjb|rcsn|rd|rdr|ren|ri|rjb|rm|rmdir|rmo|rni|rnp|rp|rsn|rsnp|rujb|rv|rvpa|rwmi|sajb|sal|saps|sasv|sbp|sc|select|set|shcm|si|sl|sleep|sls|sort|sp|spjb|spps|spsv|start|sujb|sv|swmi|tee|trcm|type|wget|where|wjb|write)\s">
|
||||
<token type="NameBuiltin"/>
|
||||
</rule>
|
||||
<rule pattern="\[[a-z_\[][\w. `,\[\]]*\]">
|
||||
<token type="NameConstant"/>
|
||||
<rule pattern="(\[)([a-z_\[][\w. `,\[\]]*)(\])">
|
||||
<bygroups>
|
||||
<token type="Punctuation"/>
|
||||
<token type="NameConstant"/>
|
||||
<token type="Punctuation"/>
|
||||
</bygroups>
|
||||
</rule>
|
||||
<rule pattern="-[a-z_]\w*">
|
||||
<rule pattern="(?<!\[)(?<=\S[^\*|\n]\.)\w+(?=\s+|\(|\{|\.)">
|
||||
<token type="NameProperty"/>
|
||||
</rule>
|
||||
<rule pattern="(?<!\w)([-+]?(?:[0-9]+)?\.?[0-9]+(?:(?:e|E)[0-9]+)?(?:F|f|D|d|M|m)?)((?i:[kmgtp]b)?)\b">
|
||||
<bygroups>
|
||||
<token type="LiteralNumberFloat"/>
|
||||
<token type="Punctuation"/>
|
||||
</bygroups>
|
||||
</rule>
|
||||
<rule pattern="-[a-z_]\w*:*">
|
||||
<token type="Name"/>
|
||||
</rule>
|
||||
<rule pattern="\w+">
|
||||
<token type="Name"/>
|
||||
</rule>
|
||||
<rule pattern="[.,;@{}\[\]$()=+*/\\&%!~?^`|<>-]|::">
|
||||
<rule pattern="[.,;@{}\[\]$()=+*/\\&%!~?^\x60|<>-]|::">
|
||||
<token type="Punctuation"/>
|
||||
</rule>
|
||||
</state>
|
||||
<state name="requires">
|
||||
<rule pattern="\s*\n|\s*$">
|
||||
<token type="TextWhitespace"/>
|
||||
<pop depth="1"/>
|
||||
</rule>
|
||||
<rule pattern="-(?i:modules|pssnapin|runasadministrator|ahellid|version|assembly|psedition)">
|
||||
<token type="KeywordDeclaration"/>
|
||||
</rule>
|
||||
<rule pattern="-\S*\b">
|
||||
<token type="Comment"/>
|
||||
</rule>
|
||||
<rule pattern="\s+(\S+)">
|
||||
<token type="NameAttribute"/>
|
||||
</rule>
|
||||
</state>
|
||||
<state name="child">
|
||||
<rule pattern="\)">
|
||||
<token type="Punctuation"/>
|
||||
@ -101,8 +171,12 @@
|
||||
<token type="CommentMultiline"/>
|
||||
<pop depth="1"/>
|
||||
</rule>
|
||||
<rule pattern="\.(component|description|example|externalhelp|forwardhelpcategory|forwardhelptargetname|functionality|inputs|link|notes|outputs|parameter|remotehelprunspace|role|synopsis)">
|
||||
<token type="LiteralStringDoc"/>
|
||||
<rule pattern="(\s*\.)(component|description|example|externalhelp|forwardhelpcategory|forwardhelptargetname|functionality|inputs|link|notes|outputs|parameter|remotehelprunspace|role|synopsis)(\s*$)">
|
||||
<bygroups>
|
||||
<token type="CommentMultiline"/>
|
||||
<token type="LiteralStringDoc"/>
|
||||
<token type="CommentMultiline"/>
|
||||
</bygroups>
|
||||
</rule>
|
||||
<rule pattern="[#&.]">
|
||||
<token type="CommentMultiline"/>
|
||||
@ -119,7 +193,7 @@
|
||||
<token type="Punctuation"/>
|
||||
<push state="child"/>
|
||||
</rule>
|
||||
<rule pattern="(\$)((global|script|private|env):)?\w+">
|
||||
<rule pattern="((\$)((global|script|private|env):)?\w+)|((\$){((global|script|private|env):)?\w+})">
|
||||
<token type="NameVariable"/>
|
||||
</rule>
|
||||
<rule pattern="""">
|
||||
@ -142,7 +216,7 @@
|
||||
<token type="Punctuation"/>
|
||||
<push state="child"/>
|
||||
</rule>
|
||||
<rule pattern="(\$)((global|script|private|env):)?\w+">
|
||||
<rule pattern="((\$)((global|script|private|env):)?\w+)|((\$){((global|script|private|env):)?\w+})">
|
||||
<token type="NameVariable"/>
|
||||
</rule>
|
||||
<rule pattern="[^@\n]+"]">
|
||||
|
87
lexers/testdata/powershell.actual
vendored
87
lexers/testdata/powershell.actual
vendored
@ -1,5 +1,82 @@
|
||||
Get-ChildItem -Recurse -Force -ErrorAction SilentlyContinue -Name -Path C:\ *.txt
|
||||
$x = "Here is a $var inside a string"
|
||||
$x = @"
|
||||
Here is a $var inside a here-string
|
||||
"@
|
||||
Get-ChildItem -Recurse -Force -ErrorAction SilentlyContinue -Name -Path C:\ *.txt
|
||||
|
||||
#Requires -modules ModuleName
|
||||
#Requires -Assembly "System.Management.Automation, Version=1.0.0.0,Culture=neutral, PublicKeyToken=31bf3856ad364e35"
|
||||
#Requires -Modules @{ ModuleName="ModuleName"; ModuleVersion="1.2.3" }
|
||||
#Requires -PSSnapin SnapinName -version 1.2
|
||||
#Requires -RunAsAdministrator
|
||||
#Requires -WrongParameter ParamValue
|
||||
|
||||
<#
|
||||
Multiline comment
|
||||
.DESCRIPTION
|
||||
This is a description
|
||||
#>
|
||||
|
||||
# this is a comment
|
||||
|
||||
function test { }
|
||||
class test {}
|
||||
class test2 : test { }
|
||||
|
||||
@"
|
||||
double quoted $MyVar here string
|
||||
"@
|
||||
|
||||
@"
|
||||
double quoted ${MyVar} here string
|
||||
"@
|
||||
|
||||
@"
|
||||
double quoted $(Get-Stuff -Param1 $MyVar ) here string
|
||||
"@
|
||||
|
||||
@'
|
||||
single quoted $(Get-Stuff -Param1 $MyVar ) here string
|
||||
'@
|
||||
|
||||
'Single quoted string $MyVar'
|
||||
"Double quoted string $MyVar"
|
||||
"Double quoted string $(Get-Stuff -Param1 $MyVar )"
|
||||
"Double quoted string ${var}"
|
||||
|
||||
$HashTable = @{
|
||||
'Something' = $Var
|
||||
'Else' = 'string'
|
||||
}
|
||||
|
||||
$myvar.'property name in string'
|
||||
[string]::UseMethod(12.34)
|
||||
15gb
|
||||
@{}
|
||||
@()
|
||||
$()
|
||||
$test = C:\test
|
||||
$MyVar = Get-Something -SwitchParam:$false
|
||||
$MyVar.property
|
||||
$MyVar.property.property.somemethod()
|
||||
$global:test
|
||||
$null
|
||||
$true
|
||||
$false
|
||||
|
||||
Configuration ConfigurationName
|
||||
{
|
||||
Import-DSCResource -ModuleName MyModule
|
||||
}
|
||||
|
||||
function Get-Stuff {
|
||||
[CmdletBinding(SupportsShouldProcess=$true)]
|
||||
param (
|
||||
[Parameter(Mandatory=$true, DontShow)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[ValidateScript({ $_ -ne $null })]
|
||||
[ValidateRange(0, [int]::MaxValue)]
|
||||
[Microsoft.PowerShell.Commands.WebRequestMethod]$Param1 = 'Get'
|
||||
)
|
||||
|
||||
Process
|
||||
{
|
||||
if ($MyVar -lt (Get-Date).AddSeconds([int](12.4 / 2))) {}
|
||||
}
|
||||
}
|
303
lexers/testdata/powershell.expected
vendored
303
lexers/testdata/powershell.expected
vendored
@ -12,26 +12,311 @@
|
||||
{"type":"Name","value":"-Name"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Name","value":"-Path"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Name","value":"C:"},
|
||||
{"type":"Punctuation","value":"\\"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":"*."},
|
||||
{"type":"Name","value":"txt"},
|
||||
{"type":"Text","value":"\n\n"},
|
||||
{"type":"Comment","value":"#"},
|
||||
{"type":"Keyword","value":"Requires"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"KeywordDeclaration","value":"-modules"},
|
||||
{"type":"NameAttribute","value":" ModuleName"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"Comment","value":"#"},
|
||||
{"type":"Keyword","value":"Requires"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"KeywordDeclaration","value":"-Assembly"},
|
||||
{"type":"NameAttribute","value":" \"System.Management.Automation, Version=1.0.0.0,Culture=neutral, PublicKeyToken=31bf3856ad364e35\""},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"Comment","value":"#"},
|
||||
{"type":"Keyword","value":"Requires"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"KeywordDeclaration","value":"-Modules"},
|
||||
{"type":"NameAttribute","value":" @{ ModuleName=\"ModuleName\"; ModuleVersion=\"1.2.3\" }"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"Comment","value":"#"},
|
||||
{"type":"Keyword","value":"Requires"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"KeywordDeclaration","value":"-PSSnapin"},
|
||||
{"type":"NameAttribute","value":" SnapinName -version 1.2"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"Comment","value":"#"},
|
||||
{"type":"Keyword","value":"Requires"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"KeywordDeclaration","value":"-RunAsAdministrator"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"Comment","value":"#"},
|
||||
{"type":"Keyword","value":"Requires"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Comment","value":"-WrongParameter"},
|
||||
{"type":"NameAttribute","value":" ParamValue"},
|
||||
{"type":"TextWhitespace","value":"\n\n"},
|
||||
{"type":"CommentMultiline","value":"\u003c#\n Multiline comment\n ."},
|
||||
{"type":"LiteralStringDoc","value":"DESCRIPTION"},
|
||||
{"type":"CommentMultiline","value":"\n This is a description\n#\u003e"},
|
||||
{"type":"Text","value":"\n\n"},
|
||||
{"type":"Comment","value":"# this is a comment"},
|
||||
{"type":"Text","value":"\n\n"},
|
||||
{"type":"KeywordDeclaration","value":"function"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"NameBuiltin","value":"test"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":"{"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":"}"},
|
||||
{"type":"Text","value":"\n"},
|
||||
{"type":"NameVariable","value":"$x"},
|
||||
{"type":"KeywordDeclaration","value":"class"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"NameBuiltin","value":"test "},
|
||||
{"type":"Punctuation","value":"{}"},
|
||||
{"type":"Text","value":"\n"},
|
||||
{"type":"KeywordDeclaration","value":"class"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"NameBuiltin","value":"test2 :"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Name","value":"test"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":"{"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":"}"},
|
||||
{"type":"Text","value":"\n\n"},
|
||||
{"type":"LiteralStringHeredoc","value":"@\"\ndouble quoted "},
|
||||
{"type":"NameVariable","value":"$MyVar"},
|
||||
{"type":"LiteralStringHeredoc","value":" here string\n\"@"},
|
||||
{"type":"Text","value":"\n\n"},
|
||||
{"type":"LiteralStringHeredoc","value":"@\"\ndouble quoted "},
|
||||
{"type":"NameVariable","value":"${MyVar}"},
|
||||
{"type":"LiteralStringHeredoc","value":" here string\n\"@"},
|
||||
{"type":"Text","value":"\n\n"},
|
||||
{"type":"LiteralStringHeredoc","value":"@\"\ndouble quoted "},
|
||||
{"type":"Punctuation","value":"$("},
|
||||
{"type":"NameBuiltin","value":"Get-Stuff"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Name","value":"-Param1"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"NameVariable","value":"$MyVar"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":")"},
|
||||
{"type":"LiteralStringHeredoc","value":" here string\n\"@"},
|
||||
{"type":"Text","value":"\n\n"},
|
||||
{"type":"LiteralStringHeredoc","value":"@'\nsingle quoted $(Get-Stuff -Param1 $MyVar ) here string\n'@"},
|
||||
{"type":"Text","value":"\n\n"},
|
||||
{"type":"LiteralStringSingle","value":"'Single quoted string $MyVar'"},
|
||||
{"type":"Text","value":"\n"},
|
||||
{"type":"LiteralStringDouble","value":"\"Double quoted string "},
|
||||
{"type":"NameVariable","value":"$MyVar"},
|
||||
{"type":"LiteralStringDouble","value":"\""},
|
||||
{"type":"Text","value":"\n"},
|
||||
{"type":"LiteralStringDouble","value":"\"Double quoted string "},
|
||||
{"type":"Punctuation","value":"$("},
|
||||
{"type":"NameBuiltin","value":"Get-Stuff"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Name","value":"-Param1"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"NameVariable","value":"$MyVar"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":")"},
|
||||
{"type":"LiteralStringDouble","value":"\""},
|
||||
{"type":"Text","value":"\n"},
|
||||
{"type":"LiteralStringDouble","value":"\"Double quoted string "},
|
||||
{"type":"NameVariable","value":"${var}"},
|
||||
{"type":"LiteralStringDouble","value":"\""},
|
||||
{"type":"Text","value":"\n\n"},
|
||||
{"type":"NameVariable","value":"$HashTable"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":"="},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"NameVariableMagic","value":"@"},
|
||||
{"type":"Punctuation","value":"{"},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"LiteralStringSingle","value":"'Something'"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":"="},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"LiteralStringDouble","value":"\"Here is a "},
|
||||
{"type":"NameVariable","value":"$var"},
|
||||
{"type":"LiteralStringDouble","value":" inside a string\""},
|
||||
{"type":"NameVariable","value":"$Var"},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"LiteralStringSingle","value":"'Else'"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":"="},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"LiteralStringSingle","value":"'string'"},
|
||||
{"type":"Text","value":"\n"},
|
||||
{"type":"NameVariable","value":"$x"},
|
||||
{"type":"Punctuation","value":"}"},
|
||||
{"type":"Text","value":"\n\n"},
|
||||
{"type":"NameVariable","value":"$myvar"},
|
||||
{"type":"Punctuation","value":"."},
|
||||
{"type":"LiteralStringSingle","value":"'property name in string'"},
|
||||
{"type":"Text","value":"\n"},
|
||||
{"type":"Punctuation","value":"["},
|
||||
{"type":"NameConstant","value":"string"},
|
||||
{"type":"Punctuation","value":"]::"},
|
||||
{"type":"Name","value":"UseMethod"},
|
||||
{"type":"Punctuation","value":"("},
|
||||
{"type":"LiteralNumberFloat","value":"12.34"},
|
||||
{"type":"Punctuation","value":")"},
|
||||
{"type":"Text","value":"\n"},
|
||||
{"type":"LiteralNumberFloat","value":"15"},
|
||||
{"type":"Punctuation","value":"gb"},
|
||||
{"type":"Text","value":"\n"},
|
||||
{"type":"NameVariableMagic","value":"@"},
|
||||
{"type":"Punctuation","value":"{}"},
|
||||
{"type":"Text","value":"\n"},
|
||||
{"type":"NameVariableMagic","value":"@"},
|
||||
{"type":"Punctuation","value":"()"},
|
||||
{"type":"Text","value":"\n"},
|
||||
{"type":"NameVariableMagic","value":"$"},
|
||||
{"type":"Punctuation","value":"()"},
|
||||
{"type":"Text","value":"\n"},
|
||||
{"type":"NameVariable","value":"$test"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":"="},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"LiteralStringHeredoc","value":"@\"\nHere is a "},
|
||||
{"type":"NameVariable","value":"$var"},
|
||||
{"type":"LiteralStringHeredoc","value":" inside a here-string\n\"@"}
|
||||
{"type":"Name","value":"C:"},
|
||||
{"type":"Punctuation","value":"\\"},
|
||||
{"type":"Name","value":"test"},
|
||||
{"type":"Text","value":"\n"},
|
||||
{"type":"NameVariable","value":"$MyVar"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":"="},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"NameBuiltin","value":"Get-Something"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Name","value":"-SwitchParam:"},
|
||||
{"type":"NameVariableMagic","value":"$false"},
|
||||
{"type":"Text","value":"\n"},
|
||||
{"type":"NameVariable","value":"$MyVar"},
|
||||
{"type":"Punctuation","value":"."},
|
||||
{"type":"NameProperty","value":"property"},
|
||||
{"type":"Text","value":"\n"},
|
||||
{"type":"NameVariable","value":"$MyVar"},
|
||||
{"type":"Punctuation","value":"."},
|
||||
{"type":"NameProperty","value":"property"},
|
||||
{"type":"Punctuation","value":"."},
|
||||
{"type":"NameProperty","value":"property"},
|
||||
{"type":"Punctuation","value":"."},
|
||||
{"type":"NameProperty","value":"somemethod"},
|
||||
{"type":"Punctuation","value":"()"},
|
||||
{"type":"Text","value":"\n"},
|
||||
{"type":"NameVariable","value":"$global:test"},
|
||||
{"type":"Text","value":"\n"},
|
||||
{"type":"NameVariableMagic","value":"$null"},
|
||||
{"type":"Text","value":"\n"},
|
||||
{"type":"NameVariableMagic","value":"$true"},
|
||||
{"type":"Text","value":"\n"},
|
||||
{"type":"NameVariableMagic","value":"$false"},
|
||||
{"type":"Text","value":"\n\n"},
|
||||
{"type":"KeywordDeclaration","value":"Configuration"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"NameBuiltin","value":"ConfigurationName\n"},
|
||||
{"type":"Punctuation","value":"{"},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"NameBuiltin","value":"Import-DSCResource"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Name","value":"-ModuleName"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Name","value":"MyModule"},
|
||||
{"type":"Text","value":"\n"},
|
||||
{"type":"Punctuation","value":"}"},
|
||||
{"type":"Text","value":"\n\n"},
|
||||
{"type":"KeywordDeclaration","value":"function"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"NameBuiltin","value":"Get-Stuff"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":"{"},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"Punctuation","value":"["},
|
||||
{"type":"NameBuiltin","value":"CmdletBinding"},
|
||||
{"type":"Punctuation","value":"("},
|
||||
{"type":"NameAttribute","value":"SupportsShouldProcess"},
|
||||
{"type":"Punctuation","value":"="},
|
||||
{"type":"NameVariableMagic","value":"$true"},
|
||||
{"type":"Punctuation","value":")]"},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"Keyword","value":"param"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":"("},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"Punctuation","value":"["},
|
||||
{"type":"NameBuiltin","value":"Parameter"},
|
||||
{"type":"Punctuation","value":"("},
|
||||
{"type":"NameAttribute","value":"Mandatory"},
|
||||
{"type":"Punctuation","value":"="},
|
||||
{"type":"NameVariableMagic","value":"$true"},
|
||||
{"type":"Punctuation","value":","},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"NameAttribute","value":"DontShow"},
|
||||
{"type":"Punctuation","value":")]"},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"Punctuation","value":"["},
|
||||
{"type":"NameBuiltin","value":"ValidateNotNullOrEmpty"},
|
||||
{"type":"Punctuation","value":"()]"},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"Punctuation","value":"["},
|
||||
{"type":"NameBuiltin","value":"ValidateScript"},
|
||||
{"type":"Punctuation","value":"({"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"NameVariable","value":"$_"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Operator","value":"-ne"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"NameVariableMagic","value":"$null"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":"})]"},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"Punctuation","value":"["},
|
||||
{"type":"NameBuiltin","value":"ValidateRange"},
|
||||
{"type":"Punctuation","value":"("},
|
||||
{"type":"LiteralNumberFloat","value":"0"},
|
||||
{"type":"Punctuation","value":","},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":"["},
|
||||
{"type":"NameConstant","value":"int"},
|
||||
{"type":"Punctuation","value":"]::"},
|
||||
{"type":"Name","value":"MaxValue"},
|
||||
{"type":"Punctuation","value":")]"},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"Punctuation","value":"["},
|
||||
{"type":"NameConstant","value":"Microsoft.PowerShell.Commands.WebRequestMethod"},
|
||||
{"type":"Punctuation","value":"]"},
|
||||
{"type":"NameVariable","value":"$Param1"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":"="},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"LiteralStringSingle","value":"'Get'"},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"Punctuation","value":")"},
|
||||
{"type":"Text","value":"\n\n "},
|
||||
{"type":"Keyword","value":"Process"},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"Punctuation","value":"{"},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"Keyword","value":"if"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":"("},
|
||||
{"type":"NameVariable","value":"$MyVar"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Operator","value":"-lt"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":"("},
|
||||
{"type":"NameBuiltin","value":"Get-Date"},
|
||||
{"type":"Punctuation","value":")."},
|
||||
{"type":"NameProperty","value":"AddSeconds"},
|
||||
{"type":"Punctuation","value":"(["},
|
||||
{"type":"NameConstant","value":"int"},
|
||||
{"type":"Punctuation","value":"]("},
|
||||
{"type":"LiteralNumberFloat","value":"12.4"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":"/"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"LiteralNumberFloat","value":"2"},
|
||||
{"type":"Punctuation","value":")))"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Punctuation","value":"{}"},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"Punctuation","value":"}"},
|
||||
{"type":"Text","value":"\n"},
|
||||
{"type":"Punctuation","value":"}"}
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user