From 028d84308d491efc70f2e0e9f00b2f74c8853ddd Mon Sep 17 00:00:00 2001 From: deathaxe Date: Thu, 25 Apr 2024 08:36:28 +0200 Subject: [PATCH] [D] Add support for named arguments (#3962) Resolves #3961 --- D/D.sublime-syntax | 24 +++++++++++++++++++++--- D/tests/syntax_test_d.d | 12 ++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/D/D.sublime-syntax b/D/D.sublime-syntax index 3afd80f95d..49fb20387b 100644 --- a/D/D.sublime-syntax +++ b/D/D.sublime-syntax @@ -665,7 +665,7 @@ contexts: captures: 1: meta.path.d storage.type.d 2: punctuation.section.parens.begin.d - set: [meta-function-call, uda-after, value-list] + set: [meta-function-call, uda-after, argument-list] - match: '({{name}})\b' scope: meta.path.d storage.type.d set: value-after @@ -1284,7 +1284,7 @@ contexts: - meta_scope: meta.function-call.d - match: '\(' scope: punctuation.section.parens.begin.d - set: [meta-function-call, value-parens-after, value-list] + set: [meta-function-call, value-parens-after, argument-list] - match: (?=\S) set: value-after new-anonymous-after-args: @@ -1401,7 +1401,7 @@ contexts: set: [value-after, value-identifier] - match: '\(' scope: punctuation.section.parens.begin.d - set: [meta-function-call, value-parens-after, value-list] + set: [meta-function-call, value-parens-after, argument-list] - match: '\[' scope: punctuation.section.brackets.begin.d set: [value-bracket-after, value-list] @@ -1497,6 +1497,24 @@ contexts: set: value-after - include: not-whitespace-illegal-pop + argument-list: + - match: '(?=\)|}|]|;|:)' + pop: true + - match: '({{name}})\s*(:)' + captures: + 1: variable.parameter.d + 2: keyword.operator.assignment.d + set: [argument-list-after, value] + - match: '(?=\S)' + set: [argument-list-after, value] + argument-list-after: + - match: '(?=\)|}|]|;|:)' + pop: true + - match: ',' + scope: punctuation.separator.sequence.d + set: argument-list + - include: not-whitespace-illegal-pop + value-list: - match: '(?=\)|}|]|;|:)' pop: true diff --git a/D/tests/syntax_test_d.d b/D/tests/syntax_test_d.d index b49098a360..184de94615 100644 --- a/D/tests/syntax_test_d.d +++ b/D/tests/syntax_test_d.d @@ -3282,3 +3282,15 @@ extern(1) // ^ keyword.operator.assignment.d // ^^^^ constant.language.d // ^ punctuation.terminator.d + + myFn(x: 10, y: 20); +// ^^^^^^^^^^^^^^^^^^ meta.function-call.d +// ^ punctuation.section.parens.begin.d +// ^ variable.parameter.d +// ^ keyword.operator.assignment.d +// ^^ constant.numeric.value.d +// ^ punctuation.separator.sequence.d +// ^ variable.parameter.d +// ^ keyword.operator.assignment.d +// ^^ constant.numeric.value.d +// ^ punctuation.section.parens.end.d