Chromium Code Reviews| 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..d3a6aa325dee57e78c256b4c109002c0ca3dd35c 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,38 @@ 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; |
| + if (combinator is HideCombinator) { |
|
Brian Wilkerson
2016/04/20 21:34:25
Can we pass in the list of names (and the hint cod
srawlins
2016/04/20 21:52:39
I've uploaded another patch. Is this what you want
Brian Wilkerson
2016/04/20 22:49:32
Close enough. I was thinking of
void _checkCombin
|
| + names = combinator.hiddenNames; |
| + } else { |
| + names = (combinator as ShowCombinator).shownNames; |
| + } |
| + for (SimpleIdentifier name in names) { |
| + String nameStr = name.name; |
| + Element element = namespace.get(nameStr); |
| + if (element == null) { |
| + element = namespace.get("$nameStr="); |
| + } |
| + if (element == null) { |
| + ErrorCode hintCode; |
| + if (combinator is HideCombinator) { |
| + hintCode = HintCode.UNDEFINED_HIDDEN_NAME; |
| + } else { |
| + hintCode = HintCode.UNDEFINED_SHOWN_NAME; |
| + } |
| + _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. |