diff --git a/CoffeeScript.sublime-syntax b/CoffeeScript.sublime-syntax index d0de7cf..565d9b4 100644 --- a/CoffeeScript.sublime-syntax +++ b/CoffeeScript.sublime-syntax @@ -169,8 +169,7 @@ contexts: - match: '[:=](?!>)' scope: keyword.operator.assignment.coffee pop: 1 - - match: (?=\S) - fail: function + - include: else-pop function-parameter-list: - match: \( @@ -778,9 +777,39 @@ contexts: - match: '{{identifier}}(?=\()' scope: meta.function-call.identifier.coffee variable.function.coffee set: function-call-argument-list - # member variable + # member function definition or variable + - match: (?=(?:(?!and=|or=)|@){{identifier}}) + branch_point: member + branch: + - member-function + - member-variable + pop: 1 + + member-function: + - meta_include_prototype: false + - meta_scope: meta.function.identifier.coffee meta.path.coffee + - match: (@?){{identifier}} + scope: entity.name.function.coffee + captures: + 1: punctuation.definition.variable.coffee + set: + - member-function-body + - function-parameter-list + - function-assignment + - match: '' + fail: member + + member-function-body: + - meta_content_scope: meta.function.coffee + - match: '[=-]>' + scope: meta.function.coffee keyword.declaration.function.coffee + pop: 1 + - match: (?=\S) + fail: member + + member-variable: - match: '{{identifier}}' - scope: variable.other.member.coffee + scope: meta.path.coffee variable.other.member.coffee pop: 1 - include: immediately-pop diff --git a/tests/syntax_test_scope.coffee b/tests/syntax_test_scope.coffee index ee41cca..9bd9371 100644 --- a/tests/syntax_test_scope.coffee +++ b/tests/syntax_test_scope.coffee @@ -78,7 +78,17 @@ class App.Router extends Snakeskin.Router # ^ keyword.operator.assignment.coffee # ^^ keyword.declaration.function.coffee - name = => + namespace.name: -> +# ^^^^^^^^^ meta.path.coffee variable.other.object.coffee +# ^ meta.path.coffee punctuation.accessor.dot.coffee +# ^^^^^^^^ - meta.function meta.function +# ^^^^ meta.function.identifier.coffee meta.path.coffee entity.name.function.coffee +# ^ meta.function.coffee keyword.operator.assignment.coffee +# ^ meta.function.coffee - keyword +# ^^ meta.function.coffee keyword.declaration.function.coffee +# ^ - meta.function + + name = -> # ^^^^^^^^^ - meta.function meta.function # ^^^^ meta.function.identifier.coffee entity.name.function.coffee # ^ meta.function.coffee - entity @@ -86,6 +96,17 @@ class App.Router extends Snakeskin.Router # ^ keyword.operator.assignment.coffee # ^^ keyword.declaration.function.coffee + namespace.name = -> +# ^^^^^^^^^ meta.path.coffee variable.other.object.coffee +# ^ meta.path.coffee punctuation.accessor.dot.coffee +# ^^^^^^^^^ - meta.function meta.function +# ^^^^ meta.function.identifier.coffee meta.path.coffee entity.name.function.coffee +# ^ meta.function.coffee - keyword +# ^ meta.function.coffee keyword.operator.assignment.coffee +# ^ meta.function.coffee - keyword +# ^^ meta.function.coffee keyword.declaration.function.coffee +# ^ - meta.function + name: => # ^^^^^^^^ - meta.function meta.function # ^^^^ meta.function.identifier.coffee entity.name.function.coffee @@ -93,6 +114,16 @@ class App.Router extends Snakeskin.Router # ^ keyword.operator.assignment.coffee # ^^ keyword.declaration.function.coffee + namespace.name: => +# ^^^^^^^^^ meta.path.coffee variable.other.object.coffee +# ^ meta.path.coffee punctuation.accessor.dot.coffee +# ^^^^^^^^ - meta.function meta.function +# ^^^^ meta.function.identifier.coffee meta.path.coffee entity.name.function.coffee +# ^ meta.function.coffee keyword.operator.assignment.coffee +# ^ meta.function.coffee - keyword +# ^^ meta.function.coffee keyword.declaration.function.coffee +# ^ - meta.function + name = => # ^^^^^^^^^ - meta.function meta.function # ^^^^ meta.function.identifier.coffee entity.name.function.coffee @@ -101,6 +132,17 @@ class App.Router extends Snakeskin.Router # ^ keyword.operator.assignment.coffee # ^^ keyword.declaration.function.coffee + namespace.name = => +# ^^^^^^^^^ meta.path.coffee variable.other.object.coffee +# ^ meta.path.coffee punctuation.accessor.dot.coffee +# ^^^^^^^^^ - meta.function meta.function +# ^^^^ meta.function.identifier.coffee meta.path.coffee entity.name.function.coffee +# ^ meta.function.coffee - keyword +# ^ meta.function.coffee keyword.operator.assignment.coffee +# ^ meta.function.coffee - keyword +# ^^ meta.function.coffee keyword.declaration.function.coffee +# ^ - meta.function + name: () -> # ^^^^^^^^^^^ - meta.function meta.function # ^^^^ meta.function.identifier.coffee entity.name.function.coffee