Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: test/plugin_transformer_test.dart

Issue 888943002: added plugin transformer which initializers can extend to do additional post-processing during tran… (Closed) Base URL: git@github.com:dart-lang/static-init.git@master
Patch Set: make allAssets public Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« lib/plugin_transformer.dart ('K') | « test/initializer_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4 library initialize.plugin_transformer_test;
5
6 import 'common.dart';
Jennifer Messerly 2015/01/30 20:34:26 trivial: put this after package: imports?
jakemac 2015/01/30 22:16:18 Done.
7 import 'package:analyzer/analyzer.dart';
8 import 'package:initialize/plugin_transformer.dart';
9 import 'package:source_maps/refactor.dart';
10 import 'package:unittest/compact_vm_config.dart';
11
12 // Simple plugin which just removes all initMethod initializers.
13 class DeleteInitMethodPlugin extends InitializePluginTransformer {
14 DeleteInitMethodPlugin(String bootstrap) : super(bootstrap);
15
16 initEntry(
17 InstanceCreationExpression expression, TextEditTransaction transaction) {
18 var firstArg = expression.argumentList.arguments[0];
19 if (firstArg is PrefixedIdentifier &&
20 firstArg.identifier.toString() == 'initMethod') {
21 removeInitializer(expression, transaction);
22 }
23 }
24 }
25
26 main() {
27 useCompactVMConfiguration();
28
29 var transformer = new DeleteInitMethodPlugin('web/index.bootstrap.dart');
30
31 testPhases('basic', [[transformer]], {
32 'a|web/index.bootstrap.dart': '''
33 import 'package:initialize/src/static_loader.dart';
34 import 'package:initialize/initialize.dart';
35 import 'index.dart' as i0;
36
37 main() {
38 initializers.addAll([
39 new InitEntry(i0.initMethod, const LibraryIdentifier(#a, null, 'a.da rt')),
Jennifer Messerly 2015/01/30 20:34:26 long line
jakemac 2015/01/30 22:16:18 This is actually intentional in this case, for sim
Jennifer Messerly 2015/01/30 23:11:03 right, but this is a string literal in the a human
40 new InitEntry(i0.initMethod, const LibraryIdentifier(#a, 'a', 'a.dar t')),
41 new InitEntry(i0.initMethod, i0.a),
42 new InitEntry(const i0.DynamicInit('a()'), i0.a),
43 ]);
44
45 i0.main();
46 }
47 '''.replaceAll(' ', '')
48 }, {
49 'a|web/index.bootstrap.dart': '''
50 import 'package:initialize/src/static_loader.dart';
51 import 'package:initialize/initialize.dart';
52 import 'index.dart' as i0;
53
54 main() {
55 initializers.addAll([
56 new InitEntry(const i0.DynamicInit('a()'), i0.a),
57 ]);
58
59 i0.main();
60 }
61 '''.replaceAll(' ', '')
62 }, []);
63 }
OLDNEW
« lib/plugin_transformer.dart ('K') | « test/initializer_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698