Skip to content

Commit

Permalink
Cleanup variables
Browse files Browse the repository at this point in the history
  • Loading branch information
deathaxe committed Aug 27, 2024
1 parent df4c43c commit 229a5dd
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 49 deletions.
74 changes: 30 additions & 44 deletions CoffeeScript.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ contexts:
- include: triple-single-quoted-strings
- include: double-quoted-strings
- include: single-quoted-strings
- include: instance-variables
- include: numbers
- include: objects
- include: variables

###[ COMMENTS ]###############################################################

Expand Down Expand Up @@ -408,45 +407,6 @@ contexts:
pop: 1
- include: else-pop

###[ OBJECTS ]################################################################

objects:
- match: (?:this|extends)(?!\s*[:=])\b
scope: variable.language.coffee
- match: ({{identifier}})?(\.)
captures:
1: variable.other.object.coffee
2: punctuation.accessor.dot.coffee
push: member
- match: '{{identifier}}'
scope: variable.other.readwrite.coffee

member:
- meta_scope: meta.path.coffee
# member objects
- match: ({{identifier}})(\.)
captures:
1: variable.other.object.coffee
2: punctuation.accessor.dot.coffee
# method
- match: '{{identifier}}(?=\()'
scope: meta.function-call.identifier.coffee variable.function.coffee
set: function-call-argument-list
# member variable
- match: '{{identifier}}'
scope: variable.other.member.coffee
pop: 1
- include: immediately-pop

variables:
# member objects
- match: ({{identifier}})(\.)
captures:
1: variable.other.object.coffee
2: punctuation.accessor.dot.coffee
- match: '{{identifier}}'
scope: variable.other.member.coffee

###[ OPERATORS ]##############################################################

punctuations:
Expand Down Expand Up @@ -790,13 +750,39 @@ contexts:
- match: $\n?|(?=})
pop: 1

###[ VARIABLES ]###############################################################
###[ VARIABLES ]##############################################################

instance-variables:
variables:
- match: (?:this|extends)(?!\s*[:=])\b
scope: variable.language.coffee
- match: ({{identifier}})?(\.)
captures:
1: variable.other.object.coffee
2: punctuation.accessor.dot.coffee
push: member
- match: (@)(?:{{identifier}})?
scope: variable.other.readwrite.instance.coffee
scope: variable.other.member.coffee
captures:
1: punctuation.definition.variable.coffee
- match: '{{identifier}}'
scope: variable.other.readwrite.coffee

member:
- meta_scope: meta.path.coffee
# member objects
- match: ({{identifier}})(\.)
captures:
1: variable.other.object.coffee
2: punctuation.accessor.dot.coffee
# method
- match: '{{identifier}}(?=\()'
scope: meta.function-call.identifier.coffee variable.function.coffee
set: function-call-argument-list
# member variable
- match: '{{identifier}}'
scope: variable.other.member.coffee
pop: 1
- include: immediately-pop

###[ PROTOTYPES ]##############################################################

Expand Down
10 changes: 5 additions & 5 deletions tests/syntax_test_scope.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,16 @@ class App.Router extends Snakeskin.Router

yield @foo
# ^^^^^ keyword.control.flow.coffee
# ^^^^ variable.other.readwrite.instance.coffee
# ^^^^ variable.other.member.coffee

yield from @foo
# ^^^^^^^^^^ keyword.control.flow.coffee
# ^^^^ variable.other.readwrite.instance.coffee
# ^^^^ variable.other.member.coffee

await return @foo;
# ^^^^^ keyword.control.flow.coffee
# ^^^^^^ keyword.control.flow.coffee
# ^^^^ variable.other.readwrite.instance.coffee
# ^^^^ variable.other.member.coffee

###[ OPERATORS ]###############################################################

Expand Down Expand Up @@ -622,7 +622,7 @@ class App.Router extends Snakeskin.Router
# ^ meta.number.integer.decimal.coffee constant.numeric.value.coffee

@variable
# ^^^^^^^^^ variable.other.readwrite.instance.coffee
# ^^^^^^^^^ variable.other.member.coffee
# ^ punctuation.definition.variable.coffee

###[ JSX ]#####################################################################
Expand All @@ -637,7 +637,7 @@ class App.Router extends Snakeskin.Router
# ^^^ meta.string.coffee string.quoted.double.coffee
# ^^^^^^ meta.string.coffee meta.interpolation.coffee
# ^ punctuation.section.interpolation.begin.coffee
# ^^^^ source.coffee.embedded.jsx variable.other.readwrite.instance.coffee
# ^^^^ source.coffee.embedded.jsx variable.other.member.coffee
# ^ punctuation.section.interpolation.end.coffee
# ^ meta.string.coffee string.quoted.double.coffee punctuation.definition.string.end.coffee
# ^ punctuation.definition.tag.end.coffee
Expand Down

0 comments on commit 229a5dd

Please sign in to comment.