| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 "lib/src/cps_ir/cps_fragment.dart": const [ | 63 "lib/src/cps_ir/cps_fragment.dart": const [ |
| 64 "The method 'beginLoop' is never called.", | 64 "The method 'beginLoop' is never called.", |
| 65 "The method 'continueLoop' is never called.", | 65 "The method 'continueLoop' is never called.", |
| 66 "The method 'invokeMethod' is never called.", | 66 "The method 'invokeMethod' is never called.", |
| 67 ], | 67 ], |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 void main() { | 70 void main() { |
| 71 var uri = currentDirectory.resolve( | 71 var uri = currentDirectory.resolve( |
| 72 'pkg/compiler/lib/src/use_unused_api.dart'); | 72 'pkg/compiler/lib/src/use_unused_api.dart'); |
| 73 asyncTest(() => analyze([uri], WHITE_LIST, | 73 asyncTest(() => analyze( |
| 74 analyzeAll: false, checkResults: checkResults)); | 74 [uri], |
| 75 // TODO(johnniwinther): Use [WHITE_LIST] again when |
| 76 // [Compiler.reportUnusedCode] is reenabled. |
| 77 const {}, // WHITE_LIST |
| 78 analyzeAll: false, |
| 79 checkResults: checkResults)); |
| 75 } | 80 } |
| 76 | 81 |
| 77 bool checkResults(Compiler compiler, CollectingDiagnosticHandler handler) { | 82 bool checkResults(Compiler compiler, CollectingDiagnosticHandler handler) { |
| 78 var helperUri = currentDirectory.resolve( | 83 var helperUri = currentDirectory.resolve( |
| 79 'pkg/compiler/lib/src/helpers/helpers.dart'); | 84 'pkg/compiler/lib/src/helpers/helpers.dart'); |
| 80 void checkLive(member) { | 85 void checkLive(member) { |
| 81 if (member.isFunction) { | 86 if (member.isFunction) { |
| 82 if (compiler.enqueuer.resolution.hasBeenResolved(member)) { | 87 if (compiler.enqueuer.resolution.hasBeenResolved(member)) { |
| 83 compiler.reportHint(member, MessageKind.GENERIC, | 88 compiler.reportHint(member, MessageKind.GENERIC, |
| 84 {'text': "Helper function in production code '$member'."}); | 89 {'text': "Helper function in production code '$member'."}); |
| 85 } | 90 } |
| 86 } else if (member.isClass) { | 91 } else if (member.isClass) { |
| 87 if (member.isResolved) { | 92 if (member.isResolved) { |
| 88 compiler.reportHint(member, MessageKind.GENERIC, | 93 compiler.reportHint(member, MessageKind.GENERIC, |
| 89 {'text': "Helper class in production code '$member'."}); | 94 {'text': "Helper class in production code '$member'."}); |
| 90 } else { | 95 } else { |
| 91 member.forEachLocalMember(checkLive); | 96 member.forEachLocalMember(checkLive); |
| 92 } | 97 } |
| 93 } else if (member.isTypedef) { | 98 } else if (member.isTypedef) { |
| 94 if (member.isResolved) { | 99 if (member.isResolved) { |
| 95 compiler.reportHint(member, MessageKind.GENERIC, | 100 compiler.reportHint(member, MessageKind.GENERIC, |
| 96 {'text': "Helper typedef in production code '$member'."}); | 101 {'text': "Helper typedef in production code '$member'."}); |
| 97 } | 102 } |
| 98 } | 103 } |
| 99 } | 104 } |
| 100 compiler.libraryLoader.lookupLibrary(helperUri).forEachLocalMember(checkLive); | 105 compiler.libraryLoader.lookupLibrary(helperUri).forEachLocalMember(checkLive); |
| 101 return handler.checkResults(); | 106 return handler.checkResults(); |
| 102 } | 107 } |
| OLD | NEW |