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/implementation/dart2jslib.dart'; | 9 import 'package:compiler/implementation/dart2jslib.dart'; |
10 import 'package:compiler/implementation/filenames.dart'; | 10 import 'package:compiler/implementation/filenames.dart'; |
(...skipping 27 matching lines...) Expand all Loading... |
38 'sdk/lib/_internal/compiler/implementation/use_unused_api.dart'); | 38 'sdk/lib/_internal/compiler/implementation/use_unused_api.dart'); |
39 asyncTest(() => analyze([uri], WHITE_LIST, | 39 asyncTest(() => analyze([uri], WHITE_LIST, |
40 analyzeAll: false, checkResults: checkResults)); | 40 analyzeAll: false, checkResults: checkResults)); |
41 } | 41 } |
42 | 42 |
43 bool checkResults(Compiler compiler, CollectingDiagnosticHandler handler) { | 43 bool checkResults(Compiler compiler, CollectingDiagnosticHandler handler) { |
44 var helperUri = currentDirectory.resolve( | 44 var helperUri = currentDirectory.resolve( |
45 'sdk/lib/_internal/compiler/implementation/helpers/helpers.dart'); | 45 'sdk/lib/_internal/compiler/implementation/helpers/helpers.dart'); |
46 void checkLive(member) { | 46 void checkLive(member) { |
47 if (member.isFunction) { | 47 if (member.isFunction) { |
48 if (compiler.enqueuer.resolution.isLive(member)) { | 48 if (compiler.enqueuer.resolution.hasBeenResolved(member)) { |
49 compiler.reportHint(member, MessageKind.GENERIC, | 49 compiler.reportHint(member, MessageKind.GENERIC, |
50 {'text': "Helper function in production code '$member'."}); | 50 {'text': "Helper function in production code '$member'."}); |
51 } | 51 } |
52 } else if (member.isClass) { | 52 } else if (member.isClass) { |
53 if (member.isResolved) { | 53 if (member.isResolved) { |
54 compiler.reportHint(member, MessageKind.GENERIC, | 54 compiler.reportHint(member, MessageKind.GENERIC, |
55 {'text': "Helper class in production code '$member'."}); | 55 {'text': "Helper class in production code '$member'."}); |
56 } else { | 56 } else { |
57 member.forEachLocalMember(checkLive); | 57 member.forEachLocalMember(checkLive); |
58 } | 58 } |
59 } else if (member.isTypedef) { | 59 } else if (member.isTypedef) { |
60 if (member.isResolved) { | 60 if (member.isResolved) { |
61 compiler.reportHint(member, MessageKind.GENERIC, | 61 compiler.reportHint(member, MessageKind.GENERIC, |
62 {'text': "Helper typedef in production code '$member'."}); | 62 {'text': "Helper typedef in production code '$member'."}); |
63 } | 63 } |
64 } | 64 } |
65 } | 65 } |
66 compiler.libraryLoader.lookupLibrary(helperUri).forEachLocalMember(checkLive); | 66 compiler.libraryLoader.lookupLibrary(helperUri).forEachLocalMember(checkLive); |
67 return handler.checkResults(); | 67 return handler.checkResults(); |
68 } | 68 } |
OLD | NEW |