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

Unified Diff: pkg/analysis_server/lib/src/search/type_hierarchy.dart

Issue 956023003: Issue 21804. Type hierarchy should show overrides in mixins. (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 | « no previous file | pkg/analysis_server/test/search/type_hierarchy_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/search/type_hierarchy.dart
diff --git a/pkg/analysis_server/lib/src/search/type_hierarchy.dart b/pkg/analysis_server/lib/src/search/type_hierarchy.dart
index c2f53230cd25e516765a6af33951e577a3b85a78..009325db95d9dbd61c39616cf5d2da9df12423b0 100644
--- a/pkg/analysis_server/lib/src/search/type_hierarchy.dart
+++ b/pkg/analysis_server/lib/src/search/type_hierarchy.dart
@@ -19,6 +19,7 @@ import 'package:analyzer/src/generated/element.dart';
class TypeHierarchyComputer {
final SearchEngine _searchEngine;
+ LibraryElement _pivotLibrary;
ElementKind _pivotKind;
String _pivotName;
@@ -33,6 +34,7 @@ class TypeHierarchyComputer {
* Returns the computed type hierarchy, maybe `null`.
*/
Future<List<TypeHierarchyItem>> compute(Element element) {
+ _pivotLibrary = element.library;
_pivotKind = element.kind;
_pivotName = element.name;
if (element is ExecutableElement &&
@@ -136,16 +138,36 @@ class TypeHierarchyComputer {
return itemId;
}
- ExecutableElement _findMemberElement(ClassElement classElement) {
+ ExecutableElement _findMemberElement(ClassElement clazz) {
+ ExecutableElement result;
+ // try to find in the class itself
if (_pivotKind == ElementKind.METHOD) {
- return classElement.getMethod(_pivotName);
+ result = clazz.getMethod(_pivotName);
+ } else if (_pivotKind == ElementKind.GETTER) {
+ result = clazz.getGetter(_pivotName);
+ } else if (_pivotKind == ElementKind.SETTER) {
+ result = clazz.getSetter(_pivotName);
}
- if (_pivotKind == ElementKind.GETTER) {
- return classElement.getGetter(_pivotName);
+ if (result != null) {
+ return result;
}
- if (_pivotKind == ElementKind.SETTER) {
- return classElement.getSetter(_pivotName);
+ // try to find in the class mixin
+ for (InterfaceType mixin in clazz.mixins.reversed) {
+ ClassElement mixinElement = mixin.element;
+ if (_pivotKind == ElementKind.METHOD) {
+ result = mixinElement.lookUpMethod(_pivotName, _pivotLibrary);
+ }
+ if (_pivotKind == ElementKind.GETTER) {
+ result = mixinElement.lookUpGetter(_pivotName, _pivotLibrary);
+ }
+ if (_pivotKind == ElementKind.SETTER) {
+ result = mixinElement.lookUpSetter(_pivotName, _pivotLibrary);
+ }
+ if (result != null) {
+ return result;
+ }
}
+ // not found
return null;
}
}
« no previous file with comments | « no previous file | pkg/analysis_server/test/search/type_hierarchy_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698