| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 dart2js.library_loader; | 5 library dart2js.library_loader; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'common/names.dart' show | 9 import 'common/names.dart' show |
| 10 Uris; | 10 Uris; |
| (...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 892 CombinatorFilter filter) { | 892 CombinatorFilter filter) { |
| 893 assert(invariant(library, exportedLibraryElement.exportsHandled)); | 893 assert(invariant(library, exportedLibraryElement.exportsHandled)); |
| 894 exportedLibraryElement.forEachExport((Element exportedElement) { | 894 exportedLibraryElement.forEachExport((Element exportedElement) { |
| 895 if (!filter.exclude(exportedElement)) { | 895 if (!filter.exclude(exportedElement)) { |
| 896 Link<ExportElement> exports = | 896 Link<ExportElement> exports = |
| 897 pendingExportMap.putIfAbsent(exportedElement, | 897 pendingExportMap.putIfAbsent(exportedElement, |
| 898 () => const Link<ExportElement>()); | 898 () => const Link<ExportElement>()); |
| 899 pendingExportMap[exportedElement] = exports.prepend(export); | 899 pendingExportMap[exportedElement] = exports.prepend(export); |
| 900 } | 900 } |
| 901 }); | 901 }); |
| 902 reporter.withCurrentElement(library, () { | 902 if (!reporter.options.suppressHints) { |
| 903 checkLibraryDependency(reporter, export.node, exportedLibraryElement); | 903 reporter.withCurrentElement(library, () { |
| 904 }); | 904 checkLibraryDependency(reporter, export.node, exportedLibraryElement); |
| 905 }); |
| 906 } |
| 905 } | 907 } |
| 906 | 908 |
| 907 /** | 909 /** |
| 908 * Registers the compute export scope with the node library. | 910 * Registers the compute export scope with the node library. |
| 909 */ | 911 */ |
| 910 void registerExports() { | 912 void registerExports() { |
| 911 library.setExports(exportScope.values.toList()); | 913 library.setExports(exportScope.values.toList()); |
| 912 } | 914 } |
| 913 | 915 |
| 914 /** | 916 /** |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1062 void checkLibraryDependency( | 1064 void checkLibraryDependency( |
| 1063 DiagnosticReporter reporter, | 1065 DiagnosticReporter reporter, |
| 1064 LibraryDependency tag, | 1066 LibraryDependency tag, |
| 1065 LibraryElement library) { | 1067 LibraryElement library) { |
| 1066 if (tag == null || tag.combinators == null) return; | 1068 if (tag == null || tag.combinators == null) return; |
| 1067 for (Combinator combinator in tag.combinators) { | 1069 for (Combinator combinator in tag.combinators) { |
| 1068 for (Identifier identifier in combinator.identifiers) { | 1070 for (Identifier identifier in combinator.identifiers) { |
| 1069 String name = identifier.source; | 1071 String name = identifier.source; |
| 1070 Element element = library.findExported(name); | 1072 Element element = library.findExported(name); |
| 1071 if (element == null) { | 1073 if (element == null) { |
| 1072 reporter.reportHintMessage( | 1074 if (combinator.isHide) { |
| 1073 identifier, | 1075 if (library.isPackageLibrary && |
| 1074 combinator.isHide | 1076 !reporter.options.showPackageWarnings) { |
| 1075 ? MessageKind.EMPTY_HIDE : MessageKind.EMPTY_SHOW, | 1077 // Only report hide hint on packages if we show warnings on these: |
| 1076 {'uri': library.canonicalUri, | 1078 // The hide may be non-empty in some versions of the package, in |
| 1077 'name': name}); | 1079 // which case you shouldn't remove the combinator. |
| 1080 continue; |
| 1081 } |
| 1082 reporter.reportHintMessage( |
| 1083 identifier, |
| 1084 MessageKind.EMPTY_HIDE, |
| 1085 {'uri': library.canonicalUri, |
| 1086 'name': name}); |
| 1087 } else { |
| 1088 reporter.reportHintMessage( |
| 1089 identifier, |
| 1090 MessageKind.EMPTY_SHOW, |
| 1091 {'uri': library.canonicalUri, |
| 1092 'name': name}); |
| 1093 } |
| 1078 } | 1094 } |
| 1079 } | 1095 } |
| 1080 } | 1096 } |
| 1081 } | 1097 } |
| 1082 | 1098 |
| 1083 } | 1099 } |
| 1084 | 1100 |
| 1085 /** | 1101 /** |
| 1086 * Helper class used for computing the possibly cyclic import/export scopes of | 1102 * Helper class used for computing the possibly cyclic import/export scopes of |
| 1087 * a set of libraries. | 1103 * a set of libraries. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1149 // imports. | 1165 // imports. |
| 1150 nodeMap.forEach((LibraryElement library, LibraryDependencyNode node) { | 1166 nodeMap.forEach((LibraryElement library, LibraryDependencyNode node) { |
| 1151 node.registerExports(); | 1167 node.registerExports(); |
| 1152 }); | 1168 }); |
| 1153 | 1169 |
| 1154 // Setup import scopes. | 1170 // Setup import scopes. |
| 1155 nodeMap.forEach((LibraryElement library, LibraryDependencyNode node) { | 1171 nodeMap.forEach((LibraryElement library, LibraryDependencyNode node) { |
| 1156 node.registerImports(reporter); | 1172 node.registerImports(reporter); |
| 1157 }); | 1173 }); |
| 1158 | 1174 |
| 1159 nodeMap.forEach((LibraryElement library, LibraryDependencyNode node) { | 1175 if (!reporter.options.suppressHints) { |
| 1160 node.checkCombinators(reporter); | 1176 nodeMap.forEach((LibraryElement library, LibraryDependencyNode node) { |
| 1161 }); | 1177 node.checkCombinators(reporter); |
| 1178 }); |
| 1179 } |
| 1162 } | 1180 } |
| 1163 | 1181 |
| 1164 /// Registers that [library] depends on [loadedLibrary] through | 1182 /// Registers that [library] depends on [loadedLibrary] through |
| 1165 /// [libraryDependency]. | 1183 /// [libraryDependency]. |
| 1166 void registerDependency(LibraryElementX library, | 1184 void registerDependency(LibraryElementX library, |
| 1167 LibraryDependencyElementX libraryDependency, | 1185 LibraryDependencyElementX libraryDependency, |
| 1168 LibraryElement loadedLibrary) { | 1186 LibraryElement loadedLibrary) { |
| 1169 if (libraryDependency.isExport) { | 1187 if (libraryDependency.isExport) { |
| 1170 // [loadedLibrary] is exported by [library]. | 1188 // [loadedLibrary] is exported by [library]. |
| 1171 LibraryDependencyNode exportingNode = nodeMap[library]; | 1189 LibraryDependencyNode exportingNode = nodeMap[library]; |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1332 } | 1350 } |
| 1333 suffixes.add(const Link<Uri>().prepend(canonicalUri)); | 1351 suffixes.add(const Link<Uri>().prepend(canonicalUri)); |
| 1334 } | 1352 } |
| 1335 suffixChainMap[library] = suffixes; | 1353 suffixChainMap[library] = suffixes; |
| 1336 return; | 1354 return; |
| 1337 } | 1355 } |
| 1338 | 1356 |
| 1339 computeSuffixes(rootLibrary, const Link<Uri>()); | 1357 computeSuffixes(rootLibrary, const Link<Uri>()); |
| 1340 } | 1358 } |
| 1341 } | 1359 } |
| OLD | NEW |