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

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

Issue 1898193004: TBR Revert "Remove MemberMap in favor of HashMap" (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 Map<String, ExecutableElement> map = 42 MemberMap map = manager.getMapOfMembersInheritedFromInterfaces(classElem);
43 manager.getMapOfMembersInheritedFromInterfaces(classElem);
44 List<String> memberNames = _computeMemberNames(map, classElem); 43 List<String> memberNames = _computeMemberNames(map, classElem);
45 44
46 // Build suggestions 45 // Build suggestions
47 List<CompletionSuggestion> suggestions = <CompletionSuggestion>[]; 46 List<CompletionSuggestion> suggestions = <CompletionSuggestion>[];
48 for (String memberName in memberNames) { 47 for (String memberName in memberNames) {
49 ExecutableElement element = map[memberName]; 48 ExecutableElement element = map.get(memberName);
50 // Gracefully degrade if the overridden element has not been resolved. 49 // Gracefully degrade if the overridden element has not been resolved.
51 if (element.returnType != null) { 50 if (element.returnType != null) {
52 CompletionSuggestion suggestion = 51 CompletionSuggestion suggestion =
53 _buildSuggestion(request, targetId, element); 52 _buildSuggestion(request, targetId, element);
54 if (suggestion != null) { 53 if (suggestion != null) {
55 suggestions.add(suggestion); 54 suggestions.add(suggestion);
56 } 55 }
57 } 56 }
58 } 57 }
59 return suggestions; 58 return suggestions;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 false); 99 false);
101 suggestion.element = protocol.convertElement(element); 100 suggestion.element = protocol.convertElement(element);
102 return suggestion; 101 return suggestion;
103 } 102 }
104 103
105 /** 104 /**
106 * Return a list containing the names of all of the inherited but not 105 * Return a list containing the names of all of the inherited but not
107 * implemented members of the class represented by the given [element]. 106 * implemented members of the class represented by the given [element].
108 * The [map] is used to find all of the members that are inherited. 107 * The [map] is used to find all of the members that are inherited.
109 */ 108 */
110 List<String> _computeMemberNames( 109 List<String> _computeMemberNames(MemberMap map, ClassElement element) {
111 Map<String, ExecutableElement> map, ClassElement element) {
112 List<String> memberNames = <String>[]; 110 List<String> memberNames = <String>[];
113 for (String memberName in map.keys) { 111 int count = map.size;
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