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

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

Issue 2053443002: Slightly better debugging output (issue-26636) (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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 | 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 3239 matching lines...) Expand 10 before | Expand all | Expand 10 after
3250 InferStaticVariableTask( 3250 InferStaticVariableTask(
3251 InternalAnalysisContext context, VariableElement variable) 3251 InternalAnalysisContext context, VariableElement variable)
3252 : super(context, variable); 3252 : super(context, variable);
3253 3253
3254 /** 3254 /**
3255 * Return the declaration of the target within the given compilation [unit]. 3255 * Return the declaration of the target within the given compilation [unit].
3256 * Throw an exception if the declaration cannot be found. 3256 * Throw an exception if the declaration cannot be found.
3257 */ 3257 */
3258 VariableDeclaration getDeclaration(CompilationUnit unit) { 3258 VariableDeclaration getDeclaration(CompilationUnit unit) {
3259 VariableElement variable = target; 3259 VariableElement variable = target;
3260 AstNode node = new NodeLocator2(variable.nameOffset).searchWithin(unit); 3260 int offset = variable.nameOffset;
3261 AstNode node = new NodeLocator2(offset).searchWithin(unit);
3261 if (node == null) { 3262 if (node == null) {
3262 Source variableSource = variable.source; 3263 Source variableSource = variable.source;
3263 Source unitSource = unit.element.source; 3264 Source unitSource = unit.element.source;
3264 if (variableSource != unitSource) { 3265 if (variableSource != unitSource) {
3265 throw new AnalysisException( 3266 throw new AnalysisException(
3266 "Failed to find the AST node for the variable " 3267 "Failed to find the AST node for the variable "
3267 "${variable.displayName} in $variableSource " 3268 "${variable.displayName} at $offset in $variableSource "
3268 "because we were looking in $unitSource"); 3269 "because we were looking in $unitSource");
3269 } 3270 }
3270 throw new AnalysisException( 3271 throw new AnalysisException(
3271 "Failed to find the AST node for the variable " 3272 "Failed to find the AST node for the variable "
3272 "${variable.displayName} in $variableSource"); 3273 "${variable.displayName} at $offset in $variableSource");
3273 } 3274 }
3274 VariableDeclaration declaration = 3275 VariableDeclaration declaration =
3275 node.getAncestor((AstNode ancestor) => ancestor is VariableDeclaration); 3276 node.getAncestor((AstNode ancestor) => ancestor is VariableDeclaration);
3276 if (declaration == null || declaration.name != node) { 3277 if (declaration == null || declaration.name != node) {
3277 Source variableSource = variable.source; 3278 Source variableSource = variable.source;
3278 Source unitSource = unit.element.source; 3279 Source unitSource = unit.element.source;
3279 if (variableSource != unitSource) { 3280 if (variableSource != unitSource) {
3281 if (declaration == null) {
3282 throw new AnalysisException(
3283 "Failed to find the declaration of the variable "
3284 "${variable.displayName} at $offset in $variableSource "
3285 "because the node was not in a variable declaration "
3286 "possibly because we were looking in $unitSource");
3287 }
3280 throw new AnalysisException( 3288 throw new AnalysisException(
3281 "Failed to find the declaration of the variable " 3289 "Failed to find the declaration of the variable "
3282 "${variable.displayName} in $variableSource" 3290 "${variable.displayName} at $offset in $variableSource "
3283 "because we were looking in $unitSource"); 3291 "because we were looking in $unitSource");
3284 } 3292 }
3293 if (declaration == null) {
3294 throw new AnalysisException(
3295 "Failed to find the declaration of the variable "
3296 "${variable.displayName} at $offset in $variableSource "
3297 "because the node was not in a variable declaration");
3298 }
3285 throw new AnalysisException( 3299 throw new AnalysisException(
3286 "Failed to find the declaration of the variable " 3300 "Failed to find the declaration of the variable "
3287 "${variable.displayName} in $variableSource"); 3301 "${variable.displayName} at $offset in $variableSource "
3302 "because the node was not the name in a variable declaration");
3288 } 3303 }
3289 return declaration; 3304 return declaration;
3290 } 3305 }
3291 } 3306 }
3292 3307
3293 /** 3308 /**
3294 * A task that ensures that all of the inferable static variables in a 3309 * A task that ensures that all of the inferable static variables in a
3295 * compilation unit have had their type inferred. 3310 * compilation unit have had their type inferred.
3296 */ 3311 */
3297 class InferStaticVariableTypesInUnitTask extends SourceBasedAnalysisTask { 3312 class InferStaticVariableTypesInUnitTask extends SourceBasedAnalysisTask {
(...skipping 2652 matching lines...) Expand 10 before | Expand all | Expand 10 after
5950 5965
5951 @override 5966 @override
5952 bool moveNext() { 5967 bool moveNext() {
5953 if (_newSources.isEmpty) { 5968 if (_newSources.isEmpty) {
5954 return false; 5969 return false;
5955 } 5970 }
5956 currentTarget = _newSources.removeLast(); 5971 currentTarget = _newSources.removeLast();
5957 return true; 5972 return true;
5958 } 5973 }
5959 } 5974 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698