Skip to content

Commit 8b5394f

Browse files
committed
Allow member access of groups
1 parent 3f3a963 commit 8b5394f

File tree

4 files changed

+47
-16
lines changed

4 files changed

+47
-16
lines changed

PowerShell.sublime-syntax

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ contexts:
400400
types:
401401
- match: \[
402402
scope: punctuation.section.brackets.begin.powershell
403-
push: [maybe-static-member, inside-type]
403+
push: [members, inside-type]
404404

405405
types-without-members:
406406
- match: \[
@@ -426,15 +426,6 @@ contexts:
426426
- match: \+
427427
scope: punctuation.accessor.plus.powershell
428428

429-
static-members:
430-
- match: '::'
431-
scope: punctuation.accessor.double-colon.powershell
432-
set: members
433-
434-
maybe-static-member:
435-
- include: static-members
436-
- include: immediately-pop
437-
438429
###[ OPERATORS ]###############################################################
439430

440431
operators:
@@ -632,6 +623,8 @@ contexts:
632623
pop: 1
633624
- match: \.(?=\w)
634625
scope: punctuation.accessor.dot.powershell
626+
- match: ::(?=\w)
627+
scope: punctuation.accessor.double-colon.powershell
635628
- match: (\w+)(\()
636629
captures:
637630
1: meta.function-call.powershell variable.function.powershell
@@ -663,7 +656,7 @@ contexts:
663656
- meta_scope: meta.group.powershell
664657
- match: \)
665658
scope: punctuation.section.group.end.powershell
666-
pop: 1
659+
set: members
667660
- include: attributes
668661
- include: expressions
669662

Tests/syntax_test_Class.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ while ($true) {
390390
Start-Sleep -ms 100
391391
# @@@@@@@@@@@ reference
392392
($Using:unsafe)::ShowRunspaceId($_)
393+
# @@@@@@@@@@@@@@ reference
393394
}
394395
}
395396

@@ -415,5 +416,6 @@ while ($true) {
415416
Start-Sleep -ms 100
416417
# @@@@@@@@@@@ reference
417418
($Using:safe)::ShowRunspaceId($_)
419+
# @@@@@@@@@@@@@@ reference
418420
}
419421
}

Tests/syntax_test_PowerShell.ps1

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,6 +1617,40 @@ function get-number {}
16171617
# ^ meta.group.complex.subexpression punctuation.section.group.end
16181618
# ^ punctuation.definition.variable
16191619
# ^ punctuation.section.interpolation.end - source.powershell.embedded
1620+
1621+
([MyType])::Name[2]
1622+
# ^^^^^^^^^^ meta.group.powershell
1623+
# ^ punctuation.section.group.begin.powershell
1624+
# ^ punctuation.section.brackets.begin.powershell
1625+
# ^^^^^^ support.type.powershell
1626+
# ^ punctuation.section.brackets.end.powershell
1627+
# ^ punctuation.section.group.end.powershell
1628+
# ^^ punctuation.accessor.double-colon.powershell
1629+
# ^^^^ variable.other.member.powershell
1630+
# ^^^ meta.brackets.indexer.powershell
1631+
# ^ punctuation.section.brackets.begin.powershell
1632+
# ^ meta.number.integer.decimal.powershell constant.numeric.value.powershell
1633+
# ^ punctuation.section.brackets.end.powershell
1634+
([MyType])::Name.ToString()[2]
1635+
# ^^^^^^^^^^ meta.group.powershell
1636+
# ^ punctuation.section.group.begin.powershell
1637+
# ^ punctuation.section.brackets.begin.powershell
1638+
# ^^^^^^ support.type.powershell
1639+
# ^ punctuation.section.brackets.end.powershell
1640+
# ^ punctuation.section.group.end.powershell
1641+
# ^^ punctuation.accessor.double-colon.powershell
1642+
# ^^^^ variable.other.member.powershell
1643+
# ^ punctuation.accessor.dot.powershell
1644+
# ^^^^^^^^ meta.function-call.powershell variable.function.powershell
1645+
# @@@@@@@@ reference
1646+
# ^^ meta.function-call.arguments.powershell
1647+
# ^ punctuation.section.arguments.begin.powershell
1648+
# ^ punctuation.section.arguments.end.powershell
1649+
# ^^^ meta.brackets.indexer.powershell
1650+
# ^ punctuation.section.brackets.begin.powershell
1651+
# ^ meta.number.integer.decimal.powershell constant.numeric.value.powershell
1652+
# ^ punctuation.section.brackets.end.powershell
1653+
16201654
"This is the DebugPreference variable: $DebugPreference"
16211655
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string string.quoted.double
16221656
# ^^^^^^^^^^^^^^^^ meta.string meta.interpolation variable.language - string

Tests/syntax_test_strings.ps1

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,19 +240,21 @@
240240
# ^^ variable.other.readwrite.powershell
241241
# ^ punctuation.definition.variable.powershell
242242

243-
# TODO: Mark ToString as a function
244243
(1.11).ToString("#.#")
245244
# ^^^^^^ meta.group.powershell
246245
# ^ punctuation.section.group.begin.powershell
247246
# ^^^^ meta.number.float.decimal.powershell constant.numeric.value.powershell
248247
# ^ punctuation.separator.decimal.powershell
249248
# ^ punctuation.section.group.end.powershell
250-
# ^^^^^^^ meta.group.powershell
251-
# ^ punctuation.section.group.begin.powershell
252-
# ^^^^^ meta.string.interpolated.powershell string.quoted.double.powershell - comment
249+
# ^ punctuation.accessor.dot.powershell
250+
# ^^^^^^^^ meta.function-call.powershell variable.function.powershell
251+
# @@@@@@@@ reference
252+
# ^^^^^^^ meta.function-call.arguments.powershell
253+
# ^ punctuation.section.arguments.begin.powershell
254+
# ^^^^^ meta.string.interpolated.powershell string.quoted.double.powershell
253255
# ^ punctuation.definition.string.begin.powershell
254256
# ^ punctuation.definition.string.end.powershell
255-
# ^ punctuation.section.group.end.powershell
257+
# ^ punctuation.section.arguments.end.powershell
256258

257259
"{1,10} {0,10} {2,10:x}" -f "First", "Second", 255
258260
# ^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.interpolated.powershell string.quoted.double.powershell

0 commit comments

Comments
 (0)