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

Side by Side Diff: pkg/analysis_server/lib/src/domains/analysis/implemented_dart.dart

Issue 2564913002: Implement SearchEngine.searchAllSubtypes() with the analysis driver. (Closed)
Patch Set: Created 4 years 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 unified diff | Download patch
OLDNEW
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698