forked from intellij-rust/intellij-rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(GRAM): Recognize assert!, assert_eq! and assert_ne! macros
This improves navigation and code highlighting inside the following macros: assert!(a == b); debug_assert!(a == b); assert_eq!(a, b); debug_assert_eq!(a, b); assert_ne!(a, b); debug_assert_ne!(a, b); Format arguments are supported: assert!(a == b, "Text {} {} syntax", "with", "format"); assert!(a == b, "Some text"); assert_eq!(a, b, "Some text"); assert_ne!(a, b, "Some text"); Different parenthesis are supported: assert!(a == b); assert![a == b]; assert!{a == b}; Fixes intellij-rust#636 assert_ne! is stable since Rust 1.12. rust-lang/rust#35074
- Loading branch information
Showing
1 changed file
with
19 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -173,7 +173,7 @@ | |
extends (".*_attr") = attr | ||
|
||
elementType ("expr_like_macro|item_like_macro") = macro | ||
extends ("(try|format_like)_macro") = macro | ||
extends ("(try|format_like|assert|assert_eq)_macro") = macro | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
matklad
|
||
elementType (".*_macro_invocation|macro_rules_invocation") = macro_invocation | ||
|
||
generateTokens=false | ||
|
@@ -1004,6 +1004,8 @@ item_like_macro ::= macro_invocation item_macro_arg | |
|
||
try_macro ::= try_macro_invocation try_macro_args { pin = 1 } | ||
format_like_macro ::= format_like_macro_invocation format_macro_args { pin = 1 } | ||
assert_macro ::= assert_macro_invocation assert_macro_args { pin = 1 } | ||
assert_eq_macro ::= assert_eq_macro_invocation assert_eq_macro_args { pin = 1 } | ||
|
||
macro_definition ::= macro_rules_invocation IDENTIFIER item_macro_arg { | ||
pin = 1 | ||
|
@@ -1012,6 +1014,8 @@ macro_definition ::= macro_rules_invocation IDENTIFIER item_macro_arg { | |
|
||
private build_in_macro ::= try_macro | ||
| format_like_macro | ||
| assert_macro | ||
| assert_eq_macro | ||
|
||
private zz_macro_call ::= build_in_macro | expr_like_macro { pin(".*") = macro_invocation } | ||
private zz_macro_item ::= macro_definition | item_like_macro { | ||
|
@@ -1039,6 +1043,14 @@ format_like_macro_invocation ::= ( "format" | |
| "trace" | ||
| "warn" ) '!' | ||
|
||
assert_macro_invocation ::= ( "assert" | ||
| "debug_assert") '!' | ||
|
||
assert_eq_macro_invocation ::= ( "assert_eq" | ||
| "assert_ne" | ||
| "debug_assert_eq" | ||
| "debug_assert_ne") '!' | ||
|
||
// Arguments | ||
macro_arg ::= <<macro_args_delim token_trees>> | ||
|
||
|
@@ -1051,6 +1063,12 @@ item_macro_arg ::= '(' token_trees ')' ';' | |
|
||
try_macro_args ::= <<macro_args_delim any_expr>> | ||
|
||
private zz_assert_macro_args ::= any_expr [ ',' <<comma_separated_list format_macro_arg>> ] | ||
This comment has been minimized.
Sorry, something went wrong.
kumbayo
Author
Owner
|
||
assert_macro_args ::= <<macro_args_delim zz_assert_macro_args>> | ||
|
||
private zz_assert_eq_macro_args ::= any_expr ',' any_expr [ ',' <<comma_separated_list format_macro_arg>> ] | ||
assert_eq_macro_args ::= <<macro_args_delim zz_assert_eq_macro_args>> | ||
|
||
format_macro_args ::= <<macro_args_delim [ <<comma_separated_list format_macro_arg>> ] >> | ||
format_macro_arg ::= [ IDENTIFIER '=' ] any_expr | ||
|
||
|
I am not sure if this part is necessary, i could not detect a difference with or without it :-/
Is there something i can test for?