Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Unified Diff: sdk/lib/_internal/compiler/implementation/compiler.dart

Issue 208423012: Add helpers library to dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/compiler.dart
diff --git a/sdk/lib/_internal/compiler/implementation/compiler.dart b/sdk/lib/_internal/compiler/implementation/compiler.dart
index 64c6f719841196b2798ac3bf8b43c41d8ca1a7ce..1e32e52d4e6861e5f45c5c157f70007a2ef956f5 100644
--- a/sdk/lib/_internal/compiler/implementation/compiler.dart
+++ b/sdk/lib/_internal/compiler/implementation/compiler.dart
@@ -1372,11 +1372,6 @@ abstract class Compiler implements DiagnosticListener {
reportDiagnosticInternal(node, messageKind, arguments, api.Diagnostic.HINT);
}
- /// For debugging only, print a message with a source location.
- void reportHere(Spannable node, String debugMessage) {
ahe 2014/04/10 11:06:32 Is there an alternative to this?
Johnni Winther 2014/04/10 11:11:45 It is moved to helpers/helpers.dart to ensure that
ahe 2014/04/10 11:43:46 That means I have to import helpers/helpers.dart.
Johnni Winther 2014/04/10 12:04:21 Why is it a problem to import 'helpers/helpers.dar
- reportInfo(node, MessageKind.GENERIC, {'text': 'HERE: $debugMessage'});
- }
-
void reportDiagnosticInternal(Spannable node,
MessageKind messageKind,
Map arguments,
@@ -1386,7 +1381,7 @@ abstract class Compiler implements DiagnosticListener {
case api.Diagnostic.WARNING:
case api.Diagnostic.HINT:
Element element = elementFromSpannable(node);
- if (!inUserCode(element)) {
+ if (!inUserCode(element, assumeInUserCode: true)) {
Uri uri = getCanonicalUri(element);
SuppressionInfo info =
suppressedWarnings.putIfAbsent(uri, () => new SuppressionInfo());
@@ -1550,10 +1545,20 @@ abstract class Compiler implements DiagnosticListener {
if (member.isFunction()) {
if (!enqueuer.resolution.isLive(member)) {
reportHint(member, MessageKind.UNUSED_METHOD,
- {'method_name': member.name});
+ {'name': member.name});
+ }
+ } else if (member.isClass()) {
+ if (!member.isResolved) {
+ reportHint(member, MessageKind.UNUSED_CLASS,
+ {'name': member.name});
+ } else {
+ member.forEachLocalMember(checkLive);
+ }
+ } else if (member.isTypedef()) {
+ if (!member.isResolved) {
+ reportHint(member, MessageKind.UNUSED_TYPEDEF,
+ {'name': member.name});
}
- } else if (member.isClass() && !member.isMixinApplication) {
- member.forEachLocalMember(checkLive);
}
}
libraries.forEach((_, library) {
@@ -1589,7 +1594,10 @@ abstract class Compiler implements DiagnosticListener {
/// with that scheme is in user code. For instance, an entry point URI is
/// 'file:///foo.dart' then every library whose canonical URI scheme is
/// 'file' is in user code.
- bool inUserCode(Element element) {
+ ///
+ /// If [assumeInUserCode] is `true`, [element] is assumed to be in user code
+ /// if no entrypoints have been set.
+ bool inUserCode(Element element, {bool assumeInUserCode: false}) {
List<Uri> entrypoints = <Uri>[];
if (mainApp != null) {
entrypoints.add(mainApp.canonicalUri);
@@ -1597,7 +1605,7 @@ abstract class Compiler implements DiagnosticListener {
if (librariesToAnalyzeWhenRun != null) {
entrypoints.addAll(librariesToAnalyzeWhenRun);
}
- if (entrypoints.isEmpty) {
+ if (entrypoints.isEmpty && assumeInUserCode) {
// Assume in user code since [mainApp] has not been set yet.
return true;
}

Powered by Google App Engine
This is Rietveld 408576698