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

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: Created 3 years, 5 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 reenable d.
Emily Fortuna 2017/07/21 21:50:51 should we file a bug so Johnni is aware of this?
Siggi Cherem (dart-lang) 2017/07/22 00:04:04 Oh, I just moved the TODO from down below :)
20 "lib/src/helpers/": const [" is never "], 20 // // Helper methods for debugging should never be called from production code :
21 // "lib/src/helpers/": const [" is never "],
21 22
22 // Node.asAssert, Node.asLiteralBool is never used. 23 // // Node.asAssert, Node.asLiteralBool is never used.
23 "lib/src/tree/nodes.dart": const [ 24 // "lib/src/tree/nodes.dart": const [
24 "The method 'asAssert' is never called.", 25 // "The method 'asAssert' is never called.",
25 "The method 'asLiteralBool' is never called." 26 // "The method 'asLiteralBool' is never called."
27 // ],
28
29 // // Uncalled methods in SemanticSendVisitor and subclasses.
30 // "lib/src/resolution/semantic_visitor.dart": const ["The method 'error"],
31 // "lib/src/resolution/semantic_visitor_mixins.dart": const [
32 // "The class 'SuperBulkMixin'",
33 // "The class 'Base",
34 // "The method 'error",
35 // "The method 'visit"
36 // ],
37
38 // // Uncalled type predicate. Keep while related predicates are used.
39 // "lib/src/ssa/nodes.dart": const ["The method 'isArray' is never called"],
40
41 // // Serialization code is only used in test.
42 // "lib/src/serialization/": const ["is never"],
43
44 // "lib/src/universe/world_builder.dart": const [
45 // "The method 'getterInvocationsByName' is never called.",
46 // "The method 'setterInvocationsByName' is never called."
47 // ],
48
49 "pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart": const [
50 "The getter 'iterator' is not defined for the class 'Object'.",
26 ], 51 ],
27 52
28 // Uncalled methods in SemanticSendVisitor and subclasses. 53 "pkg/front_end/lib/src/fasta/type_inference/type_schema.dart": const [
29 "lib/src/resolution/semantic_visitor.dart": const ["The method 'error"], 54 "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 ], 55 ],
36 56
37 // Uncalled type predicate. Keep while related predicates are used. 57 "pkg/kernel/lib/transformations/closure/": const [
38 "lib/src/ssa/nodes.dart": const ["The method 'isArray' is never called"], 58 "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 ], 59 ],
47 }; 60 };
48 61
49 void main() { 62 void main() {
50 var uri = 63 var uri =
51 currentDirectory.resolve('pkg/compiler/lib/src/use_unused_api.dart'); 64 currentDirectory.resolve('pkg/compiler/lib/src/use_unused_api.dart');
52 asyncTest(() => analyze([uri], 65 asyncTest(() => analyze([uri], WHITE_LIST,
53 // TODO(johnniwinther): Use [WHITE_LIST] again when 66 mode: AnalysisMode.TREE_SHAKING, checkResults: checkResults));
54 // [Compiler.reportUnusedCode] is reenabled.
55 const {}, // WHITE_LIST
56 mode: AnalysisMode.TREE_SHAKING,
57 checkResults: checkResults));
58 } 67 }
59 68
60 bool checkResults(Compiler compiler, CollectingDiagnosticHandler handler) { 69 bool checkResults(Compiler compiler, CollectingDiagnosticHandler handler) {
61 var helperUri = 70 var helperUri =
62 currentDirectory.resolve('pkg/compiler/lib/src/helpers/helpers.dart'); 71 currentDirectory.resolve('pkg/compiler/lib/src/helpers/helpers.dart');
63 void checkLive(member) { 72 void checkLive(member) {
64 if (member.isFunction) { 73 if (member.isFunction) {
65 if (compiler.resolutionWorldBuilder.isMemberUsed(member)) { 74 if (compiler.resolutionWorldBuilder.isMemberUsed(member)) {
66 compiler.reporter.reportHintMessage(member, MessageKind.GENERIC, 75 compiler.reporter.reportHintMessage(member, MessageKind.GENERIC,
67 {'text': "Helper function in production code '$member'."}); 76 {'text': "Helper function in production code '$member'."});
(...skipping 10 matching lines...) Expand all
78 compiler.reporter.reportHintMessage(member, MessageKind.GENERIC, 87 compiler.reporter.reportHintMessage(member, MessageKind.GENERIC,
79 {'text': "Helper typedef in production code '$member'."}); 88 {'text': "Helper typedef in production code '$member'."});
80 } 89 }
81 } 90 }
82 } 91 }
83 92
84 (compiler.libraryLoader.lookupLibrary(helperUri) as LibraryElement) 93 (compiler.libraryLoader.lookupLibrary(helperUri) as LibraryElement)
85 .forEachLocalMember(checkLive); 94 .forEachLocalMember(checkLive);
86 return handler.checkResults(); 95 return handler.checkResults();
87 } 96 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698