Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ruby] Safe accessor #4109

Merged
merged 1 commit into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Ruby/Ruby.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ contexts:
pop: true

name-parts:
- match: ({{identifier}})?(?:(::)|(\.))
- match: ({{identifier}})?(?:(::)|(&?\.))
captures:
1: support.other.namespace.ruby
2: punctuation.accessor.double-colon.ruby
Expand Down Expand Up @@ -572,7 +572,7 @@ contexts:
- match: '!+|&&|\|\|'
scope: keyword.operator.logical.ruby
push: after-operator
- match: '[~&|^]'
- match: '(?:[~|^]|&(?!\.))'
scope: keyword.operator.bitwise.ruby
push: after-operator
- match: \?
Expand Down Expand Up @@ -626,7 +626,7 @@ contexts:
- match: ''
set: after-identifier
# This consumes attribute access so we don't need a lookbehind for .
- match: \.(?={{identifier}}{{method_punctuation}})
- match: '&?\.(?={{identifier}}{{method_punctuation}})'
scope: punctuation.accessor.dot.ruby
push:
- include: well-known-methods
Expand All @@ -637,7 +637,7 @@ contexts:
- match: '{{identifier}}{{method_punctuation}}'
# This consumes module/class accessor so we don't need a lookbehind for ::
push: after-identifier
- match: \.
- match: '&?\.'
scope: punctuation.accessor.dot.ruby
- match: '::'
scope: punctuation.accessor.double-colon.ruby
Expand Down
12 changes: 9 additions & 3 deletions Ruby/syntax_test_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,10 @@ def #{sym}(*args, &block)
#^^ meta.number.integer.decimal.ruby constant.numeric.value.ruby
# ^ punctuation.accessor - constant.numeric - invalid.illegal
# ^^ - constant.numeric - invalid.illegal - storage.type.numeric
12&.ir
#^^ meta.number.integer.decimal.ruby constant.numeric.value.ruby
# ^^ punctuation.accessor - constant.numeric - invalid.illegal - keyword.operator
# ^^ - constant.numeric - invalid.illegal - storage.type.numeric

12.34
#^^^^^ meta.number.float.decimal.ruby constant.numeric.value.ruby
Expand Down Expand Up @@ -978,12 +982,14 @@ def #{sym}(*args, &block)
# ^ punctuation.terminator.statement.ruby
.
# ^ punctuation.accessor.dot.ruby
&.
# ^^ punctuation.accessor.dot.ruby
::
# ^^ punctuation.accessor.double-colon.ruby
<<=
# ^^^ keyword.operator.assignment.augmented.ruby
&&=
# ^^^ keyword.operator.assignment.augmented.ruby
# ^^^ keyword.operator.assignment.augmented.ruby - punctuation
||=
# ^^^ keyword.operator.assignment.augmented.ruby
**=
Expand Down Expand Up @@ -1037,7 +1043,7 @@ def #{sym}(*args, &block)
<
# ^ keyword.operator.comparison.ruby
&&
# ^^ keyword.operator.logical.ruby
# ^^ keyword.operator.logical.ruby - punctuation
||
# ^^ keyword.operator.logical.ruby
!
Expand All @@ -1049,7 +1055,7 @@ def #{sym}(*args, &block)
~
# ^ keyword.operator.bitwise.ruby
&
# ^ keyword.operator.bitwise.ruby
# ^ keyword.operator.bitwise.ruby - punctuation
|
# ^ keyword.operator.bitwise.ruby
^
Expand Down
Loading