Skip to content

Commit b79b628

Browse files
authored
Format native methods. (#1340)
1 parent 5b89991 commit b79b628

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

lib/src/front_end/ast_node_visitor.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,11 @@ class AstNodeVisitor extends ThrowingAstVisitor<Piece> with PieceFactory {
11621162

11631163
@override
11641164
Piece visitNativeFunctionBody(NativeFunctionBody node) {
1165-
throw UnimplementedError();
1165+
return buildPiece((b) {
1166+
b.token(node.nativeKeyword);
1167+
b.visit(node.stringLiteral, spaceBefore: true);
1168+
b.token(node.semicolon);
1169+
});
11661170
}
11671171

11681172
@override

test/declaration/native.unit

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
40 columns |
2+
>>> Without strings.
3+
class Foo {
4+
Foo() native ;
5+
int bar() native ;
6+
}
7+
<<<
8+
class Foo {
9+
Foo() native;
10+
int bar() native;
11+
}
12+
>>> With strings.
13+
class Foo {
14+
Foo() native "Foo" ;
15+
int bar() native "bar" ;
16+
}
17+
<<<
18+
class Foo {
19+
Foo() native "Foo";
20+
int bar() native "bar";
21+
}
22+
>>> class
23+
class Foo native "Foo" { }
24+
<<<
25+
class Foo native "Foo" {}

0 commit comments

Comments
 (0)