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