From 17c7dfd6394be2b21adccc75ca3a13a423bc9a54 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Wed, 24 Apr 2024 20:14:15 +0200 Subject: [PATCH] [D] Add support for named arguments 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