Skip to content

Commit

Permalink
Add dummy function definitions and references to make symbol tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
matteocoder committed Jan 11, 2025
1 parent 6b87cb5 commit 7da8d07
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 71 deletions.
10 changes: 10 additions & 0 deletions Tests/syntax_test_Class.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ class TypeName
# ^ punctuation.section.brackets.begin
# ^^^^ storage.type
# ^ punctuation.section.brackets.end
# ^^^^^^^^^^^^^ entity.name.function
# @@@@@@@@@@@@@ definition
# ^ punctuation.section.group.begin
# ^ punctuation.section.brackets.begin
# ^^^^^^^^^ storage.type
Expand All @@ -105,6 +107,8 @@ class TypeName
# <- punctuation.section.brackets.begin
# ^ storage.type
# ^ punctuation.section.brackets.end
# ^^^^^^^^^^^^^ entity.name.function
# @@@@@@@@@@@@@ definition
# ^ punctuation.section.group.begin
# ^ punctuation.section.brackets.begin
# ^^^ storage.type
Expand All @@ -126,3 +130,9 @@ class TypeName
# ^^ variable.other.member
}
}

[TypeName]::MemberMethod1()
# @@@@@@@@@@@@@ reference

$object.MemberMethod2()
# @@@@@@@@@@@@@ reference
3 changes: 3 additions & 0 deletions Tests/syntax_test_Function.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ using module Microsoft.Management
# ^ keyword.other
# ^ variable.parameter

function Test-Path {}
# @@@@@@@@@ definition
<#
# <- punctuation.definition.comment.block.begin
.Synopsis
Expand Down Expand Up @@ -321,6 +323,7 @@ function Verb-Noun {
# ^ meta.attribute punctuation.section.group.end
# ^ meta.attribute punctuation.section.brackets.end
[ValidateScript({Test-Path $_})] #Make sure cmdlets don't break highlighting
# @@@@@@@@@ reference
# <- meta.attribute punctuation.section.brackets.begin
# ^ meta.attribute support.function.attribute
# ^ meta.attribute punctuation.section.group.begin
Expand Down
190 changes: 119 additions & 71 deletions Tests/syntax_test_PowerShell.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -262,23 +262,29 @@ $properties = @{
}
# <- punctuation.section.braces.end

function Invoke-Something {}
# @@@@@@@@@@@@@@@@ definition

# Spatting
Invoke-Something @properties
# ^^^^^^^^^^^^^^^^ support.function
# @@@@@@@@@@@@@@@@ reference
# ^ punctuation.definition.variable
# ^ variable.other.readwrite

# ScriptBlock
{Invoke-Something @properties}
# ^ punctuation.section.braces.begin
# ^^^^^^^^^^^^^^^^ support.function
# @@@@@@@@@@@@@@@@ reference
# ^ punctuation.definition.variable
# ^ variable.other.readwrite
# ^ punctuation.section.braces.end
{
# <- punctuation.section.braces.begin
Invoke-Something @properties
# ^^^^^^^^^^^^^^^^ support.function
# @@@@@@@@@@@@@@@@ reference
# ^ punctuation.definition.variable
# ^ variable.other.readwrite
}
Expand All @@ -290,6 +296,7 @@ $sb = {
# ^ punctuation.section.braces.begin
Invoke-Something @properties
# ^^^^^^^^^^^^^^^^ support.function
# @@@@@@@@@@@@@@@@ reference
# ^ punctuation.definition.variable
# ^ variable.other.readwrite
}
Expand Down Expand Up @@ -445,6 +452,7 @@ $a3[1..2]
# ^^ punctuation.section.interpolation.begin
# ^^^^^^^^^^^^^^^^ support.function
# ^ punctuation.section.interpolation.end
# @@@@@@@@@@@@@@@@ reference
"This 'string' is nice."
# ^^^^^^^^^^^^^^^^^^^^^^^^ meta.string string.quoted.double

Expand Down Expand Up @@ -773,54 +781,65 @@ There is no @platting here!
# ^ punctuation.section.arguments.end

# Commands (functions)
Invoke-Something -foobar
# <- support.function
# ^ punctuation.definition.parameter
# ^^^^^^^ variable.parameter.option
Invoke-Something -foobar value
# <- support.function
# ^ punctuation.definition.parameter
# ^^^^^^^ variable.parameter.option
Invoke-Something -foobar:$true
# <- support.function
# ^ punctuation.definition.parameter
# ^^^^^^^ variable.parameter.option
# ^ punctuation.definition.variable
# ^^^^ constant.language
Invoke-Something -foobar: $true
# <- support.function
# ^ punctuation.definition.parameter
# ^^^^^^^ variable.parameter.option
Invoke-Something -p1 v1 -p2 10 -p3 'value' -switch -verbose
# <- support.function
# ^ punctuation.definition.parameter
# ^^^ variable.parameter.option
# ^ punctuation.definition.parameter
# ^^^ variable.parameter.option
# ^^ meta.number.integer.decimal constant.numeric.value
# ^^^^^^ - keyword
# ^ punctuation.definition.parameter
# ^^^ variable.parameter.option
Invoke-Something (1..20 | Invoke-Something) -p2 'value'
# <- support.function
# ^^ keyword.operator.range
Invoke-Something -p1 v2 -p2 30 | Invoke-Something -switch
# <- support.function
# ^ punctuation.definition.parameter
# ^^^ variable.parameter.option
# ^ punctuation.definition.parameter
# ^^^ variable.parameter.option
# ^^ meta.number.integer.decimal constant.numeric.value
# ^ keyword.operator.logical.pipe
# ^ support.function
# ^ punctuation.definition.parameter
# ^^^^^^^ variable.parameter.option - keyword
Invoke-Something -p1 {
# <- support.function
# ^ punctuation.definition.parameter
# ^^^ variable.parameter.option
Invoke-Something -foobar
#^ support.function
# ^ punctuation.definition.parameter
# ^^^^^^^ variable.parameter.option
#@@@@@@@@@@@@@@@@ reference
Invoke-Something -foobar value
#^ support.function
# ^ punctuation.definition.parameter
# ^^^^^^^ variable.parameter.option
#@@@@@@@@@@@@@@@@ reference
Invoke-Something -foobar:$true
#^ support.function
#@@@@@@@@@@@@@@@@ reference
# ^ punctuation.definition.parameter
# ^^^^^^^ variable.parameter.option
# ^ punctuation.definition.variable
# ^^^^ constant.language
Invoke-Something -foobar: $true
#^ support.function
#@@@@@@@@@@@@@@@@ reference
# ^ punctuation.definition.parameter
# ^^^^^^^ variable.parameter.option
Invoke-Something -p1 v1 -p2 10 -p3 'value' -switch -verbose
#^ support.function
#@@@@@@@@@@@@@@@@ reference
# ^ punctuation.definition.parameter
# ^^^ variable.parameter.option
# ^ punctuation.definition.parameter
# ^^^ variable.parameter.option
# ^^ meta.number.integer.decimal constant.numeric.value
# ^^^^^^ - keyword
# ^ punctuation.definition.parameter
# ^^^ variable.parameter.option
Invoke-Something (1..20 | Invoke-Something) -p2 'value'
#^ support.function
#@@@@@@@@@@@@@@@@ reference
# @@@@@@@@@@@@@@@@ reference
# ^^ keyword.operator.range
Invoke-Something -p1 v2 -p2 30 | Invoke-Something -switch
#^ support.function
# @@@@@@@@@@@@@@@@ reference
#@@@@@@@@@@@@@@@@ reference
# ^ punctuation.definition.parameter
# ^^^ variable.parameter.option
# ^ punctuation.definition.parameter
# ^^^ variable.parameter.option
# ^^ meta.number.integer.decimal constant.numeric.value
# ^ keyword.operator.logical.pipe
# ^ support.function
# ^ punctuation.definition.parameter
# ^^^^^^^ variable.parameter.option - keyword
Invoke-Something -p1 {
#^ support.function
#@@@@@@@@@@@@@@@@ reference
# ^ punctuation.definition.parameter
# ^^^ variable.parameter.option
Invoke-Something -foobar:$true
# ^ support.function
# @@@@@@@@@@@@@@@@ reference
# ^ punctuation.definition.parameter
# ^^^^^^^ variable.parameter.option
# ^ punctuation.definition.variable
Expand All @@ -829,11 +848,13 @@ Invoke-Something -p1 {
# <- punctuation.section.braces.end
# ^ keyword.operator.logical.pipe
# ^ support.function
Invoke-Something -p1 value `
# <- support.function
# ^ punctuation.definition.parameter
# ^^^ variable.parameter.option
# ^ punctuation.separator.continuation
# @@@@@@@@@@@@@@@@ reference
Invoke-Something -p1 value `
#^ support.function
#@@@@@@@@@@@@@@@@ reference
# ^ punctuation.definition.parameter
# ^^^ variable.parameter.option
# ^ punctuation.separator.continuation
-p2 14.4 `
# ^ punctuation.definition.parameter
# ^^^ variable.parameter.option
Expand All @@ -842,6 +863,7 @@ Invoke-Something -p1 value `
-p3 $value | Invoke-Something -verbose
# ^ punctuation.definition.parameter
# ^^^ variable.parameter.option
# @@@@@@@@@@@@@@@@ reference
# ^ punctuation.definition.parameter
# ^^^^^^^^ variable.parameter.option
# ^ punctuation.definition.variable
Expand Down Expand Up @@ -1523,19 +1545,29 @@ $b -cLike $c
# ^ string.quoted.single
# ^ keyword.operator.string-format

function Test-Function {}
# @@@@@@@@@@@@@ definition
function New-Object {}
# @@@@@@@@@@ definition
# Misc test cases
Test-Function -Class ClassName
# ^^^^^ - storage.type
New-Object -TypeName System.Diagnostics.Process
# ^^^^^^^ - keyword.control
New-Object -TypeName System.Data
# ^^^^ - keyword.control
New-Object -TypeName Sy-stem.if
# ^^ - keyword.control
New-Object -TypeName S_ystem.Clean
# ^^^^^ - keyword.control
New-Object -TypeName Sy_stem-.Throw
Test-Function -Class ClassName
# ^^^^^ - storage.type
#@@@@@@@@@@@@@ reference
New-Object -TypeName System.Diagnostics.Process
# ^^^^^^^ - keyword.control
#@@@@@@@@@@ reference
New-Object -TypeName System.Data
# ^^^^ - keyword.control
#@@@@@@@@@@ reference
New-Object -TypeName Sy-stem.if
# ^^ - keyword.control
#@@@@@@@@@@ reference
New-Object -TypeName S_ystem.Clean
# ^^^^^ - keyword.control
#@@@@@@@@@@ reference
New-Object -TypeName Sy_stem-.Throw
# ^^^^^ - keyword.control
#@@@@@@@@@@ reference
echo `"test`"
# ^^^^^^^^^ - string.quoted
# ^^ constant.character.escape
Expand All @@ -1560,16 +1592,22 @@ echo `"test`"
# ^ meta.group.array-expression
# ^ keyword.control
# ^ meta.block
function join-path {}
# @@@@@@@@@ definition
$file = join-path $env:SystemDrive "$([System.io.path]::GetRandomFileName()).ps1"
# <- punctuation.definition.variable
# @@@@@@@@@ reference
# ^ support.function
# ^ support.variable.drive
# ^ variable.other.readwrite
# ^^ meta.string meta.interpolation punctuation.section.interpolation.begin
# ^ storage.type
# @@@@@@@@@@@@@@@@@ reference
function out-file {}
# @@@@@@@@ definition
$ScriptBlock | Out-File $file -Force
# <- punctuation.definition.variable
# @@@@@@@@ reference
# ^ keyword.operator.logical.pipe
# ^ punctuation.definition.variable
# ^ punctuation.definition.parameter
Expand All @@ -1589,15 +1627,21 @@ Workflow work { sequence {} }
# ^ punctuation.section.braces.begin
# ^ punctuation.section.braces.end
# ^ punctuation.section.braces.end
get-thing | Out-WithYou > $null # destroy
# ^^^^^^^ support.function
# ^^^^^^^^^^^ support.function
# ^ keyword.operator.logical.pipe
# ^ keyword.operator.redirection
# ^ punctuation.definition.variable
# ^ constant.language
# ^ punctuation.definition.comment
# ^^^^^^^^^ comment.line
function get-something {}
# @@@@@@@@@@@@@ definition
function Out-WithYou {}
# @@@@@@@@@@@ definition
get-thing | Out-WithYou > $null # destroy
#^^^^^^^^^ support.function
#@@@@@@@@@ reference
# ^^^^^^^^^^^ support.function
# @@@@@@@@@@@ reference
# ^ keyword.operator.logical.pipe
# ^ keyword.operator.redirection
# ^ punctuation.definition.variable
# ^ constant.language
# ^ punctuation.definition.comment
# ^^^^^^^^^ comment.line
"Escaped chars: `", `n, `$, `b, `t, `e, `u{10ffff}, `""
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double
# ^^ constant.character.escape
Expand All @@ -1611,8 +1655,12 @@ get-thing | Out-WithYou > $null # destroy
'But here they''re not escape chars: `", `n, `$, `b, `"'
# ^^ constant.character.escape
# ^^^^^^^^^^^^^^^^^^^ - constant
function get-number {}
# @@@@@@@@@@ definition
"When you call a method: $( get-number | %{ invoke-command $( [string]::format("Like (this{0})","what?") ) $var } )"
# ^^ punctuation.section.interpolation.begin - source.powershell.embedded
# @@@@@@@@@@ reference
# @@@@@@@@@@@@@@ reference
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.powershell.embedded
# ^ keyword.operator.logical.pipe
# ^ meta.group.complex.subexpression punctuation.section.group.begin
Expand Down

0 comments on commit 7da8d07

Please sign in to comment.