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

Side by Side Diff: pkg/analysis_server/lib/src/services/completion/dart/override_contributor.dart

Issue 1893313004: Remove references to and uses of MemberMap (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/error_verifier.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 services.completion.dart.override; 5 library services.completion.dart.override;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/protocol_server.dart' 9 import 'package:analysis_server/src/protocol_server.dart'
10 show CompletionSuggestion, CompletionSuggestionKind; 10 show CompletionSuggestion, CompletionSuggestionKind;
(...skipping 21 matching lines...) Expand all
32 } 32 }
33 ClassDeclaration classDecl = 33 ClassDeclaration classDecl =
34 targetId.getAncestor((p) => p is ClassDeclaration); 34 targetId.getAncestor((p) => p is ClassDeclaration);
35 if (classDecl == null) { 35 if (classDecl == null) {
36 return EMPTY_LIST; 36 return EMPTY_LIST;
37 } 37 }
38 38
39 // Generate a collection of inherited members 39 // Generate a collection of inherited members
40 ClassElement classElem = classDecl.element; 40 ClassElement classElem = classDecl.element;
41 InheritanceManager manager = new InheritanceManager(classElem.library); 41 InheritanceManager manager = new InheritanceManager(classElem.library);
42 MemberMap map = manager.getMapOfMembersInheritedFromInterfaces(classElem); 42 Map<String, ExecutableElement> map =
43 manager.getMembersInheritedFromInterfaces(classElem);
43 List<String> memberNames = _computeMemberNames(map, classElem); 44 List<String> memberNames = _computeMemberNames(map, classElem);
44 45
45 // Build suggestions 46 // Build suggestions
46 List<CompletionSuggestion> suggestions = <CompletionSuggestion>[]; 47 List<CompletionSuggestion> suggestions = <CompletionSuggestion>[];
47 for (String memberName in memberNames) { 48 for (String memberName in memberNames) {
48 ExecutableElement element = map.get(memberName); 49 ExecutableElement element = map[memberName];
49 // Gracefully degrade if the overridden element has not been resolved. 50 // Gracefully degrade if the overridden element has not been resolved.
50 if (element.returnType != null) { 51 if (element.returnType != null) {
51 CompletionSuggestion suggestion = 52 CompletionSuggestion suggestion =
52 _buildSuggestion(request, targetId, element); 53 _buildSuggestion(request, targetId, element);
53 if (suggestion != null) { 54 if (suggestion != null) {
54 suggestions.add(suggestion); 55 suggestions.add(suggestion);
55 } 56 }
56 } 57 }
57 } 58 }
58 return suggestions; 59 return suggestions;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 false); 100 false);
100 suggestion.element = protocol.convertElement(element); 101 suggestion.element = protocol.convertElement(element);
101 return suggestion; 102 return suggestion;
102 } 103 }
103 104
104 /** 105 /**
105 * Return a list containing the names of all of the inherited but not 106 * Return a list containing the names of all of the inherited but not
106 * implemented members of the class represented by the given [element]. 107 * implemented members of the class represented by the given [element].
107 * The [map] is used to find all of the members that are inherited. 108 * The [map] is used to find all of the members that are inherited.
108 */ 109 */
109 List<String> _computeMemberNames(MemberMap map, ClassElement element) { 110 List<String> _computeMemberNames(
111 Map<String, ExecutableElement> map, ClassElement element) {
110 List<String> memberNames = <String>[]; 112 List<String> memberNames = <String>[];
111 int count = map.size; 113 for (String memberName in map.keys) {
112 for (int i = 0; i < count; i++) {
113 String memberName = map.getKey(i);
114 if (!_hasMember(element, memberName)) { 114 if (!_hasMember(element, memberName)) {
115 memberNames.add(memberName); 115 memberNames.add(memberName);
116 } 116 }
117 } 117 }
118 return memberNames; 118 return memberNames;
119 } 119 }
120 120
121 /** 121 /**
122 * If the target looks like a partial identifier inside a class declaration 122 * If the target looks like a partial identifier inside a class declaration
123 * then return that identifier, otherwise return `null`. 123 * then return that identifier, otherwise return `null`.
(...skipping 19 matching lines...) Expand all
143 * Return `true` if the given [classElement] directly declares a member with 143 * Return `true` if the given [classElement] directly declares a member with
144 * the given [memberName]. 144 * the given [memberName].
145 */ 145 */
146 bool _hasMember(ClassElement classElement, String memberName) { 146 bool _hasMember(ClassElement classElement, String memberName) {
147 return classElement.getField(memberName) != null || 147 return classElement.getField(memberName) != null ||
148 classElement.getGetter(memberName) != null || 148 classElement.getGetter(memberName) != null ||
149 classElement.getMethod(memberName) != null || 149 classElement.getMethod(memberName) != null ||
150 classElement.getSetter(memberName) != null; 150 classElement.getSetter(memberName) != null;
151 } 151 }
152 } 152 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/error_verifier.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698