| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.task.dart; | 5 library analyzer.src.task.dart; |
| 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 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 870 | 870 |
| 871 @override | 871 @override |
| 872 void internalPerform() { | 872 void internalPerform() { |
| 873 // | 873 // |
| 874 // Prepare inputs. | 874 // Prepare inputs. |
| 875 // | 875 // |
| 876 LibrarySpecificUnit librarySpecificUnit = target; | 876 LibrarySpecificUnit librarySpecificUnit = target; |
| 877 Source source = getRequiredSource(); | 877 Source source = getRequiredSource(); |
| 878 CompilationUnit unit = getRequiredInput(PARSED_UNIT_INPUT_NAME); | 878 CompilationUnit unit = getRequiredInput(PARSED_UNIT_INPUT_NAME); |
| 879 // | 879 // |
| 880 // Try to get the existing CompilationUnitElement. |
| 881 // |
| 882 CompilationUnitElement element; |
| 883 { |
| 884 InternalAnalysisContext internalContext = |
| 885 context as InternalAnalysisContext; |
| 886 AnalysisCache analysisCache = internalContext.analysisCache; |
| 887 CacheEntry cacheEntry = internalContext.getCacheEntry(target); |
| 888 element = analysisCache.getValue(target, COMPILATION_UNIT_ELEMENT); |
| 889 if (element == null && |
| 890 internalContext.aboutToComputeResult( |
| 891 cacheEntry, COMPILATION_UNIT_ELEMENT)) { |
| 892 element = analysisCache.getValue(target, COMPILATION_UNIT_ELEMENT); |
| 893 } |
| 894 } |
| 895 // |
| 880 // Build or reuse CompilationUnitElement. | 896 // Build or reuse CompilationUnitElement. |
| 881 // | 897 // |
| 882 // unit = AstCloner.clone(unit); | |
| 883 AnalysisCache analysisCache = | |
| 884 (context as InternalAnalysisContext).analysisCache; | |
| 885 CompilationUnitElement element = | |
| 886 analysisCache.getValue(target, COMPILATION_UNIT_ELEMENT); | |
| 887 if (element == null) { | 898 if (element == null) { |
| 888 CompilationUnitBuilder builder = new CompilationUnitBuilder(); | 899 CompilationUnitBuilder builder = new CompilationUnitBuilder(); |
| 889 element = builder.buildCompilationUnit( | 900 element = builder.buildCompilationUnit( |
| 890 source, unit, librarySpecificUnit.library); | 901 source, unit, librarySpecificUnit.library); |
| 891 } else { | 902 } else { |
| 892 new DeclarationResolver().resolve(unit, element); | 903 new DeclarationResolver().resolve(unit, element); |
| 893 } | 904 } |
| 894 // | 905 // |
| 895 // Prepare constants. | 906 // Prepare constants. |
| 896 // | 907 // |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1349 errors.add(error); | 1360 errors.add(error); |
| 1350 } | 1361 } |
| 1351 // | 1362 // |
| 1352 // Create and populate the library element. | 1363 // Create and populate the library element. |
| 1353 // | 1364 // |
| 1354 AnalysisContext owningContext = context; | 1365 AnalysisContext owningContext = context; |
| 1355 if (context is InternalAnalysisContext) { | 1366 if (context is InternalAnalysisContext) { |
| 1356 InternalAnalysisContext internalContext = context; | 1367 InternalAnalysisContext internalContext = context; |
| 1357 owningContext = internalContext.getContextFor(librarySource); | 1368 owningContext = internalContext.getContextFor(librarySource); |
| 1358 } | 1369 } |
| 1359 LibraryElementImpl libraryElement = | 1370 // |
| 1360 new LibraryElementImpl.forNode(owningContext, libraryNameNode); | 1371 // Try to get the existing LibraryElement. |
| 1361 libraryElement.definingCompilationUnit = definingCompilationUnitElement; | 1372 // |
| 1362 libraryElement.entryPoint = entryPoint; | 1373 LibraryElementImpl libraryElement; |
| 1363 libraryElement.parts = sourcedCompilationUnits; | 1374 { |
| 1364 for (Directive directive in directivesToResolve) { | 1375 InternalAnalysisContext internalContext = |
| 1365 directive.element = libraryElement; | 1376 context as InternalAnalysisContext; |
| 1377 AnalysisCache analysisCache = internalContext.analysisCache; |
| 1378 CacheEntry cacheEntry = internalContext.getCacheEntry(target); |
| 1379 libraryElement = analysisCache.getValue(target, LIBRARY_ELEMENT1); |
| 1380 if (libraryElement == null && |
| 1381 internalContext.aboutToComputeResult(cacheEntry, LIBRARY_ELEMENT1)) { |
| 1382 libraryElement = analysisCache.getValue(target, LIBRARY_ELEMENT1); |
| 1383 } |
| 1366 } | 1384 } |
| 1367 BuildLibraryElementUtils.patchTopLevelAccessors(libraryElement); | 1385 // |
| 1368 // set the library documentation to the docs associated with the first | 1386 // Create a new LibraryElement. |
| 1369 // directive in the compilation unit. | 1387 // |
| 1370 if (definingCompilationUnit.directives.isNotEmpty) { | 1388 if (libraryElement == null) { |
| 1371 setElementDocumentationComment( | 1389 libraryElement = |
| 1372 libraryElement, definingCompilationUnit.directives.first); | 1390 new LibraryElementImpl.forNode(owningContext, libraryNameNode); |
| 1391 libraryElement.definingCompilationUnit = definingCompilationUnitElement; |
| 1392 libraryElement.entryPoint = entryPoint; |
| 1393 libraryElement.parts = sourcedCompilationUnits; |
| 1394 for (Directive directive in directivesToResolve) { |
| 1395 directive.element = libraryElement; |
| 1396 } |
| 1397 BuildLibraryElementUtils.patchTopLevelAccessors(libraryElement); |
| 1398 // set the library documentation to the docs associated with the first |
| 1399 // directive in the compilation unit. |
| 1400 if (definingCompilationUnit.directives.isNotEmpty) { |
| 1401 setElementDocumentationComment( |
| 1402 libraryElement, definingCompilationUnit.directives.first); |
| 1403 } |
| 1373 } | 1404 } |
| 1374 | |
| 1375 // | 1405 // |
| 1376 // Record outputs. | 1406 // Record outputs. |
| 1377 // | 1407 // |
| 1378 outputs[BUILD_LIBRARY_ERRORS] = errors; | 1408 outputs[BUILD_LIBRARY_ERRORS] = errors; |
| 1379 outputs[LIBRARY_ELEMENT1] = libraryElement; | 1409 outputs[LIBRARY_ELEMENT1] = libraryElement; |
| 1380 outputs[IS_LAUNCHABLE] = entryPoint != null; | 1410 outputs[IS_LAUNCHABLE] = entryPoint != null; |
| 1381 } | 1411 } |
| 1382 | 1412 |
| 1383 /** | 1413 /** |
| 1384 * Return the top-level [FunctionElement] entry point, or `null` if the given | 1414 * Return the top-level [FunctionElement] entry point, or `null` if the given |
| (...skipping 3864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5249 | 5279 |
| 5250 @override | 5280 @override |
| 5251 bool moveNext() { | 5281 bool moveNext() { |
| 5252 if (_newSources.isEmpty) { | 5282 if (_newSources.isEmpty) { |
| 5253 return false; | 5283 return false; |
| 5254 } | 5284 } |
| 5255 currentTarget = _newSources.removeLast(); | 5285 currentTarget = _newSources.removeLast(); |
| 5256 return true; | 5286 return true; |
| 5257 } | 5287 } |
| 5258 } | 5288 } |
| OLD | NEW |