Rust: Add keywords & bytes, fix identifiers, and other improvements/fixes
ClosedPublic

Authored by nibags on Jun 12 2018, 5:54 PM.

Details

Summary

Changes:

NOTE: The POSIX character class [[::ascii::]] is used. I don't know from which version of KTextEditor (or Qt) the use of POSIX character class is available, or if the use of this is a correct way. It works well, but if it isn't the correct way to do it, I can change it without any problem.

  • Improved and fixes in the highlighting of numbers:
    • Add missing integer suffixes (i128, u128, isize, usize).
    • Add word border (\b) in numbers (Hex, Octal, Binary, Float, Decimal).
    • Improves float detection; floats with suffix 'f' are not allowed (only 'f32' & 'f64').
    • Highlight as 'Error' invalid numbers (Hexadecimal, Octal, Binary).
  • Fix Raw Hashed Strings (r##"text"##). Before, only a maximum of 2 hashes are detected (this is mentioned in a comment). Now any number of #'s are allowed.
  • Add byte characters & byte strings (b'X', b"XX", br"XX", br#"XX"#).
  • Improves character detection and escape characters:
    • Highlight as 'Error' invalid characters.
    • Fixes unicode escapes: only the \u{NNNNNN} type is allowed (Not \uNNNN or \UNNNNNNNN).

NOTES:

  • The style of the itemData 'Scope' is changed from 'dsNormal' to 'dsProcessador', since the detection of identifiers was corrected.

I also added a test file. Any inconvenience or if I need to correct something, do not hesitate to notify!

Sources:

Test Plan

I checked the modifications with the documentation and the compiler of Rust to avoid regressions.

Diff Detail

Repository
R216 Syntax Highlighting
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
nibags created this revision.Jun 12 2018, 5:54 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptJun 12 2018, 5:54 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
nibags requested review of this revision.Jun 12 2018, 5:54 PM
nibags edited the summary of this revision. (Show Details)Jun 12 2018, 5:57 PM
nibags added reviewers: dhaumann, cullmann.
nibags edited the summary of this revision. (Show Details)
nibags edited the summary of this revision. (Show Details)
dhaumann accepted this revision.Jun 12 2018, 7:49 PM

Nice update, will integrate. And thanks for the unit test!

This revision is now accepted and ready to land.Jun 12 2018, 7:49 PM
This revision was automatically updated to reflect the committed changes.