| 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/dart2jslib.dart'; | 9 import 'package:compiler/src/dart2jslib.dart'; |
| 10 import 'package:compiler/src/filenames.dart'; | 10 import 'package:compiler/src/filenames.dart'; |
| 11 | 11 |
| 12 import 'analyze_helper.dart'; | 12 import 'analyze_helper.dart'; |
| 13 | 13 |
| 14 // Do not remove WHITE_LIST even if it's empty. The error message for | 14 // Do not remove WHITE_LIST even if it's empty. The error message for |
| 15 // unused members refers to WHITE_LIST by name. | 15 // unused members refers to WHITE_LIST by name. |
| 16 const Map<String, List<String>> WHITE_LIST = const { | 16 const Map<String, List<String>> WHITE_LIST = const { |
| 17 // Helper methods for debugging should never be called from production code: | 17 // Helper methods for debugging should never be called from production code: |
| 18 "lib/src/helpers/": const [" is never "], | 18 "lib/src/helpers/": const [" is never "], |
| 19 | 19 |
| 20 // Node.asLiteralBool is never used. | 20 // Node.asLiteralBool is never used. |
| 21 "lib/src/tree/nodes.dart": const [ | 21 "lib/src/tree/nodes.dart": const [ |
| 22 "The method 'asLiteralBool' is never called"], | 22 "The method 'asLiteralBool' is never called"], |
| 23 | 23 |
| 24 // Some things in dart_printer are not yet used | 24 // Some things in dart_printer are not yet used |
| 25 "lib/src/dart_backend/backend_ast_nodes.dart": const [" is never "], | 25 "lib/src/dart_backend/backend_ast_nodes.dart": const [" is never "], |
| 26 |
| 27 // Uncalled error methods in SemanticSendVisitor and subclasses. |
| 28 "lib/src/resolution/semantic_visitor.dart": const [ |
| 29 "The method 'error"], |
| 30 "lib/src/resolution/semantic_visitor_mixins.dart": const [ |
| 31 "The method 'error", |
| 32 "The class 'SuperBulkMixin' is never used."] |
| 26 }; | 33 }; |
| 27 | 34 |
| 28 void main() { | 35 void main() { |
| 29 var uri = currentDirectory.resolve( | 36 var uri = currentDirectory.resolve( |
| 30 'pkg/compiler/lib/src/use_unused_api.dart'); | 37 'pkg/compiler/lib/src/use_unused_api.dart'); |
| 31 asyncTest(() => analyze([uri], WHITE_LIST, | 38 asyncTest(() => analyze([uri], WHITE_LIST, |
| 32 analyzeAll: false, checkResults: checkResults)); | 39 analyzeAll: false, checkResults: checkResults)); |
| 33 } | 40 } |
| 34 | 41 |
| 35 bool checkResults(Compiler compiler, CollectingDiagnosticHandler handler) { | 42 bool checkResults(Compiler compiler, CollectingDiagnosticHandler handler) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 51 } else if (member.isTypedef) { | 58 } else if (member.isTypedef) { |
| 52 if (member.isResolved) { | 59 if (member.isResolved) { |
| 53 compiler.reportHint(member, MessageKind.GENERIC, | 60 compiler.reportHint(member, MessageKind.GENERIC, |
| 54 {'text': "Helper typedef in production code '$member'."}); | 61 {'text': "Helper typedef in production code '$member'."}); |
| 55 } | 62 } |
| 56 } | 63 } |
| 57 } | 64 } |
| 58 compiler.libraryLoader.lookupLibrary(helperUri).forEachLocalMember(checkLive); | 65 compiler.libraryLoader.lookupLibrary(helperUri).forEachLocalMember(checkLive); |
| 59 return handler.checkResults(); | 66 return handler.checkResults(); |
| 60 } | 67 } |
| OLD | NEW |