Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[D] Separate built-in type-aliases from built-in types #3965

Merged
merged 7 commits into from
Apr 27, 2024
Merged
24 changes: 16 additions & 8 deletions D/D.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ variables:
construction_lookahead: '(?=~?\s*this\s*\()'

keyword: 'else|enum|export|extern|debug|default|delegate|delete|deprecated|do|body|break|case|cast|catch|class|const|continue|abstract|alias|align|asm|assert|auto|final|finally|for|foreach|foreach_reverse|function|goto|if|immutable|import|in|inout|interface|invariant|is|lazy|macro|mixin|module|new|nothrow|out|override|package|pragma|private|protected|public|pure|ref|return|scope|shared|static|struct|switch|synchronized|template|throw|try|typeid|typeof|union|unittest|version|while|with|__gshared|__traits|__vector|__parameters'
basic_type: 'bool|byte|cdouble|cent|cfloat|char|creal|dchar|double|float|idouble|ifloat|int|ireal|long|real|short|ubyte|ucent|uint|ulong|ushort|void|wchar|string|dstring|wstring|size_t|ptrdiff_t'
basic_type: 'bool|byte|cdouble|cent|cfloat|char|creal|dchar|double|float|idouble|ifloat|int|ireal|long|real|short|ubyte|ucent|uint|ulong|ushort|void|wchar'
builtin_type_alias: 'string|dstring|wstring|size_t|ptrdiff_t|noreturn'
language_constant: 'null|true|false|__FILE__|__FILE_FULL_PATH__|__MODULE__|__LINE__|__FUNCTION__|__PRETTY_FUNCTION__|__DATE__|__EOF__|__TIME__|__TIMESTAMP__|__VENDOR__|__VERSION__|__ctfe'
language_variable: 'this|super'
reserved: '{{keyword}}|{{basic_type}}|{{language_constant}}|{{language_variable}}'
Expand Down Expand Up @@ -1243,6 +1244,9 @@ contexts:
- match: '\b({{basic_type}})\b'
scope: storage.type.d
set: value-after
- match: '\b({{builtin_type_alias}})\b'
scope: support.type.builtin-alias.d
set: value-after
- match: '\b({{name}})\s*(=>)'
captures:
1: variable.parameter.d
Expand Down Expand Up @@ -2234,15 +2238,19 @@ contexts:
- match: '\b{{name}}\b(?=\s*!)'
scope: meta.function-call.template.d meta.path.d variable.function.d
pop: true
- match: '\b{{builtin_type_alias}}\b'
scope: meta.path.d storage.type.d support.type.builtin-alias.d
ichordev marked this conversation as resolved.
Show resolved Hide resolved
set: type-identifier-after
- match: '\b{{name}}\b'
scope: meta.path.d storage.type.d
set:
- match: \.
scope: meta.path.d punctuation.accessor.dot.d
set: type-identifier
- match: '(?=\S)'
pop: true
- include: not-whitespace-illegal-pop
set: type-identifier-after
- include: not-whitespace-illegal-pop
type-identifier-after:
- match: \.
scope: meta.path.d punctuation.accessor.dot.d
set: type-identifier
- match: '(?=\S)'
pop: true
ichordev marked this conversation as resolved.
Show resolved Hide resolved
type-identifier-ref:
- match: \.
scope: meta.path.d punctuation.accessor.dot.d
Expand Down
18 changes: 9 additions & 9 deletions D/tests/syntax_test_d.d
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ extern(1)
// ^ meta.path.d variable.other.d
// ^ punctuation.terminator.d
string foo = import("foo.txt");
//^^^^^^ storage.type.d
//^^^^^^ storage.type.d support.type.builtin-alias.d
// ^^^ variable.other.d
// ^ keyword.operator.assignment.d
// ^^^^^^ keyword.control.import.d
Expand Down Expand Up @@ -580,7 +580,7 @@ extern(1)
// ^^^^^ storage.modifier.d
// ^^^ storage.type.d
// ^ punctuation.section.brackets.begin.d
// ^^^^^^ storage.type.d
// ^^^^^^ storage.type.d support.type.builtin-alias.d
// ^ punctuation.section.brackets.end.d
// ^ punctuation.separator.sequence.d
// ^^^ entity.name.type.d
Expand Down Expand Up @@ -915,7 +915,7 @@ extern(1)
//^^^^^ keyword.declaration.union.d
// ^^^^ entity.name.union.d
// ^ punctuation.section.group.begin.d
// ^^^^^^ storage.type.d
// ^^^^^^ storage.type.d support.type.builtin-alias.d
// ^ variable.parameter.d
// ^ punctuation.separator.sequence.d
// ^ variable.parameter.d
Expand Down Expand Up @@ -1494,7 +1494,7 @@ extern(1)
// ^ keyword.operator.comparison.d
// ^^^ storage.type.d
// ^ punctuation.separator.sequence.d
// ^^^^^^ storage.type.d
// ^^^^^^ storage.type.d support.type.builtin-alias.d
// ^ variable.parameter.d
// ^ keyword.operator.comparison.d
// ^^^ string.quoted.double.d
Expand Down Expand Up @@ -1769,7 +1769,7 @@ extern(1)
//^^^^^^^^ keyword.declaration.template.d
// ^ entity.name.template.d
// ^ punctuation.section.group.begin.d
// ^^^^^^ storage.type.d
// ^^^^^^ storage.type.d support.type.builtin-alias.d
// ^ variable.parameter.d
// ^ punctuation.section.group.end.d
// ^ punctuation.section.block.begin.d
Expand Down Expand Up @@ -2034,7 +2034,7 @@ extern(1)
for (size_t i; !val.empty; val.popFront(), ++i) {}
//^^^ keyword.control.loop.d
// ^ punctuation.section.parens.begin.d
// ^^^^^^ storage.type.d
// ^^^^^^ storage.type.d support.type.builtin-alias.d
// ^ variable.other.d
// ^ punctuation.terminator.d
// ^ keyword.operator.logical.d
Expand Down Expand Up @@ -2864,7 +2864,7 @@ extern(1)
// ^^^ storage.type.d
// ^ variable.parameter.d
// ^ punctuation.separator.sequence.d
// ^^^^^^ storage.type.d
// ^^^^^^ storage.type.d support.type.builtin-alias.d
// ^ variable.parameter.d
// ^ punctuation.section.group.end.d
// ^^^^^^^^^^^ meta.function.d
Expand All @@ -2875,7 +2875,7 @@ extern(1)
function size_t(foo a) {};
//^^^^^^^^^^^^^^^ meta.function.d
//^^^^^^^^ keyword.other.d
// ^^^^^^ storage.type.d
// ^^^^^^ storage.type.d support.type.builtin-alias.d
// ^^^^^^^ meta.function.parameters.d
// ^ punctuation.section.group.begin.d
// ^^^ storage.type.d
Expand Down Expand Up @@ -3041,7 +3041,7 @@ extern(1)
// ^^^^^^^^^^^ meta.function.d entity.name.function.d
// ^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.d
// ^ punctuation.section.group.begin.d
// ^^^^^^ storage.type.d
// ^^^^^^ storage.type.d support.type.builtin-alias.d
// ^ variable.parameter.d
// ^ punctuation.separator.sequence.d
// ^ variable.parameter.d
Expand Down
Loading