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

Unified Diff: pkg/analyzer/test/src/context/context_test.dart

Issue 2485043004: Don't serialize elements of top-level function/constructor/method bodies. (Closed)
Patch Set: Created 4 years, 1 month 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
Index: pkg/analyzer/test/src/context/context_test.dart
diff --git a/pkg/analyzer/test/src/context/context_test.dart b/pkg/analyzer/test/src/context/context_test.dart
index 54f5619874e1328cac1eebb63ad5b619f892368e..13a5526e6f35aa564a4773087e0e15a4301b28ac 100644
--- a/pkg/analyzer/test/src/context/context_test.dart
+++ b/pkg/analyzer/test/src/context/context_test.dart
@@ -5395,8 +5395,7 @@ class _ElementComparer extends GeneralizingElementVisitor {
@override
void visitElement(Element element) {
Element previousElement = previousElements[element];
- bool expectIdentical = element is! LocalVariableElement;
- bool ok = expectIdentical
+ bool ok = _expectedIdentical(element)
? identical(previousElement, element)
: previousElement == element;
if (!ok) {
@@ -5414,6 +5413,23 @@ class _ElementComparer extends GeneralizingElementVisitor {
}
super.visitElement(element);
}
+
+ /**
+ * Return `true` if the given [element] should be the same as the previous
+ * element at the same position in the element model.
+ */
+ static bool _expectedIdentical(Element element) {
+ while (element != null) {
+ if (element is ConstructorElement ||
+ element is MethodElement ||
+ element is FunctionElement &&
+ element.enclosingElement is CompilationUnitElement) {
+ return false;
+ }
+ element = element.enclosingElement;
+ }
+ return true;
+ }
}
/**

Powered by Google App Engine
This is Rietveld 408576698