| 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 engine.resolver; | 5 library engine.resolver; |
| 6 | 6 |
| 7 import "dart:math" as math; | 7 import "dart:math" as math; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import 'package:analyzer/src/generated/utilities_collection.dart'; | 10 import 'package:analyzer/src/generated/utilities_collection.dart'; |
| 11 | 11 |
| 12 import 'ast.dart'; | 12 import 'ast.dart'; |
| 13 import 'constant.dart'; | 13 import 'constant.dart'; |
| 14 import 'element.dart'; | 14 import 'element.dart'; |
| 15 import 'element_resolver.dart'; | 15 import 'element_resolver.dart'; |
| 16 import 'engine.dart'; | 16 import 'engine.dart'; |
| 17 import 'error.dart'; | 17 import 'error.dart'; |
| 18 import 'error_verifier.dart'; | 18 import 'error_verifier.dart'; |
| 19 import 'html.dart' as ht; | 19 import 'html.dart' as ht; |
| 20 import 'instrumentation.dart'; | |
| 21 import 'java_core.dart'; | 20 import 'java_core.dart'; |
| 22 import 'java_engine.dart'; | 21 import 'java_engine.dart'; |
| 23 import 'scanner.dart' as sc; | 22 import 'scanner.dart' as sc; |
| 24 import 'sdk.dart' show DartSdk, SdkLibrary; | 23 import 'sdk.dart' show DartSdk, SdkLibrary; |
| 25 import 'source.dart'; | 24 import 'source.dart'; |
| 26 import 'static_type_analyzer.dart'; | 25 import 'static_type_analyzer.dart'; |
| 27 import 'utilities_dart.dart'; | 26 import 'utilities_dart.dart'; |
| 28 import 'utilities_general.dart'; | 27 import 'utilities_general.dart'; |
| 29 | 28 |
| 30 /** | 29 /** |
| (...skipping 8358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8389 * | 8388 * |
| 8390 * @param librarySource the source specifying the defining compilation unit of
the library to be | 8389 * @param librarySource the source specifying the defining compilation unit of
the library to be |
| 8391 * resolved | 8390 * resolved |
| 8392 * @param unit the compilation unit representing the embedded library | 8391 * @param unit the compilation unit representing the embedded library |
| 8393 * @param fullAnalysis `true` if a full analysis should be performed | 8392 * @param fullAnalysis `true` if a full analysis should be performed |
| 8394 * @return the element representing the resolved library | 8393 * @return the element representing the resolved library |
| 8395 * @throws AnalysisException if the library could not be resolved for some rea
son | 8394 * @throws AnalysisException if the library could not be resolved for some rea
son |
| 8396 */ | 8395 */ |
| 8397 LibraryElement resolveEmbeddedLibrary(Source librarySource, | 8396 LibraryElement resolveEmbeddedLibrary(Source librarySource, |
| 8398 CompilationUnit unit, bool fullAnalysis) { | 8397 CompilationUnit unit, bool fullAnalysis) { |
| 8399 InstrumentationBuilder instrumentation = | 8398 // |
| 8400 Instrumentation.builder2("dart.engine.LibraryResolver.resolveEmbeddedLib
rary"); | 8399 // Create the objects representing the library being resolved and the core |
| 8401 try { | 8400 // library. |
| 8402 instrumentation.metric("fullAnalysis", fullAnalysis); | 8401 // |
| 8403 instrumentation.data3("fullName", librarySource.fullName); | 8402 Library targetLibrary = _createLibraryWithUnit(librarySource, unit); |
| 8404 // | 8403 _coreLibrary = _libraryMap[_coreLibrarySource]; |
| 8405 // Create the objects representing the library being resolved and the core | 8404 if (_coreLibrary == null) { |
| 8405 // This will be true unless the library being analyzed is the core |
| 8406 // library. | 8406 // library. |
| 8407 // | 8407 _coreLibrary = createLibrary(_coreLibrarySource); |
| 8408 Library targetLibrary = _createLibraryWithUnit(librarySource, unit); | |
| 8409 _coreLibrary = _libraryMap[_coreLibrarySource]; | |
| 8410 if (_coreLibrary == null) { | 8408 if (_coreLibrary == null) { |
| 8411 // This will be true unless the library being analyzed is the core | 8409 LibraryResolver2.missingCoreLibrary( |
| 8412 // library. | 8410 analysisContext, |
| 8413 _coreLibrary = createLibrary(_coreLibrarySource); | 8411 _coreLibrarySource); |
| 8414 if (_coreLibrary == null) { | |
| 8415 LibraryResolver2.missingCoreLibrary( | |
| 8416 analysisContext, | |
| 8417 _coreLibrarySource); | |
| 8418 } | |
| 8419 } | 8412 } |
| 8420 instrumentation.metric3("createLibrary", "complete"); | |
| 8421 // | |
| 8422 // Compute the set of libraries that need to be resolved together. | |
| 8423 // | |
| 8424 _computeEmbeddedLibraryDependencies(targetLibrary, unit); | |
| 8425 _librariesInCycles = _computeLibrariesInCycles(targetLibrary); | |
| 8426 // | |
| 8427 // Build the element models representing the libraries being resolved. | |
| 8428 // This is done in three steps: | |
| 8429 // | |
| 8430 // 1. Build the basic element models without making any connections | |
| 8431 // between elements other than the basic parent/child relationships. | |
| 8432 // This includes building the elements representing the libraries. | |
| 8433 // 2. Build the elements for the import and export directives. This | |
| 8434 // requires that we have the elements built for the referenced | |
| 8435 // libraries, but because of the possibility of circular references | |
| 8436 // needs to happen after all of the library elements have been created. | |
| 8437 // 3. Build the rest of the type model by connecting superclasses, mixins, | |
| 8438 // and interfaces. This requires that we be able to compute the names | |
| 8439 // visible in the libraries being resolved, which in turn requires that | |
| 8440 // we have resolved the import directives. | |
| 8441 // | |
| 8442 _buildElementModels(); | |
| 8443 instrumentation.metric3("buildElementModels", "complete"); | |
| 8444 LibraryElement coreElement = _coreLibrary.libraryElement; | |
| 8445 if (coreElement == null) { | |
| 8446 throw new AnalysisException("Could not resolve dart:core"); | |
| 8447 } | |
| 8448 _buildDirectiveModels(); | |
| 8449 instrumentation.metric3("buildDirectiveModels", "complete"); | |
| 8450 _typeProvider = new TypeProviderImpl(coreElement); | |
| 8451 _buildTypeAliases(); | |
| 8452 _buildTypeHierarchies(); | |
| 8453 instrumentation.metric3("buildTypeHierarchies", "complete"); | |
| 8454 // | |
| 8455 // Perform resolution and type analysis. | |
| 8456 // | |
| 8457 // TODO(brianwilkerson) Decide whether we want to resolve all of the | |
| 8458 // libraries or whether we want to only resolve the target library. | |
| 8459 // The advantage to resolving everything is that we have already done part | |
| 8460 // of the work so we'll avoid duplicated effort. The disadvantage of | |
| 8461 // resolving everything is that we might do extra work that we don't | |
| 8462 // really care about. Another possibility is to add a parameter to this | |
| 8463 // method and punt the decision to the clients. | |
| 8464 // | |
| 8465 //if (analyzeAll) { | |
| 8466 _resolveReferencesAndTypes(); | |
| 8467 instrumentation.metric3("resolveReferencesAndTypes", "complete"); | |
| 8468 //} else { | |
| 8469 // resolveReferencesAndTypes(targetLibrary); | |
| 8470 //} | |
| 8471 _performConstantEvaluation(); | |
| 8472 instrumentation.metric3("performConstantEvaluation", "complete"); | |
| 8473 return targetLibrary.libraryElement; | |
| 8474 } finally { | |
| 8475 instrumentation.log(); | |
| 8476 } | 8413 } |
| 8414 // |
| 8415 // Compute the set of libraries that need to be resolved together. |
| 8416 // |
| 8417 _computeEmbeddedLibraryDependencies(targetLibrary, unit); |
| 8418 _librariesInCycles = _computeLibrariesInCycles(targetLibrary); |
| 8419 // |
| 8420 // Build the element models representing the libraries being resolved. |
| 8421 // This is done in three steps: |
| 8422 // |
| 8423 // 1. Build the basic element models without making any connections |
| 8424 // between elements other than the basic parent/child relationships. |
| 8425 // This includes building the elements representing the libraries. |
| 8426 // 2. Build the elements for the import and export directives. This |
| 8427 // requires that we have the elements built for the referenced |
| 8428 // libraries, but because of the possibility of circular references |
| 8429 // needs to happen after all of the library elements have been created. |
| 8430 // 3. Build the rest of the type model by connecting superclasses, mixins, |
| 8431 // and interfaces. This requires that we be able to compute the names |
| 8432 // visible in the libraries being resolved, which in turn requires that |
| 8433 // we have resolved the import directives. |
| 8434 // |
| 8435 _buildElementModels(); |
| 8436 LibraryElement coreElement = _coreLibrary.libraryElement; |
| 8437 if (coreElement == null) { |
| 8438 throw new AnalysisException("Could not resolve dart:core"); |
| 8439 } |
| 8440 _buildDirectiveModels(); |
| 8441 _typeProvider = new TypeProviderImpl(coreElement); |
| 8442 _buildTypeAliases(); |
| 8443 _buildTypeHierarchies(); |
| 8444 // |
| 8445 // Perform resolution and type analysis. |
| 8446 // |
| 8447 // TODO(brianwilkerson) Decide whether we want to resolve all of the |
| 8448 // libraries or whether we want to only resolve the target library. |
| 8449 // The advantage to resolving everything is that we have already done part |
| 8450 // of the work so we'll avoid duplicated effort. The disadvantage of |
| 8451 // resolving everything is that we might do extra work that we don't |
| 8452 // really care about. Another possibility is to add a parameter to this |
| 8453 // method and punt the decision to the clients. |
| 8454 // |
| 8455 //if (analyzeAll) { |
| 8456 _resolveReferencesAndTypes(); |
| 8457 //} else { |
| 8458 // resolveReferencesAndTypes(targetLibrary); |
| 8459 //} |
| 8460 _performConstantEvaluation(); |
| 8461 return targetLibrary.libraryElement; |
| 8477 } | 8462 } |
| 8478 | 8463 |
| 8479 /** | 8464 /** |
| 8480 * Resolve the library specified by the given source in the given context. | 8465 * Resolve the library specified by the given source in the given context. |
| 8481 * | 8466 * |
| 8482 * Note that because Dart allows circular imports between libraries, it is pos
sible that more than | 8467 * Note that because Dart allows circular imports between libraries, it is pos
sible that more than |
| 8483 * one library will need to be resolved. In such cases the error listener can
receive errors from | 8468 * one library will need to be resolved. In such cases the error listener can
receive errors from |
| 8484 * multiple libraries. | 8469 * multiple libraries. |
| 8485 * | 8470 * |
| 8486 * @param librarySource the source specifying the defining compilation unit of
the library to be | 8471 * @param librarySource the source specifying the defining compilation unit of
the library to be |
| 8487 * resolved | 8472 * resolved |
| 8488 * @param fullAnalysis `true` if a full analysis should be performed | 8473 * @param fullAnalysis `true` if a full analysis should be performed |
| 8489 * @return the element representing the resolved library | 8474 * @return the element representing the resolved library |
| 8490 * @throws AnalysisException if the library could not be resolved for some rea
son | 8475 * @throws AnalysisException if the library could not be resolved for some rea
son |
| 8491 */ | 8476 */ |
| 8492 LibraryElement resolveLibrary(Source librarySource, bool fullAnalysis) { | 8477 LibraryElement resolveLibrary(Source librarySource, bool fullAnalysis) { |
| 8493 InstrumentationBuilder instrumentation = | 8478 // |
| 8494 Instrumentation.builder2("dart.engine.LibraryResolver.resolveLibrary"); | 8479 // Create the objects representing the library being resolved and the core |
| 8495 try { | 8480 // library. |
| 8496 instrumentation.metric("fullAnalysis", fullAnalysis); | 8481 // |
| 8497 instrumentation.data3("fullName", librarySource.fullName); | 8482 Library targetLibrary = createLibrary(librarySource); |
| 8498 // | 8483 _coreLibrary = _libraryMap[_coreLibrarySource]; |
| 8499 // Create the objects representing the library being resolved and the core | 8484 if (_coreLibrary == null) { |
| 8485 // This will be true unless the library being analyzed is the core |
| 8500 // library. | 8486 // library. |
| 8501 // | 8487 _coreLibrary = _createLibraryOrNull(_coreLibrarySource); |
| 8502 Library targetLibrary = createLibrary(librarySource); | |
| 8503 _coreLibrary = _libraryMap[_coreLibrarySource]; | |
| 8504 if (_coreLibrary == null) { | 8488 if (_coreLibrary == null) { |
| 8505 // This will be true unless the library being analyzed is the core | 8489 LibraryResolver2.missingCoreLibrary( |
| 8506 // library. | 8490 analysisContext, |
| 8507 _coreLibrary = _createLibraryOrNull(_coreLibrarySource); | 8491 _coreLibrarySource); |
| 8508 if (_coreLibrary == null) { | |
| 8509 LibraryResolver2.missingCoreLibrary( | |
| 8510 analysisContext, | |
| 8511 _coreLibrarySource); | |
| 8512 } | |
| 8513 } | 8492 } |
| 8514 instrumentation.metric3("createLibrary", "complete"); | |
| 8515 // | |
| 8516 // Compute the set of libraries that need to be resolved together. | |
| 8517 // | |
| 8518 _computeLibraryDependencies(targetLibrary); | |
| 8519 _librariesInCycles = _computeLibrariesInCycles(targetLibrary); | |
| 8520 // | |
| 8521 // Build the element models representing the libraries being resolved. | |
| 8522 // This is done in three steps: | |
| 8523 // | |
| 8524 // 1. Build the basic element models without making any connections | |
| 8525 // between elements other than the basic parent/child relationships. | |
| 8526 // This includes building the elements representing the libraries, but | |
| 8527 // excludes members defined in enums. | |
| 8528 // 2. Build the elements for the import and export directives. This | |
| 8529 // requires that we have the elements built for the referenced | |
| 8530 // libraries, but because of the possibility of circular references | |
| 8531 // needs to happen after all of the library elements have been created. | |
| 8532 // 3. Build the members in enum declarations. | |
| 8533 // 4. Build the rest of the type model by connecting superclasses, mixins, | |
| 8534 // and interfaces. This requires that we be able to compute the names | |
| 8535 // visible in the libraries being resolved, which in turn requires that | |
| 8536 // we have resolved the import directives. | |
| 8537 // | |
| 8538 _buildElementModels(); | |
| 8539 instrumentation.metric3("buildElementModels", "complete"); | |
| 8540 LibraryElement coreElement = _coreLibrary.libraryElement; | |
| 8541 if (coreElement == null) { | |
| 8542 throw new AnalysisException("Could not resolve dart:core"); | |
| 8543 } | |
| 8544 _buildDirectiveModels(); | |
| 8545 instrumentation.metric3("buildDirectiveModels", "complete"); | |
| 8546 _typeProvider = new TypeProviderImpl(coreElement); | |
| 8547 _buildEnumMembers(); | |
| 8548 _buildTypeAliases(); | |
| 8549 _buildTypeHierarchies(); | |
| 8550 _buildImplicitConstructors(); | |
| 8551 instrumentation.metric3("buildTypeHierarchies", "complete"); | |
| 8552 // | |
| 8553 // Perform resolution and type analysis. | |
| 8554 // | |
| 8555 // TODO(brianwilkerson) Decide whether we want to resolve all of the | |
| 8556 // libraries or whether we want to only resolve the target library. The | |
| 8557 // advantage to resolving everything is that we have already done part of | |
| 8558 // the work so we'll avoid duplicated effort. The disadvantage of | |
| 8559 // resolving everything is that we might do extra work that we don't | |
| 8560 // really care about. Another possibility is to add a parameter to this | |
| 8561 // method and punt the decision to the clients. | |
| 8562 // | |
| 8563 //if (analyzeAll) { | |
| 8564 _resolveReferencesAndTypes(); | |
| 8565 instrumentation.metric3("resolveReferencesAndTypes", "complete"); | |
| 8566 //} else { | |
| 8567 // resolveReferencesAndTypes(targetLibrary); | |
| 8568 //} | |
| 8569 _performConstantEvaluation(); | |
| 8570 instrumentation.metric3("performConstantEvaluation", "complete"); | |
| 8571 instrumentation.metric2("librariesInCycles", _librariesInCycles.length); | |
| 8572 for (Library lib in _librariesInCycles) { | |
| 8573 instrumentation.metric2( | |
| 8574 "librariesInCycles-CompilationUnitSources-Size", | |
| 8575 lib.compilationUnitSources.length); | |
| 8576 } | |
| 8577 return targetLibrary.libraryElement; | |
| 8578 } finally { | |
| 8579 instrumentation.log2(15); | |
| 8580 //Log if >= than 15ms | |
| 8581 } | 8493 } |
| 8494 // |
| 8495 // Compute the set of libraries that need to be resolved together. |
| 8496 // |
| 8497 _computeLibraryDependencies(targetLibrary); |
| 8498 _librariesInCycles = _computeLibrariesInCycles(targetLibrary); |
| 8499 // |
| 8500 // Build the element models representing the libraries being resolved. |
| 8501 // This is done in three steps: |
| 8502 // |
| 8503 // 1. Build the basic element models without making any connections |
| 8504 // between elements other than the basic parent/child relationships. |
| 8505 // This includes building the elements representing the libraries, but |
| 8506 // excludes members defined in enums. |
| 8507 // 2. Build the elements for the import and export directives. This |
| 8508 // requires that we have the elements built for the referenced |
| 8509 // libraries, but because of the possibility of circular references |
| 8510 // needs to happen after all of the library elements have been created. |
| 8511 // 3. Build the members in enum declarations. |
| 8512 // 4. Build the rest of the type model by connecting superclasses, mixins, |
| 8513 // and interfaces. This requires that we be able to compute the names |
| 8514 // visible in the libraries being resolved, which in turn requires that |
| 8515 // we have resolved the import directives. |
| 8516 // |
| 8517 _buildElementModels(); |
| 8518 LibraryElement coreElement = _coreLibrary.libraryElement; |
| 8519 if (coreElement == null) { |
| 8520 throw new AnalysisException("Could not resolve dart:core"); |
| 8521 } |
| 8522 _buildDirectiveModels(); |
| 8523 _typeProvider = new TypeProviderImpl(coreElement); |
| 8524 _buildEnumMembers(); |
| 8525 _buildTypeAliases(); |
| 8526 _buildTypeHierarchies(); |
| 8527 _buildImplicitConstructors(); |
| 8528 // |
| 8529 // Perform resolution and type analysis. |
| 8530 // |
| 8531 // TODO(brianwilkerson) Decide whether we want to resolve all of the |
| 8532 // libraries or whether we want to only resolve the target library. The |
| 8533 // advantage to resolving everything is that we have already done part of |
| 8534 // the work so we'll avoid duplicated effort. The disadvantage of |
| 8535 // resolving everything is that we might do extra work that we don't |
| 8536 // really care about. Another possibility is to add a parameter to this |
| 8537 // method and punt the decision to the clients. |
| 8538 // |
| 8539 //if (analyzeAll) { |
| 8540 _resolveReferencesAndTypes(); |
| 8541 //} else { |
| 8542 // resolveReferencesAndTypes(targetLibrary); |
| 8543 //} |
| 8544 _performConstantEvaluation(); |
| 8545 return targetLibrary.libraryElement; |
| 8582 } | 8546 } |
| 8583 | 8547 |
| 8584 /** | 8548 /** |
| 8585 * Add a dependency to the given map from the referencing library to the refer
enced library. | 8549 * Add a dependency to the given map from the referencing library to the refer
enced library. |
| 8586 * | 8550 * |
| 8587 * @param dependencyMap the map to which the dependency is to be added | 8551 * @param dependencyMap the map to which the dependency is to be added |
| 8588 * @param referencingLibrary the library that references the referenced librar
y | 8552 * @param referencingLibrary the library that references the referenced librar
y |
| 8589 * @param referencedLibrary the library referenced by the referencing library | 8553 * @param referencedLibrary the library referenced by the referencing library |
| 8590 */ | 8554 */ |
| 8591 void _addDependencyToMap(HashMap<Library, List<Library>> dependencyMap, | 8555 void _addDependencyToMap(HashMap<Library, List<Library>> dependencyMap, |
| (...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9302 * multiple libraries. | 9266 * multiple libraries. |
| 9303 * | 9267 * |
| 9304 * @param librarySource the source specifying the defining compilation unit of
the library to be | 9268 * @param librarySource the source specifying the defining compilation unit of
the library to be |
| 9305 * resolved | 9269 * resolved |
| 9306 * @param fullAnalysis `true` if a full analysis should be performed | 9270 * @param fullAnalysis `true` if a full analysis should be performed |
| 9307 * @return the element representing the resolved library | 9271 * @return the element representing the resolved library |
| 9308 * @throws AnalysisException if the library could not be resolved for some rea
son | 9272 * @throws AnalysisException if the library could not be resolved for some rea
son |
| 9309 */ | 9273 */ |
| 9310 LibraryElement resolveLibrary(Source librarySource, | 9274 LibraryElement resolveLibrary(Source librarySource, |
| 9311 List<ResolvableLibrary> librariesInCycle) { | 9275 List<ResolvableLibrary> librariesInCycle) { |
| 9312 InstrumentationBuilder instrumentation = | 9276 // |
| 9313 Instrumentation.builder2("dart.engine.LibraryResolver.resolveLibrary"); | 9277 // Build the map of libraries that are known. |
| 9314 try { | 9278 // |
| 9315 instrumentation.data3("fullName", librarySource.fullName); | 9279 this._librariesInCycle = librariesInCycle; |
| 9316 // | 9280 _libraryMap = _buildLibraryMap(); |
| 9317 // Build the map of libraries that are known. | 9281 ResolvableLibrary targetLibrary = _libraryMap[librarySource]; |
| 9318 // | 9282 _coreLibrary = _libraryMap[_coreLibrarySource]; |
| 9319 this._librariesInCycle = librariesInCycle; | 9283 // |
| 9320 _libraryMap = _buildLibraryMap(); | 9284 // Build the element models representing the libraries being resolved. |
| 9321 ResolvableLibrary targetLibrary = _libraryMap[librarySource]; | 9285 // This is done in three steps: |
| 9322 _coreLibrary = _libraryMap[_coreLibrarySource]; | 9286 // |
| 9323 instrumentation.metric3("buildLibraryMap", "complete"); | 9287 // 1. Build the basic element models without making any connections |
| 9324 // | 9288 // between elements other than the basic parent/child relationships. |
| 9325 // Build the element models representing the libraries being resolved. | 9289 // This includes building the elements representing the libraries, but |
| 9326 // This is done in three steps: | 9290 // excludes members defined in enums. |
| 9327 // | 9291 // 2. Build the elements for the import and export directives. This |
| 9328 // 1. Build the basic element models without making any connections | 9292 // requires that we have the elements built for the referenced |
| 9329 // between elements other than the basic parent/child relationships. | 9293 // libraries, but because of the possibility of circular references |
| 9330 // This includes building the elements representing the libraries, but | 9294 // needs to happen after all of the library elements have been created. |
| 9331 // excludes members defined in enums. | 9295 // 3. Build the members in enum declarations. |
| 9332 // 2. Build the elements for the import and export directives. This | 9296 // 4. Build the rest of the type model by connecting superclasses, mixins, |
| 9333 // requires that we have the elements built for the referenced | 9297 // and interfaces. This requires that we be able to compute the names |
| 9334 // libraries, but because of the possibility of circular references | 9298 // visible in the libraries being resolved, which in turn requires that |
| 9335 // needs to happen after all of the library elements have been created. | 9299 // we have resolved the import directives. |
| 9336 // 3. Build the members in enum declarations. | 9300 // |
| 9337 // 4. Build the rest of the type model by connecting superclasses, mixins, | 9301 _buildElementModels(); |
| 9338 // and interfaces. This requires that we be able to compute the names | 9302 LibraryElement coreElement = _coreLibrary.libraryElement; |
| 9339 // visible in the libraries being resolved, which in turn requires that | 9303 if (coreElement == null) { |
| 9340 // we have resolved the import directives. | 9304 missingCoreLibrary(analysisContext, _coreLibrarySource); |
| 9341 // | |
| 9342 _buildElementModels(); | |
| 9343 instrumentation.metric3("buildElementModels", "complete"); | |
| 9344 LibraryElement coreElement = _coreLibrary.libraryElement; | |
| 9345 if (coreElement == null) { | |
| 9346 missingCoreLibrary(analysisContext, _coreLibrarySource); | |
| 9347 } | |
| 9348 _buildDirectiveModels(); | |
| 9349 instrumentation.metric3("buildDirectiveModels", "complete"); | |
| 9350 _typeProvider = new TypeProviderImpl(coreElement); | |
| 9351 _buildEnumMembers(); | |
| 9352 _buildTypeAliases(); | |
| 9353 _buildTypeHierarchies(); | |
| 9354 _buildImplicitConstructors(); | |
| 9355 instrumentation.metric3("buildTypeHierarchies", "complete"); | |
| 9356 // | |
| 9357 // Perform resolution and type analysis. | |
| 9358 // | |
| 9359 // TODO(brianwilkerson) Decide whether we want to resolve all of the | |
| 9360 // libraries or whether we want to only resolve the target library. The | |
| 9361 // advantage to resolving everything is that we have already done part of | |
| 9362 // the work so we'll avoid duplicated effort. The disadvantage of | |
| 9363 // resolving everything is that we might do extra work that we don't | |
| 9364 // really care about. Another possibility is to add a parameter to this | |
| 9365 // method and punt the decision to the clients. | |
| 9366 // | |
| 9367 //if (analyzeAll) { | |
| 9368 _resolveReferencesAndTypes(); | |
| 9369 instrumentation.metric3("resolveReferencesAndTypes", "complete"); | |
| 9370 //} else { | |
| 9371 // resolveReferencesAndTypes(targetLibrary); | |
| 9372 //} | |
| 9373 _performConstantEvaluation(); | |
| 9374 instrumentation.metric3("performConstantEvaluation", "complete"); | |
| 9375 instrumentation.metric2("librariesInCycles", librariesInCycle.length); | |
| 9376 for (ResolvableLibrary lib in librariesInCycle) { | |
| 9377 instrumentation.metric2( | |
| 9378 "librariesInCycles-CompilationUnitSources-Size", | |
| 9379 lib.compilationUnitSources.length); | |
| 9380 } | |
| 9381 return targetLibrary.libraryElement; | |
| 9382 } finally { | |
| 9383 instrumentation.log(); | |
| 9384 } | 9305 } |
| 9306 _buildDirectiveModels(); |
| 9307 _typeProvider = new TypeProviderImpl(coreElement); |
| 9308 _buildEnumMembers(); |
| 9309 _buildTypeAliases(); |
| 9310 _buildTypeHierarchies(); |
| 9311 _buildImplicitConstructors(); |
| 9312 // |
| 9313 // Perform resolution and type analysis. |
| 9314 // |
| 9315 // TODO(brianwilkerson) Decide whether we want to resolve all of the |
| 9316 // libraries or whether we want to only resolve the target library. The |
| 9317 // advantage to resolving everything is that we have already done part of |
| 9318 // the work so we'll avoid duplicated effort. The disadvantage of |
| 9319 // resolving everything is that we might do extra work that we don't |
| 9320 // really care about. Another possibility is to add a parameter to this |
| 9321 // method and punt the decision to the clients. |
| 9322 // |
| 9323 //if (analyzeAll) { |
| 9324 _resolveReferencesAndTypes(); |
| 9325 //} else { |
| 9326 // resolveReferencesAndTypes(targetLibrary); |
| 9327 //} |
| 9328 _performConstantEvaluation(); |
| 9329 return targetLibrary.libraryElement; |
| 9385 } | 9330 } |
| 9386 | 9331 |
| 9387 /** | 9332 /** |
| 9388 * Build the element model representing the combinators declared by the given
directive. | 9333 * Build the element model representing the combinators declared by the given
directive. |
| 9389 * | 9334 * |
| 9390 * @param directive the directive that declares the combinators | 9335 * @param directive the directive that declares the combinators |
| 9391 * @return an array containing the import combinators that were built | 9336 * @return an array containing the import combinators that were built |
| 9392 */ | 9337 */ |
| 9393 List<NamespaceCombinator> _buildCombinators(NamespaceDirective directive) { | 9338 List<NamespaceCombinator> _buildCombinators(NamespaceDirective directive) { |
| 9394 List<NamespaceCombinator> combinators = new List<NamespaceCombinator>(); | 9339 List<NamespaceCombinator> combinators = new List<NamespaceCombinator>(); |
| (...skipping 7028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16423 * library. | 16368 * library. |
| 16424 */ | 16369 */ |
| 16425 final HashSet<String> members = new HashSet<String>(); | 16370 final HashSet<String> members = new HashSet<String>(); |
| 16426 | 16371 |
| 16427 /** | 16372 /** |
| 16428 * Names of resolved or unresolved class members that are read in the | 16373 * Names of resolved or unresolved class members that are read in the |
| 16429 * library. | 16374 * library. |
| 16430 */ | 16375 */ |
| 16431 final HashSet<String> readMembers = new HashSet<String>(); | 16376 final HashSet<String> readMembers = new HashSet<String>(); |
| 16432 } | 16377 } |
| OLD | NEW |