Skip to content

Commit b7ad48d

Browse files
committed
Added support for properties and fixed missing abstract keyword on classes
1 parent 62be452 commit b7ad48d

File tree

2 files changed

+48
-6
lines changed

2 files changed

+48
-6
lines changed

AngelScript.sublime-syntax

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ variables:
1111
number: ((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f)?
1212
primitives: (int|int8|int16|int32|int64|uint|uint8|uint16|uint32|uint64|bool|float|double|bool|auto|void|array|dictionary|ref)
1313

14+
class_modifiers: '(abstract)'
15+
definition_modifiers: '(protected|private)'
16+
1417
language_variables: '(this)'
1518
language_support_functions: '(GetVar(Int|Float|Bool|String|Ivec2|Vec[234])|GetParam(Int|Long|Float|Bool|I?Vec[234]|String|Array|Dictionary)|HashString|SetVar|AddVar|print|xy|xyz|xyzw|atan|sin|asin|cos|acos|sqrt|pow|pow2|round|roundl|floor|ceil|log|normalize|dot|length|lengthsq|max|min|clamp|randf|randi|randdir|randfn|addrot|rottowards|capangle|angdiff|dist|distsq|formatTime|ease|formatThousands|formatInt|formatFloat|lerp|ilerp|sign|tocolor|i?vec[234]|UnitPtr)'
1619

@@ -54,10 +57,12 @@ contexts:
5457
pop: true
5558

5659
class:
57-
- match: 'class'
60+
- meta_scope: meta.class
61+
- match: '\b{{class_modifiers}}\b'
62+
scope: storage.modifier
63+
- match: '\bclass\b'
5864
scope: storage.type.class
5965
set:
60-
- meta_scope: meta.class
6166
- include: global
6267
- match: '{{identifier}}'
6368
scope: entity.name.class
@@ -441,17 +446,35 @@ contexts:
441446

442447
definition:
443448
- include: global
444-
- match: '(?={{identifier}}\s*[=;])'
445-
set: variable-definition
446449
- match: '(?={{identifier}}\s*\()'
447450
set: function-definition
451+
- match: '(?={{identifier}}\s*)'
452+
set: variable-definition
448453

449454
definition-in-code:
450455
- include: global
451456
- match: '(?={{identifier}}\s*[=;\(])'
452457
set: variable-definition
453458

454459
variable-definition-value:
460+
- match: '{'
461+
scope: punctuation.section.brackets.begin
462+
set:
463+
- include: global
464+
- match: '\b{{definition_modifiers}}\b'
465+
scope: storage.modifier
466+
- match: '\b(get|set)\b'
467+
scope: keyword.other
468+
push:
469+
- include: global
470+
- match: '{'
471+
scope: punctuation.section.block.begin
472+
set:
473+
- meta_scope: meta.function
474+
- include: code-scope
475+
- match: '}'
476+
scope: punctuation.section.brackets.end
477+
pop: true
455478
- match: '='
456479
scope: keyword.operator.assignment
457480
set: expression
@@ -591,7 +614,7 @@ contexts:
591614

592615
has-classes:
593616
- include: has-metadatas
594-
- match: '\b(?=class)\b'
617+
- match: '\b(?=({{class_modifiers}}\s+)?class)\b'
595618
push: class
596619

597620
has-enums:
@@ -606,7 +629,7 @@ contexts:
606629

607630
has-definitions:
608631
- include: has-metadatas
609-
- match: '\b(protected|private)\b'
632+
- match: '\b{{definition_modifiers}}\b'
610633
scope: storage.modifier
611634
- match: '(?=\b{{possible_typename}})'
612635
push:

syntax_test_stuff.as

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,25 @@
2222
// <- source.as
2323
#endif
2424

25+
abstract class ProjectileBase : IProjectile {}
26+
// <- meta.class storage.modifier
27+
// ^^^^^ meta.class storage.type.class
28+
29+
class ClassWithProperty
30+
{
31+
uint Team { get { return 0; } }
32+
// <- storage.type
33+
// ^^^^ variable.other
34+
// ^ punctuation.section.brackets.begin
35+
// ^^^ keyword.other
36+
// ^ punctuation.section.block.begin
37+
// ^^^^^^ keyword.control
38+
// ^ constant.numeric
39+
// ^ punctuation.terminator
40+
// ^ punctuation.section.block.end
41+
// ^ punctuation.section.brackets.end
42+
}
43+
2544
void func2(const string &in str, SValue& sval) {}
2645
// <- storage.type
2746
// ^^^^^ meta.function entity.name.function

0 commit comments

Comments
 (0)