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

Side by Side Diff: tests/compiler/dart2js/analyze_unused_dart2js_test.dart

Issue 2989453002: Add support for compiling Dart via the FE in dart2js. (Closed)
Patch Set: update status Created 3 years, 4 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyze_unused_dart2js; 5 library analyze_unused_dart2js;
6 6
7 import 'package:async_helper/async_helper.dart'; 7 import 'package:async_helper/async_helper.dart';
8 8
9 import 'package:compiler/src/compiler.dart'; 9 import 'package:compiler/src/compiler.dart';
10 import 'package:compiler/src/diagnostics/messages.dart'; 10 import 'package:compiler/src/diagnostics/messages.dart';
11 import 'package:compiler/src/elements/elements.dart' show LibraryElement; 11 import 'package:compiler/src/elements/elements.dart' show LibraryElement;
12 import 'package:compiler/src/filenames.dart'; 12 import 'package:compiler/src/filenames.dart';
13 13
14 import 'analyze_helper.dart'; 14 import 'analyze_helper.dart';
15 15
16 // Do not remove WHITE_LIST even if it's empty. The error message for 16 // Do not remove WHITE_LIST even if it's empty. The error message for
17 // unused members refers to WHITE_LIST by name. 17 // unused members refers to WHITE_LIST by name.
18 const Map<String, List<String>> WHITE_LIST = const { 18 const Map<String, List<String>> WHITE_LIST = const {
19 // Helper methods for debugging should never be called from production code: 19 // TODO(johnniwinther): uncomment when [Compiler.reportUnusedCode] is
20 "lib/src/helpers/": const [" is never "], 20 // reenabled.
21 // // Helper methods for debugging should never be called from production code :
22 // "lib/src/helpers/": const [" is never "],
21 23
22 // Node.asAssert, Node.asLiteralBool is never used. 24 // // Node.asAssert, Node.asLiteralBool is never used.
23 "lib/src/tree/nodes.dart": const [ 25 // "lib/src/tree/nodes.dart": const [
24 "The method 'asAssert' is never called.", 26 // "The method 'asAssert' is never called.",
25 "The method 'asLiteralBool' is never called." 27 // "The method 'asLiteralBool' is never called."
28 // ],
29
30 // // Uncalled methods in SemanticSendVisitor and subclasses.
31 // "lib/src/resolution/semantic_visitor.dart": const ["The method 'error"],
32 // "lib/src/resolution/semantic_visitor_mixins.dart": const [
33 // "The class 'SuperBulkMixin'",
34 // "The class 'Base",
35 // "The method 'error",
36 // "The method 'visit"
37 // ],
38
39 // // Uncalled type predicate. Keep while related predicates are used.
40 // "lib/src/ssa/nodes.dart": const ["The method 'isArray' is never called"],
41
42 // // Serialization code is only used in test.
43 // "lib/src/serialization/": const ["is never"],
44
45 // "lib/src/universe/world_builder.dart": const [
46 // "The method 'getterInvocationsByName' is never called.",
47 // "The method 'setterInvocationsByName' is never called."
48 // ],
49
50 "pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart": const [
51 "The getter 'iterator' is not defined for the class 'Object'.",
26 ], 52 ],
27 53
28 // Uncalled methods in SemanticSendVisitor and subclasses. 54 "pkg/front_end/lib/src/fasta/type_inference/type_schema.dart": const [
29 "lib/src/resolution/semantic_visitor.dart": const ["The method 'error"], 55 "The class 'UnknownType' overrides 'operator==', but not 'get hashCode'."
30 "lib/src/resolution/semantic_visitor_mixins.dart": const [
31 "The class 'SuperBulkMixin'",
32 "The class 'Base",
33 "The method 'error",
34 "The method 'visit"
35 ], 56 ],
36 57
37 // Uncalled type predicate. Keep while related predicates are used. 58 "pkg/kernel/lib/transformations/closure/": const [
38 "lib/src/ssa/nodes.dart": const ["The method 'isArray' is never called"], 59 "Duplicated library name 'kernel.transformations.closure.converter'",
39
40 // Serialization code is only used in test.
41 "lib/src/serialization/": const ["is never"],
42
43 "lib/src/universe/world_builder.dart": const [
44 "The method 'getterInvocationsByName' is never called.",
45 "The method 'setterInvocationsByName' is never called."
46 ], 60 ],
47 }; 61 };
48 62
49 void main() { 63 void main() {
50 var uri = 64 var uri =
51 currentDirectory.resolve('pkg/compiler/lib/src/use_unused_api.dart'); 65 currentDirectory.resolve('pkg/compiler/lib/src/use_unused_api.dart');
52 asyncTest(() => analyze([uri], 66 asyncTest(() => analyze([uri], WHITE_LIST,
53 // TODO(johnniwinther): Use [WHITE_LIST] again when 67 mode: AnalysisMode.TREE_SHAKING, checkResults: checkResults));
54 // [Compiler.reportUnusedCode] is reenabled.
55 const {}, // WHITE_LIST
56 mode: AnalysisMode.TREE_SHAKING,
57 checkResults: checkResults));
58 } 68 }
59 69
60 bool checkResults(Compiler compiler, CollectingDiagnosticHandler handler) { 70 bool checkResults(Compiler compiler, CollectingDiagnosticHandler handler) {
61 var helperUri = 71 var helperUri =
62 currentDirectory.resolve('pkg/compiler/lib/src/helpers/helpers.dart'); 72 currentDirectory.resolve('pkg/compiler/lib/src/helpers/helpers.dart');
63 void checkLive(member) { 73 void checkLive(member) {
64 if (member.isFunction) { 74 if (member.isFunction) {
65 if (compiler.resolutionWorldBuilder.isMemberUsed(member)) { 75 if (compiler.resolutionWorldBuilder.isMemberUsed(member)) {
66 compiler.reporter.reportHintMessage(member, MessageKind.GENERIC, 76 compiler.reporter.reportHintMessage(member, MessageKind.GENERIC,
67 {'text': "Helper function in production code '$member'."}); 77 {'text': "Helper function in production code '$member'."});
(...skipping 10 matching lines...) Expand all
78 compiler.reporter.reportHintMessage(member, MessageKind.GENERIC, 88 compiler.reporter.reportHintMessage(member, MessageKind.GENERIC,
79 {'text': "Helper typedef in production code '$member'."}); 89 {'text': "Helper typedef in production code '$member'."});
80 } 90 }
81 } 91 }
82 } 92 }
83 93
84 (compiler.libraryLoader.lookupLibrary(helperUri) as LibraryElement) 94 (compiler.libraryLoader.lookupLibrary(helperUri) as LibraryElement)
85 .forEachLocalMember(checkLive); 95 .forEachLocalMember(checkLive);
86 return handler.checkResults(); 96 return handler.checkResults();
87 } 97 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698