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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | pkg/analyzer/test/src/context/abstract_context.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 import 'dart:math' as math; 8 import 'dart:math' as math;
9 9
10 import 'package:analyzer/src/context/cache.dart';
10 import 'package:analyzer/src/generated/ast.dart'; 11 import 'package:analyzer/src/generated/ast.dart';
11 import 'package:analyzer/src/generated/constant.dart'; 12 import 'package:analyzer/src/generated/constant.dart';
12 import 'package:analyzer/src/generated/element.dart'; 13 import 'package:analyzer/src/generated/element.dart';
13 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; 14 import 'package:analyzer/src/generated/engine.dart'
15 hide AnalysisCache, AnalysisTask;
14 import 'package:analyzer/src/generated/error.dart'; 16 import 'package:analyzer/src/generated/error.dart';
15 import 'package:analyzer/src/generated/error_verifier.dart'; 17 import 'package:analyzer/src/generated/error_verifier.dart';
16 import 'package:analyzer/src/generated/java_engine.dart'; 18 import 'package:analyzer/src/generated/java_engine.dart';
17 import 'package:analyzer/src/generated/parser.dart'; 19 import 'package:analyzer/src/generated/parser.dart';
18 import 'package:analyzer/src/generated/resolver.dart'; 20 import 'package:analyzer/src/generated/resolver.dart';
19 import 'package:analyzer/src/generated/scanner.dart'; 21 import 'package:analyzer/src/generated/scanner.dart';
20 import 'package:analyzer/src/generated/sdk.dart'; 22 import 'package:analyzer/src/generated/sdk.dart';
21 import 'package:analyzer/src/generated/source.dart'; 23 import 'package:analyzer/src/generated/source.dart';
22 import 'package:analyzer/src/task/driver.dart'; 24 import 'package:analyzer/src/task/driver.dart';
23 import 'package:analyzer/src/task/general.dart'; 25 import 'package:analyzer/src/task/general.dart';
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 663
662 @override 664 @override
663 void internalPerform() { 665 void internalPerform() {
664 // 666 //
665 // Prepare inputs. 667 // Prepare inputs.
666 // 668 //
667 LibrarySpecificUnit librarySpecificUnit = target; 669 LibrarySpecificUnit librarySpecificUnit = target;
668 Source source = getRequiredSource(); 670 Source source = getRequiredSource();
669 CompilationUnit unit = getRequiredInput(PARSED_UNIT_INPUT_NAME); 671 CompilationUnit unit = getRequiredInput(PARSED_UNIT_INPUT_NAME);
670 // 672 //
671 // Process inputs. 673 // Build or reuse CompilationUnitElement.
672 // 674 //
673 unit = AstCloner.clone(unit); 675 unit = AstCloner.clone(unit);
674 CompilationUnitBuilder builder = new CompilationUnitBuilder(); 676 AnalysisCache analysisCache =
677 (context as InternalAnalysisContext).analysisCache;
675 CompilationUnitElement element = 678 CompilationUnitElement element =
676 builder.buildCompilationUnit(source, unit, librarySpecificUnit.library); 679 analysisCache.getValue(target, COMPILATION_UNIT_ELEMENT);
680 if (element == null) {
681 CompilationUnitBuilder builder = new CompilationUnitBuilder();
682 element = builder.buildCompilationUnit(
683 source, unit, librarySpecificUnit.library);
684 } else {
685 new DeclarationResolver().resolve(unit, element);
686 }
687 //
688 // Prepare constants.
689 //
677 ConstantFinder constantFinder = 690 ConstantFinder constantFinder =
678 new ConstantFinder(context, source, librarySpecificUnit.library); 691 new ConstantFinder(context, source, librarySpecificUnit.library);
679 unit.accept(constantFinder); 692 unit.accept(constantFinder);
680 List<ConstantEvaluationTarget> constants = 693 List<ConstantEvaluationTarget> constants =
681 new List<ConstantEvaluationTarget>.from( 694 new List<ConstantEvaluationTarget>.from(
682 constantFinder.constantsToCompute); 695 constantFinder.constantsToCompute);
683 // 696 //
684 // Record outputs. 697 // Record outputs.
685 // 698 //
686 outputs[COMPILATION_UNIT_ELEMENT] = element; 699 outputs[COMPILATION_UNIT_ELEMENT] = element;
(...skipping 2659 matching lines...) Expand 10 before | Expand all | Expand 10 after
3346 @override 3359 @override
3347 bool moveNext() { 3360 bool moveNext() {
3348 if (_newSources.isEmpty) { 3361 if (_newSources.isEmpty) {
3349 return false; 3362 return false;
3350 } 3363 }
3351 currentTarget = _newSources.first; 3364 currentTarget = _newSources.first;
3352 _newSources.remove(currentTarget); 3365 _newSources.remove(currentTarget);
3353 return true; 3366 return true;
3354 } 3367 }
3355 } 3368 }
OLDNEW
« 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