File tree Expand file tree Collapse file tree 2 files changed +51
-1
lines changed Expand file tree Collapse file tree 2 files changed +51
-1
lines changed Original file line number Diff line number Diff line change @@ -863,7 +863,16 @@ class AstNodeVisitor extends ThrowingAstVisitor<void>
863
863
864
864
@override
865
865
void visitPrefixExpression (PrefixExpression node) {
866
- throw UnimplementedError ();
866
+ token (node.operator );
867
+
868
+ // Edge case: put a space after "-" if the operand is "-" or "--" so that
869
+ // we don't merge the operator tokens.
870
+ if (node.operand
871
+ case PrefixExpression (operator : Token (lexeme: '-' || '--' ))) {
872
+ space ();
873
+ }
874
+
875
+ visit (node.operand);
867
876
}
868
877
869
878
@override
Original file line number Diff line number Diff line change
1
+ 40 columns |
2
+ >>> Unary negate.
3
+ - foo ;
4
+ <<<
5
+ -foo;
6
+ >>> Bitwise not.
7
+ ~ foo ;
8
+ <<<
9
+ ~foo;
10
+ >>> Boolean not.
11
+ ! foo ;
12
+ <<<
13
+ !foo;
14
+ >>> Prefix increment.
15
+ ++ foo ;
16
+ <<<
17
+ ++foo;
18
+ >>> Prefix decrement.
19
+ -- foo ;
20
+ <<<
21
+ --foo;
22
+ >>> Multiple prefix operators.
23
+ - ~ ! foo;
24
+ <<<
25
+ -~!foo;
26
+ >>> Sequential `-` operators are not joined.
27
+ - - - -foo;
28
+ <<<
29
+ - - - -foo;
30
+ >>> A `-` operator before a negative integer is not joined.
31
+ - -1;
32
+ <<<
33
+ - -1;
34
+ >>> A `-` operator before a negative floating point number is not joined.
35
+ - -1.2;
36
+ <<<
37
+ - -1.2;
38
+ >>> A `-` before a `--` is not joined.
39
+ - -- foo;
40
+ <<<
41
+ - --foo;
You can’t perform that action at this time.
0 commit comments