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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | 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 ea97f7984a29ead1944bee6662bf382c3b6356af..c898feb81ab3f63da05b044a77bbc2989424a7ba 100644
--- a/pkg/analyzer/lib/src/task/dart.dart
+++ b/pkg/analyzer/lib/src/task/dart.dart
@@ -3257,19 +3257,20 @@ abstract class InferStaticVariableTask extends ConstantEvaluationAnalysisTask {
*/
VariableDeclaration getDeclaration(CompilationUnit unit) {
VariableElement variable = target;
- AstNode node = new NodeLocator2(variable.nameOffset).searchWithin(unit);
+ int offset = variable.nameOffset;
+ AstNode node = new NodeLocator2(offset).searchWithin(unit);
if (node == null) {
Source variableSource = variable.source;
Source unitSource = unit.element.source;
if (variableSource != unitSource) {
throw new AnalysisException(
"Failed to find the AST node for the variable "
- "${variable.displayName} in $variableSource "
+ "${variable.displayName} at $offset in $variableSource "
"because we were looking in $unitSource");
}
throw new AnalysisException(
"Failed to find the AST node for the variable "
- "${variable.displayName} in $variableSource");
+ "${variable.displayName} at $offset in $variableSource");
}
VariableDeclaration declaration =
node.getAncestor((AstNode ancestor) => ancestor is VariableDeclaration);
@@ -3277,14 +3278,28 @@ abstract class InferStaticVariableTask extends ConstantEvaluationAnalysisTask {
Source variableSource = variable.source;
Source unitSource = unit.element.source;
if (variableSource != unitSource) {
+ if (declaration == null) {
+ throw new AnalysisException(
+ "Failed to find the declaration of the variable "
+ "${variable.displayName} at $offset in $variableSource "
+ "because the node was not in a variable declaration "
+ "possibly because we were looking in $unitSource");
+ }
throw new AnalysisException(
"Failed to find the declaration of the variable "
- "${variable.displayName} in $variableSource"
+ "${variable.displayName} at $offset in $variableSource "
"because we were looking in $unitSource");
}
+ if (declaration == null) {
+ throw new AnalysisException(
+ "Failed to find the declaration of the variable "
+ "${variable.displayName} at $offset in $variableSource "
+ "because the node was not in a variable declaration");
+ }
throw new AnalysisException(
"Failed to find the declaration of the variable "
- "${variable.displayName} in $variableSource");
+ "${variable.displayName} at $offset in $variableSource "
+ "because the node was not the name in a variable declaration");
}
return declaration;
}
« 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