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

Side by Side Diff: pkg/analyzer/lib/src/task/dart.dart

Issue 1787623005: Add more debugging code (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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 | « pkg/analyzer/lib/src/dart/element/element.dart ('k') | no next file » | 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 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 2934 matching lines...) Expand 10 before | Expand all | Expand 10 after
2945 InternalAnalysisContext context, VariableElement variable) 2945 InternalAnalysisContext context, VariableElement variable)
2946 : super(context, variable); 2946 : super(context, variable);
2947 2947
2948 /** 2948 /**
2949 * Return the declaration of the target within the given compilation [unit]. 2949 * Return the declaration of the target within the given compilation [unit].
2950 * Throw an exception if the declaration cannot be found. 2950 * Throw an exception if the declaration cannot be found.
2951 */ 2951 */
2952 VariableDeclaration getDeclaration(CompilationUnit unit) { 2952 VariableDeclaration getDeclaration(CompilationUnit unit) {
2953 VariableElement variable = target; 2953 VariableElement variable = target;
2954 AstNode node = new NodeLocator2(variable.nameOffset).searchWithin(unit); 2954 AstNode node = new NodeLocator2(variable.nameOffset).searchWithin(unit);
2955 if (node == null) {
2956 Source variableSource = variable.source;
2957 Source unitSource = unit.element.source;
2958 if (variableSource != unitSource) {
2959 throw new AnalysisException(
2960 "Failed to find the AST node for the variable "
2961 "${variable.displayName} in $variableSource "
2962 "because we were looking in $unitSource");
2963 }
2964 throw new AnalysisException(
2965 "Failed to find the AST node for the variable "
2966 "${variable.displayName} in $variableSource");
2967 }
2955 VariableDeclaration declaration = 2968 VariableDeclaration declaration =
2956 node.getAncestor((AstNode ancestor) => ancestor is VariableDeclaration); 2969 node.getAncestor((AstNode ancestor) => ancestor is VariableDeclaration);
2957 if (declaration == null || declaration.name != node) { 2970 if (declaration == null || declaration.name != node) {
2971 Source variableSource = variable.source;
2972 Source unitSource = unit.element.source;
2973 if (variableSource != unitSource) {
2974 throw new AnalysisException(
2975 "Failed to find the declaration of the variable "
2976 "${variable.displayName} in $variableSource"
2977 "because we were looking in $unitSource");
2978 }
2958 throw new AnalysisException( 2979 throw new AnalysisException(
2959 "Failed to find the declaration of the variable " 2980 "Failed to find the declaration of the variable "
2960 "${variable.displayName} in ${variable.source}"); 2981 "${variable.displayName} in $variableSource");
2961 } 2982 }
2962 return declaration; 2983 return declaration;
2963 } 2984 }
2964 } 2985 }
2965 2986
2966 /** 2987 /**
2967 * A task that ensures that all of the inferable static variables in a 2988 * A task that ensures that all of the inferable static variables in a
2968 * compilation unit have had their type inferred. 2989 * compilation unit have had their type inferred.
2969 */ 2990 */
2970 class InferStaticVariableTypesInUnitTask extends SourceBasedAnalysisTask { 2991 class InferStaticVariableTypesInUnitTask extends SourceBasedAnalysisTask {
(...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after
3904 outputs[PROPAGATED_VARIABLE] = variable; 3925 outputs[PROPAGATED_VARIABLE] = variable;
3905 } 3926 }
3906 3927
3907 /** 3928 /**
3908 * Return a map from the names of the inputs of this kind of task to the task 3929 * Return a map from the names of the inputs of this kind of task to the task
3909 * input descriptors describing those inputs for a task with the given 3930 * input descriptors describing those inputs for a task with the given
3910 * [target]. 3931 * [target].
3911 */ 3932 */
3912 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { 3933 static Map<String, TaskInput> buildInputs(AnalysisTarget target) {
3913 VariableElement variable = target; 3934 VariableElement variable = target;
3935 if (variable.library == null) {
3936 StringBuffer buffer = new StringBuffer();
3937 buffer.write(
3938 'PropagateVariableTypeTask building inputs for a variable with no libr ary. Variable name = "');
3939 buffer.write(variable.name);
3940 buffer.write('". Path = ');
3941 (variable as ElementImpl).appendPathTo(buffer);
3942 throw new AnalysisException(buffer.toString());
3943 }
3914 LibrarySpecificUnit unit = 3944 LibrarySpecificUnit unit =
3915 new LibrarySpecificUnit(variable.library.source, variable.source); 3945 new LibrarySpecificUnit(variable.library.source, variable.source);
3916 return <String, TaskInput>{ 3946 return <String, TaskInput>{
3917 'dependencies': PROPAGABLE_VARIABLE_DEPENDENCIES 3947 'dependencies': PROPAGABLE_VARIABLE_DEPENDENCIES
3918 .of(variable) 3948 .of(variable)
3919 .toListOf(PROPAGATED_VARIABLE), 3949 .toListOf(PROPAGATED_VARIABLE),
3920 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), 3950 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request),
3921 UNIT_INPUT: RESOLVED_UNIT5.of(unit), 3951 UNIT_INPUT: RESOLVED_UNIT5.of(unit),
3922 }; 3952 };
3923 } 3953 }
(...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after
5112 RecordingErrorListener errorListener = new RecordingErrorListener(); 5142 RecordingErrorListener errorListener = new RecordingErrorListener();
5113 Source source = getRequiredSource(); 5143 Source source = getRequiredSource();
5114 errorReporter = new ErrorReporter(errorListener, source); 5144 errorReporter = new ErrorReporter(errorListener, source);
5115 // 5145 //
5116 // Prepare inputs. 5146 // Prepare inputs.
5117 // 5147 //
5118 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT); 5148 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT);
5119 CompilationUnit unit = getRequiredInput(UNIT_INPUT); 5149 CompilationUnit unit = getRequiredInput(UNIT_INPUT);
5120 CompilationUnitElement unitElement = unit.element; 5150 CompilationUnitElement unitElement = unit.element;
5121 LibraryElement libraryElement = unitElement.library; 5151 LibraryElement libraryElement = unitElement.library;
5152 if (libraryElement == null) {
5153 throw new AnalysisException(
5154 'VerifyUnitTask verifying constants in a unit with no library: '
scheglov 2016/03/11 18:57:12 Hm... Why do you mention constants here? Isn't it
Brian Wilkerson 2016/03/11 19:04:54 Incomplete clean up after copy paste. Thanks for c
5155 '${unitElement.source.fullName}');
5156 }
5122 // 5157 //
5123 // Validate the directives. 5158 // Validate the directives.
5124 // 5159 //
5125 validateDirectives(unit); 5160 validateDirectives(unit);
5126 // 5161 //
5127 // Use the ConstantVerifier to compute errors. 5162 // Use the ConstantVerifier to compute errors.
5128 // 5163 //
5129 ConstantVerifier constantVerifier = new ConstantVerifier( 5164 ConstantVerifier constantVerifier = new ConstantVerifier(
5130 errorReporter, libraryElement, typeProvider, context.declaredVariables); 5165 errorReporter, libraryElement, typeProvider, context.declaredVariables);
5131 unit.accept(constantVerifier); 5166 unit.accept(constantVerifier);
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
5302 5337
5303 @override 5338 @override
5304 bool moveNext() { 5339 bool moveNext() {
5305 if (_newSources.isEmpty) { 5340 if (_newSources.isEmpty) {
5306 return false; 5341 return false;
5307 } 5342 }
5308 currentTarget = _newSources.removeLast(); 5343 currentTarget = _newSources.removeLast();
5309 return true; 5344 return true;
5310 } 5345 }
5311 } 5346 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/element.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698