-
Notifications
You must be signed in to change notification settings - Fork 144
Fix missing scopes on separators and self
, differentiate ->
#224
Conversation
Please review and approve this! |
@@ -60,60 +60,88 @@ | |||
''' | |||
'patterns': [ | |||
{ | |||
'begin': '\\bclass\\b' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do classes need to be at the start of the line per the previous ^\\s*class\\s*
regex?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, classes can be declared after another statement on the same line.
grammars/ruby.cson
Outdated
} | ||
{ | ||
'begin': '<<' | ||
'captures': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
beginCaptures
grammars/ruby.cson
Outdated
@@ -60,60 +60,88 @@ | |||
''' | |||
'patterns': [ | |||
{ | |||
'begin': '\\bclass\\b' | |||
'captures': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
beginCaptures
grammars/ruby.cson
Outdated
'include': '#separators' | ||
} | ||
{ | ||
'begin': '<<' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like you could redo this as (<<)\\s*
and directly add a contentName here to get rid of the inner pattern.
grammars/ruby.cson
Outdated
] | ||
} | ||
{ | ||
'begin': '<' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as concerns as above.
} | ||
{ | ||
'begin': '\\bmodule\\b' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same concerns as above.
grammars/ruby.cson
Outdated
} | ||
{ | ||
'match': ';' | ||
'name': 'punctuation.separator.statement.ruby' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally tokenized as punctuation.terminator.statement
grammars/ruby.cson
Outdated
} | ||
{ | ||
'match': ',' | ||
'name': 'punctuation.separator.object.ruby' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally tokenized as punctuation.separator.delimiter
. Is ,
only for objects in Ruby?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are also commas in hashes so punctuation.separator.delimiter
is indeed better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it okay if I replace all instances of punctuation.separator.object
by the generic punctuation.separator.delimiter
? Commas in method calls are tokenized by line 2325 but commas in method definitions have their own regexes.
grammars/ruby.cson
Outdated
'name': 'punctuation.separator.object.ruby' | ||
} | ||
{ | ||
'match': '(::)\\s*(?=[A-Z])' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The \\s*
can be in the lookahead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason I thought lookaheads could only have a fixed number of characters.
@50Wliu I have a commit pending for |
Yes, I think what you're saying is fine. |
@50Wliu Do you have any other comments on this pull request? It looks ready to merge for me. |
Sorry for the delay @chbk, someone from the team will take a look as soon as they can. |
Thanks for the contribution 🙇🏾 @chbk |
Description of the Change
Added a
separators
entry to the repositoryRewrote the grammar for class and module declarations with begin/end patterns:
punctuation.separator.inheritance.ruby
topunctuation.separator.namespace.ruby
for consistencyentity.name.type.class.ruby
,entity.name.type.module.ruby
andentity.other.inherited-class.module.ruby
to start with an uppercase letter and to exclude separatorsThis is now scoped properly:
Scoped commas in function declarations:
Scoped
self
and separators in function declarations:Unfortunately, I wasn't able to rewrite the grammar for function declarations with begin/end patterns. I used existing regular expressions to capture separators. Since the captures are placed inside repetition patterns
()*
, only the last separator will be scoped. Not perfect, but still an improvement.Changed scopes for
->
:support.function.kernel.arrow.ruby
Added specs
Applicable Issues
#221 Missing scope on commas
#222 Differentiate
->
from other keywords#223 Namespace separator
::
not scoped in class definition