Skip to content

Commit 4757339

Browse files
authored
Remove dependency on code_builder (#3451)
1 parent 370cb2c commit 4757339

9 files changed

+1058
-763
lines changed

lib/src/generator/templates.aot_renderers_for_html.dart

Lines changed: 463 additions & 314 deletions
Large diffs are not rendered by default.

lib/src/generator/templates.aot_renderers_for_md.dart

Lines changed: 403 additions & 279 deletions
Large diffs are not rendered by default.

pubspec.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ dependencies:
2626

2727
dev_dependencies:
2828
async: ^2.11.0
29-
code_builder: ^4.4.0
3029
dart_style: ^2.3.1
3130
grinder: ^0.9.4
3231
http: ">=0.13.6 <2.0.0"

test/mustachio/aot_compiler_builder_test.dart

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ import 'annotations.dart';
6666
],
6767
);
6868
var generatedContent = await File(aotRenderersForHtmlPath).readAsString();
69-
expect(
70-
generatedContent, contains('String renderFoo<T>(_i1.Foo<T> context0)'));
69+
expect(generatedContent, contains('String renderFoo<T>(Foo<T> context0)'));
7170
});
7271

7372
test('builds a private render function for a partial', () async {
@@ -94,10 +93,8 @@ import 'annotations.dart';
9493
],
9594
);
9695
var generatedContent = await File(aotRenderersForHtmlPath).readAsString();
97-
expect(
98-
generatedContent,
99-
contains(
100-
'String _renderFoo_partial_foo_header_0<T>(_i1.Foo<T> context0)'));
96+
expect(generatedContent,
97+
contains('String _renderFoo_partial_foo_header_0<T>(Foo<T> context0)'));
10198
});
10299

103100
test('builds a renderer for a generic, bounded type', () async {
@@ -151,12 +148,12 @@ import 'annotations.dart';
151148
var generatedContent = await File(aotRenderersForHtmlPath).readAsString();
152149
expect(
153150
generatedContent,
154-
contains('String _renderFoo_partial_base_0(_i1.Foo context0) =>\n'
151+
contains('String _renderFoo_partial_base_0(Foo context0) =>\n'
155152
' _deduplicated_lib_templates_html__base_html(context0);\n'),
156153
);
157154
expect(
158155
generatedContent,
159-
contains('String _renderBar_partial_base_0(_i1.Bar context0) =>\n'
156+
contains('String _renderBar_partial_base_0(Bar context0) =>\n'
160157
' _deduplicated_lib_templates_html__base_html(context0);\n'),
161158
);
162159
expect(
@@ -198,11 +195,11 @@ import 'annotations.dart';
198195
var generatedContent = await File(aotRenderersForHtmlPath).readAsString();
199196
expect(
200197
generatedContent,
201-
contains('String _renderFoo_partial_base_0(_i1.Foo context0) {'),
198+
contains('String _renderFoo_partial_base_0(Foo context0) {'),
202199
);
203200
expect(
204201
generatedContent,
205-
contains('String _renderBar_partial_base_0(_i1.Bar context0) {'),
202+
contains('String _renderBar_partial_base_0(Bar context0) {'),
206203
);
207204
});
208205
}

test/mustachio/aot_compiler_render_test.dart

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ import 'annotations.dart';
9090
var generatedContent = await File(
9191
'${d.sandbox}/foo_package/lib/foo.aot_renderers_for_html.dart')
9292
.readAsString();
93+
generatedContent = generatedContent.replaceFirst(
94+
"import 'foo.dart';", "import 'package:foo/foo.dart';");
9395
renderScript.writeAsStringSync('''
9496
import 'dart:io';
9597
@@ -179,7 +181,7 @@ void main() {
179181
() => [
180182
d.dir('lib/templates/html', [d.file('foo.html', 'Text {{s1}}')]),
181183
],
182-
'_i1.Foo()..s1 = "<p>hello</p>"',
184+
'Foo()..s1 = "<p>hello</p>"',
183185
);
184186
expect(output, equals('Text &lt;p&gt;hello&lt;&#47;p&gt;'));
185187
});
@@ -189,7 +191,7 @@ void main() {
189191
() => [
190192
d.dir('lib/templates/html', [d.file('foo.html', 'Text {{{s1}}}')]),
191193
],
192-
'_i1.Foo()..s1 = "<p>hello</p>"',
194+
'Foo()..s1 = "<p>hello</p>"',
193195
);
194196
expect(output, equals('Text <p>hello</p>'));
195197
});
@@ -199,7 +201,7 @@ void main() {
199201
() => [
200202
d.dir('lib/templates/html', [d.file('foo.html', 'Text {{b1}}')]),
201203
],
202-
'_i1.Foo()..b1 = true',
204+
'Foo()..b1 = true',
203205
);
204206
expect(output, equals('Text true'));
205207
});
@@ -209,7 +211,7 @@ void main() {
209211
() => [
210212
d.dir('lib/templates/html', [d.file('foo.html', 'Text {{l1}}')]),
211213
],
212-
'_i1.Foo()..l1 = [1, 2, 3]',
214+
'Foo()..l1 = [1, 2, 3]',
213215
);
214216
expect(output, equals('Text [1, 2, 3]'));
215217
});
@@ -220,7 +222,7 @@ void main() {
220222
d.dir('lib/templates/html',
221223
[d.file('foo.html', 'Text {{#b1}}Section{{/b1}}')]),
222224
],
223-
'_i1.Foo()..b1 = true',
225+
'Foo()..b1 = true',
224226
);
225227
expect(output, equals('Text Section'));
226228
});
@@ -231,7 +233,7 @@ void main() {
231233
d.dir('lib/templates/html',
232234
[d.file('foo.html', 'Text {{#b1}}Section{{/b1}}')]),
233235
],
234-
'_i1.Foo()..b1 = false',
236+
'Foo()..b1 = false',
235237
);
236238
expect(output, equals('Text '));
237239
});
@@ -242,7 +244,7 @@ void main() {
242244
d.dir('lib/templates/html',
243245
[d.file('foo.html', 'Text {{#b1}}Section{{/b1}}')]),
244246
],
245-
'_i1.Foo()..b1 = false',
247+
'Foo()..b1 = false',
246248
);
247249
expect(output, equals('Text '));
248250
});
@@ -254,7 +256,7 @@ void main() {
254256
d.dir('lib/templates/html',
255257
[d.file('foo.html', 'Text {{^b1}}Section{{/b1}}')]),
256258
],
257-
'_i1.Foo()..b1 = true',
259+
'Foo()..b1 = true',
258260
);
259261
expect(output, equals('Text '));
260262
});
@@ -265,7 +267,7 @@ void main() {
265267
d.dir('lib/templates/html',
266268
[d.file('foo.html', 'Text {{^b1}}Section{{/b1}}')]),
267269
],
268-
'_i1.Foo()..b1 = false',
270+
'Foo()..b1 = false',
269271
);
270272
expect(output, equals('Text Section'));
271273
});
@@ -276,7 +278,7 @@ void main() {
276278
d.dir('lib/templates/html',
277279
[d.file('foo.html', 'Text {{#l1}}Num {{.}}, {{/l1}}')]),
278280
],
279-
'_i1.Foo()..l1 = [1, 2, 3]',
281+
'Foo()..l1 = [1, 2, 3]',
280282
);
281283
expect(output, equals('Text Num 1, Num 2, Num 3, '));
282284
});
@@ -288,7 +290,7 @@ void main() {
288290
d.dir('lib/templates/html',
289291
[d.file('bar.html', 'Text {{#foo.l1}}Num {{.}}, {{/foo.l1}}')]),
290292
],
291-
'_i1.Bar()..foo = (_i1.Foo()..l1 = [1, 2, 3])',
293+
'Bar()..foo = (Foo()..l1 = [1, 2, 3])',
292294
);
293295
expect(output, equals('Text Num 1, Num 2, Num 3, '));
294296
});
@@ -299,7 +301,7 @@ void main() {
299301
d.dir('lib/templates/html',
300302
[d.file('foo.html', 'Text {{#l1}}Num {{.}}, {{/l1}}')]),
301303
],
302-
'_i1.Foo()..l1 = []',
304+
'Foo()..l1 = []',
303305
);
304306
expect(output, equals('Text '));
305307
});
@@ -310,7 +312,7 @@ void main() {
310312
d.dir('lib/templates/html',
311313
[d.file('foo.html', 'Text {{^l1}}Empty{{/l1}}')]),
312314
],
313-
'_i1.Foo()..l1 = []',
315+
'Foo()..l1 = []',
314316
);
315317
expect(output, equals('Text Empty'));
316318
});
@@ -321,7 +323,7 @@ void main() {
321323
d.dir('lib/templates/html',
322324
[d.file('foo.html', 'Text {{^l1}}Empty{{/l1}}')]),
323325
],
324-
'_i1.Foo()..l1 = [1, 2, 3]',
326+
'Foo()..l1 = [1, 2, 3]',
325327
);
326328
expect(output, equals('Text '));
327329
});
@@ -332,7 +334,7 @@ void main() {
332334
d.dir('lib/templates/html',
333335
[d.file('bar.html', 'Text {{#foo}}Foo: {{s1}}{{/foo}}')]),
334336
],
335-
'_i1.Bar()..foo = (_i1.Foo()..s1 = "hello")',
337+
'Bar()..foo = (Foo()..s1 = "hello")',
336338
);
337339
expect(output, equals('Text Foo: hello'));
338340
});
@@ -344,7 +346,7 @@ void main() {
344346
d.dir('lib/templates/html',
345347
[d.file('bar.html', 'Text {{#foo}}One {{#s2}}Two{{/s2}}{{/foo}}')]),
346348
],
347-
'_i1.Bar()..foo = _i1.Foo()..s2 = "hello"',
349+
'Bar()..foo = Foo()..s2 = "hello"',
348350
);
349351
expect(output, equals('Text One Two'));
350352
});
@@ -355,7 +357,7 @@ void main() {
355357
d.dir('lib/templates/html',
356358
[d.file('foo.html', 'Text {{#s1}}"{{.}}" ({{length}}){{/s1}}')]),
357359
],
358-
'_i1.Foo()..s1 = null',
360+
'Foo()..s1 = null',
359361
);
360362
expect(output, equals('Text '));
361363
});
@@ -366,7 +368,7 @@ void main() {
366368
d.dir('lib/templates/html',
367369
[d.file('foo.html', 'Text {{^s1}}Section{{/s1}}')]),
368370
],
369-
'_i1.Foo()..s1 = "hello"',
371+
'Foo()..s1 = "hello"',
370372
);
371373
expect(output, equals('Text '));
372374
});
@@ -377,7 +379,7 @@ void main() {
377379
d.dir('lib/templates/html',
378380
[d.file('foo.html', 'Text {{^s1}}Section{{/s1}}')]),
379381
],
380-
'_i1.Foo()..s1 = null',
382+
'Foo()..s1 = null',
381383
);
382384
expect(output, equals('Text Section'));
383385
});
@@ -388,7 +390,7 @@ void main() {
388390
d.dir('lib/templates/html',
389391
[d.file('bar.html', 'Text {{#foo}}{{s1}}{{/foo}}')]),
390392
],
391-
'_i1.Bar()..foo = (_i1.Foo()..s1 = "hello")',
393+
'Bar()..foo = (Foo()..s1 = "hello")',
392394
);
393395
expect(output, equals('Text hello'));
394396
});
@@ -400,7 +402,7 @@ void main() {
400402
d.dir('lib/templates/html',
401403
[d.file('bar.html', 'Text {{#foo}}{{s2}}{{/foo}}')]),
402404
],
403-
'_i1.Bar()..foo = (_i1.Foo()..s1 = "hello")..s2 = "goodbye"',
405+
'Bar()..foo = (Foo()..s1 = "hello")..s2 = "goodbye"',
404406
);
405407
expect(output, equals('Text goodbye'));
406408
});
@@ -410,7 +412,7 @@ void main() {
410412
() => [
411413
d.dir('lib/templates/html', [d.file('bar.html', 'Text {{foo.s1}}')]),
412414
],
413-
'_i1.Bar()..foo = (_i1.Foo()..s1 = "hello")..s2 = "goodbye"',
415+
'Bar()..foo = (Foo()..s1 = "hello")..s2 = "goodbye"',
414416
);
415417
expect(output, equals('Text hello'));
416418
});
@@ -420,7 +422,7 @@ void main() {
420422
() => [
421423
d.dir('lib/templates/html', [d.file('foo.html', 'Text {{p1.p2.s}}')]),
422424
],
423-
'_i1.Foo()..p1 = (_i1.Property1()..p2 = (_i1.Property2()..s = "hello"))',
425+
'Foo()..p1 = (Property1()..p2 = (Property2()..s = "hello"))',
424426
);
425427
expect(output, equals('Text hello'));
426428
});
@@ -432,9 +434,9 @@ void main() {
432434
d.dir(
433435
'lib/templates/html', [d.file('foo.html', 'Text {{p1.p2.p3.s}}')]),
434436
],
435-
'_i1.Foo()'
436-
'..p1 = (_i1.Property1()'
437-
'..p2 = (_i1.Property2()..p3 = (_i1.Property3()..s = "hello")))',
437+
'Foo()'
438+
'..p1 = (Property1()'
439+
'..p2 = (Property2()..p3 = (Property3()..s = "hello")))',
438440
);
439441
expect(output, equals('Text hello'));
440442
});
@@ -445,7 +447,7 @@ void main() {
445447
d.dir('lib/templates/html',
446448
[d.file('bar.html', 'Text {{#foo}}{{foo.s1}}{{/foo}}')]),
447449
],
448-
'_i1.Bar()..foo = (_i1.Foo()..s1 = "hello")..s2 = "goodbye"',
450+
'Bar()..foo = (Foo()..s1 = "hello")..s2 = "goodbye"',
449451
);
450452
expect(output, equals('Text hello'));
451453
});
@@ -456,7 +458,7 @@ void main() {
456458
d.dir('lib/templates/html',
457459
[d.file('baz.html', 'Text {{#bar}}{{bar.foo.s1}}{{/bar}}')]),
458460
],
459-
'_i1.Baz()..bar = (_i1.Bar()..foo = (_i1.Foo()..s1 = "hello"))',
461+
'Baz()..bar = (Bar()..foo = (Foo()..s1 = "hello"))',
460462
);
461463
expect(output, equals('Text hello'));
462464
});
@@ -469,7 +471,7 @@ void main() {
469471
d.file('baz.html', 'Text {{#bar}}{{bar.foo.baz.bar.foo.s1}}{{/bar}}')
470472
]),
471473
],
472-
'_i1.Baz()..bar = (_i1.Bar()..foo = (_i1.Foo()..s1 = "hello"));'
474+
'Baz()..bar = (Bar()..foo = (Foo()..s1 = "hello"));'
473475
'baz.bar!.foo!.baz = baz',
474476
);
475477
expect(output, equals('Text hello'));
@@ -483,7 +485,7 @@ void main() {
483485
d.file('_foo.mustache.html', 'Partial {{s1}}'),
484486
]),
485487
],
486-
'_i1.Bar()..foo = (_i1.Foo()..s1 = "hello")',
488+
'Bar()..foo = (Foo()..s1 = "hello")',
487489
);
488490
expect(output, equals('Text Partial hello'));
489491
});
@@ -498,7 +500,7 @@ void main() {
498500
d.file('_foo.mustache.html', 'Partial {{s1}}'),
499501
]),
500502
],
501-
'_i1.Bar()..foo = (_i1.Foo()..s1 = "hello")',
503+
'Bar()..foo = (Foo()..s1 = "hello")',
502504
);
503505
expect(output, equals('Text Partial hello'));
504506
});
@@ -515,7 +517,7 @@ void main() {
515517
d.file('_foo.mustache.html', 'Partial {{s2}}'),
516518
]),
517519
],
518-
'_i1.Bar()..foo = (_i1.Foo()..s1 = "hello")..s2 = "goodbye"',
520+
'Bar()..foo = (Foo()..s1 = "hello")..s2 = "goodbye"',
519521
);
520522
expect(output, equals('Text Partial goodbye'));
521523
});
@@ -530,7 +532,7 @@ void main() {
530532
d.file('_foo_l1.mustache.html', 'p2 {{.}}, '),
531533
]),
532534
],
533-
'_i1.Bar()..foo = (_i1.Foo()..s1 = "hello"..l1 = [1, 2, 3])',
535+
'Bar()..foo = (Foo()..s1 = "hello"..l1 = [1, 2, 3])',
534536
);
535537
expect(output, equals('Text, p1, p2 1, p2 2, p2 3, '));
536538
});
@@ -552,7 +554,7 @@ void main() {
552554
() => [
553555
d.dir('lib/templates/html', [d.file('foo.html', 'Text {{s2}}')]),
554556
],
555-
'_i1.Foo()',
557+
'Foo()',
556558
),
557559
throwsA(const TypeMatcher<MustachioResolutionError>()
558560
.having((e) => e.message, 'message', contains('''
@@ -571,7 +573,7 @@ line 1, column 8 of lib/templates/html/foo.html: Failed to resolve '[s2]' as a p
571573
d.dir('lib/templates/html',
572574
[d.file('foo.html', 'Text {{#s2}}Section{{/s2}}')]),
573575
],
574-
'_i1.Foo()',
576+
'Foo()',
575577
),
576578
throwsA(const TypeMatcher<MustachioResolutionError>()
577579
.having((e) => e.message, 'message', contains('''
@@ -590,7 +592,7 @@ line 1, column 9 of lib/templates/html/foo.html: Failed to resolve '[s2]' as a p
590592
() => [
591593
d.dir('lib/templates/html', [d.file('bar.html', 'Text {{foo.x}}')]),
592594
],
593-
'_i1.Bar()..foo = _i1.Foo()',
595+
'Bar()..foo = Foo()',
594596
),
595597
throwsA(const TypeMatcher<MustachioResolutionError>()
596598
.having((e) => e.message, 'message', contains('''
@@ -610,7 +612,7 @@ line 1, column 8 of lib/templates/html/bar.html: Failed to resolve 'x' on Bar wh
610612
d.dir('lib/templates/html',
611613
[d.file('bar.html', 'Text {{#foo.x}}Section{{/foo.x}}')]),
612614
],
613-
'_i1.Bar()..foo = _i1.Foo()',
615+
'Bar()..foo = Foo()',
614616
),
615617
throwsA(const TypeMatcher<MustachioResolutionError>()
616618
.having((e) => e.message, 'message', contains('''
@@ -634,7 +636,7 @@ line 1, column 13 of lib/templates/html/bar.html: Failed to resolve '[x]' as a p
634636
d.file('bar.html', 'Text {{#foo}}{{>missing.mustache}}{{/foo}}')
635637
]),
636638
],
637-
'_i1.Bar()',
639+
'Bar()',
638640
),
639641
throwsA(const TypeMatcher<PathNotFoundException>()),
640642
);

0 commit comments

Comments
 (0)