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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 const {}, // WHITE_LIST | 78 const {}, // WHITE_LIST |
79 analyzeAll: false, | 79 analyzeAll: false, |
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.hasBeenResolved(member)) { |
89 compiler.reporter.reportHintMessage( | 89 compiler.reporter.reportHintMessage( |
90 member, MessageKind.GENERIC, | 90 member, MessageKind.GENERIC, |
91 {'text': "Helper function in production code '$member'."}); | 91 {'text': "Helper function in production code '$member'."}); |
92 } | 92 } |
93 } else if (member.isClass) { | 93 } else if (member.isClass) { |
94 if (member.isResolved) { | 94 if (member.isResolved) { |
95 compiler.reporter.reportHintMessage( | 95 compiler.reporter.reportHintMessage( |
96 member, MessageKind.GENERIC, | 96 member, MessageKind.GENERIC, |
97 {'text': "Helper class in production code '$member'."}); | 97 {'text': "Helper class in production code '$member'."}); |
98 } else { | 98 } else { |
99 member.forEachLocalMember(checkLive); | 99 member.forEachLocalMember(checkLive); |
100 } | 100 } |
101 } else if (member.isTypedef) { | 101 } else if (member.isTypedef) { |
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 |