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

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

Issue 1148153002: Reuse CompilationUnitElement in BuildCompilationUnitElementTask. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 7 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 | « no previous file | pkg/analyzer/test/src/context/abstract_context.dart » ('j') | 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 567f63490b786bfde5c07fa7d173cf562d6511dc..f8fef187a883d6f9a81528a62f682f0a302f5347 100644
--- a/pkg/analyzer/lib/src/task/dart.dart
+++ b/pkg/analyzer/lib/src/task/dart.dart
@@ -7,10 +7,12 @@ library analyzer.src.task.dart;
import 'dart:collection';
import 'dart:math' as math;
+import 'package:analyzer/src/context/cache.dart';
import 'package:analyzer/src/generated/ast.dart';
import 'package:analyzer/src/generated/constant.dart';
import 'package:analyzer/src/generated/element.dart';
-import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask;
+import 'package:analyzer/src/generated/engine.dart'
+ hide AnalysisCache, AnalysisTask;
import 'package:analyzer/src/generated/error.dart';
import 'package:analyzer/src/generated/error_verifier.dart';
import 'package:analyzer/src/generated/java_engine.dart';
@@ -668,12 +670,23 @@ class BuildCompilationUnitElementTask extends SourceBasedAnalysisTask {
Source source = getRequiredSource();
CompilationUnit unit = getRequiredInput(PARSED_UNIT_INPUT_NAME);
//
- // Process inputs.
+ // Build or reuse CompilationUnitElement.
//
unit = AstCloner.clone(unit);
- CompilationUnitBuilder builder = new CompilationUnitBuilder();
+ AnalysisCache analysisCache =
+ (context as InternalAnalysisContext).analysisCache;
CompilationUnitElement element =
- builder.buildCompilationUnit(source, unit, librarySpecificUnit.library);
+ analysisCache.getValue(target, COMPILATION_UNIT_ELEMENT);
+ if (element == null) {
+ CompilationUnitBuilder builder = new CompilationUnitBuilder();
+ element = builder.buildCompilationUnit(
+ source, unit, librarySpecificUnit.library);
+ } else {
+ new DeclarationResolver().resolve(unit, element);
+ }
+ //
+ // Prepare constants.
+ //
ConstantFinder constantFinder =
new ConstantFinder(context, source, librarySpecificUnit.library);
unit.accept(constantFinder);
« no previous file with comments | « no previous file | pkg/analyzer/test/src/context/abstract_context.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698