| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library domains.analysis.implemented_dart; | 5 library domains.analysis.implemented_dart; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/protocol_server.dart' as protocol; | 7 import 'package:analysis_server/src/protocol_server.dart' as protocol; |
| 8 import 'package:analysis_server/src/services/search/hierarchy.dart'; | 8 import 'package:analysis_server/src/services/search/hierarchy.dart'; |
| 9 import 'package:analysis_server/src/services/search/search_engine.dart'; | 9 import 'package:analysis_server/src/services/search/search_engine.dart'; |
| 10 import 'package:analyzer/src/generated/element.dart'; | 10 import 'package:analyzer/src/generated/element.dart'; |
| 11 | 11 |
| 12 class ImplementedComputer { | 12 class ImplementedComputer { |
| 13 final SearchEngine searchEngine; | 13 final SearchEngine searchEngine; |
| 14 final CompilationUnitElement unitElement; | 14 final CompilationUnitElement unitElement; |
| 15 | 15 |
| 16 List<protocol.ImplementedClass> classes = <protocol.ImplementedClass>[]; | 16 List<protocol.ImplementedClass> classes = <protocol.ImplementedClass>[]; |
| 17 List<protocol.ImplementedMember> members = <protocol.ImplementedMember>[]; | 17 List<protocol.ImplementedMember> members = <protocol.ImplementedMember>[]; |
| 18 | 18 |
| 19 Set<ClassElement> subtypes; | 19 Set<ClassElement> subtypes; |
| 20 | 20 |
| 21 ImplementedComputer(this.searchEngine, this.unitElement); | 21 ImplementedComputer(this.searchEngine, this.unitElement); |
| 22 | 22 |
| 23 compute() async { | 23 compute() async { |
| 24 for (ClassElement type in unitElement.types) { | 24 for (ClassElement type in unitElement.types) { |
| 25 // always include Object and its members |
| 26 if (type.supertype == null) { |
| 27 _addImplementedClass(type); |
| 28 type.accessors.forEach(_addImplementedMember); |
| 29 type.fields.forEach(_addImplementedMember); |
| 30 type.methods.forEach(_addImplementedMember); |
| 31 continue; |
| 32 } |
| 33 // analyze ancestors |
| 25 subtypes = await getSubClasses(searchEngine, type); | 34 subtypes = await getSubClasses(searchEngine, type); |
| 26 if (subtypes.isNotEmpty) { | 35 if (subtypes.isNotEmpty) { |
| 27 _addImplementedClass(type); | 36 _addImplementedClass(type); |
| 28 } | 37 } |
| 29 type.accessors.forEach(_addMemberIfImplemented); | 38 type.accessors.forEach(_addMemberIfImplemented); |
| 30 type.fields.forEach(_addMemberIfImplemented); | 39 type.fields.forEach(_addMemberIfImplemented); |
| 31 type.methods.forEach(_addMemberIfImplemented); | 40 type.methods.forEach(_addMemberIfImplemented); |
| 32 } | 41 } |
| 33 } | 42 } |
| 34 | 43 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 58 if (subtype.getMethod(name) != null) { | 67 if (subtype.getMethod(name) != null) { |
| 59 return true; | 68 return true; |
| 60 } | 69 } |
| 61 if (subtype.getField(name) != null) { | 70 if (subtype.getField(name) != null) { |
| 62 return true; | 71 return true; |
| 63 } | 72 } |
| 64 } | 73 } |
| 65 return false; | 74 return false; |
| 66 } | 75 } |
| 67 } | 76 } |
| OLD | NEW |