From 229a5dd215b480c39f9555f002e575be48c9fe4f Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 27 Aug 2024 20:59:56 +0200 Subject: [PATCH] Cleanup variables --- CoffeeScript.sublime-syntax | 74 ++++++++++++++-------------------- tests/syntax_test_scope.coffee | 10 ++--- 2 files changed, 35 insertions(+), 49 deletions(-) diff --git a/CoffeeScript.sublime-syntax b/CoffeeScript.sublime-syntax index 975d17a..d0de7cf 100644 --- a/CoffeeScript.sublime-syntax +++ b/CoffeeScript.sublime-syntax @@ -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 ]############################################################### @@ -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: @@ -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 ]############################################################## diff --git a/tests/syntax_test_scope.coffee b/tests/syntax_test_scope.coffee index eb25845..ee41cca 100644 --- a/tests/syntax_test_scope.coffee +++ b/tests/syntax_test_scope.coffee @@ -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 ]############################################################### @@ -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 ]##################################################################### @@ -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