| Index: pkg/analyzer/lib/src/generated/resolver.dart
|
| diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
|
| index 3f1c0ed3e7638d871a9b04261d8f8aa9ee92354b..a56ec4a20a17ea4a9831fc7e671a350afbba514c 100644
|
| --- a/pkg/analyzer/lib/src/generated/resolver.dart
|
| +++ b/pkg/analyzer/lib/src/generated/resolver.dart
|
| @@ -1932,6 +1932,21 @@ class DeadCodeVerifier extends RecursiveAstVisitor<Object> {
|
| }
|
|
|
| @override
|
| + Object visitExportDirective(ExportDirective node) {
|
| + ExportElement exportElement = node.element;
|
| + if (exportElement != null) {
|
| + // The element is null when the URI is invalid
|
| + LibraryElement library = exportElement.exportedLibrary;
|
| + if (library != null) {
|
| + for (Combinator combinator in node.combinators) {
|
| + _checkCombinator(exportElement.exportedLibrary, combinator);
|
| + }
|
| + }
|
| + }
|
| + return super.visitExportDirective(node);
|
| + }
|
| +
|
| + @override
|
| Object visitIfStatement(IfStatement node) {
|
| Expression conditionExpression = node.condition;
|
| conditionExpression?.accept(this);
|
| @@ -1961,6 +1976,21 @@ class DeadCodeVerifier extends RecursiveAstVisitor<Object> {
|
| }
|
|
|
| @override
|
| + Object visitImportDirective(ImportDirective node) {
|
| + ImportElement importElement = node.element;
|
| + if (importElement != null) {
|
| + // The element is null when the URI is invalid
|
| + LibraryElement library = importElement.importedLibrary;
|
| + if (library != null) {
|
| + for (Combinator combinator in node.combinators) {
|
| + _checkCombinator(library, combinator);
|
| + }
|
| + }
|
| + }
|
| + return super.visitImportDirective(node);
|
| + }
|
| +
|
| + @override
|
| Object visitSwitchCase(SwitchCase node) {
|
| _checkForDeadStatementsInNodeList(node.statements);
|
| return super.visitSwitchCase(node);
|
| @@ -2060,6 +2090,35 @@ class DeadCodeVerifier extends RecursiveAstVisitor<Object> {
|
| }
|
|
|
| /**
|
| + * Resolve the names in the given [combinator] in the scope of the given
|
| + * [library].
|
| + */
|
| + void _checkCombinator(LibraryElement library, Combinator combinator) {
|
| + Namespace namespace =
|
| + new NamespaceBuilder().createExportNamespaceForLibrary(library);
|
| + NodeList<SimpleIdentifier> names;
|
| + ErrorCode hintCode;
|
| + if (combinator is HideCombinator) {
|
| + names = combinator.hiddenNames;
|
| + hintCode = HintCode.UNDEFINED_HIDDEN_NAME;
|
| + } else {
|
| + names = (combinator as ShowCombinator).shownNames;
|
| + hintCode = HintCode.UNDEFINED_SHOWN_NAME;
|
| + }
|
| + for (SimpleIdentifier name in names) {
|
| + String nameStr = name.name;
|
| + Element element = namespace.get(nameStr);
|
| + if (element == null) {
|
| + element = namespace.get("$nameStr=");
|
| + }
|
| + if (element == null) {
|
| + _errorReporter.reportErrorForNode(
|
| + hintCode, name, [library.identifier, nameStr]);
|
| + }
|
| + }
|
| + }
|
| +
|
| + /**
|
| * Given some [NodeList] of [Statement]s, from either a [Block] or
|
| * [SwitchMember], this loops through the list in reverse order searching for statements
|
| * after a return, unlabeled break or unlabeled continue statement to mark them as dead code.
|
|
|