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

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

Issue 421123005: Update 'search.getTypeHierarchy' to the latest spec. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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') | pkg/analysis_services/lib/constants.dart » ('j') | 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 b0a54f85173e2c39f797e15f9acec53b58934ed8..c338298bae992b8c02c1afe3d3ad0e1e56d24f1b 100644
--- a/pkg/analysis_server/test/search/type_hierarchy_test.dart
+++ b/pkg/analysis_server/test/search/type_hierarchy_test.dart
@@ -46,8 +46,8 @@ main() {
}
''');
return waitForTasksFinished().then((_) {
- return _getTypeHierarchy('main() {').then((json) {
- expect(json, isNull);
+ return _getTypeHierarchy('main() {').then((jsons) {
+ expect(jsons, isEmpty);
});
});
}
@@ -60,29 +60,30 @@ class B extends A {
}
''');
return waitForTasksFinished().then((_) {
- return _getTypeHierarchy('B extends A').then((json) {
- expect(json, {
- 'classElement': {
- 'kind': 'CLASS',
- 'name': 'B',
- 'location': anything,
- 'flags': 0
- },
- 'superclass': {
+ return _getTypeHierarchy('B extends A').then((jsons) {
+ expect(jsons, [{
'classElement': {
'kind': 'CLASS',
- 'name': 'A',
+ 'name': 'B',
'location': anything,
'flags': 0
},
+ 'superclass': 1,
'interfaces': [],
'mixins': [],
'subclasses': []
- },
- 'interfaces': [],
- 'mixins': [],
- 'subclasses': []
- });
+ }, {
+ 'classElement': {
+ 'kind': 'CLASS',
+ 'name': 'A',
+ 'location': anything,
+ 'flags': 0
+ },
+ 'superclass': 0,
+ 'interfaces': [],
+ 'mixins': [],
+ 'subclasses': [1]
+ }]);
});
});
}
@@ -95,8 +96,9 @@ class B extends A<int> {
}
''');
return waitForTasksFinished().then((_) {
- return _getTypeHierarchy('B extends').then((jsonB) {
- var jsonA = jsonB[SUPERCLASS];
+ return _getTypeHierarchy('B extends').then((jsons) {
+ var jsonB = jsons[0];
+ var jsonA = jsons[jsonB[SUPERCLASS]];
expect(jsonA[CLASS_ELEMENT][NAME], 'A');
expect(jsonB[CLASS_ELEMENT][NAME], 'B');
expect(jsonA[DISPLAY_NAME], 'A<int>');
@@ -114,14 +116,18 @@ class C extends B {
''');
return waitForTasksFinished().then((_) {
return _getTypeHierarchy('A {}').then((json) {
- expect(json, {
- 'classElement': {
- 'kind': 'CLASS',
- 'name': 'A',
- 'location': anything,
- 'flags': 0
- },
- 'superclass': {
+ expect(json, [{
+ 'classElement': {
+ 'kind': 'CLASS',
+ 'name': 'A',
+ 'location': anything,
+ 'flags': 0
+ },
+ 'superclass': 1,
+ 'interfaces': [],
+ 'mixins': [],
+ 'subclasses': [2]
+ }, {
'classElement': {
'kind': 'CLASS',
'name': 'Object',
@@ -131,31 +137,29 @@ class C extends B {
'interfaces': [],
'mixins': [],
'subclasses': []
- },
- 'interfaces': [],
- 'mixins': [],
- 'subclasses': [{
- 'classElement': {
- 'kind': 'CLASS',
- 'name': 'B',
- 'location': anything,
- 'flags': 0
- },
- 'interfaces': [],
- 'mixins': [],
- 'subclasses': [{
- 'classElement': {
- 'kind': 'CLASS',
- 'name': 'C',
- 'location': anything,
- 'flags': 0
- },
- 'interfaces': [],
- 'mixins': [],
- 'subclasses': []
- }]
- }]
- });
+ }, {
+ 'classElement': {
+ 'kind': 'CLASS',
+ 'name': 'B',
+ 'location': anything,
+ 'flags': 0
+ },
+ 'superclass': 0,
+ 'interfaces': [],
+ 'mixins': [],
+ 'subclasses': [3]
+ }, {
+ 'classElement': {
+ 'kind': 'CLASS',
+ 'name': 'C',
+ 'location': anything,
+ 'flags': 0
+ },
+ 'superclass': 2,
+ 'interfaces': [],
+ 'mixins': [],
+ 'subclasses': []
+ }]);
});
});
}
@@ -171,49 +175,50 @@ class C extends B {
''');
return waitForTasksFinished().then((_) {
return _getTypeHierarchy('B extends').then((json) {
- expect(json, {
- 'classElement': {
- 'kind': 'CLASS',
- 'name': 'B',
- 'location': anything,
- 'flags': 0
- },
- 'superclass': {
+ expect(json, [{
+ 'classElement': {
+ 'kind': 'CLASS',
+ 'name': 'B',
+ 'location': anything,
+ 'flags': 0
+ },
+ 'superclass': 1,
+ 'interfaces': [],
+ 'mixins': [],
+ 'subclasses': [3]
+ }, {
'classElement': {
'kind': 'CLASS',
'name': 'A',
'location': anything,
'flags': 0
},
- 'superclass': {
- 'classElement': {
- 'kind': 'CLASS',
- 'name': 'Object',
- 'location': anything,
- 'flags': 0
- },
- 'interfaces': [],
- 'mixins': [],
- 'subclasses': []
+ 'superclass': 2,
+ 'interfaces': [],
+ 'mixins': [],
+ 'subclasses': []
+ }, {
+ 'classElement': {
+ 'kind': 'CLASS',
+ 'name': 'Object',
+ 'location': anything,
+ 'flags': 0
+ },
+ 'interfaces': [],
+ 'mixins': [],
+ 'subclasses': []
+ }, {
+ 'classElement': {
+ 'kind': 'CLASS',
+ 'name': 'C',
+ 'location': anything,
+ 'flags': 0
},
+ 'superclass': 0,
'interfaces': [],
'mixins': [],
'subclasses': []
- },
- 'interfaces': [],
- 'mixins': [],
- 'subclasses': [{
- 'classElement': {
- 'kind': 'CLASS',
- 'name': 'C',
- 'location': anything,
- 'flags': 0
- },
- 'interfaces': [],
- 'mixins': [],
- 'subclasses': []
- }]
- });
+ }]);
});
});
}
@@ -229,50 +234,50 @@ class C extends B {
''');
return waitForTasksFinished().then((_) {
return _getTypeHierarchy('C extends').then((json) {
- expect(json, {
- 'classElement': {
- 'kind': 'CLASS',
- 'name': 'C',
- 'location': anything,
- 'flags': 0
- },
- 'superclass': {
+ expect(json, [{
+ 'classElement': {
+ 'kind': 'CLASS',
+ 'name': 'C',
+ 'location': anything,
+ 'flags': 0
+ },
+ 'superclass': 1,
+ 'interfaces': [],
+ 'mixins': [],
+ 'subclasses': []
+ }, {
'classElement': {
'kind': 'CLASS',
'name': 'B',
'location': anything,
'flags': 0
},
- 'superclass': {
- 'classElement': {
- 'kind': 'CLASS',
- 'name': 'A',
- 'location': anything,
- 'flags': 0
- },
- 'superclass': {
- 'classElement': {
- 'kind': 'CLASS',
- 'name': 'Object',
- 'location': anything,
- 'flags': 0
- },
- 'interfaces': [],
- 'mixins': [],
- 'subclasses': []
- },
- 'interfaces': [],
- 'mixins': [],
- 'subclasses': []
+ 'superclass': 2,
+ 'interfaces': [],
+ 'mixins': [],
+ 'subclasses': []
+ }, {
+ 'classElement': {
+ 'kind': 'CLASS',
+ 'name': 'A',
+ 'location': anything,
+ 'flags': 0
+ },
+ 'superclass': 3,
+ 'interfaces': [],
+ 'mixins': [],
+ 'subclasses': []
+ }, {
+ 'classElement': {
+ 'kind': 'CLASS',
+ 'name': 'Object',
+ 'location': anything,
+ 'flags': 0
},
'interfaces': [],
'mixins': [],
'subclasses': []
- },
- 'interfaces': [],
- 'mixins': [],
- 'subclasses': []
- });
+ }]);
});
});
}
@@ -288,14 +293,18 @@ class T implements MA, MB {
''');
return waitForTasksFinished().then((_) {
return _getTypeHierarchy('T implements').then((json) {
- expect(json, {
- 'classElement': {
- 'kind': 'CLASS',
- 'name': 'T',
- 'location': anything,
- 'flags': 0
- },
- 'superclass': {
+ expect(json, [{
+ 'classElement': {
+ 'kind': 'CLASS',
+ 'name': 'T',
+ 'location': anything,
+ 'flags': 0
+ },
+ 'superclass': 1,
+ 'interfaces': [2, 3],
+ 'mixins': [],
+ 'subclasses': []
+ }, {
'classElement': {
'kind': 'CLASS',
'name': 'Object',
@@ -305,31 +314,29 @@ class T implements MA, MB {
'interfaces': [],
'mixins': [],
'subclasses': []
- },
- 'interfaces': [{
- 'classElement': {
- 'kind': 'CLASS',
- 'name': 'MA',
- 'location': anything,
- 'flags': 0
- },
- 'interfaces': [],
- 'mixins': [],
- 'subclasses': []
- }, {
- 'classElement': {
- 'kind': 'CLASS',
- 'name': 'MB',
- 'location': anything,
- 'flags': 0
- },
- 'interfaces': [],
- 'mixins': [],
- 'subclasses': []
- }],
- 'mixins': [],
- 'subclasses': []
- });
+ }, {
+ 'classElement': {
+ 'kind': 'CLASS',
+ 'name': 'MA',
+ 'location': anything,
+ 'flags': 0
+ },
+ 'superclass': 1,
+ 'interfaces': [],
+ 'mixins': [],
+ 'subclasses': []
+ }, {
+ 'classElement': {
+ 'kind': 'CLASS',
+ 'name': 'MB',
+ 'location': anything,
+ 'flags': 0
+ },
+ 'superclass': 1,
+ 'interfaces': [],
+ 'mixins': [],
+ 'subclasses': []
+ }]);
});
});
}
@@ -345,14 +352,18 @@ class T extends Object with MA, MB {
''');
return waitForTasksFinished().then((_) {
return _getTypeHierarchy('T extends Object').then((json) {
- expect(json, {
- 'classElement': {
- 'kind': 'CLASS',
- 'name': 'T',
- 'location': anything,
- 'flags': 0
- },
- 'superclass': {
+ expect(json, [{
+ 'classElement': {
+ 'kind': 'CLASS',
+ 'name': 'T',
+ 'location': anything,
+ 'flags': 0
+ },
+ 'superclass': 1,
+ 'interfaces': [],
+ 'mixins': [2, 3],
+ 'subclasses': []
+ }, {
'classElement': {
'kind': 'CLASS',
'name': 'Object',
@@ -362,31 +373,29 @@ class T extends Object with MA, MB {
'interfaces': [],
'mixins': [],
'subclasses': []
- },
- 'interfaces': [],
- 'mixins': [{
- 'classElement': {
- 'kind': 'CLASS',
- 'name': 'MA',
- 'location': anything,
- 'flags': 0
- },
- 'interfaces': [],
- 'mixins': [],
- 'subclasses': []
- }, {
- 'classElement': {
- 'kind': 'CLASS',
- 'name': 'MB',
- 'location': anything,
- 'flags': 0
- },
- 'interfaces': [],
- 'mixins': [],
- 'subclasses': []
- }],
- 'subclasses': []
- });
+ }, {
+ 'classElement': {
+ 'kind': 'CLASS',
+ 'name': 'MA',
+ 'location': anything,
+ 'flags': 0
+ },
+ 'superclass': 1,
+ 'interfaces': [],
+ 'mixins': [],
+ 'subclasses': []
+ }, {
+ 'classElement': {
+ 'kind': 'CLASS',
+ 'name': 'MB',
+ 'location': anything,
+ 'flags': 0
+ },
+ 'superclass': 1,
+ 'interfaces': [],
+ 'mixins': [],
+ 'subclasses': []
+ }]);
});
});
}
@@ -406,10 +415,11 @@ class D extends C {
}
''');
return waitForTasksFinished().then((_) {
- return _getTypeHierarchy('test => null; // in B').then((jsonB) {
- var jsonA = jsonB[SUPERCLASS];
- var jsonC = jsonB[SUBCLASSES][0];
- var jsonD = jsonC[SUBCLASSES][0];
+ return _getTypeHierarchy('test => null; // in B').then((jsons) {
+ Map jsonB = jsons[0];
+ Map jsonA = jsons[jsonB[SUPERCLASS]];
+ Map jsonC = jsons[jsonB[SUBCLASSES][0]];
+ Map jsonD = jsons[jsonC[SUBCLASSES][0]];
expect(jsonA[CLASS_ELEMENT][NAME], 'A');
expect(jsonB[CLASS_ELEMENT][NAME], 'B');
expect(jsonC[CLASS_ELEMENT][NAME], 'C');
@@ -443,10 +453,11 @@ class D extends C {
}
''');
return waitForTasksFinished().then((_) {
- return _getTypeHierarchy('test() {} // in B').then((jsonB) {
- var jsonA = jsonB[SUPERCLASS];
- var jsonC = jsonB[SUBCLASSES][0];
- var jsonD = jsonC[SUBCLASSES][0];
+ return _getTypeHierarchy('test() {} // in B').then((jsons) {
+ var jsonB = jsons[0];
+ var jsonA = jsons[jsonB[SUPERCLASS]];
+ var jsonC = jsons[jsonB[SUBCLASSES][0]];
+ var jsonD = jsons[jsonC[SUBCLASSES][0]];
expect(jsonA[CLASS_ELEMENT][NAME], 'A');
expect(jsonB[CLASS_ELEMENT][NAME], 'B');
expect(jsonC[CLASS_ELEMENT][NAME], 'C');
@@ -480,10 +491,11 @@ class D extends C {
}
''');
return waitForTasksFinished().then((_) {
- return _getTypeHierarchy('==(x) => null; // in B').then((jsonB) {
- var jsonA = jsonB[SUPERCLASS];
- var jsonC = jsonB[SUBCLASSES][0];
- var jsonD = jsonC[SUBCLASSES][0];
+ return _getTypeHierarchy('==(x) => null; // in B').then((jsons) {
+ var jsonB = jsons[0];
+ var jsonA = jsons[jsonB[SUPERCLASS]];
+ var jsonC = jsons[jsonB[SUBCLASSES][0]];
+ var jsonD = jsons[jsonC[SUBCLASSES][0]];
expect(jsonA[CLASS_ELEMENT][NAME], 'A');
expect(jsonB[CLASS_ELEMENT][NAME], 'B');
expect(jsonC[CLASS_ELEMENT][NAME], 'C');
@@ -517,10 +529,11 @@ class D extends C {
}
''');
return waitForTasksFinished().then((_) {
- return _getTypeHierarchy('test(x) {} // in B').then((jsonB) {
- var jsonA = jsonB[SUPERCLASS];
- var jsonC = jsonB[SUBCLASSES][0];
- var jsonD = jsonC[SUBCLASSES][0];
+ return _getTypeHierarchy('test(x) {} // in B').then((jsons) {
+ var jsonB = jsons[0];
+ var jsonA = jsons[jsonB[SUPERCLASS]];
+ var jsonC = jsons[jsonB[SUBCLASSES][0]];
+ var jsonD = jsons[jsonC[SUBCLASSES][0]];
expect(jsonA[CLASS_ELEMENT][NAME], 'A');
expect(jsonB[CLASS_ELEMENT][NAME], 'B');
expect(jsonC[CLASS_ELEMENT][NAME], 'C');
@@ -547,10 +560,10 @@ class D extends C {
return request;
}
- Future<Map<String, Object>> _getTypeHierarchy(String search) {
+ Future<List<Map<String, Object>>> _getTypeHierarchy(String search) {
Request request = _createGetTypeHierarchyRequest(search);
return serverChannel.sendRequest(request).then((Response response) {
- return response.getResult(HIERARCHY) as Map<String, Object>;
+ return response.getResult(HIERARCHY_ITEMS) as List<Map<String, Object>>;
});
}
}
« no previous file with comments | « pkg/analysis_server/lib/src/search/type_hierarchy.dart ('k') | pkg/analysis_services/lib/constants.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698