Skip to content

Commit

Permalink
Refine class definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
deathaxe committed Aug 29, 2024
1 parent 5d6bce5 commit e60e410
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 16 deletions.
43 changes: 37 additions & 6 deletions CoffeeScript.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,44 @@ contexts:
###[ CLASS DECLARATIONS ]#####################################################

classes:
- match: (class\b)\s+((?!extends)@?[a-zA-Z\$_][\w\.]*)?(?:\s*(extends)\s+(@?[a-zA-Z\$\._][\w\.]*))?
scope: meta.class.coffee
- match: class\b
scope: meta.class.coffee keyword.declaration.class.coffee
push:
- class-extends
- class-name

class-name:
- match: (?=extends\b)
pop: 1
- match: ({{identifier}})(\.)
captures:
1: support.class.coffee
2: punctuation.accessor.dot.coffee
- match: '{{identifier}}'
scope: entity.name.class.coffee
pop: 1
- include: comments
- include: else-pop

class-extends:
- meta_content_scope: meta.class.identifier.coffee
- match: extends\b
scope: storage.modifier.extends.coffee
set: class-extends-name
- include: comments
- include: else-pop

class-extends-name:
- meta_scope: meta.class.extends.coffee
- match: ({{identifier}})(\.)
captures:
1: storage.type.class.coffee
2: entity.name.type.class.coffee
3: keyword.control.inheritance.coffee
4: entity.other.inherited-class.coffee
1: support.class.coffee
2: punctuation.accessor.dot.coffee
- match: '{{identifier}}'
scope: entity.other.inherited-class.coffee
pop: 1
- include: comments
- include: else-pop

###[ FUNCTION DECLARATIONS ]##################################################

Expand Down
28 changes: 18 additions & 10 deletions tests/syntax_test_scope.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,29 @@ export parentClass
###[ CLASSES ]################################################################

class extends parentClass
# <- meta.class.coffee storage.type.class.coffee
#^^^^^^^^^^^^^^^^^^^^^^^^ meta.class.coffee
#^^^^ storage.type.class.coffee
# ^^^^^^^ keyword.control.inheritance.coffee
# <- meta.class.coffee keyword.declaration.class.coffee
#^^^^ meta.class.coffee
# ^ meta.class.identifier.coffee
# ^^^^^^^^^^^^^^^^^^^ meta.class.extends.coffee
#^^^^ keyword.declaration.class.coffee
# ^^^^^^^ storage.modifier.extends.coffee
# ^^^^^^^^^^^ entity.other.inherited-class.coffee
constructor: ->
return

class App.Router extends Snakeskin.Router
# <- meta.class.coffee storage.type.class.coffee
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.class.coffee
#^^^^ storage.type.class.coffee
# ^^^^^^^^^^ entity.name.type.class.coffee
# ^^^^^^^ keyword.control.inheritance.coffee
# ^^^^^^^^^^^^^^^^ entity.other.inherited-class.coffee
# <- meta.class.coffee keyword.declaration.class.coffee
#^^^^ meta.class.coffee
# ^^^^^^^^^^^^ meta.class.identifier.coffee
# ^^^^^^^^^^^^^^^^^^^^^^^^ meta.class.extends.coffee
#^^^^ keyword.declaration.class.coffee
# ^^^ support.class.coffee
# ^ punctuation.accessor.dot.coffee
# ^^^^^^ entity.name.class.coffee
# ^^^^^^^ storage.modifier.extends.coffee
# ^^^^^^^^^ support.class.coffee
# ^ punctuation.accessor.dot.coffee
# ^^^^^^ entity.other.inherited-class.coffee

###[ FUNCTIONS ]###############################################################

Expand Down

0 comments on commit e60e410

Please sign in to comment.