From e97e7ba443baa02853b8541c3ff3486d4685b725 Mon Sep 17 00:00:00 2001 From: IchorDev <15670465+ichordev@users.noreply.github.com> Date: Fri, 26 Apr 2024 20:14:57 +1000 Subject: [PATCH] [D] Add support for enum member attributes (#3967) --- D/D.sublime-syntax | 1 + D/tests/syntax_test_d.d | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/D/D.sublime-syntax b/D/D.sublime-syntax index 49fb20387b..7cb8c7ec6d 100644 --- a/D/D.sublime-syntax +++ b/D/D.sublime-syntax @@ -1718,6 +1718,7 @@ contexts: - match: '}' scope: punctuation.section.block.end.d pop: true + - include: attribute-in - match: '(?=\b({{name}})\b)' push: enum-member - include: not-whitespace-illegal diff --git a/D/tests/syntax_test_d.d b/D/tests/syntax_test_d.d index 184de94615..036f146c6e 100644 --- a/D/tests/syntax_test_d.d +++ b/D/tests/syntax_test_d.d @@ -941,6 +941,43 @@ extern(1) 1 //^ meta.enum.d invalid.illegal.d } + enum Boo { +//^^^^^^^^^^^ meta.enum.d +//^^^^ keyword.declaration.enum.d +// ^^^ entity.name.enum.d +// ^ punctuation.section.block.begin.d + deprecated foo, + //^^^^^^^^^^^^^^^^ meta.enum.d + //^^^^^^^^^^ keyword.other.deprecated.d + // ^^^ entity.name.constant.d + // ^ punctuation.separator.sequence.d + @Test bar = 2, + //^^^^^^^^^^^^^^^ meta.enum.d + //^ punctuation.definition.annotation.begin.d + // ^^^^ meta.path.d storage.type.d + // ^^^ entity.name.constant.d + // ^ keyword.operator.assignment.d + // ^ meta.number.integer.decimal.d + // ^ punctuation.separator.sequence.d + deprecated( "Oops!" ) boo, + //^^^^^^^^^^^^^^^^^^^^^^^^^ meta.enum.d + //^^^^^^^^^^ keyword.other.deprecated.d + // ^ punctuation.section.parens.begin.d + // ^^^^^^^ string.quoted.double.d + // ^ punctuation.section.parens.end.d + // ^^^ entity.name.constant.d + // ^ punctuation.separator.sequence.d + @("Test") par = 2, + //^^^^^^^^^^^^^^^^^^^ meta.enum.d + //^ punctuation.definition.annotation.begin.d + // ^ punctuation.section.parens.begin.d + // ^^^^^^ string.quoted.double.d + // ^ punctuation.section.parens.end.d + // ^^^ entity.name.constant.d + // ^ keyword.operator.assignment.d + // ^ meta.number.integer.decimal.d + // ^ punctuation.separator.sequence.d + } //^ meta.enum.d punctuation.section.block.end.d enum Foo : int { a = 12 } //^^^^^^^^^^^^^^^^^^^^^^^^^ meta.enum.d