From 8d2a8a7ce82817ad0fdd923fe980db75259ead60 Mon Sep 17 00:00:00 2001 From: chbk Date: Wed, 6 Dec 2017 21:24:01 +0100 Subject: [PATCH 01/12] Add separators to repository --- grammars/ruby.cson | 66 +++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 36 deletions(-) diff --git a/grammars/ruby.cson b/grammars/ruby.cson index b5ffd6f..1621560 100644 --- a/grammars/ruby.cson +++ b/grammars/ruby.cson @@ -1878,8 +1878,7 @@ ] } { - 'match': '=>' - 'name': 'punctuation.separator.key-value' + 'include': '#separators' } { 'match': '->' @@ -1902,13 +1901,6 @@ 'match': '(?<=^|[ \\t])!|&&|\\|\\||\\^' 'name': 'keyword.operator.logical.ruby' } - { - 'comment': 'Safe navigation operator' - 'match': '(&\\.)\\s*(?![A-Z])' - 'captures': - '1': - 'name': 'punctuation.separator.method.ruby' - } { 'match': '(%|&|\\*\\*|\\*|\\+|-|/)' 'name': 'keyword.operator.arithmetic.ruby' @@ -1921,33 +1913,6 @@ 'match': '\\||~|>>' 'name': 'keyword.operator.other.ruby' } - { - 'match': ';' - 'name': 'punctuation.separator.statement.ruby' - } - { - 'match': ',' - 'name': 'punctuation.separator.object.ruby' - } - { - 'comment': 'Mark as namespace separator if double colons followed by capital letter' - 'match': '(::)\\s*(?=[A-Z])' - 'captures': - '1': - 'name': 'punctuation.separator.namespace.ruby' - } - { - 'comment': 'Mark as method separator if double colons not followed by capital letter' - 'match': '(\\.|::)\\s*(?![A-Z])' - 'captures': - '1': - 'name': 'punctuation.separator.method.ruby' - } - { - 'comment': 'Must come after method and constant separators to prefer double colons' - 'match': ':' - 'name': 'punctuation.separator.other.ruby' - } { 'match': '{' 'name': 'punctuation.section.scope.begin.ruby' @@ -2283,6 +2248,35 @@ 'name': 'comment.line.number-sign.ruby' } ] + 'separators': + 'patterns': [ + { + 'match': '=>' + 'name': 'punctuation.separator.key-value.ruby' + } + { + 'match': ';' + 'name': 'punctuation.separator.statement.ruby' + } + { + 'match': ',' + 'name': 'punctuation.separator.object.ruby' + } + { + 'match': '(::)\\s*(?=[A-Z])' + 'captures': + '1': + 'name': 'punctuation.separator.namespace.ruby' + } + { + 'match': '&?\\.|::' + 'name': 'punctuation.separator.method.ruby' + } + { + 'match': ':' + 'name': 'punctuation.separator.other.ruby' + } + ] 'yard': 'patterns': [ { From 7185bae4325d388ab83a251837765716da9361ba Mon Sep 17 00:00:00 2001 From: chbk Date: Wed, 6 Dec 2017 21:30:20 +0100 Subject: [PATCH 02/12] Tokenize commas in function declarations --- grammars/ruby.cson | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/grammars/ruby.cson b/grammars/ruby.cson index 1621560..cb9e948 100644 --- a/grammars/ruby.cson +++ b/grammars/ruby.cson @@ -291,6 +291,10 @@ } ] } + { + 'match': ',' + 'name': 'punctuation.separator.object.ruby' + } ] } { @@ -338,6 +342,10 @@ } ] } + { + 'match': ',' + 'name': 'punctuation.separator.object.ruby' + } ] } { From 51690ca408b91c2d0f67a51f30bce176ff3ebb38 Mon Sep 17 00:00:00 2001 From: chbk Date: Wed, 6 Dec 2017 21:33:17 +0100 Subject: [PATCH 03/12] Rewrite grammar for class and module declarations --- grammars/ruby.cson | 120 ++++++++++++++++++++++++++++----------------- 1 file changed, 74 insertions(+), 46 deletions(-) diff --git a/grammars/ruby.cson b/grammars/ruby.cson index cb9e948..f72f8ab 100644 --- a/grammars/ruby.cson +++ b/grammars/ruby.cson @@ -60,60 +60,88 @@ ''' 'patterns': [ { + 'begin': '\\bclass\\b' 'captures': - '1': + '0': 'name': 'keyword.control.class.ruby' - '2': - 'name': 'entity.name.type.class.ruby' - '4': - 'name': 'entity.other.inherited-class.ruby' - '5': - 'name': 'punctuation.separator.inheritance.ruby' - '6': - 'name': 'variable.other.object.ruby' - '7': - 'name': 'punctuation.definition.variable.ruby' - 'match': '''(?x) - ^\\s*(class)\\s+ - ( - ( - [.a-zA-Z0-9_:]+ - (\\s*(<)\\s*[.a-zA-Z0-9_:]+)? # class A < B - ) - | - ((<<)\\s*[.a-zA-Z0-9_:]+) # class << C - ) - ''' + 'end': '\\s*$|(?![\\s\\w.:<])' 'name': 'meta.class.ruby' + 'patterns': [ + { + 'match': '[A-Z]\\w*' + 'name': 'entity.name.type.class.ruby' + } + { + 'include': '#separators' + } + { + 'begin': '<<' + 'captures': + '0': + 'name': 'punctuation.definition.variable.ruby' + 'end': '(?=$)|(?![\\s\\w.:])' + 'patterns': [ + { + 'begin': '\\s*' + 'end': '(?=$)|(?![\\s\\w.:])' + 'contentName': 'variable.other.object.ruby' + 'patterns': [ + { + 'match': '[A-Z]\\w*' + 'name': 'entity.name.type.class.ruby' + } + { + 'include': '#separators' + } + ] + } + ] + } + { + 'begin': '<' + 'captures': + '0': + 'name': 'punctuation.separator.inheritance.ruby' + 'end': '(?=$)|(?![\\s\\w.:])' + 'patterns': [ + { + 'begin': '\\s*' + 'end': '(?=$)|(?![\\s\\w.:])' + 'contentName': 'entity.other.inherited-class.ruby' + 'patterns': [ + { + 'match': '[A-Z]\\w*' + 'name': 'entity.name.type.class.ruby' + } + { + 'include': '#separators' + } + ] + } + ] + } + ] } { + 'begin': '^\\bmodule\\b' 'captures': - '1': + '0': 'name': 'keyword.control.module.ruby' - '2': - 'name': 'entity.name.type.module.ruby' - '3': - 'name': 'entity.other.inherited-class.module.first.ruby' - '4': - 'name': 'punctuation.separator.inheritance.ruby' - '5': - 'name': 'entity.other.inherited-class.module.second.ruby' - '6': - 'name': 'punctuation.separator.inheritance.ruby' - '7': - 'name': 'entity.other.inherited-class.module.third.ruby' - '8': - 'name': 'punctuation.separator.inheritance.ruby' - 'match': '''(?x) - ^\\s*(module)\\s+ - ( - ([A-Z]\\w*(::))? - ([A-Z]\\w*(::))? - ([A-Z]\\w*(::))* - [A-Z]\\w* - ) - ''' + 'end': '\\s*$|(?![\\s\\w.:])' 'name': 'meta.module.ruby' + 'patterns': [ + { + 'match': '[A-Z]\\w*(?=::)' + 'name': 'entity.other.inherited-class.module.ruby' + } + { + 'match': '[A-Z]\\w*' + 'name': 'entity.name.type.module.ruby' + } + { + 'include': '#separators' + } + ] } { 'comment': 'else if is a common mistake carried over from other languages. it works if you put in a second end, but it’s never what you want.' From 670cf19730a9f3e609095afd6aa63360047ca907 Mon Sep 17 00:00:00 2001 From: chbk Date: Wed, 6 Dec 2017 21:35:08 +0100 Subject: [PATCH 04/12] Tokenize `self` and separators in function declarations --- grammars/ruby.cson | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/grammars/ruby.cson b/grammars/ruby.cson index f72f8ab..90a6a25 100644 --- a/grammars/ruby.cson +++ b/grammars/ruby.cson @@ -275,7 +275,8 @@ (?=def\\b) # optimization to help Oniguruma fail fast (?<=^|\\s)(def)\\s+ ( - (?>[a-zA-Z_]\\w*(?>\\.|::))? # method prefix + (?:(self)(\\.|::))? + (?>[a-zA-Z_]\\w*(?>(\\.|::)))* # method prefix (?> # method name [a-zA-Z_]\\w*(?>[?!]|=(?!>))? | @@ -290,6 +291,13 @@ '2': 'name': 'entity.name.function.ruby' '3': + 'name': 'variable.language.self.ruby' + '4': + 'name': 'punctuation.separator.method.ruby' + '5': + 'comment': 'Unfortunately, the repeated pattern (\\.|::)* only captures the last occurring separator' + 'name': 'punctuation.separator.method.ruby' + '6': 'name': 'punctuation.definition.parameters.ruby' 'comment': 'The method pattern comes from the symbol pattern. See there for an explanation.' 'end': '\\)' @@ -330,7 +338,8 @@ (?=def\\b) # optimization to help Oniguruma fail fast (?<=^|\\s)(def)\\s+ ( - (?>[a-zA-Z_]\\w*(?>\\.|::))? # method prefix + (?:(self)(\\.|::))? + (?>[a-zA-Z_]\\w*(?>(\\.|::)))* # method prefix (?> # method name [a-zA-Z_]\\w*(?>[?!]|=(?!>))? | @@ -345,6 +354,13 @@ 'name': 'keyword.control.def.ruby' '2': 'name': 'entity.name.function.ruby' + '3': + 'name': 'variable.language.self.ruby' + '4': + 'name': 'punctuation.separator.method.ruby' + '5': + 'comment': 'Unfortunately, the repeated pattern (\\.|::)* only captures the last occurring separator' + 'name': 'punctuation.separator.method.ruby' 'comment': 'same as the previous rule, but without parentheses around the arguments' 'end': '$' 'name': 'meta.function.method.with-arguments.ruby' @@ -382,6 +398,13 @@ 'name': 'keyword.control.def.ruby' '3': 'name': 'entity.name.function.ruby' + '4': + 'name': 'variable.language.self.ruby' + '5': + 'name': 'punctuation.separator.method.ruby' + '6': + 'comment': 'Unfortunately, the repeated pattern (\\.|::)* only captures the last occurring separator' + 'name': 'punctuation.separator.method.ruby' 'comment': ' the optional name is just to catch the def also without a method-name' 'match': '''(?x) (?=def\\b) # optimization to help Oniguruma fail fast @@ -389,7 +412,8 @@ ( \\s+ ( - (?>[a-zA-Z_]\\w*(?>\\.|::))? # method prefix + (?:(self)(\\.|::))? + (?>[a-zA-Z_]\\w*(?>(\\.|::)))* # method prefix (?> # method name [a-zA-Z_]\\w*(?>[?!]|=(?!>))? | From d86d8d427e48b777ff2828daaf107fae095086e4 Mon Sep 17 00:00:00 2001 From: chbk Date: Wed, 6 Dec 2017 21:37:38 +0100 Subject: [PATCH 05/12] Differentiate `->` from other keywords --- grammars/ruby.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/ruby.cson b/grammars/ruby.cson index 90a6a25..d415b4d 100644 --- a/grammars/ruby.cson +++ b/grammars/ruby.cson @@ -1942,7 +1942,7 @@ } { 'match': '->' - 'name': 'support.function.kernel.ruby' + 'name': 'support.function.kernel.arrow.ruby' } { 'match': '<<=|%=|&{1,2}=|\\*=|\\*\\*=|\\+=|-=|\\^=|\\|{1,2}=|<<' From 0890205001aedcf390c5e8438f915c06aa0ecfbc Mon Sep 17 00:00:00 2001 From: chbk Date: Wed, 6 Dec 2017 21:39:28 +0100 Subject: [PATCH 06/12] Add specs --- spec/ruby-spec.coffee | 159 +++++++++++++++++++++++++++++++++++------- 1 file changed, 132 insertions(+), 27 deletions(-) diff --git a/spec/ruby-spec.coffee b/spec/ruby-spec.coffee index 508e6bc..fa5a715 100644 --- a/spec/ruby-spec.coffee +++ b/spec/ruby-spec.coffee @@ -103,7 +103,7 @@ describe "TextMate Ruby grammar", -> expect(tokens[0]).toEqual value: ':', scopes: ['source.ruby', 'constant.other.symbol.hashkey.ruby', 'punctuation.definition.constant.ruby'] expect(tokens[1]).toEqual value: 'foo', scopes: ['source.ruby', 'constant.other.symbol.hashkey.ruby'] expect(tokens[2]).toEqual value: ' ', scopes: ['source.ruby'] - expect(tokens[3]).toEqual value: '=>', scopes: ['source.ruby', 'punctuation.separator.key-value'] + expect(tokens[3]).toEqual value: '=>', scopes: ['source.ruby', 'punctuation.separator.key-value.ruby'] expect(tokens[4]).toEqual value: ' ', scopes: ['source.ruby'] expect(tokens[5]).toEqual value: '1', scopes: ['source.ruby', 'constant.numeric.ruby'] @@ -116,8 +116,7 @@ describe "TextMate Ruby grammar", -> {tokens} = grammar.tokenizeLine('File:: read "test"') expect(tokens[0]).toEqual value: 'File', scopes: ['source.ruby', 'variable.other.constant.ruby'] expect(tokens[1]).toEqual value: '::', scopes: ['source.ruby', 'punctuation.separator.method.ruby'] - expect(tokens[2]).toEqual value: ' ', scopes: ['source.ruby'] - expect(tokens[3]).toEqual value: 'read ', scopes: ['source.ruby'] + expect(tokens[2]).toEqual value: ' read ', scopes: ['source.ruby'] {tokens} = grammar.tokenizeLine('RbConfig::CONFIG') expect(tokens[0]).toEqual value: 'RbConfig', scopes: ['source.ruby', 'support.class.ruby'] @@ -130,6 +129,34 @@ describe "TextMate Ruby grammar", -> expect(tokens[2]).toEqual value: ' ', scopes: ['source.ruby'] expect(tokens[3]).toEqual value: 'CONFIG', scopes: ['source.ruby', 'variable.other.constant.ruby'] + {tokens} = grammar.tokenizeLine('class A::B::C < ::D::E') + expect(tokens[0]).toEqual value: 'class', scopes: ['source.ruby', 'meta.class.ruby', 'keyword.control.class.ruby'] + expect(tokens[2]).toEqual value: 'A', scopes: ['source.ruby', 'meta.class.ruby', 'entity.name.type.class.ruby'] + expect(tokens[3]).toEqual value: '::', scopes: ['source.ruby', 'meta.class.ruby', 'punctuation.separator.namespace.ruby'] + expect(tokens[4]).toEqual value: 'B', scopes: ['source.ruby', 'meta.class.ruby', 'entity.name.type.class.ruby'] + expect(tokens[5]).toEqual value: '::', scopes: ['source.ruby', 'meta.class.ruby', 'punctuation.separator.namespace.ruby'] + expect(tokens[6]).toEqual value: 'C', scopes: ['source.ruby', 'meta.class.ruby', 'entity.name.type.class.ruby'] + expect(tokens[8]).toEqual value: '<', scopes: ['source.ruby', 'meta.class.ruby', 'punctuation.separator.inheritance.ruby'] + expect(tokens[10]).toEqual value: '::', scopes: ['source.ruby', 'meta.class.ruby', 'entity.other.inherited-class.ruby', 'punctuation.separator.namespace.ruby'] + expect(tokens[11]).toEqual value: 'D', scopes: ['source.ruby', 'meta.class.ruby', 'entity.other.inherited-class.ruby', 'entity.name.type.class.ruby'] + expect(tokens[12]).toEqual value: '::', scopes: ['source.ruby', 'meta.class.ruby','entity.other.inherited-class.ruby', 'punctuation.separator.namespace.ruby'] + expect(tokens[13]).toEqual value: 'E', scopes: ['source.ruby', 'meta.class.ruby', 'entity.other.inherited-class.ruby', 'entity.name.type.class.ruby'] + + {tokens} = grammar.tokenizeLine('class << A::B') + expect(tokens[0]).toEqual value: 'class', scopes: ['source.ruby', 'meta.class.ruby', 'keyword.control.class.ruby'] + expect(tokens[2]).toEqual value: '<<', scopes: ['source.ruby', 'meta.class.ruby', 'punctuation.definition.variable.ruby'] + expect(tokens[4]).toEqual value: 'A', scopes: ['source.ruby', 'meta.class.ruby', 'variable.other.object.ruby', 'entity.name.type.class.ruby'] + expect(tokens[5]).toEqual value: '::', scopes: ['source.ruby', 'meta.class.ruby', 'variable.other.object.ruby', 'punctuation.separator.namespace.ruby'] + expect(tokens[6]).toEqual value: 'B', scopes: ['source.ruby', 'meta.class.ruby', 'variable.other.object.ruby', 'entity.name.type.class.ruby'] + + {tokens} = grammar.tokenizeLine('module A::B::C') + expect(tokens[0]).toEqual value: 'module', scopes: ['source.ruby', 'meta.module.ruby', 'keyword.control.module.ruby'] + expect(tokens[2]).toEqual value: 'A', scopes: ['source.ruby', 'meta.module.ruby', 'entity.other.inherited-class.module.ruby'] + expect(tokens[3]).toEqual value: '::', scopes: ['source.ruby', 'meta.module.ruby', 'punctuation.separator.namespace.ruby'] + expect(tokens[4]).toEqual value: 'B', scopes: ['source.ruby', 'meta.module.ruby', 'entity.other.inherited-class.module.ruby'] + expect(tokens[5]).toEqual value: '::', scopes: ['source.ruby', 'meta.module.ruby', 'punctuation.separator.namespace.ruby'] + expect(tokens[6]).toEqual value: 'C', scopes: ['source.ruby', 'meta.module.ruby', 'entity.name.type.module.ruby'] + it "tokenizes . separator", -> {tokens} = grammar.tokenizeLine('File.read "test"') expect(tokens[0]).toEqual value: 'File', scopes: ['source.ruby', 'support.class.ruby'] @@ -139,8 +166,82 @@ describe "TextMate Ruby grammar", -> {tokens} = grammar.tokenizeLine('File. read "test"') expect(tokens[0]).toEqual value: 'File', scopes: ['source.ruby', 'variable.other.constant.ruby'] expect(tokens[1]).toEqual value: '.', scopes: ['source.ruby', 'punctuation.separator.method.ruby'] - expect(tokens[2]).toEqual value: ' ', scopes: ['source.ruby'] - expect(tokens[3]).toEqual value: 'read ', scopes: ['source.ruby'] + expect(tokens[2]).toEqual value: ' read ', scopes: ['source.ruby'] + + {tokens} = grammar.tokenizeLine('def a.b(*args)') + expect(tokens[0]).toEqual value: 'def', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'keyword.control.def.ruby'] + expect(tokens[2]).toEqual value: 'a', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'entity.name.function.ruby'] + expect(tokens[3]).toEqual value: '.', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'entity.name.function.ruby', 'punctuation.separator.method.ruby'] + expect(tokens[4]).toEqual value: 'b', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'entity.name.function.ruby'] + expect(tokens[5]).toEqual value: '(', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.definition.parameters.ruby'] + expect(tokens[6]).toEqual value: '*', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'storage.type.variable.ruby'] + expect(tokens[7]).toEqual value: 'args', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'variable.parameter.function.ruby'] + expect(tokens[8]).toEqual value: ')', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.definition.parameters.ruby'] + + {tokens} = grammar.tokenizeLine('def a.b *args') + expect(tokens[0]).toEqual value: 'def', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'keyword.control.def.ruby'] + expect(tokens[2]).toEqual value: 'a', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'entity.name.function.ruby'] + expect(tokens[3]).toEqual value: '.', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'entity.name.function.ruby', 'punctuation.separator.method.ruby'] + expect(tokens[4]).toEqual value: 'b', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'entity.name.function.ruby'] + expect(tokens[6]).toEqual value: '*', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'storage.type.variable.ruby'] + expect(tokens[7]).toEqual value: 'args', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'variable.parameter.function.ruby'] + + {tokens} = grammar.tokenizeLine('def a.b') + expect(tokens[0]).toEqual value: 'def', scopes: ['source.ruby', 'meta.function.method.without-arguments.ruby', 'keyword.control.def.ruby'] + expect(tokens[2]).toEqual value: 'a', scopes: ['source.ruby', 'meta.function.method.without-arguments.ruby', 'entity.name.function.ruby'] + expect(tokens[3]).toEqual value: '.', scopes: ['source.ruby', 'meta.function.method.without-arguments.ruby', 'entity.name.function.ruby', 'punctuation.separator.method.ruby'] + expect(tokens[4]).toEqual value: 'b', scopes: ['source.ruby', 'meta.function.method.without-arguments.ruby', 'entity.name.function.ruby'] + + {tokens} = grammar.tokenizeLine('def self.b(*args)') + expect(tokens[0]).toEqual value: 'def', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'keyword.control.def.ruby'] + expect(tokens[2]).toEqual value: 'self', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'entity.name.function.ruby', 'variable.language.self.ruby'] + expect(tokens[3]).toEqual value: '.', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'entity.name.function.ruby', 'punctuation.separator.method.ruby'] + expect(tokens[4]).toEqual value: 'b', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'entity.name.function.ruby'] + expect(tokens[5]).toEqual value: '(', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.definition.parameters.ruby'] + expect(tokens[6]).toEqual value: '*', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'storage.type.variable.ruby'] + expect(tokens[7]).toEqual value: 'args', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'variable.parameter.function.ruby'] + expect(tokens[8]).toEqual value: ')', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.definition.parameters.ruby'] + + {tokens} = grammar.tokenizeLine('def self.b *args') + expect(tokens[0]).toEqual value: 'def', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'keyword.control.def.ruby'] + expect(tokens[2]).toEqual value: 'self', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'entity.name.function.ruby', 'variable.language.self.ruby'] + expect(tokens[3]).toEqual value: '.', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'entity.name.function.ruby', 'punctuation.separator.method.ruby'] + expect(tokens[4]).toEqual value: 'b', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'entity.name.function.ruby'] + expect(tokens[6]).toEqual value: '*', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'storage.type.variable.ruby'] + expect(tokens[7]).toEqual value: 'args', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'variable.parameter.function.ruby'] + + {tokens} = grammar.tokenizeLine('def self.b') + expect(tokens[0]).toEqual value: 'def', scopes: ['source.ruby', 'meta.function.method.without-arguments.ruby', 'keyword.control.def.ruby'] + expect(tokens[2]).toEqual value: 'self', scopes: ['source.ruby', 'meta.function.method.without-arguments.ruby', 'entity.name.function.ruby', 'variable.language.self.ruby'] + expect(tokens[3]).toEqual value: '.', scopes: ['source.ruby', 'meta.function.method.without-arguments.ruby', 'entity.name.function.ruby', 'punctuation.separator.method.ruby'] + expect(tokens[4]).toEqual value: 'b', scopes: ['source.ruby', 'meta.function.method.without-arguments.ruby', 'entity.name.function.ruby'] + + it "tokenizes , separator", -> + {tokens} = grammar.tokenizeLine('hash = {1 => \'one\', 2 => \'two\'}') + expect(tokens[0]).toEqual value: 'hash ', scopes: ['source.ruby'] + expect(tokens[1]).toEqual value: '=', scopes: ['source.ruby', 'keyword.operator.assignment.ruby'] + expect(tokens[3]).toEqual value: '{', scopes: ['source.ruby', 'punctuation.section.scope.begin.ruby'] + expect(tokens[4]).toEqual value: '1', scopes: ['source.ruby', 'constant.numeric.ruby'] + expect(tokens[6]).toEqual value: '=>', scopes: ['source.ruby', 'punctuation.separator.key-value.ruby'] + expect(tokens[8]).toEqual value: '\'', scopes: ['source.ruby', 'string.quoted.single.ruby', 'punctuation.definition.string.begin.ruby'] + expect(tokens[9]).toEqual value: 'one', scopes: ['source.ruby', 'string.quoted.single.ruby'] + expect(tokens[10]).toEqual value: '\'', scopes: ['source.ruby', 'string.quoted.single.ruby', 'punctuation.definition.string.end.ruby'] + expect(tokens[11]).toEqual value: ',', scopes: ['source.ruby', 'punctuation.separator.object.ruby'] + expect(tokens[13]).toEqual value: '2', scopes: ['source.ruby', 'constant.numeric.ruby'] + expect(tokens[15]).toEqual value: '=>', scopes: ['source.ruby', 'punctuation.separator.key-value.ruby'] + expect(tokens[17]).toEqual value: '\'', scopes: ['source.ruby', 'string.quoted.single.ruby', 'punctuation.definition.string.begin.ruby'] + expect(tokens[18]).toEqual value: 'two', scopes: ['source.ruby', 'string.quoted.single.ruby'] + expect(tokens[19]).toEqual value: '\'', scopes: ['source.ruby', 'string.quoted.single.ruby', 'punctuation.definition.string.end.ruby'] + expect(tokens[20]).toEqual value: '}', scopes: ['source.ruby', 'punctuation.section.scope.end.ruby'] + + {tokens} = grammar.tokenizeLine('method(a,b)') + expect(tokens[0]).toEqual value: 'method', scopes: ['source.ruby'] + expect(tokens[1]).toEqual value: '(', scopes: ['source.ruby', 'punctuation.section.function.ruby'] + expect(tokens[2]).toEqual value: 'a', scopes: ['source.ruby'] + expect(tokens[3]).toEqual value: ',', scopes: ['source.ruby', 'punctuation.separator.object.ruby'] + expect(tokens[4]).toEqual value: 'b', scopes: ['source.ruby'] + expect(tokens[5]).toEqual value: ')', scopes: ['source.ruby', 'punctuation.section.function.ruby'] + it "tokenizes %() style strings", -> {tokens} = grammar.tokenizeLine('%(te(s)t)') @@ -478,7 +579,7 @@ describe "TextMate Ruby grammar", -> expect(tokens[2]).toEqual value: 'test', scopes: ['source.ruby', 'string.regexp.interpolated.ruby'] expect(tokens[3]).toEqual value: '/', scopes: ['source.ruby', 'string.regexp.interpolated.ruby', 'punctuation.section.regexp.ruby'] expect(tokens[4]).toEqual value: ' ', scopes: ['source.ruby'] - expect(tokens[5]).toEqual value: '=>', scopes: ['source.ruby', 'punctuation.separator.key-value'] + expect(tokens[5]).toEqual value: '=>', scopes: ['source.ruby', 'punctuation.separator.key-value.ruby'] expect(tokens[6]).toEqual value: ' ', scopes: ['source.ruby'] expect(tokens[7]).toEqual value: '1', scopes: ['source.ruby', 'constant.numeric.ruby'] @@ -730,16 +831,18 @@ describe "TextMate Ruby grammar", -> expect(tokens[8]).toEqual value: '(', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.section.function.ruby'] expect(tokens[9]).toEqual value: '2', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'constant.numeric.ruby'] expect(tokens[10]).toEqual value: ')', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.section.function.ruby'] - expect(tokens[12]).toEqual value: 'green', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'constant.other.symbol.hashkey.parameter.function.ruby'] - expect(tokens[15]).toEqual value: 'rand', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'support.function.kernel.ruby'] - expect(tokens[16]).toEqual value: '(', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.section.function.ruby'] - expect(tokens[17]).toEqual value: '3', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'constant.numeric.ruby'] - expect(tokens[18]).toEqual value: ')', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.section.function.ruby'] - expect(tokens[20]).toEqual value: 'blue', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'constant.other.symbol.hashkey.parameter.function.ruby'] - expect(tokens[23]).toEqual value: 'rand', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'support.function.kernel.ruby'] - expect(tokens[24]).toEqual value: '(', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.section.function.ruby'] - expect(tokens[25]).toEqual value: '4', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'constant.numeric.ruby'] - expect(tokens[26]).toEqual value: ')', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.section.function.ruby'] + expect(tokens[11]).toEqual value: ',', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.separator.object.ruby'] + expect(tokens[13]).toEqual value: 'green', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'constant.other.symbol.hashkey.parameter.function.ruby'] + expect(tokens[16]).toEqual value: 'rand', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'support.function.kernel.ruby'] + expect(tokens[17]).toEqual value: '(', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.section.function.ruby'] + expect(tokens[18]).toEqual value: '3', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'constant.numeric.ruby'] + expect(tokens[19]).toEqual value: ')', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.section.function.ruby'] + expect(tokens[20]).toEqual value: ',', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.separator.object.ruby'] + expect(tokens[22]).toEqual value: 'blue', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'constant.other.symbol.hashkey.parameter.function.ruby'] + expect(tokens[25]).toEqual value: 'rand', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'support.function.kernel.ruby'] + expect(tokens[26]).toEqual value: '(', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.section.function.ruby'] + expect(tokens[27]).toEqual value: '4', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'constant.numeric.ruby'] + expect(tokens[28]).toEqual value: ')', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.section.function.ruby'] it "tokenizes a method with symbol: arg(paren), symbol: arg2(paren)... (no outer parens) properly", -> {tokens} = grammar.tokenizeLine('def method red: rand(2), green: rand(3), blue: rand(4)') @@ -750,20 +853,22 @@ describe "TextMate Ruby grammar", -> expect(tokens[8]).toEqual value: '(', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.section.function.ruby'] expect(tokens[9]).toEqual value: '2', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'constant.numeric.ruby'] expect(tokens[10]).toEqual value: ')', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.section.function.ruby'] - expect(tokens[12]).toEqual value: 'green', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'constant.other.symbol.hashkey.parameter.function.ruby'] - expect(tokens[15]).toEqual value: 'rand', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'support.function.kernel.ruby'] - expect(tokens[16]).toEqual value: '(', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.section.function.ruby'] - expect(tokens[17]).toEqual value: '3', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'constant.numeric.ruby'] - expect(tokens[18]).toEqual value: ')', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.section.function.ruby'] - expect(tokens[20]).toEqual value: 'blue', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'constant.other.symbol.hashkey.parameter.function.ruby'] - expect(tokens[23]).toEqual value: 'rand', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'support.function.kernel.ruby'] - expect(tokens[24]).toEqual value: '(', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.section.function.ruby'] - expect(tokens[25]).toEqual value: '4', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'constant.numeric.ruby'] - expect(tokens[26]).toEqual value: ')', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.section.function.ruby'] + expect(tokens[11]).toEqual value: ',', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.separator.object.ruby'] + expect(tokens[13]).toEqual value: 'green', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'constant.other.symbol.hashkey.parameter.function.ruby'] + expect(tokens[16]).toEqual value: 'rand', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'support.function.kernel.ruby'] + expect(tokens[17]).toEqual value: '(', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.section.function.ruby'] + expect(tokens[18]).toEqual value: '3', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'constant.numeric.ruby'] + expect(tokens[19]).toEqual value: ')', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.section.function.ruby'] + expect(tokens[20]).toEqual value: ',', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.separator.object.ruby'] + expect(tokens[22]).toEqual value: 'blue', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'constant.other.symbol.hashkey.parameter.function.ruby'] + expect(tokens[25]).toEqual value: 'rand', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'support.function.kernel.ruby'] + expect(tokens[26]).toEqual value: '(', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.section.function.ruby'] + expect(tokens[27]).toEqual value: '4', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'constant.numeric.ruby'] + expect(tokens[28]).toEqual value: ')', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.section.function.ruby'] it "tokenizes a stabby lambda properly", -> {tokens} = grammar.tokenizeLine('method_name -> { puts "A message"} do') - expect(tokens[1]).toEqual value: '->', scopes: ['source.ruby', 'support.function.kernel.ruby'] + expect(tokens[1]).toEqual value: '->', scopes: ['source.ruby', 'support.function.kernel.arrow.ruby'] it "tokenizes a simple do block properly", -> {tokens} = grammar.tokenizeLine('do |foo| ') From ea85a378e27c39a8a10d6d9e9000ba1dbd34d4df Mon Sep 17 00:00:00 2001 From: chbk Date: Wed, 6 Dec 2017 22:33:34 +0100 Subject: [PATCH 07/12] Lint --- spec/ruby-spec.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/ruby-spec.coffee b/spec/ruby-spec.coffee index fa5a715..d9d545e 100644 --- a/spec/ruby-spec.coffee +++ b/spec/ruby-spec.coffee @@ -139,7 +139,7 @@ describe "TextMate Ruby grammar", -> expect(tokens[8]).toEqual value: '<', scopes: ['source.ruby', 'meta.class.ruby', 'punctuation.separator.inheritance.ruby'] expect(tokens[10]).toEqual value: '::', scopes: ['source.ruby', 'meta.class.ruby', 'entity.other.inherited-class.ruby', 'punctuation.separator.namespace.ruby'] expect(tokens[11]).toEqual value: 'D', scopes: ['source.ruby', 'meta.class.ruby', 'entity.other.inherited-class.ruby', 'entity.name.type.class.ruby'] - expect(tokens[12]).toEqual value: '::', scopes: ['source.ruby', 'meta.class.ruby','entity.other.inherited-class.ruby', 'punctuation.separator.namespace.ruby'] + expect(tokens[12]).toEqual value: '::', scopes: ['source.ruby', 'meta.class.ruby', 'entity.other.inherited-class.ruby', 'punctuation.separator.namespace.ruby'] expect(tokens[13]).toEqual value: 'E', scopes: ['source.ruby', 'meta.class.ruby', 'entity.other.inherited-class.ruby', 'entity.name.type.class.ruby'] {tokens} = grammar.tokenizeLine('class << A::B') From aa3c55b72cb7d67fd1c31c394ed59381f8562333 Mon Sep 17 00:00:00 2001 From: chbk Date: Thu, 7 Dec 2017 02:20:52 +0100 Subject: [PATCH 08/12] Unnecessary ^ --- grammars/ruby.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/ruby.cson b/grammars/ruby.cson index d415b4d..2fe51fb 100644 --- a/grammars/ruby.cson +++ b/grammars/ruby.cson @@ -123,7 +123,7 @@ ] } { - 'begin': '^\\bmodule\\b' + 'begin': '\\bmodule\\b' 'captures': '0': 'name': 'keyword.control.module.ruby' From 2fb56506b210c666980be70e7b85ee5601fdc080 Mon Sep 17 00:00:00 2001 From: chbk Date: Thu, 8 Mar 2018 00:30:04 +0100 Subject: [PATCH 09/12] Simplify begin/end patterns --- grammars/ruby.cson | 52 ++++++++++++++++++---------------------------- 1 file changed, 20 insertions(+), 32 deletions(-) diff --git a/grammars/ruby.cson b/grammars/ruby.cson index 2fe51fb..dfad608 100644 --- a/grammars/ruby.cson +++ b/grammars/ruby.cson @@ -61,7 +61,7 @@ 'patterns': [ { 'begin': '\\bclass\\b' - 'captures': + 'beginCaptures': '0': 'name': 'keyword.control.class.ruby' 'end': '\\s*$|(?![\\s\\w.:<])' @@ -75,48 +75,36 @@ 'include': '#separators' } { - 'begin': '<<' - 'captures': - '0': + 'begin': '(<<)\\s*' + 'beginCaptures': + '1': 'name': 'punctuation.definition.variable.ruby' + 'contentName': 'variable.other.object.ruby' 'end': '(?=$)|(?![\\s\\w.:])' 'patterns': [ { - 'begin': '\\s*' - 'end': '(?=$)|(?![\\s\\w.:])' - 'contentName': 'variable.other.object.ruby' - 'patterns': [ - { - 'match': '[A-Z]\\w*' - 'name': 'entity.name.type.class.ruby' - } - { - 'include': '#separators' - } - ] + 'match': '[A-Z]\\w*' + 'name': 'entity.name.type.class.ruby' + } + { + 'include': '#separators' } ] } { - 'begin': '<' - 'captures': - '0': + 'begin': '(<)\\s*' + 'beginCaptures': + '1': 'name': 'punctuation.separator.inheritance.ruby' + 'contentName': 'entity.other.inherited-class.ruby' 'end': '(?=$)|(?![\\s\\w.:])' 'patterns': [ { - 'begin': '\\s*' - 'end': '(?=$)|(?![\\s\\w.:])' - 'contentName': 'entity.other.inherited-class.ruby' - 'patterns': [ - { - 'match': '[A-Z]\\w*' - 'name': 'entity.name.type.class.ruby' - } - { - 'include': '#separators' - } - ] + 'match': '[A-Z]\\w*' + 'name': 'entity.name.type.class.ruby' + } + { + 'include': '#separators' } ] } @@ -124,7 +112,7 @@ } { 'begin': '\\bmodule\\b' - 'captures': + 'beginCaptures': '0': 'name': 'keyword.control.module.ruby' 'end': '\\s*$|(?![\\s\\w.:])' From 974810a671b7b43d2eb3b43813b0d8b5b34fb774 Mon Sep 17 00:00:00 2001 From: chbk Date: Thu, 8 Mar 2018 00:32:37 +0100 Subject: [PATCH 10/12] Rewrite regex for namespace separator --- grammars/ruby.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/ruby.cson b/grammars/ruby.cson index dfad608..e2e5625 100644 --- a/grammars/ruby.cson +++ b/grammars/ruby.cson @@ -2311,7 +2311,7 @@ 'name': 'punctuation.separator.object.ruby' } { - 'match': '(::)\\s*(?=[A-Z])' + 'match': '(::)(?=\\s*[A-Z])' 'captures': '1': 'name': 'punctuation.separator.namespace.ruby' From db12c23e634e62f70fb5f2c3516285d896ebe79a Mon Sep 17 00:00:00 2001 From: chbk Date: Thu, 8 Mar 2018 00:34:50 +0100 Subject: [PATCH 11/12] Change semicolon scope name --- grammars/ruby.cson | 2 +- spec/ruby-spec.coffee | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/grammars/ruby.cson b/grammars/ruby.cson index e2e5625..ff438f3 100644 --- a/grammars/ruby.cson +++ b/grammars/ruby.cson @@ -2304,7 +2304,7 @@ } { 'match': ';' - 'name': 'punctuation.separator.statement.ruby' + 'name': 'punctuation.terminator.statement.ruby' } { 'match': ',' diff --git a/spec/ruby-spec.coffee b/spec/ruby-spec.coffee index d9d545e..5ca7b49 100644 --- a/spec/ruby-spec.coffee +++ b/spec/ruby-spec.coffee @@ -433,7 +433,7 @@ describe "TextMate Ruby grammar", -> expect(tokens[8]).toEqual value: '/', scopes: ['source.ruby', 'string.regexp.interpolated.ruby', 'punctuation.section.regexp.ruby'] expect(tokens[9]).toEqual value: 'test', scopes: ['source.ruby', 'string.regexp.interpolated.ruby'] expect(tokens[10]).toEqual value: '/', scopes: ['source.ruby', 'string.regexp.interpolated.ruby', 'punctuation.section.regexp.ruby'] - expect(tokens[11]).toEqual value: ';', scopes: ['source.ruby', 'punctuation.separator.statement.ruby'] + expect(tokens[11]).toEqual value: ';', scopes: ['source.ruby', 'punctuation.terminator.statement.ruby'] {tokens} = grammar.tokenizeLine('/test/ =~ "test"') @@ -653,7 +653,7 @@ describe "TextMate Ruby grammar", -> expect(tokens[1]).toEqual value: '/', scopes: ['source.ruby', 'keyword.operator.arithmetic.ruby'] expect(tokens[2]).toEqual value: ' ', scopes: ['source.ruby'] expect(tokens[3]).toEqual value: '2', scopes: ['source.ruby', 'constant.numeric.ruby'] - expect(tokens[4]).toEqual value: ';', scopes: ['source.ruby', 'punctuation.separator.statement.ruby'] + expect(tokens[4]).toEqual value: ';', scopes: ['source.ruby', 'punctuation.terminator.statement.ruby'] expect(tokens[6]).toEqual value: '/=', scopes: ['source.ruby', 'keyword.operator.assignment.augmented.ruby'] expect(tokens[7]).toEqual value: ' ', scopes: ['source.ruby'] expect(tokens[8]).toEqual value: '2', scopes: ['source.ruby', 'constant.numeric.ruby'] From 43d4aa05901e45a626a59917b352da0eb11f1742 Mon Sep 17 00:00:00 2001 From: chbk Date: Fri, 16 Mar 2018 17:03:01 +0100 Subject: [PATCH 12/12] Change comma scope name --- grammars/ruby.cson | 6 +++--- spec/ruby-spec.coffee | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/grammars/ruby.cson b/grammars/ruby.cson index ff438f3..f6740ba 100644 --- a/grammars/ruby.cson +++ b/grammars/ruby.cson @@ -317,7 +317,7 @@ } { 'match': ',' - 'name': 'punctuation.separator.object.ruby' + 'name': 'punctuation.separator.delimiter.ruby' } ] } @@ -376,7 +376,7 @@ } { 'match': ',' - 'name': 'punctuation.separator.object.ruby' + 'name': 'punctuation.separator.delimiter.ruby' } ] } @@ -2308,7 +2308,7 @@ } { 'match': ',' - 'name': 'punctuation.separator.object.ruby' + 'name': 'punctuation.separator.delimiter.ruby' } { 'match': '(::)(?=\\s*[A-Z])' diff --git a/spec/ruby-spec.coffee b/spec/ruby-spec.coffee index 5ca7b49..37b6b53 100644 --- a/spec/ruby-spec.coffee +++ b/spec/ruby-spec.coffee @@ -226,7 +226,7 @@ describe "TextMate Ruby grammar", -> expect(tokens[8]).toEqual value: '\'', scopes: ['source.ruby', 'string.quoted.single.ruby', 'punctuation.definition.string.begin.ruby'] expect(tokens[9]).toEqual value: 'one', scopes: ['source.ruby', 'string.quoted.single.ruby'] expect(tokens[10]).toEqual value: '\'', scopes: ['source.ruby', 'string.quoted.single.ruby', 'punctuation.definition.string.end.ruby'] - expect(tokens[11]).toEqual value: ',', scopes: ['source.ruby', 'punctuation.separator.object.ruby'] + expect(tokens[11]).toEqual value: ',', scopes: ['source.ruby', 'punctuation.separator.delimiter.ruby'] expect(tokens[13]).toEqual value: '2', scopes: ['source.ruby', 'constant.numeric.ruby'] expect(tokens[15]).toEqual value: '=>', scopes: ['source.ruby', 'punctuation.separator.key-value.ruby'] expect(tokens[17]).toEqual value: '\'', scopes: ['source.ruby', 'string.quoted.single.ruby', 'punctuation.definition.string.begin.ruby'] @@ -238,7 +238,7 @@ describe "TextMate Ruby grammar", -> expect(tokens[0]).toEqual value: 'method', scopes: ['source.ruby'] expect(tokens[1]).toEqual value: '(', scopes: ['source.ruby', 'punctuation.section.function.ruby'] expect(tokens[2]).toEqual value: 'a', scopes: ['source.ruby'] - expect(tokens[3]).toEqual value: ',', scopes: ['source.ruby', 'punctuation.separator.object.ruby'] + expect(tokens[3]).toEqual value: ',', scopes: ['source.ruby', 'punctuation.separator.delimiter.ruby'] expect(tokens[4]).toEqual value: 'b', scopes: ['source.ruby'] expect(tokens[5]).toEqual value: ')', scopes: ['source.ruby', 'punctuation.section.function.ruby'] @@ -377,7 +377,7 @@ describe "TextMate Ruby grammar", -> expect(tokens[1]).toEqual value: '/', scopes: ['source.ruby', 'string.regexp.interpolated.ruby', 'punctuation.section.regexp.ruby'] expect(tokens[2]).toEqual value: 'test', scopes: ['source.ruby', 'string.regexp.interpolated.ruby'] expect(tokens[3]).toEqual value: '/', scopes: ['source.ruby', 'string.regexp.interpolated.ruby', 'punctuation.section.regexp.ruby'] - expect(tokens[4]).toEqual value: ',', scopes: ['source.ruby', 'punctuation.separator.object.ruby'] + expect(tokens[4]).toEqual value: ',', scopes: ['source.ruby', 'punctuation.separator.delimiter.ruby'] {tokens} = grammar.tokenizeLine('[/test/]') @@ -831,13 +831,13 @@ describe "TextMate Ruby grammar", -> expect(tokens[8]).toEqual value: '(', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.section.function.ruby'] expect(tokens[9]).toEqual value: '2', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'constant.numeric.ruby'] expect(tokens[10]).toEqual value: ')', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.section.function.ruby'] - expect(tokens[11]).toEqual value: ',', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.separator.object.ruby'] + expect(tokens[11]).toEqual value: ',', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.separator.delimiter.ruby'] expect(tokens[13]).toEqual value: 'green', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'constant.other.symbol.hashkey.parameter.function.ruby'] expect(tokens[16]).toEqual value: 'rand', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'support.function.kernel.ruby'] expect(tokens[17]).toEqual value: '(', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.section.function.ruby'] expect(tokens[18]).toEqual value: '3', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'constant.numeric.ruby'] expect(tokens[19]).toEqual value: ')', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.section.function.ruby'] - expect(tokens[20]).toEqual value: ',', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.separator.object.ruby'] + expect(tokens[20]).toEqual value: ',', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.separator.delimiter.ruby'] expect(tokens[22]).toEqual value: 'blue', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'constant.other.symbol.hashkey.parameter.function.ruby'] expect(tokens[25]).toEqual value: 'rand', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'support.function.kernel.ruby'] expect(tokens[26]).toEqual value: '(', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.section.function.ruby'] @@ -853,13 +853,13 @@ describe "TextMate Ruby grammar", -> expect(tokens[8]).toEqual value: '(', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.section.function.ruby'] expect(tokens[9]).toEqual value: '2', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'constant.numeric.ruby'] expect(tokens[10]).toEqual value: ')', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.section.function.ruby'] - expect(tokens[11]).toEqual value: ',', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.separator.object.ruby'] + expect(tokens[11]).toEqual value: ',', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.separator.delimiter.ruby'] expect(tokens[13]).toEqual value: 'green', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'constant.other.symbol.hashkey.parameter.function.ruby'] expect(tokens[16]).toEqual value: 'rand', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'support.function.kernel.ruby'] expect(tokens[17]).toEqual value: '(', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.section.function.ruby'] expect(tokens[18]).toEqual value: '3', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'constant.numeric.ruby'] expect(tokens[19]).toEqual value: ')', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.section.function.ruby'] - expect(tokens[20]).toEqual value: ',', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.separator.object.ruby'] + expect(tokens[20]).toEqual value: ',', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.separator.delimiter.ruby'] expect(tokens[22]).toEqual value: 'blue', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'constant.other.symbol.hashkey.parameter.function.ruby'] expect(tokens[25]).toEqual value: 'rand', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'support.function.kernel.ruby'] expect(tokens[26]).toEqual value: '(', scopes: ['source.ruby', 'meta.function.method.with-arguments.ruby', 'punctuation.section.function.ruby'] @@ -888,11 +888,11 @@ describe "TextMate Ruby grammar", -> expect(tokens[10]).toEqual value: '||', scopes: ['source.ruby', 'keyword.operator.logical.ruby'] expect(tokens[12]).toEqual value: 'b', scopes: ['source.ruby', 'variable.other.block.ruby'] expect(tokens[13]).toEqual value: ')', scopes: ['source.ruby', 'punctuation.section.function.ruby'] - expect(tokens[14]).toEqual value: ',', scopes: ['source.ruby', 'punctuation.separator.object.ruby'] + expect(tokens[14]).toEqual value: ',', scopes: ['source.ruby', 'punctuation.separator.delimiter.ruby'] expect(tokens[16]).toEqual value: 'hash', scopes: ['source.ruby', 'variable.other.block.ruby'] expect(tokens[18]).toEqual value: '=', scopes: ['source.ruby', 'keyword.operator.assignment.ruby'] expect(tokens[20]).toEqual value: 'config', scopes: ['source.ruby', 'variable.other.block.ruby'] - expect(tokens[21]).toEqual value: ',', scopes: ['source.ruby', 'punctuation.separator.object.ruby'] + expect(tokens[21]).toEqual value: ',', scopes: ['source.ruby', 'punctuation.separator.delimiter.ruby'] expect(tokens[23]).toEqual value: 'create', scopes: ['source.ruby', 'constant.other.symbol.hashkey.ruby'] expect(tokens[24]).toEqual value: ':', scopes: ['source.ruby', 'constant.other.symbol.hashkey.ruby', 'punctuation.definition.constant.hashkey.ruby'] expect(tokens[26]).toEqual value: 'false', scopes: ['source.ruby', 'constant.language.boolean.ruby']