| 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'; | |
| 9 import 'package:analysis_server/src/services/search/search_engine.dart'; | 8 import 'package:analysis_server/src/services/search/search_engine.dart'; |
| 10 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 11 | 10 |
| 12 class ImplementedComputer { | 11 class ImplementedComputer { |
| 13 final SearchEngine searchEngine; | 12 final SearchEngine searchEngine; |
| 14 final CompilationUnitElement unitElement; | 13 final CompilationUnitElement unitElement; |
| 15 | 14 |
| 16 List<protocol.ImplementedClass> classes = <protocol.ImplementedClass>[]; | 15 List<protocol.ImplementedClass> classes = <protocol.ImplementedClass>[]; |
| 17 List<protocol.ImplementedMember> members = <protocol.ImplementedMember>[]; | 16 List<protocol.ImplementedMember> members = <protocol.ImplementedMember>[]; |
| 18 | 17 |
| 19 Set<ClassElement> subtypes; | 18 Set<ClassElement> subtypes; |
| 20 | 19 |
| 21 ImplementedComputer(this.searchEngine, this.unitElement); | 20 ImplementedComputer(this.searchEngine, this.unitElement); |
| 22 | 21 |
| 23 compute() async { | 22 compute() async { |
| 24 for (ClassElement type in unitElement.types) { | 23 for (ClassElement type in unitElement.types) { |
| 25 // always include Object and its members | 24 // always include Object and its members |
| 26 if (type.supertype == null) { | 25 if (type.supertype == null) { |
| 27 _addImplementedClass(type); | 26 _addImplementedClass(type); |
| 28 type.accessors.forEach(_addImplementedMember); | 27 type.accessors.forEach(_addImplementedMember); |
| 29 type.fields.forEach(_addImplementedMember); | 28 type.fields.forEach(_addImplementedMember); |
| 30 type.methods.forEach(_addImplementedMember); | 29 type.methods.forEach(_addImplementedMember); |
| 31 continue; | 30 continue; |
| 32 } | 31 } |
| 33 // analyze ancestors | 32 // analyze ancestors |
| 34 subtypes = await getSubClasses(searchEngine, type); | 33 subtypes = await searchEngine.searchAllSubtypes(type); |
| 35 if (subtypes.isNotEmpty) { | 34 if (subtypes.isNotEmpty) { |
| 36 _addImplementedClass(type); | 35 _addImplementedClass(type); |
| 37 } | 36 } |
| 38 type.accessors.forEach(_addMemberIfImplemented); | 37 type.accessors.forEach(_addMemberIfImplemented); |
| 39 type.fields.forEach(_addMemberIfImplemented); | 38 type.fields.forEach(_addMemberIfImplemented); |
| 40 type.methods.forEach(_addMemberIfImplemented); | 39 type.methods.forEach(_addMemberIfImplemented); |
| 41 } | 40 } |
| 42 } | 41 } |
| 43 | 42 |
| 44 void _addImplementedClass(ClassElement type) { | 43 void _addImplementedClass(ClassElement type) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 */ | 83 */ |
| 85 static bool _isStatic(Element element) { | 84 static bool _isStatic(Element element) { |
| 86 if (element is ExecutableElement) { | 85 if (element is ExecutableElement) { |
| 87 return element.isStatic; | 86 return element.isStatic; |
| 88 } else if (element is PropertyInducingElement) { | 87 } else if (element is PropertyInducingElement) { |
| 89 return element.isStatic; | 88 return element.isStatic; |
| 90 } | 89 } |
| 91 return false; | 90 return false; |
| 92 } | 91 } |
| 93 } | 92 } |
| OLD | NEW |