Chromium Code Reviews| Index: pkg/compiler/lib/src/compiler.dart |
| diff --git a/pkg/compiler/lib/src/compiler.dart b/pkg/compiler/lib/src/compiler.dart |
| index 65620fda8e12fd01ac36f67a8728c26b339a147f..4a66ead599d112781bad7e8496b5c251d39488bb 100644 |
| --- a/pkg/compiler/lib/src/compiler.dart |
| +++ b/pkg/compiler/lib/src/compiler.dart |
| @@ -380,37 +380,45 @@ abstract class Compiler { |
| backend.setAnnotations(library); |
| }); |
| - for (Uri uri in resolvedUriTranslator.disallowedLibraryUris) { |
| - if (loadedLibraries.containsLibrary(uri)) { |
| - Set<String> importChains = computeImportChainsFor(loadedLibraries, uri); |
| - reporter.reportInfo( |
| - NO_LOCATION_SPANNABLE, MessageKind.DISALLOWED_LIBRARY_IMPORT, { |
| - 'uri': uri, |
| - 'importChain': importChains |
| - .join(MessageTemplate.DISALLOWED_LIBRARY_IMPORT_PADDING) |
| - }); |
| + // TODO(efortuna, sigmund): These validation steps should be done in the |
| + // front end for the Kernel path since Kernel doesn't have the notion of |
| + // imports (everything has already been resolved). (See |
| + // https://github.com/dart-lang/sdk/issues/29368) |
| + if (loadedLibraries.rootLibrary is LibraryElement) { |
|
Siggi Cherem (dart-lang)
2017/04/19 15:36:29
nit: I prefer to make this check as
if (!option
Emily Fortuna
2017/04/19 22:35:45
Done.
|
| + for (Uri uri in resolvedUriTranslator.disallowedLibraryUris) { |
| + if (loadedLibraries.containsLibrary(uri)) { |
| + Set<String> importChains = |
| + computeImportChainsFor(loadedLibraries, uri); |
| + reporter.reportInfo( |
| + NO_LOCATION_SPANNABLE, MessageKind.DISALLOWED_LIBRARY_IMPORT, { |
| + 'uri': uri, |
| + 'importChain': importChains |
| + .join(MessageTemplate.DISALLOWED_LIBRARY_IMPORT_PADDING) |
| + }); |
| + } |
| } |
| - } |
| - if (loadedLibraries.containsLibrary(Uris.dart_core)) { |
| - bool importsMirrorsLibrary = |
| - loadedLibraries.containsLibrary(Uris.dart_mirrors); |
| - if (importsMirrorsLibrary && !backend.supportsReflection) { |
| - Set<String> importChains = |
| - computeImportChainsFor(loadedLibraries, Uris.dart_mirrors); |
| - reporter.reportErrorMessage(NO_LOCATION_SPANNABLE, |
| - MessageKind.MIRRORS_LIBRARY_NOT_SUPPORT_BY_BACKEND, { |
| - 'importChain': importChains |
| - .join(MessageTemplate.MIRRORS_NOT_SUPPORTED_BY_BACKEND_PADDING) |
| - }); |
| - } else if (importsMirrorsLibrary && !options.enableExperimentalMirrors) { |
| - Set<String> importChains = |
| - computeImportChainsFor(loadedLibraries, Uris.dart_mirrors); |
| - reporter.reportWarningMessage( |
| - NO_LOCATION_SPANNABLE, MessageKind.IMPORT_EXPERIMENTAL_MIRRORS, { |
| - 'importChain': importChains |
| - .join(MessageTemplate.IMPORT_EXPERIMENTAL_MIRRORS_PADDING) |
| - }); |
| + if (loadedLibraries.containsLibrary(Uris.dart_core)) { |
| + bool importsMirrorsLibrary = |
| + loadedLibraries.containsLibrary(Uris.dart_mirrors); |
| + if (importsMirrorsLibrary && !backend.supportsReflection) { |
| + Set<String> importChains = |
| + computeImportChainsFor(loadedLibraries, Uris.dart_mirrors); |
| + reporter.reportErrorMessage(NO_LOCATION_SPANNABLE, |
| + MessageKind.MIRRORS_LIBRARY_NOT_SUPPORT_BY_BACKEND, { |
| + 'importChain': importChains |
| + .join(MessageTemplate.MIRRORS_NOT_SUPPORTED_BY_BACKEND_PADDING) |
| + }); |
| + } else if (importsMirrorsLibrary && |
| + !options.enableExperimentalMirrors) { |
| + Set<String> importChains = |
| + computeImportChainsFor(loadedLibraries, Uris.dart_mirrors); |
| + reporter.reportWarningMessage( |
| + NO_LOCATION_SPANNABLE, MessageKind.IMPORT_EXPERIMENTAL_MIRRORS, { |
| + 'importChain': importChains |
| + .join(MessageTemplate.IMPORT_EXPERIMENTAL_MIRRORS_PADDING) |
| + }); |
| + } |
| } |
| } |
| backend.onLibrariesLoaded(loadedLibraries); |
| @@ -595,14 +603,12 @@ abstract class Compiler { |
| libraryLoader.libraries.where((LibraryEntity library) { |
| return !serialization.isDeserialized(library); |
| }).forEach((LibraryEntity library) { |
| - reporter |
| - .log('Enqueuing ${(library as LibraryElement).canonicalUri}'); |
|
Siggi Cherem (dart-lang)
2017/04/19 15:36:29
thx!
|
| + reporter.log('Enqueuing ${library.canonicalUri}'); |
| resolutionEnqueuer.applyImpact(computeImpactForLibrary(library)); |
| }); |
| } else if (analyzeAll) { |
| libraryLoader.libraries.forEach((LibraryEntity library) { |
| - reporter |
| - .log('Enqueuing ${(library as LibraryElement).canonicalUri}'); |
| + reporter.log('Enqueuing ${library.canonicalUri}'); |
| resolutionEnqueuer.applyImpact(computeImpactForLibrary(library)); |
| }); |
| } else if (options.analyzeMain) { |
| @@ -648,15 +654,6 @@ abstract class Compiler { |
| })); |
| } |
| if (options.analyzeOnly) { |
|
Siggi Cherem (dart-lang)
2017/04/19 15:36:29
nit - we can now remove the braces and make this a
Emily Fortuna
2017/04/19 22:35:45
Done.
|
| - if (!analyzeAll && !compilationFailed) { |
| - // No point in reporting unused code when [analyzeAll] is true: all |
| - // code is artificially used. |
| - // If compilation failed, it is possible that the error prevents the |
| - // compiler from analyzing all the code. |
| - // TODO(johnniwinther): Reenable this when the reporting is more |
| - // precise. |
| - //reportUnusedCode(); |
| - } |
| return; |
| } |
| assert(mainFunction != null); |
| @@ -930,41 +927,6 @@ abstract class Compiler { |
| bool get isMockCompilation => false; |
| - void reportUnusedCode() { |
| - void checkLive(member) { |
| - if (member.isMalformed) return; |
| - if (member.isFunction) { |
| - if (!resolutionWorldBuilder.isMemberUsed(member)) { |
| - reporter.reportHintMessage( |
| - member, MessageKind.UNUSED_METHOD, {'name': member.name}); |
| - } |
| - } else if (member.isClass) { |
| - if (!member.isResolved) { |
| - reporter.reportHintMessage( |
| - member, MessageKind.UNUSED_CLASS, {'name': member.name}); |
| - } else { |
| - member.forEachLocalMember(checkLive); |
| - } |
| - } else if (member.isTypedef) { |
| - if (!member.isResolved) { |
| - reporter.reportHintMessage( |
| - member, MessageKind.UNUSED_TYPEDEF, {'name': member.name}); |
| - } |
| - } |
| - } |
| - |
| - libraryLoader.libraries.forEach((LibraryEntity entity) { |
| - // TODO(ahe): Implement better heuristics to discover entry points of |
| - // packages and use that to discover unused implementation details in |
| - // packages. |
| - LibraryElement library = entity; |
| - if (library.isPlatformLibrary || library.isPackageLibrary) return; |
| - library.compilationUnits.forEach((unit) { |
| - unit.forEachLocalMember(checkLive); |
| - }); |
| - }); |
| - } |
| - |
| /// Helper for determining whether the current element is declared within |
| /// 'user code'. |
| /// |