File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -677,8 +677,20 @@ pub struct NspUnaryRule {
677677pub type NspUnaryArgs = ZeroRange ;
678678
679679impl NspUnaryArgs {
680+ fn is_exception ( node : & UnaryExpressionContent ) -> bool {
681+ // Defined keyword counts as UnaryOp for DLS, but we allow space after it
682+ match node. operation . get_token ( ) {
683+ Some ( token) => match token. kind {
684+ TokenKind :: Defined => true ,
685+ _ => false ,
686+ } ,
687+ None => false ,
688+ }
689+ }
690+
680691 pub fn from_unary_expr ( node : & UnaryExpressionContent )
681692 -> Option < NspUnaryArgs > {
693+ if Self :: is_exception ( node) { return None ; }
682694 let mut gap = node. range ( ) ;
683695 gap. col_start = node. operation . range ( ) . col_end ;
684696 gap. col_end = node. expr . range ( ) . col_start ;
Original file line number Diff line number Diff line change @@ -43,4 +43,16 @@ method this_is_some_method(conf_object_t *dummy_obj) {
4343fn no_space_unary_correct ( ) {
4444 let rules = set_up ( ) ;
4545 assert_snippet ( NO_SPACE_UNARY_CORRECT , vec ! [ ] , & rules) ;
46+ }
47+
48+ static UNARY_EXCEPTIONS : & str = "
49+ method this_is_some_method(conf_object_t *dummy_obj) {
50+ if (!defined attr_workaround)
51+ return;
52+ }
53+ " ;
54+ #[ test]
55+ fn unary_exceptions ( ) {
56+ let rules = set_up ( ) ;
57+ assert_snippet ( UNARY_EXCEPTIONS , vec ! [ ] , & rules) ;
4658}
You can’t perform that action at this time.
0 commit comments