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

Unified Diff: pkg/analysis_server/test/search/type_hierarchy_test.dart

Issue 962743003: Issue 22575. Fix for type hierarchy from FieldElement. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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/analysis_server/lib/src/search/type_hierarchy.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/test/search/type_hierarchy_test.dart
diff --git a/pkg/analysis_server/test/search/type_hierarchy_test.dart b/pkg/analysis_server/test/search/type_hierarchy_test.dart
index 7f6429b8038986840eda5f7b0ced1ab11c38b130..23265313fa672365151b1be718d9137b2097eb42 100644
--- a/pkg/analysis_server/test/search/type_hierarchy_test.dart
+++ b/pkg/analysis_server/test/search/type_hierarchy_test.dart
@@ -412,6 +412,138 @@ class T extends Object with MA, MB {
}]);
}
+ test_fromField_toMixinGetter() async {
+ addTestFile('''
+abstract class A {
+ var test = 1;
+}
+class Mixin {
+ get test => 2;
+}
+class B extends A with Mixin {}
+''');
+ List<TypeHierarchyItem> items = await _getTypeHierarchy('test = 1;');
+ var itemA = items.firstWhere((e) => e.classElement.name == 'A');
+ var itemB = items.firstWhere((e) => e.classElement.name == 'B');
+ Element memberA = itemA.memberElement;
+ Element memberB = itemB.memberElement;
+ expect(memberA, isNotNull);
+ expect(memberB, isNotNull);
+ expect(memberA.location.offset, findOffset('test = 1;'));
+ expect(memberB.location.offset, findOffset('test => 2;'));
+ }
+
+ test_fromField_toMixinSetter() async {
+ addTestFile('''
+abstract class A {
+ var test = 1;
+}
+class Mixin {
+ set test(m) {}
+}
+class B extends A with Mixin {}
+''');
+ List<TypeHierarchyItem> items = await _getTypeHierarchy('test = 1;');
+ var itemA = items.firstWhere((e) => e.classElement.name == 'A');
+ var itemB = items.firstWhere((e) => e.classElement.name == 'B');
+ Element memberA = itemA.memberElement;
+ Element memberB = itemB.memberElement;
+ expect(memberA, isNotNull);
+ expect(memberB, isNotNull);
+ expect(memberA.location.offset, findOffset('test = 1;'));
+ expect(memberB.location.offset, findOffset('test(m) {}'));
+ }
+
+ test_member_fromField_toField() async {
+ addTestFile('''
+class A {
+ var test = 1;
+}
+class B extends A {
+ var test = 2;
+}
+''');
+ List<TypeHierarchyItem> items = await _getTypeHierarchy('test = 2;');
+ TypeHierarchyItem itemB = items[0];
+ TypeHierarchyItem itemA = items[itemB.superclass];
+ expect(itemA.classElement.name, 'A');
+ expect(itemB.classElement.name, 'B');
+ expect(itemA.memberElement.location.offset, findOffset('test = 1;'));
+ expect(itemB.memberElement.location.offset, findOffset('test = 2;'));
+ }
+
+ test_member_fromField_toGetter() async {
+ addTestFile('''
+class A {
+ get test => 1;
+}
+class B extends A {
+ var test = 2;
+}
+''');
+ List<TypeHierarchyItem> items = await _getTypeHierarchy('test = 2;');
+ TypeHierarchyItem itemB = items[0];
+ TypeHierarchyItem itemA = items[itemB.superclass];
+ expect(itemA.classElement.name, 'A');
+ expect(itemB.classElement.name, 'B');
+ expect(itemA.memberElement.location.offset, findOffset('test => 1'));
+ expect(itemB.memberElement.location.offset, findOffset('test = 2;'));
+ }
+
+ test_member_fromField_toSetter() async {
+ addTestFile('''
+class A {
+ set test(a) {}
+}
+class B extends A {
+ var test = 2;
+}
+''');
+ List<TypeHierarchyItem> items = await _getTypeHierarchy('test = 2;');
+ TypeHierarchyItem itemB = items[0];
+ TypeHierarchyItem itemA = items[itemB.superclass];
+ expect(itemA.classElement.name, 'A');
+ expect(itemB.classElement.name, 'B');
+ expect(itemA.memberElement.location.offset, findOffset('test(a) {}'));
+ expect(itemB.memberElement.location.offset, findOffset('test = 2;'));
+ }
+
+ test_member_fromFinalField_toGetter() async {
+ addTestFile('''
+class A {
+ get test => 1;
+}
+class B extends A {
+ final test = 2;
+}
+''');
+ List<TypeHierarchyItem> items = await _getTypeHierarchy('test = 2;');
+ TypeHierarchyItem itemB = items[0];
+ TypeHierarchyItem itemA = items[itemB.superclass];
+ expect(itemA.classElement.name, 'A');
+ expect(itemB.classElement.name, 'B');
+ expect(itemA.memberElement.location.offset, findOffset('test => 1;'));
+ expect(itemB.memberElement.location.offset, findOffset('test = 2;'));
+ }
+
+ test_member_fromFinalField_toSetter() async {
+ addTestFile('''
+class A {
+ set test(x) {}
+}
+class B extends A {
+ final test = 2;
+}
+''');
+ List<TypeHierarchyItem> items = await _getTypeHierarchy('test = 2;');
+ TypeHierarchyItem itemB = items[0];
+ TypeHierarchyItem itemA = items[itemB.superclass];
+ expect(itemA.classElement.name, 'A');
+ expect(itemB.classElement.name, 'B');
+ expect(itemA.memberElement, isNull);
+ expect(itemB.memberElement.location.offset, findOffset('test = 2;'));
+ }
+
test_member_getter() async {
addTestFile('''
class A {
« no previous file with comments | « pkg/analysis_server/lib/src/search/type_hierarchy.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698