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.element; | 5 library analyzer.src.dart.element.element; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 import 'dart:math' show min; | 8 import 'dart:math' show min; |
9 | 9 |
10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
(...skipping 4269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4280 * The unlinked representation of the export in the summary. | 4280 * The unlinked representation of the export in the summary. |
4281 */ | 4281 */ |
4282 final UnlinkedExportPublic _unlinkedExportPublic; | 4282 final UnlinkedExportPublic _unlinkedExportPublic; |
4283 | 4283 |
4284 /** | 4284 /** |
4285 * The unlinked representation of the export in the summary. | 4285 * The unlinked representation of the export in the summary. |
4286 */ | 4286 */ |
4287 final UnlinkedExportNonPublic _unlinkedExportNonPublic; | 4287 final UnlinkedExportNonPublic _unlinkedExportNonPublic; |
4288 | 4288 |
4289 /** | 4289 /** |
| 4290 * The kernel of the element. |
| 4291 */ |
| 4292 final kernel.LibraryDependency _kernel; |
| 4293 |
| 4294 /** |
4290 * The library that is exported from this library by this export directive. | 4295 * The library that is exported from this library by this export directive. |
4291 */ | 4296 */ |
4292 LibraryElement _exportedLibrary; | 4297 LibraryElement _exportedLibrary; |
4293 | 4298 |
4294 /** | 4299 /** |
4295 * The combinators that were specified as part of the export directive in the | 4300 * The combinators that were specified as part of the export directive in the |
4296 * order in which they were specified. | 4301 * order in which they were specified. |
4297 */ | 4302 */ |
4298 List<NamespaceCombinator> _combinators; | 4303 List<NamespaceCombinator> _combinators; |
4299 | 4304 |
4300 /** | 4305 /** |
4301 * The URI that was selected based on the [context] declared variables. | 4306 * The URI that was selected based on the [context] declared variables. |
4302 */ | 4307 */ |
4303 String _selectedUri; | 4308 String _selectedUri; |
4304 | 4309 |
4305 /** | 4310 /** |
4306 * Initialize a newly created export element at the given [offset]. | 4311 * Initialize a newly created export element at the given [offset]. |
4307 */ | 4312 */ |
4308 ExportElementImpl(int offset) | 4313 ExportElementImpl(int offset) |
4309 : _unlinkedExportPublic = null, | 4314 : _unlinkedExportPublic = null, |
4310 _unlinkedExportNonPublic = null, | 4315 _unlinkedExportNonPublic = null, |
| 4316 _kernel = null, |
4311 super(null, offset); | 4317 super(null, offset); |
4312 | 4318 |
4313 /** | 4319 /** |
| 4320 * Initialize using the given kernel. |
| 4321 */ |
| 4322 ExportElementImpl.forKernel(LibraryElementImpl enclosingLibrary, this._kernel) |
| 4323 : _unlinkedExportPublic = null, |
| 4324 _unlinkedExportNonPublic = null, |
| 4325 super.forSerialized(enclosingLibrary); |
| 4326 |
| 4327 /** |
4314 * Initialize using the given serialized information. | 4328 * Initialize using the given serialized information. |
4315 */ | 4329 */ |
4316 ExportElementImpl.forSerialized(this._unlinkedExportPublic, | 4330 ExportElementImpl.forSerialized(this._unlinkedExportPublic, |
4317 this._unlinkedExportNonPublic, LibraryElementImpl enclosingLibrary) | 4331 this._unlinkedExportNonPublic, LibraryElementImpl enclosingLibrary) |
4318 : super.forSerialized(enclosingLibrary); | 4332 : _kernel = null, |
| 4333 super.forSerialized(enclosingLibrary); |
4319 | 4334 |
4320 @override | 4335 @override |
4321 List<NamespaceCombinator> get combinators { | 4336 List<NamespaceCombinator> get combinators { |
4322 if (_unlinkedExportPublic != null && _combinators == null) { | 4337 if (_unlinkedExportPublic != null && _combinators == null) { |
4323 _combinators = ImportElementImpl | 4338 _combinators = ImportElementImpl |
4324 ._buildCombinators(_unlinkedExportPublic.combinators); | 4339 ._buildCombinators(_unlinkedExportPublic.combinators); |
4325 } | 4340 } |
4326 return _combinators ?? const <NamespaceCombinator>[]; | 4341 return _combinators ?? const <NamespaceCombinator>[]; |
4327 } | 4342 } |
4328 | 4343 |
4329 void set combinators(List<NamespaceCombinator> combinators) { | 4344 void set combinators(List<NamespaceCombinator> combinators) { |
4330 _assertNotResynthesized(_unlinkedExportPublic); | 4345 _assertNotResynthesized(_unlinkedExportPublic); |
4331 _combinators = combinators; | 4346 _combinators = combinators; |
4332 } | 4347 } |
4333 | 4348 |
4334 @override | 4349 @override |
4335 LibraryElement get exportedLibrary { | 4350 LibraryElement get exportedLibrary { |
4336 if (_unlinkedExportNonPublic != null && _exportedLibrary == null) { | 4351 if (_exportedLibrary == null) { |
4337 LibraryElementImpl library = enclosingElement as LibraryElementImpl; | 4352 if (_kernel != null) { |
4338 _exportedLibrary = library.resynthesizerContext.buildExportedLibrary(uri); | 4353 Uri exportedUri = _kernel.targetLibrary.importUri; |
| 4354 String exportedUriStr = exportedUri.toString(); |
| 4355 LibraryElementImpl library = enclosingElement as LibraryElementImpl; |
| 4356 _exportedLibrary = library._kernelContext.getLibrary(exportedUriStr); |
| 4357 } |
| 4358 if (_unlinkedExportNonPublic != null) { |
| 4359 LibraryElementImpl library = enclosingElement as LibraryElementImpl; |
| 4360 _exportedLibrary = |
| 4361 library.resynthesizerContext.buildExportedLibrary(uri); |
| 4362 } |
4339 } | 4363 } |
4340 return _exportedLibrary; | 4364 return _exportedLibrary; |
4341 } | 4365 } |
4342 | 4366 |
4343 void set exportedLibrary(LibraryElement exportedLibrary) { | 4367 void set exportedLibrary(LibraryElement exportedLibrary) { |
4344 _assertNotResynthesized(_unlinkedExportNonPublic); | 4368 _assertNotResynthesized(_unlinkedExportNonPublic); |
4345 _exportedLibrary = exportedLibrary; | 4369 _exportedLibrary = exportedLibrary; |
4346 } | 4370 } |
4347 | 4371 |
4348 @override | 4372 @override |
(...skipping 1861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6210 } | 6234 } |
6211 return _exportNamespace; | 6235 return _exportNamespace; |
6212 } | 6236 } |
6213 | 6237 |
6214 void set exportNamespace(Namespace exportNamespace) { | 6238 void set exportNamespace(Namespace exportNamespace) { |
6215 _exportNamespace = exportNamespace; | 6239 _exportNamespace = exportNamespace; |
6216 } | 6240 } |
6217 | 6241 |
6218 @override | 6242 @override |
6219 List<ExportElement> get exports { | 6243 List<ExportElement> get exports { |
6220 if (_unlinkedDefiningUnit != null && _exports == null) { | 6244 if (_exports == null) { |
6221 List<UnlinkedExportNonPublic> unlinkedNonPublicExports = | 6245 if (_kernelContext != null) { |
6222 _unlinkedDefiningUnit.exports; | 6246 _exports = _kernelContext.library.dependencies |
6223 List<UnlinkedExportPublic> unlinkedPublicExports = | 6247 .where((k) => k.isExport) |
6224 _unlinkedDefiningUnit.publicNamespace.exports; | 6248 .map((k) => new ExportElementImpl.forKernel(this, k)) |
6225 assert( | 6249 .toList(growable: false); |
6226 _unlinkedDefiningUnit.exports.length == unlinkedPublicExports.length); | 6250 } |
6227 int length = unlinkedNonPublicExports.length; | 6251 if (_unlinkedDefiningUnit != null) { |
6228 if (length != 0) { | 6252 List<UnlinkedExportNonPublic> unlinkedNonPublicExports = |
6229 List<ExportElement> exports = new List<ExportElement>(); | 6253 _unlinkedDefiningUnit.exports; |
6230 for (int i = 0; i < length; i++) { | 6254 List<UnlinkedExportPublic> unlinkedPublicExports = |
6231 UnlinkedExportPublic serializedExportPublic = | 6255 _unlinkedDefiningUnit.publicNamespace.exports; |
6232 unlinkedPublicExports[i]; | 6256 assert(_unlinkedDefiningUnit.exports.length == |
6233 UnlinkedExportNonPublic serializedExportNonPublic = | 6257 unlinkedPublicExports.length); |
6234 unlinkedNonPublicExports[i]; | 6258 int length = unlinkedNonPublicExports.length; |
6235 ExportElementImpl exportElement = new ExportElementImpl.forSerialized( | 6259 if (length != 0) { |
6236 serializedExportPublic, serializedExportNonPublic, library); | 6260 List<ExportElement> exports = new List<ExportElement>(); |
6237 exports.add(exportElement); | 6261 for (int i = 0; i < length; i++) { |
| 6262 UnlinkedExportPublic serializedExportPublic = |
| 6263 unlinkedPublicExports[i]; |
| 6264 UnlinkedExportNonPublic serializedExportNonPublic = |
| 6265 unlinkedNonPublicExports[i]; |
| 6266 ExportElementImpl exportElement = |
| 6267 new ExportElementImpl.forSerialized( |
| 6268 serializedExportPublic, serializedExportNonPublic, library); |
| 6269 exports.add(exportElement); |
| 6270 } |
| 6271 _exports = exports; |
| 6272 } else { |
| 6273 _exports = const <ExportElement>[]; |
6238 } | 6274 } |
6239 _exports = exports; | |
6240 } else { | |
6241 _exports = const <ExportElement>[]; | |
6242 } | 6275 } |
6243 } | 6276 } |
6244 return _exports ?? const <ExportElement>[]; | 6277 return _exports ?? const <ExportElement>[]; |
6245 } | 6278 } |
6246 | 6279 |
6247 /** | 6280 /** |
6248 * Set the specifications of all of the exports defined in this library to the | 6281 * Set the specifications of all of the exports defined in this library to the |
6249 * given list of [exports]. | 6282 * given list of [exports]. |
6250 */ | 6283 */ |
6251 void set exports(List<ExportElement> exports) { | 6284 void set exports(List<ExportElement> exports) { |
(...skipping 3380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9632 | 9665 |
9633 @override | 9666 @override |
9634 DartObject computeConstantValue() => null; | 9667 DartObject computeConstantValue() => null; |
9635 | 9668 |
9636 @override | 9669 @override |
9637 void visitChildren(ElementVisitor visitor) { | 9670 void visitChildren(ElementVisitor visitor) { |
9638 super.visitChildren(visitor); | 9671 super.visitChildren(visitor); |
9639 _initializer?.accept(visitor); | 9672 _initializer?.accept(visitor); |
9640 } | 9673 } |
9641 } | 9674 } |
OLD | NEW |