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

Unified Diff: pkg/analyzer/lib/src/task/dart.dart

Issue 1712313002: Get LibraryElement(s) and CompilationUnitElement(s) from summary. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/summary/summary_sdk.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/task/dart.dart
diff --git a/pkg/analyzer/lib/src/task/dart.dart b/pkg/analyzer/lib/src/task/dart.dart
index b9f2f51f0a4dd5ce9001ca7c42aced6519461d94..95f934eb7a1eea4036f7813a03300747edcff842 100644
--- a/pkg/analyzer/lib/src/task/dart.dart
+++ b/pkg/analyzer/lib/src/task/dart.dart
@@ -877,13 +877,24 @@ class BuildCompilationUnitElementTask extends SourceBasedAnalysisTask {
Source source = getRequiredSource();
CompilationUnit unit = getRequiredInput(PARSED_UNIT_INPUT_NAME);
//
+ // Try to get the existing CompilationUnitElement.
+ //
+ CompilationUnitElement element;
+ {
+ InternalAnalysisContext internalContext =
+ context as InternalAnalysisContext;
+ AnalysisCache analysisCache = internalContext.analysisCache;
+ CacheEntry cacheEntry = internalContext.getCacheEntry(target);
+ element = analysisCache.getValue(target, COMPILATION_UNIT_ELEMENT);
+ if (element == null &&
+ internalContext.aboutToComputeResult(
+ cacheEntry, COMPILATION_UNIT_ELEMENT)) {
+ element = analysisCache.getValue(target, COMPILATION_UNIT_ELEMENT);
+ }
+ }
+ //
// Build or reuse CompilationUnitElement.
//
-// unit = AstCloner.clone(unit);
- AnalysisCache analysisCache =
- (context as InternalAnalysisContext).analysisCache;
- CompilationUnitElement element =
- analysisCache.getValue(target, COMPILATION_UNIT_ELEMENT);
if (element == null) {
CompilationUnitBuilder builder = new CompilationUnitBuilder();
element = builder.buildCompilationUnit(
@@ -1356,22 +1367,41 @@ class BuildLibraryElementTask extends SourceBasedAnalysisTask {
InternalAnalysisContext internalContext = context;
owningContext = internalContext.getContextFor(librarySource);
}
- LibraryElementImpl libraryElement =
- new LibraryElementImpl.forNode(owningContext, libraryNameNode);
- libraryElement.definingCompilationUnit = definingCompilationUnitElement;
- libraryElement.entryPoint = entryPoint;
- libraryElement.parts = sourcedCompilationUnits;
- for (Directive directive in directivesToResolve) {
- directive.element = libraryElement;
+ //
+ // Try to get the existing LibraryElement.
+ //
+ LibraryElementImpl libraryElement;
+ {
+ InternalAnalysisContext internalContext =
+ context as InternalAnalysisContext;
+ AnalysisCache analysisCache = internalContext.analysisCache;
+ CacheEntry cacheEntry = internalContext.getCacheEntry(target);
+ libraryElement = analysisCache.getValue(target, LIBRARY_ELEMENT1);
+ if (libraryElement == null &&
+ internalContext.aboutToComputeResult(cacheEntry, LIBRARY_ELEMENT1)) {
+ libraryElement = analysisCache.getValue(target, LIBRARY_ELEMENT1);
+ }
}
- BuildLibraryElementUtils.patchTopLevelAccessors(libraryElement);
- // set the library documentation to the docs associated with the first
- // directive in the compilation unit.
- if (definingCompilationUnit.directives.isNotEmpty) {
- setElementDocumentationComment(
- libraryElement, definingCompilationUnit.directives.first);
+ //
+ // Create a new LibraryElement.
+ //
+ if (libraryElement == null) {
+ libraryElement =
+ new LibraryElementImpl.forNode(owningContext, libraryNameNode);
+ libraryElement.definingCompilationUnit = definingCompilationUnitElement;
+ libraryElement.entryPoint = entryPoint;
+ libraryElement.parts = sourcedCompilationUnits;
+ for (Directive directive in directivesToResolve) {
+ directive.element = libraryElement;
+ }
+ BuildLibraryElementUtils.patchTopLevelAccessors(libraryElement);
+ // set the library documentation to the docs associated with the first
+ // directive in the compilation unit.
+ if (definingCompilationUnit.directives.isNotEmpty) {
+ setElementDocumentationComment(
+ libraryElement, definingCompilationUnit.directives.first);
+ }
}
-
//
// Record outputs.
//
« no previous file with comments | « pkg/analyzer/lib/src/summary/summary_sdk.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698