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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/element.dart ('k') | 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 11a704df7352bf0d201c622b9c5e6e520c47657c..1ac82ab1816c431084a8782693fcf5dbcaffde25 100644
--- a/pkg/analyzer/lib/src/task/dart.dart
+++ b/pkg/analyzer/lib/src/task/dart.dart
@@ -2952,12 +2952,33 @@ abstract class InferStaticVariableTask extends ConstantEvaluationAnalysisTask {
VariableDeclaration getDeclaration(CompilationUnit unit) {
VariableElement variable = target;
AstNode node = new NodeLocator2(variable.nameOffset).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 "
+ "because we were looking in $unitSource");
+ }
+ throw new AnalysisException(
+ "Failed to find the AST node for the variable "
+ "${variable.displayName} in $variableSource");
+ }
VariableDeclaration declaration =
node.getAncestor((AstNode ancestor) => ancestor is VariableDeclaration);
if (declaration == null || declaration.name != node) {
+ Source variableSource = variable.source;
+ Source unitSource = unit.element.source;
+ if (variableSource != unitSource) {
+ throw new AnalysisException(
+ "Failed to find the declaration of the variable "
+ "${variable.displayName} in $variableSource"
+ "because we were looking in $unitSource");
+ }
throw new AnalysisException(
"Failed to find the declaration of the variable "
- "${variable.displayName} in ${variable.source}");
+ "${variable.displayName} in $variableSource");
}
return declaration;
}
@@ -3911,6 +3932,15 @@ class PropagateVariableTypeTask extends InferStaticVariableTask {
*/
static Map<String, TaskInput> buildInputs(AnalysisTarget target) {
VariableElement variable = target;
+ if (variable.library == null) {
+ StringBuffer buffer = new StringBuffer();
+ buffer.write(
+ 'PropagateVariableTypeTask building inputs for a variable with no library. Variable name = "');
+ buffer.write(variable.name);
+ buffer.write('". Path = ');
+ (variable as ElementImpl).appendPathTo(buffer);
+ throw new AnalysisException(buffer.toString());
+ }
LibrarySpecificUnit unit =
new LibrarySpecificUnit(variable.library.source, variable.source);
return <String, TaskInput>{
@@ -5119,6 +5149,11 @@ class VerifyUnitTask extends SourceBasedAnalysisTask {
CompilationUnit unit = getRequiredInput(UNIT_INPUT);
CompilationUnitElement unitElement = unit.element;
LibraryElement libraryElement = unitElement.library;
+ if (libraryElement == null) {
+ throw new AnalysisException(
+ '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
+ '${unitElement.source.fullName}');
+ }
//
// Validate the directives.
//
« 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