| OLD | NEW | 
|---|
| 1 // Copyright (c) 2014, the Dart project authors.  Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 analyzer.src.dart.element.builder; | 5 library analyzer.src.dart.element.builder; | 
| 6 | 6 | 
| 7 import 'dart:collection'; | 7 import 'dart:collection'; | 
| 8 | 8 | 
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; | 
| 10 import 'package:analyzer/dart/ast/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; | 
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 147     } | 147     } | 
| 148     // | 148     // | 
| 149     // Ensure "dart:core" import. | 149     // Ensure "dart:core" import. | 
| 150     // | 150     // | 
| 151     Source librarySource = libraryElement.source; | 151     Source librarySource = libraryElement.source; | 
| 152     Source coreLibrarySource = context.sourceFactory.forUri(DartSdk.DART_CORE); | 152     Source coreLibrarySource = context.sourceFactory.forUri(DartSdk.DART_CORE); | 
| 153     if (!explicitlyImportsCore && coreLibrarySource != librarySource) { | 153     if (!explicitlyImportsCore && coreLibrarySource != librarySource) { | 
| 154       ImportElementImpl importElement = new ImportElementImpl(-1); | 154       ImportElementImpl importElement = new ImportElementImpl(-1); | 
| 155       importElement.importedLibrary = importLibraryMap[coreLibrarySource]; | 155       importElement.importedLibrary = importLibraryMap[coreLibrarySource]; | 
| 156       importElement.synthetic = true; | 156       importElement.synthetic = true; | 
| 157       importElement.uriExists = true; |  | 
| 158       imports.add(importElement); | 157       imports.add(importElement); | 
| 159     } | 158     } | 
| 160     // | 159     // | 
| 161     // Populate the library element. | 160     // Populate the library element. | 
| 162     // | 161     // | 
| 163     libraryElement.imports = imports; | 162     libraryElement.imports = imports; | 
| 164     libraryElement.exports = exports; | 163     libraryElement.exports = exports; | 
| 165     return null; | 164     return null; | 
| 166   } | 165   } | 
| 167 | 166 | 
| 168   @override | 167   @override | 
| 169   Object visitExportDirective(ExportDirective node) { | 168   Object visitExportDirective(ExportDirective node) { | 
| 170     // Remove previous element. (It will remain null if the target is missing.) | 169     // Remove previous element. (It will remain null if the target is missing.) | 
| 171     node.element = null; | 170     node.element = null; | 
| 172     Source exportedSource = node.source; | 171     Source exportedSource = node.source; | 
| 173     int exportedTime = sourceModificationTimeMap[exportedSource] ?? -1; | 172     int exportedTime = sourceModificationTimeMap[exportedSource] ?? -1; | 
| 174     // The exported source will be null if the URI in the export | 173     // The exported source will be null if the URI in the export | 
| 175     // directive was invalid. | 174     // directive was invalid. | 
| 176     LibraryElement exportedLibrary = exportLibraryMap[exportedSource]; | 175     LibraryElement exportedLibrary = exportLibraryMap[exportedSource]; | 
| 177     if (exportedLibrary != null) { | 176     if (exportedLibrary != null) { | 
| 178       ExportElementImpl exportElement = new ExportElementImpl(node.offset); | 177       ExportElementImpl exportElement = new ExportElementImpl(node.offset); | 
| 179       exportElement.metadata = _getElementAnnotations(node.metadata); | 178       exportElement.metadata = _getElementAnnotations(node.metadata); | 
| 180       StringLiteral uriLiteral = node.uri; | 179       StringLiteral uriLiteral = node.uri; | 
| 181       if (uriLiteral != null) { | 180       if (uriLiteral != null) { | 
| 182         exportElement.uriOffset = uriLiteral.offset; | 181         exportElement.uriOffset = uriLiteral.offset; | 
| 183         exportElement.uriEnd = uriLiteral.end; | 182         exportElement.uriEnd = uriLiteral.end; | 
| 184       } | 183       } | 
| 185       exportElement.uri = node.uriContent; | 184       exportElement.uri = node.uriContent; | 
| 186       exportElement.uriExists = exportedTime >= 0; |  | 
| 187       exportElement.combinators = _buildCombinators(node); | 185       exportElement.combinators = _buildCombinators(node); | 
| 188       exportElement.exportedLibrary = exportedLibrary; | 186       exportElement.exportedLibrary = exportedLibrary; | 
| 189       setElementDocumentationComment(exportElement, node); | 187       setElementDocumentationComment(exportElement, node); | 
| 190       node.element = exportElement; | 188       node.element = exportElement; | 
| 191       exports.add(exportElement); | 189       exports.add(exportElement); | 
| 192       if (exportedTime >= 0 && | 190       if (exportedTime >= 0 && | 
| 193           exportSourceKindMap[exportedSource] != SourceKind.LIBRARY) { | 191           exportSourceKindMap[exportedSource] != SourceKind.LIBRARY) { | 
| 194         int offset = node.offset; | 192         int offset = node.offset; | 
| 195         int length = node.length; | 193         int length = node.length; | 
| 196         if (uriLiteral != null) { | 194         if (uriLiteral != null) { | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
| 222         explicitlyImportsCore = true; | 220         explicitlyImportsCore = true; | 
| 223       } | 221       } | 
| 224       ImportElementImpl importElement = new ImportElementImpl(node.offset); | 222       ImportElementImpl importElement = new ImportElementImpl(node.offset); | 
| 225       importElement.metadata = _getElementAnnotations(node.metadata); | 223       importElement.metadata = _getElementAnnotations(node.metadata); | 
| 226       StringLiteral uriLiteral = node.uri; | 224       StringLiteral uriLiteral = node.uri; | 
| 227       if (uriLiteral != null) { | 225       if (uriLiteral != null) { | 
| 228         importElement.uriOffset = uriLiteral.offset; | 226         importElement.uriOffset = uriLiteral.offset; | 
| 229         importElement.uriEnd = uriLiteral.end; | 227         importElement.uriEnd = uriLiteral.end; | 
| 230       } | 228       } | 
| 231       importElement.uri = node.uriContent; | 229       importElement.uri = node.uriContent; | 
| 232       importElement.uriExists = importedTime >= 0; |  | 
| 233       importElement.deferred = node.deferredKeyword != null; | 230       importElement.deferred = node.deferredKeyword != null; | 
| 234       importElement.combinators = _buildCombinators(node); | 231       importElement.combinators = _buildCombinators(node); | 
| 235       importElement.importedLibrary = importedLibrary; | 232       importElement.importedLibrary = importedLibrary; | 
| 236       setElementDocumentationComment(importElement, node); | 233       setElementDocumentationComment(importElement, node); | 
| 237       SimpleIdentifier prefixNode = node.prefix; | 234       SimpleIdentifier prefixNode = node.prefix; | 
| 238       if (prefixNode != null) { | 235       if (prefixNode != null) { | 
| 239         importElement.prefixOffset = prefixNode.offset; | 236         importElement.prefixOffset = prefixNode.offset; | 
| 240         String prefixName = prefixNode.name; | 237         String prefixName = prefixNode.name; | 
| 241         PrefixElementImpl prefix = nameToPrefixMap[prefixName]; | 238         PrefixElementImpl prefix = nameToPrefixMap[prefixName]; | 
| 242         if (prefix == null) { | 239         if (prefix == null) { | 
| (...skipping 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1458     return null; | 1455     return null; | 
| 1459   } | 1456   } | 
| 1460 | 1457 | 
| 1461   /** | 1458   /** | 
| 1462    * Return the lexical identifiers associated with the given [identifiers]. | 1459    * Return the lexical identifiers associated with the given [identifiers]. | 
| 1463    */ | 1460    */ | 
| 1464   static List<String> _getIdentifiers(NodeList<SimpleIdentifier> identifiers) { | 1461   static List<String> _getIdentifiers(NodeList<SimpleIdentifier> identifiers) { | 
| 1465     return identifiers.map((identifier) => identifier.name).toList(); | 1462     return identifiers.map((identifier) => identifier.name).toList(); | 
| 1466   } | 1463   } | 
| 1467 } | 1464 } | 
| OLD | NEW | 
|---|