Ruby: fix RegExp after ": " and fix/improve detection of HEREDOC
ClosedPublic

Authored by nibags on Jan 11 2019, 7:33 AM.

Details

Summary

Allow regular expressions after ": "

BUG: 361875

Previously, after text: , []: or $text=: regular expressions weren't highlighted (the check_div_1 context prevents highlighting regex, similar to NoRegExp context in "javascript.xml"). Regular expressions are allowed there, so they will now be highlighted.

Don't highlight HEREDOC in singleton class definition (operator <<)

BUG: 358273

Now, after the keyword "class", Heredoc's will not be highlighted [1]. For example:

Before, <<Foo was highlighted as Heredoc.

I did some tests in Ruby 2.6.0, 2.5.1 and 2.3.8, and Heredoc isn't considered in the code: class <<Foo, class <<21, class <<"Foo" or class <<-Foo, so I can say that the fix is correct.

Improvements in HEREDOC:

  • Add squiggly HEREDOC (introduced in Ruby 2.3) [2][3]

For example: <<~HEREDOC

  • Backticks can surround identifiers [3]. Example: <<-HEREDOC
  • Improve highlighting of identifier quotes. Now you need to close quotes to highlight the HEREDOC.

For example, HEREDOC was previously highlighted as: <<"HEREDOC , <<HEREDOC"

I also added a modeline to force the use of tabs as an indentation, since the file uses tabs.

References:

FIXED-IN: 5.55.0

Diff Detail

Repository
R216 Syntax Highlighting
Branch
fix-ruby
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 7163
Build 7181: arc lint + arc unit
nibags created this revision.Jan 11 2019, 7:33 AM
Restricted Application added projects: Kate, Frameworks. · View Herald TranscriptJan 11 2019, 7:33 AM
Restricted Application added subscribers: kde-frameworks-devel, kwrite-devel. · View Herald Transcript
nibags requested review of this revision.Jan 11 2019, 7:33 AM
cullmann accepted this revision.Jan 15 2019, 11:20 AM

I am no Ruby expert, but your screenshots show a clear improvement, please push ;=)
Thanks for the improvement + tests!

This revision is now accepted and ready to land.Jan 15 2019, 11:20 AM
nibags updated this revision to Diff 49600.Jan 16 2019, 8:59 AM
nibags edited the summary of this revision. (Show Details)
  • Small correction in comment
nibags edited the summary of this revision. (Show Details)Jan 16 2019, 9:04 AM
nibags closed this revision.Jan 16 2019, 9:07 AM