OLD | NEW |
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'; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 }; | 69 }; |
70 | 70 |
71 void main() { | 71 void main() { |
72 var uri = currentDirectory.resolve( | 72 var uri = currentDirectory.resolve( |
73 'pkg/compiler/lib/src/use_unused_api.dart'); | 73 'pkg/compiler/lib/src/use_unused_api.dart'); |
74 asyncTest(() => analyze( | 74 asyncTest(() => analyze( |
75 [uri], | 75 [uri], |
76 // TODO(johnniwinther): Use [WHITE_LIST] again when | 76 // TODO(johnniwinther): Use [WHITE_LIST] again when |
77 // [Compiler.reportUnusedCode] is reenabled. | 77 // [Compiler.reportUnusedCode] is reenabled. |
78 const {}, // WHITE_LIST | 78 const {}, // WHITE_LIST |
79 analyzeAll: false, | 79 mode: AnalysisMode.TREE_SHAKING, |
80 checkResults: checkResults)); | 80 checkResults: checkResults)); |
81 } | 81 } |
82 | 82 |
83 bool checkResults(Compiler compiler, CollectingDiagnosticHandler handler) { | 83 bool checkResults(Compiler compiler, CollectingDiagnosticHandler handler) { |
84 var helperUri = currentDirectory.resolve( | 84 var helperUri = currentDirectory.resolve( |
85 'pkg/compiler/lib/src/helpers/helpers.dart'); | 85 'pkg/compiler/lib/src/helpers/helpers.dart'); |
86 void checkLive(member) { | 86 void checkLive(member) { |
87 if (member.isFunction) { | 87 if (member.isFunction) { |
88 if (compiler.enqueuer.resolution.hasBeenProcessed(member)) { | 88 if (compiler.enqueuer.resolution.hasBeenProcessed(member)) { |
89 compiler.reporter.reportHintMessage( | 89 compiler.reporter.reportHintMessage( |
(...skipping 12 matching lines...) Expand all Loading... |
102 if (member.isResolved) { | 102 if (member.isResolved) { |
103 compiler.reporter.reportHintMessage( | 103 compiler.reporter.reportHintMessage( |
104 member, MessageKind.GENERIC, | 104 member, MessageKind.GENERIC, |
105 {'text': "Helper typedef in production code '$member'."}); | 105 {'text': "Helper typedef in production code '$member'."}); |
106 } | 106 } |
107 } | 107 } |
108 } | 108 } |
109 compiler.libraryLoader.lookupLibrary(helperUri).forEachLocalMember(checkLive); | 109 compiler.libraryLoader.lookupLibrary(helperUri).forEachLocalMember(checkLive); |
110 return handler.checkResults(); | 110 return handler.checkResults(); |
111 } | 111 } |
OLD | NEW |