Index: pkg/analyzer/lib/src/generated/engine.dart |
diff --git a/pkg/analyzer/lib/src/generated/engine.dart b/pkg/analyzer/lib/src/generated/engine.dart |
index 5eccbf7ee5b33c7932856815551ae5e221f02f47..c0e548ccf0bee04c3cb17c8ae7256f1746cd34dd 100644 |
--- a/pkg/analyzer/lib/src/generated/engine.dart |
+++ b/pkg/analyzer/lib/src/generated/engine.dart |
@@ -10309,6 +10309,12 @@ class RecursiveXmlVisitor_ResolveHtmlTask_internalPerform |
* used to visit that structure. |
*/ |
class ResolutionEraser extends GeneralizingAstVisitor<Object> { |
+ /** |
+ * A flag indicating whether the elements associated with declarations should |
+ * be erased. |
+ */ |
+ bool eraseDeclarations = true; |
scheglov
2015/09/10 20:35:38
Why not to make it final and initialize in the con
Brian Wilkerson
2015/09/10 21:00:31
I debated about both approaches. This has the adva
|
+ |
@override |
Object visitAssignmentExpression(AssignmentExpression node) { |
node.staticElement = null; |
@@ -10331,13 +10337,17 @@ class ResolutionEraser extends GeneralizingAstVisitor<Object> { |
@override |
Object visitCompilationUnit(CompilationUnit node) { |
- node.element = null; |
+ if (eraseDeclarations) { |
+ node.element = null; |
+ } |
return super.visitCompilationUnit(node); |
} |
@override |
Object visitConstructorDeclaration(ConstructorDeclaration node) { |
- node.element = null; |
+ if (eraseDeclarations) { |
+ node.element = null; |
+ } |
return super.visitConstructorDeclaration(node); |
} |
@@ -10355,7 +10365,9 @@ class ResolutionEraser extends GeneralizingAstVisitor<Object> { |
@override |
Object visitDirective(Directive node) { |
- node.element = null; |
+ if (eraseDeclarations) { |
+ node.element = null; |
+ } |
return super.visitDirective(node); |
} |
@@ -10368,7 +10380,9 @@ class ResolutionEraser extends GeneralizingAstVisitor<Object> { |
@override |
Object visitFunctionExpression(FunctionExpression node) { |
- node.element = null; |
+ if (eraseDeclarations) { |
+ node.element = null; |
+ } |
return super.visitFunctionExpression(node); |
} |
@@ -10415,7 +10429,9 @@ class ResolutionEraser extends GeneralizingAstVisitor<Object> { |
@override |
Object visitSimpleIdentifier(SimpleIdentifier node) { |
- node.staticElement = null; |
+ if (eraseDeclarations || !node.inDeclarationContext()) { |
+ node.staticElement = null; |
+ } |
node.propagatedElement = null; |
return super.visitSimpleIdentifier(node); |
} |
@@ -10429,8 +10445,10 @@ class ResolutionEraser extends GeneralizingAstVisitor<Object> { |
/** |
* Remove any resolution information from the given AST structure. |
*/ |
- static void erase(AstNode node) { |
- node.accept(new ResolutionEraser()); |
+ static void erase(AstNode node, {bool eraseDeclarations: true}) { |
+ ResolutionEraser eraser = new ResolutionEraser(); |
+ eraser.eraseDeclarations = eraseDeclarations; |
+ node.accept(eraser); |
} |
} |