Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: pkg/analyzer/lib/src/generated/engine.dart

Issue 898513002: Fix async/await type checking in analyzer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Reformat and sort methods Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine; 8 library engine;
9 9
10 import "dart:math" as math; 10 import "dart:math" as math;
(...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 * The set of declared variables used when computing constant values. 961 * The set of declared variables used when computing constant values.
962 */ 962 */
963 DeclaredVariables _declaredVariables = new DeclaredVariables(); 963 DeclaredVariables _declaredVariables = new DeclaredVariables();
964 964
965 /** 965 /**
966 * A source representing the core library. 966 * A source representing the core library.
967 */ 967 */
968 Source _coreLibrarySource; 968 Source _coreLibrarySource;
969 969
970 /** 970 /**
971 * A source representing the async library.
972 */
973 Source _asyncLibrarySource;
974
975 /**
971 * The partition that contains analysis results that are not shared with other contexts. 976 * The partition that contains analysis results that are not shared with other contexts.
972 */ 977 */
973 CachePartition _privatePartition; 978 CachePartition _privatePartition;
974 979
975 /** 980 /**
976 * A table mapping the sources known to the context to the information known a bout the source. 981 * A table mapping the sources known to the context to the information known a bout the source.
977 */ 982 */
978 AnalysisCache _cache; 983 AnalysisCache _cache;
979 984
980 /** 985 /**
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
1396 } else if (factory.context != null) { 1401 } else if (factory.context != null) {
1397 throw new IllegalStateException( 1402 throw new IllegalStateException(
1398 "Source factories cannot be shared between contexts"); 1403 "Source factories cannot be shared between contexts");
1399 } 1404 }
1400 if (_sourceFactory != null) { 1405 if (_sourceFactory != null) {
1401 _sourceFactory.context = null; 1406 _sourceFactory.context = null;
1402 } 1407 }
1403 factory.context = this; 1408 factory.context = this;
1404 _sourceFactory = factory; 1409 _sourceFactory = factory;
1405 _coreLibrarySource = _sourceFactory.forUri(DartSdk.DART_CORE); 1410 _coreLibrarySource = _sourceFactory.forUri(DartSdk.DART_CORE);
1411 _asyncLibrarySource = _sourceFactory.forUri(DartSdk.DART_ASYNC);
1406 _cache = createCacheFromSourceFactory(factory); 1412 _cache = createCacheFromSourceFactory(factory);
1407 _invalidateAllLocalResolutionInformation(true); 1413 _invalidateAllLocalResolutionInformation(true);
1408 } 1414 }
1409 1415
1410 /** 1416 /**
1411 * Return a list of the sources that would be processed by [performAnalysisTas k]. This 1417 * Return a list of the sources that would be processed by [performAnalysisTas k]. This
1412 * method duplicates, and must therefore be kept in sync with, [getNextAnalysi sTask]. 1418 * method duplicates, and must therefore be kept in sync with, [getNextAnalysi sTask].
1413 * This method is intended to be used for testing purposes only. 1419 * This method is intended to be used for testing purposes only.
1414 * 1420 *
1415 * @return a list of the sources that would be processed by [performAnalysisTa sk] 1421 * @return a list of the sources that would be processed by [performAnalysisTa sk]
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1470 @override 1476 @override
1471 TypeProvider get typeProvider { 1477 TypeProvider get typeProvider {
1472 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE); 1478 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE);
1473 if (coreSource == null) { 1479 if (coreSource == null) {
1474 throw new AnalysisException("Could not create a source for dart:core"); 1480 throw new AnalysisException("Could not create a source for dart:core");
1475 } 1481 }
1476 LibraryElement coreElement = computeLibraryElement(coreSource); 1482 LibraryElement coreElement = computeLibraryElement(coreSource);
1477 if (coreElement == null) { 1483 if (coreElement == null) {
1478 throw new AnalysisException("Could not create an element for dart:core"); 1484 throw new AnalysisException("Could not create an element for dart:core");
1479 } 1485 }
1480 return new TypeProviderImpl(coreElement); 1486 Source asyncSource = sourceFactory.forUri(DartSdk.DART_ASYNC);
1487 if (asyncSource == null) {
1488 throw new AnalysisException("Could not create a source for dart:async");
1489 }
1490 LibraryElement asyncElement = computeLibraryElement(asyncSource);
1491 if (asyncElement == null) {
1492 throw new AnalysisException("Could not create an element for dart:async");
1493 }
1494 return new TypeProviderImpl(coreElement, asyncElement);
1481 } 1495 }
1482 1496
1483 @override 1497 @override
1484 void addListener(AnalysisListener listener) { 1498 void addListener(AnalysisListener listener) {
1485 if (!_listeners.contains(listener)) { 1499 if (!_listeners.contains(listener)) {
1486 _listeners.add(listener); 1500 _listeners.add(listener);
1487 } 1501 }
1488 } 1502 }
1489 1503
1490 @override 1504 @override
(...skipping 3859 matching lines...) Expand 10 before | Expand all | Expand 10 after
5350 if (_taskData != null) { 5364 if (_taskData != null) {
5351 // At least one part needs to be parsed. 5365 // At least one part needs to be parsed.
5352 return; 5366 return;
5353 } 5367 }
5354 // All of the AST's necessary to perform a resolution of the library cycle 5368 // All of the AST's necessary to perform a resolution of the library cycle
5355 // have been gathered, so it is no longer necessary to retain them in the 5369 // have been gathered, so it is no longer necessary to retain them in the
5356 // cache. 5370 // cache.
5357 AnalysisContextImpl_this._neededForResolution = null; 5371 AnalysisContextImpl_this._neededForResolution = null;
5358 } 5372 }
5359 5373
5374 bool _addDependency(ResolvableLibrary dependant, Source dependency,
5375 List<ResolvableLibrary> dependencyList) {
5376 if (dependant.librarySource == dependency) {
5377 // Don't add a dependency of a library on itself; there's no point.
5378 return true;
5379 }
5380 ResolvableLibrary importedLibrary = _libraryMap[dependency];
5381 if (importedLibrary == null) {
5382 importedLibrary = _createLibraryOrNull(dependency);
5383 if (importedLibrary != null) {
5384 _computeLibraryDependencies(importedLibrary);
5385 if (_taskData != null) {
5386 return false;
5387 }
5388 }
5389 }
5390 if (importedLibrary != null) {
5391 if (dependencyList != null) {
5392 dependencyList.add(importedLibrary);
5393 }
5394 _dependencyGraph.addEdge(dependant, importedLibrary);
5395 }
5396 return true;
5397 }
5398
5360 /** 5399 /**
5361 * Recursively traverse the libraries reachable from the given library, creati ng instances of 5400 * Recursively traverse the libraries reachable from the given library, creati ng instances of
5362 * the class [Library] to represent them, and record the references in the lib rary 5401 * the class [Library] to represent them, and record the references in the lib rary
5363 * objects. 5402 * objects.
5364 * 5403 *
5365 * @param library the library to be processed to find libraries that have not yet been traversed 5404 * @param library the library to be processed to find libraries that have not yet been traversed
5366 * @throws AnalysisException if some portion of the library graph could not be traversed 5405 * @throws AnalysisException if some portion of the library graph could not be traversed
5367 */ 5406 */
5368 void _computeLibraryDependencies(ResolvableLibrary library) { 5407 void _computeLibraryDependencies(ResolvableLibrary library) {
5369 Source librarySource = library.librarySource; 5408 Source librarySource = library.librarySource;
(...skipping 22 matching lines...) Expand all
5392 * 5431 *
5393 * @param library the library to be processed to find libraries that have not yet been traversed 5432 * @param library the library to be processed to find libraries that have not yet been traversed
5394 * @param importedSources an array containing the sources that are imported in to the given 5433 * @param importedSources an array containing the sources that are imported in to the given
5395 * library 5434 * library
5396 * @param exportedSources an array containing the sources that are exported fr om the given 5435 * @param exportedSources an array containing the sources that are exported fr om the given
5397 * library 5436 * library
5398 */ 5437 */
5399 void _computeLibraryDependenciesFromDirectives(ResolvableLibrary library, 5438 void _computeLibraryDependenciesFromDirectives(ResolvableLibrary library,
5400 List<Source> importedSources, List<Source> exportedSources) { 5439 List<Source> importedSources, List<Source> exportedSources) {
5401 int importCount = importedSources.length; 5440 int importCount = importedSources.length;
5402 if (importCount > 0) { 5441 List<ResolvableLibrary> importedLibraries = new List<ResolvableLibrary>();
5403 List<ResolvableLibrary> importedLibraries = new List<ResolvableLibrary>(); 5442 bool explicitlyImportsCore = false;
5404 bool explicitlyImportsCore = false; 5443 bool importsAsync = false;
5405 for (int i = 0; i < importCount; i++) { 5444 for (int i = 0; i < importCount; i++) {
5406 Source importedSource = importedSources[i]; 5445 Source importedSource = importedSources[i];
5407 if (importedSource == AnalysisContextImpl_this._coreLibrarySource) { 5446 if (importedSource == AnalysisContextImpl_this._coreLibrarySource) {
5408 explicitlyImportsCore = true; 5447 explicitlyImportsCore = true;
5409 } 5448 } else if (importedSource ==
5410 ResolvableLibrary importedLibrary = _libraryMap[importedSource]; 5449 AnalysisContextImpl_this._asyncLibrarySource) {
5411 if (importedLibrary == null) { 5450 importsAsync = true;
5412 importedLibrary = _createLibraryOrNull(importedSource);
5413 if (importedLibrary != null) {
5414 _computeLibraryDependencies(importedLibrary);
5415 if (_taskData != null) {
5416 return;
5417 }
5418 }
5419 }
5420 if (importedLibrary != null) {
5421 importedLibraries.add(importedLibrary);
5422 _dependencyGraph.addEdge(library, importedLibrary);
5423 }
5424 } 5451 }
5425 library.explicitlyImportsCore = explicitlyImportsCore; 5452 if (!_addDependency(library, importedSource, importedLibraries)) {
5426 if (!explicitlyImportsCore && 5453 return;
5427 AnalysisContextImpl_this._coreLibrarySource != library.librarySource) {
5428 ResolvableLibrary importedLibrary =
5429 _libraryMap[AnalysisContextImpl_this._coreLibrarySource];
5430 if (importedLibrary == null) {
5431 importedLibrary =
5432 _createLibraryOrNull(AnalysisContextImpl_this._coreLibrarySource);
5433 if (importedLibrary != null) {
5434 _computeLibraryDependencies(importedLibrary);
5435 if (_taskData != null) {
5436 return;
5437 }
5438 }
5439 }
5440 if (importedLibrary != null) {
5441 importedLibraries.add(importedLibrary);
5442 _dependencyGraph.addEdge(library, importedLibrary);
5443 }
5444 }
5445 library.importedLibraries = importedLibraries;
5446 } else {
5447 library.explicitlyImportsCore = false;
5448 ResolvableLibrary importedLibrary =
5449 _libraryMap[AnalysisContextImpl_this._coreLibrarySource];
5450 if (importedLibrary == null) {
5451 importedLibrary =
5452 _createLibraryOrNull(AnalysisContextImpl_this._coreLibrarySource);
5453 if (importedLibrary != null) {
5454 _computeLibraryDependencies(importedLibrary);
5455 if (_taskData != null) {
5456 return;
5457 }
5458 }
5459 }
5460 if (importedLibrary != null) {
5461 _dependencyGraph.addEdge(library, importedLibrary);
5462 library.importedLibraries = <ResolvableLibrary>[importedLibrary];
5463 } 5454 }
5464 } 5455 }
5456 library.explicitlyImportsCore = explicitlyImportsCore;
5457 if (!explicitlyImportsCore) {
5458 if (!_addDependency(
5459 library,
5460 AnalysisContextImpl_this._coreLibrarySource,
5461 importedLibraries)) {
5462 return;
5463 }
5464 }
5465 if (!importsAsync) {
5466 // Add a dependency on async to ensure that the Future element will be
5467 // built before we generate errors and warnings for async methods. Also
5468 // include it in importedLibraries, so that it will be picked up by
5469 // LibraryResolver2._buildLibraryMap().
5470 // TODO(paulberry): this is a bit of a hack, since the async library
5471 // isn't actually being imported.
Brian Wilkerson 2015/02/02 19:41:48 I don't think this is (or should be) necessary und
Paul Berry 2015/02/02 20:55:38 Hmm, your reasoning seems valid. However, if I re
5472 if (!_addDependency(
5473 library,
5474 AnalysisContextImpl_this._asyncLibrarySource,
5475 importedLibraries)) {
5476 return;
5477 }
5478 }
5479 library.importedLibraries = importedLibraries;
5465 int exportCount = exportedSources.length; 5480 int exportCount = exportedSources.length;
5466 if (exportCount > 0) { 5481 if (exportCount > 0) {
5467 List<ResolvableLibrary> exportedLibraries = new List<ResolvableLibrary>(); 5482 List<ResolvableLibrary> exportedLibraries = new List<ResolvableLibrary>();
5468 for (int i = 0; i < exportCount; i++) { 5483 for (int i = 0; i < exportCount; i++) {
5469 Source exportedSource = exportedSources[i]; 5484 Source exportedSource = exportedSources[i];
5470 ResolvableLibrary exportedLibrary = _libraryMap[exportedSource]; 5485 if (!_addDependency(library, exportedSource, exportedLibraries)) {
5471 if (exportedLibrary == null) { 5486 return;
5472 exportedLibrary = _createLibraryOrNull(exportedSource);
5473 if (exportedLibrary != null) {
5474 _computeLibraryDependencies(exportedLibrary);
5475 if (_taskData != null) {
5476 return;
5477 }
5478 }
5479 }
5480 if (exportedLibrary != null) {
5481 exportedLibraries.add(exportedLibrary);
5482 _dependencyGraph.addEdge(library, exportedLibrary);
5483 } 5487 }
5484 } 5488 }
5485 library.exportedLibraries = exportedLibraries; 5489 library.exportedLibraries = exportedLibraries;
5486 } 5490 }
5487 } 5491 }
5488 5492
5489 /** 5493 /**
5490 * Gather the resolvable AST structures for each of the compilation units in e ach of the 5494 * Gather the resolvable AST structures for each of the compilation units in e ach of the
5491 * libraries in the cycle. This is done in two phases: first we ensure that we have cached an 5495 * libraries in the cycle. This is done in two phases: first we ensure that we have cached an
5492 * AST structure for each compilation unit, then we gather them. We split the work this way 5496 * AST structure for each compilation unit, then we gather them. We split the work this way
(...skipping 6821 matching lines...) Expand 10 before | Expand all | Expand 10 after
12314 if (element.id == _id) { 12318 if (element.id == _id) {
12315 result = element; 12319 result = element;
12316 throw new _ElementByIdFinderException(); 12320 throw new _ElementByIdFinderException();
12317 } 12321 }
12318 super.visitElement(element); 12322 super.visitElement(element);
12319 } 12323 }
12320 } 12324 }
12321 12325
12322 class _ElementByIdFinderException { 12326 class _ElementByIdFinderException {
12323 } 12327 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698