diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-28 13:38:39 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-28 13:38:39 +0000 |
| commit | 5370a0d74d90799ca010d308d54330283116ca5e (patch) | |
| tree | 3e721f6833eb021fa24edc428832dd6d6c810d53 /plugin | |
| parent | 96fd8bab8630f2abcc74cfc69fdbccc530579b9c (diff) | |
feat(editor): highlight default return modifiers
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'plugin')
| -rw-r--r-- | plugin/syntaxes/cie-pseudocode.tmLanguage.json | 7 | ||||
| -rw-r--r-- | plugin/test/highlighting.test.js | 16 |
2 files changed, 21 insertions, 2 deletions
diff --git a/plugin/syntaxes/cie-pseudocode.tmLanguage.json b/plugin/syntaxes/cie-pseudocode.tmLanguage.json index 14ef33c..ef8146f 100644 --- a/plugin/syntaxes/cie-pseudocode.tmLanguage.json +++ b/plugin/syntaxes/cie-pseudocode.tmLanguage.json @@ -139,12 +139,15 @@ } }, "return_type": { - "match": "(?<!\\w)(RETURNS)\\s+((?<type>[A-Za-z_][A-Za-z0-9_]*(?:\\s*<\\s*\\g<type>(?:\\s*,\\s*\\g<type>)*\\s*>)?(?:\\s*\\.\\.\\.)?))", + "match": "(?<!\\w)(RETURNS)\\s+(?:(DEFAULT)\\s+)?((?<type>[A-Za-z_][A-Za-z0-9_]*(?:\\s*<\\s*\\g<type>(?:\\s*,\\s*\\g<type>)*\\s*>)?(?:\\s*\\.\\.\\.)?))", "captures": { "1": { "name": "storage.modifier.cie-pseudocode" }, "2": { + "name": "storage.modifier.cpp" + }, + "3": { "patterns": [ { "include": "#type_tokens" @@ -477,7 +480,7 @@ "name": "keyword.other.operator.overload.cpp" }, { - "match": "(?<!\\w)(?:OVERLOAD)(?!\\w)", + "match": "(?<!\\w)(?:OVERLOAD|DEFAULT)(?!\\w)", "name": "storage.modifier.cpp" }, { diff --git a/plugin/test/highlighting.test.js b/plugin/test/highlighting.test.js index 1edac7b..95b10c6 100644 --- a/plugin/test/highlighting.test.js +++ b/plugin/test/highlighting.test.js @@ -70,6 +70,22 @@ test('function names include underscores and explicit nested template arguments' assert.equal('_value'.match(new RegExp(configuration.wordPattern))[0], '_value'); }); +test('default return modifiers preserve builtin and nested result type scopes', () => { + for (const [text, names] of [ + ['OVERLOAD FUNCTION Foo(X : STRING) RETURNS DEFAULT REAL', ['REAL']], + ['PUBLIC OVERLOAD FUNCTION Foo() RETURNS DEFAULT Box<Pair<Widget, REAL>>', ['Box', 'Pair', 'Widget', 'REAL']] + ]) { + assert.ok(scopesAt(text, 'DEFAULT').includes('storage.modifier.cpp')); + assert.ok(!scopesAt(text, 'DEFAULT').includes('entity.name.type.cpp')); + for (const name of names) { + assert.ok(scopesAt(text, name).some(s => /^(entity\.name\.type|storage\.type)\./.test(s)), `${text}: ${name}`); + } + } + assert.ok(!scopesAt('OUTPUT "DEFAULT"', 'DEFAULT').includes('storage.modifier.cpp')); + assert.ok(!scopesAt('// DEFAULT', 'DEFAULT').includes('storage.modifier.cpp')); + assert.ok(!scopesAt('default()', 'default').includes('storage.modifier.cpp')); +}); + test('types are recognized in declarations, signatures, arrays, aliases, constructors and templates', () => { for (const [text, names] of [ ['TYPE Student', ['Student']], |
