Chromium Code Reviews| Index: pkg/analyzer/lib/src/dart/element/builder.dart |
| diff --git a/pkg/analyzer/lib/src/dart/element/builder.dart b/pkg/analyzer/lib/src/dart/element/builder.dart |
| index 6eaaedb6910bc133bddad43cea1e41ba51b3b927..7296d5b046568a995ad0a626d4eed20a94f1e436 100644 |
| --- a/pkg/analyzer/lib/src/dart/element/builder.dart |
| +++ b/pkg/analyzer/lib/src/dart/element/builder.dart |
| @@ -213,53 +213,52 @@ class DirectiveElementBuilder extends SimpleAstVisitor<Object> { |
| node.element = null; |
| Source importedSource = node.source; |
| int importedTime = sourceModificationTimeMap[importedSource] ?? -1; |
| - if (importedTime != -1) { |
| - // The imported source will be null if the URI in the import |
| - // directive was invalid. |
| - LibraryElement importedLibrary = importLibraryMap[importedSource]; |
| - if (importedLibrary != null) { |
| - if (importedLibrary.isDartCore) { |
| - explicitlyImportsCore = true; |
| + // The imported source will be null if the URI in the import |
|
Brian Wilkerson
2016/08/08 20:50:38
I moved the test for a missing source to line 249
|
| + // directive was invalid. |
| + LibraryElement importedLibrary = importLibraryMap[importedSource]; |
| + if (importedLibrary != null) { |
| + if (importedLibrary.isDartCore) { |
| + explicitlyImportsCore = true; |
| + } |
| + ImportElementImpl importElement = new ImportElementImpl(node.offset); |
| + importElement.metadata = _getElementAnnotations(node.metadata); |
| + StringLiteral uriLiteral = node.uri; |
| + if (uriLiteral != null) { |
| + importElement.uriOffset = uriLiteral.offset; |
| + importElement.uriEnd = uriLiteral.end; |
| + } |
| + importElement.uri = node.uriContent; |
| + importElement.deferred = node.deferredKeyword != null; |
| + importElement.combinators = _buildCombinators(node); |
| + importElement.importedLibrary = importedLibrary; |
| + setElementDocumentationComment(importElement, node); |
| + SimpleIdentifier prefixNode = node.prefix; |
| + if (prefixNode != null) { |
| + importElement.prefixOffset = prefixNode.offset; |
| + String prefixName = prefixNode.name; |
| + PrefixElementImpl prefix = nameToPrefixMap[prefixName]; |
| + if (prefix == null) { |
| + prefix = new PrefixElementImpl.forNode(prefixNode); |
| + nameToPrefixMap[prefixName] = prefix; |
| } |
| - ImportElementImpl importElement = new ImportElementImpl(node.offset); |
| - importElement.metadata = _getElementAnnotations(node.metadata); |
| - StringLiteral uriLiteral = node.uri; |
| + importElement.prefix = prefix; |
| + prefixNode.staticElement = prefix; |
| + } |
| + node.element = importElement; |
| + imports.add(importElement); |
| + if (importedTime >= 0 && |
| + importSourceKindMap[importedSource] != SourceKind.LIBRARY) { |
| + int offset = node.offset; |
| + int length = node.length; |
| if (uriLiteral != null) { |
| - importElement.uriOffset = uriLiteral.offset; |
| - importElement.uriEnd = uriLiteral.end; |
| - } |
| - importElement.uri = node.uriContent; |
| - importElement.deferred = node.deferredKeyword != null; |
| - importElement.combinators = _buildCombinators(node); |
| - importElement.importedLibrary = importedLibrary; |
| - setElementDocumentationComment(importElement, node); |
| - SimpleIdentifier prefixNode = node.prefix; |
| - if (prefixNode != null) { |
| - importElement.prefixOffset = prefixNode.offset; |
| - String prefixName = prefixNode.name; |
| - PrefixElementImpl prefix = nameToPrefixMap[prefixName]; |
| - if (prefix == null) { |
| - prefix = new PrefixElementImpl.forNode(prefixNode); |
| - nameToPrefixMap[prefixName] = prefix; |
| - } |
| - importElement.prefix = prefix; |
| - prefixNode.staticElement = prefix; |
| - } |
| - node.element = importElement; |
| - imports.add(importElement); |
| - if (importSourceKindMap[importedSource] != SourceKind.LIBRARY) { |
| - int offset = node.offset; |
| - int length = node.length; |
| - if (uriLiteral != null) { |
| - offset = uriLiteral.offset; |
| - length = uriLiteral.length; |
| - } |
| - ErrorCode errorCode = (importElement.isDeferred |
| - ? StaticWarningCode.IMPORT_OF_NON_LIBRARY |
| - : CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY); |
| - errors.add(new AnalysisError(libraryElement.source, offset, length, |
| - errorCode, [uriLiteral.toSource()])); |
| + offset = uriLiteral.offset; |
| + length = uriLiteral.length; |
| } |
| + ErrorCode errorCode = importElement.isDeferred |
| + ? StaticWarningCode.IMPORT_OF_NON_LIBRARY |
| + : CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY; |
| + errors.add(new AnalysisError(libraryElement.source, offset, length, |
| + errorCode, [uriLiteral.toSource()])); |
| } |
| } |
| return null; |
| @@ -975,8 +974,8 @@ class ElementBuilder extends RecursiveAstVisitor<Object> { |
| } else { |
| SimpleIdentifier propertyNameNode = node.name; |
| String propertyName = propertyNameNode.name; |
| - FieldElementImpl field = |
| - _currentHolder.getField(propertyName, synthetic: true) as FieldElementImpl; |
| + FieldElementImpl field = _currentHolder.getField(propertyName, |
| + synthetic: true) as FieldElementImpl; |
| if (field == null) { |
| field = new FieldElementImpl(node.name.name, -1); |
| field.final2 = true; |