nibags created this revision. Restricted Application added a project: Frameworks. Restricted Application added a subscriber: kde-frameworks-devel. nibags requested review of this revision.
REVISION SUMMARY **Changes:** - Add missing keywords. - Remove obsolete types `int` & `uint` (these were depreciated by isize/usize): https://github.com/nox/rust-rfcs/blob/master/text/0544-rename-int-uint.md - Remove type `float`, because it isn't a valid data type: https://doc.rust-lang.org/std/index.html#primitives - Fix identifiers (entity `rustIdent`, marked with FIXME). The Rust identifier highlighting also detects Non-ASCII characters (in the Rust parser, an identifier is: `[a-zA-Z\x80-\xff_][a-zA-Z0-9\x80-\xff_]*`). **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:** - Binaries don't allow unicode escapes, so a difference is made between common and unicode escapes. The RegExpr rules used to detect escape characters are placed in the entities `&commonEscape`; and `&unicodeEscape;`. - Escapes supported in: https://doc.rust-lang.org/std/primitive.char.html#method.escape_default - 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: - Rust documentation: https://doc.rust-lang.org/ - Rust Playground: https://play.rust-lang.org/ - Rust in Vim: https://github.com/rust-lang/rust.vim/blob/master/syntax/rust.vim - Rust in VSCode: https://github.com/Microsoft/vscode/blob/master/extensions/rust/syntaxes/rust.tmLanguage.json - Rust in gedit: https://github.com/GNOME/gtksourceview/blob/master/data/language-specs/rust.lang - Rust in ACE: https://github.com/ajaxorg/ace/blob/master/lib/ace/mode/rust_highlight_rules.js - https://github.com/rust-lang/kate-config TEST PLAN I checked the modifications with the documentation and the compiler of Rust to avoid regressions. REPOSITORY R216 Syntax Highlighting BRANCH improve-rust (branched from master) REVISION DETAIL https://phabricator.kde.org/D13498 AFFECTED FILES autotests/folding/test.rs.fold autotests/html/test.rs.html autotests/input/test.rs autotests/reference/test.rs.ref data/syntax/rust.xml To: nibags Cc: kde-frameworks-devel, michaelh, ngraham, bruns