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

Unified Diff: pkg/analyzer/test/src/task/incremental_element_builder_test.dart

Issue 2158973003: Fixes for updating synthetic element offsets. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 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/task/incremental_element_builder.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/task/incremental_element_builder_test.dart
diff --git a/pkg/analyzer/test/src/task/incremental_element_builder_test.dart b/pkg/analyzer/test/src/task/incremental_element_builder_test.dart
index 0e675176fb38a09094551b38b007a4846cf94c69..9a69798bf55497528af00479b136af5be1817bda 100644
--- a/pkg/analyzer/test/src/task/incremental_element_builder_test.dart
+++ b/pkg/analyzer/test/src/task/incremental_element_builder_test.dart
@@ -6,6 +6,7 @@ library analyzer.test.src.task.incremental_element_builder_test;
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/element/element.dart';
+import 'package:analyzer/dart/element/visitor.dart';
import 'package:analyzer/src/dart/ast/utilities.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/generated/engine.dart';
@@ -1775,6 +1776,33 @@ class A {}
''');
}
+ test_update_element_implicitAccessors_classField() {
+ _buildOldUnit(r'''
+// 0
+class A {
+ var F = 0;
+}
+''');
+ _materializeLazyElements(unitElement);
+ _buildNewUnit(r'''
+// 012
+class A {
+ var F = 0;
+}
+''');
+ }
+
+ test_update_element_implicitAccessors_topLevelVariable() {
+ _buildOldUnit(r'''
+var A = 0;
+var B = 1;
+''');
+ _materializeLazyElements(unitElement);
+ _buildNewUnit(r'''
+var B = 1;
+''');
+ }
+
test_update_rewrittenConstructorName() {
_buildOldUnit(r'''
class A {
@@ -1844,6 +1872,10 @@ main() {
expect(unitElement, isNotNull);
}
+ void _materializeLazyElements(CompilationUnitElement unitElement) {
+ unitElement.accept(new _MaterializeLazyElementsVisitor());
+ }
+
void _verifyNoClassDeltaForTheLast(String oldCode, String newCode) {
_buildOldUnit(oldCode);
List<CompilationUnitMember> oldMembers = oldUnit.declarations.toList();
@@ -1862,6 +1894,8 @@ main() {
* Compares tokens and ASTs, and built elements of declared identifiers.
*/
class _BuiltElementsValidator extends AstComparator {
+ final Set visited = new Set.identity();
+
@override
bool isEqualNodes(AstNode expected, AstNode actual) {
// Elements of nodes which are children of ClassDeclaration(s) must be
@@ -1923,13 +1957,17 @@ class _BuiltElementsValidator extends AstComparator {
expect(actual.inDeclarationContext(), isTrue);
Element expectedElement = expected.staticElement;
Element actualElement = actual.staticElement;
- _verifyElement(expectedElement, actualElement, 'staticElement');
+ _verifyElement(
+ expectedElement, actualElement, 'staticElement ($expectedElement)');
}
}
return true;
}
void _verifyElement(Element expected, Element actual, String desc) {
+ if (!visited.add(expected)) {
+ return;
+ }
if (expected == null && actual == null) {
return;
}
@@ -1959,6 +1997,23 @@ class _BuiltElementsValidator extends AstComparator {
'${expectedEnclosing.name}.$desc');
}
}
+ // Compare implicit accessors.
+ if (expected is PropertyInducingElement &&
+ actual is PropertyInducingElement &&
+ !expected.isSynthetic) {
+ _verifyElement(expected.getter, actual.getter, '$desc getter');
+ _verifyElement(expected.setter, actual.setter, '$desc setter');
+ }
+ // Compare parameters.
+ if (expected is ExecutableElement && actual is ExecutableElement) {
+ List<ParameterElement> actualParameters = actual.parameters;
+ List<ParameterElement> expectedParameters = expected.parameters;
+ expect(actualParameters, hasLength(expectedParameters.length));
+ for (int i = 0; i < expectedParameters.length; i++) {
+ _verifyElement(
+ expectedParameters[i], actualParameters[i], '$desc parameters[$i]');
+ }
+ }
}
void _verifyEqual(String name, expected, actual) {
@@ -2000,3 +2055,11 @@ class _ClassDeltaHelper {
unit.declarations.singleWhere((unitMember) =>
unitMember is ClassDeclaration && unitMember.name.name == name);
}
+
+class _MaterializeLazyElementsVisitor extends GeneralizingElementVisitor {
+ @override
+ visitExecutableElement(ExecutableElement element) {
+ element.parameters;
+ super.visitExecutableElement(element);
+ }
+}
« no previous file with comments | « pkg/analyzer/lib/src/task/incremental_element_builder.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698