Skip to content

Commit e45c447

Browse files
authored
Format the experimental "macro" keyword before classes. (#1357)
In order to use this, you have to pass "--enable-experiment=macros" to the formatter (which the formatter tests now pass).
1 parent f9181eb commit e45c447

File tree

5 files changed

+20
-4
lines changed

5 files changed

+20
-4
lines changed

lib/src/front_end/ast_node_visitor.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ class AstNodeVisitor extends ThrowingAstVisitor<Piece> with PieceFactory {
256256
node.interfaceKeyword,
257257
node.finalKeyword,
258258
node.sealedKeyword,
259+
node.macroKeyword,
259260
node.mixinKeyword,
260261
],
261262
node.classKeyword,

lib/src/source_visitor.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,7 @@ class SourceVisitor extends ThrowingAstVisitor {
592592
modifier(node.finalKeyword);
593593
modifier(node.sealedKeyword);
594594
modifier(node.mixinKeyword);
595+
modifier(node.macroKeyword);
595596
token(node.classKeyword);
596597
space();
597598
token(node.name);

test/declaration/class.unit

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,11 @@ abstract base mixin class C13 {}
7373
class SomeClass native "Zapp" {
7474
}
7575
<<<
76-
class SomeClass native "Zapp" {}
76+
class SomeClass native "Zapp" {}
77+
>>> Macro class.
78+
macro class C {}
79+
abstract macro class D {}
80+
<<<
81+
macro class C {}
82+
83+
abstract macro class D {}

test/utils.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ void _testFile(
151151
indent: formatTest.leadingIndent,
152152
fixes: [...?baseFixes, ...formatTest.fixes],
153153
experimentFlags: useTallStyle
154-
? const ['inline-class', tallStyleExperimentFlag]
155-
: const ['inline-class']);
154+
? const ['inline-class', 'macros', tallStyleExperimentFlag]
155+
: const ['inline-class', 'macros']);
156156

157157
var actual = formatter.formatSource(formatTest.input);
158158

test/whitespace/classes.unit

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,4 +243,11 @@ base mixin class C11 = Object
243243
abstract mixin class C12 = Object
244244
with Mixin;
245245
abstract base mixin class C13 = Object
246-
with Mixin;
246+
with Mixin;
247+
>>> macro class
248+
macro class C1 {}
249+
abstract macro class C6 {}
250+
<<<
251+
macro class C1 {}
252+
253+
abstract macro class C6 {}

0 commit comments

Comments
 (0)