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

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

Issue 838053003: suggest fields rather than synthetic getters (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address comments Created 5 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/completion/local_computer.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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.computer.dart.toplevel; 5 library services.completion.computer.dart.toplevel;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analysis_server/src/protocol_server.dart' hide Element, 10 import 'package:analysis_server/src/protocol_server.dart' hide Element,
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 if (elem.isOperator) { 117 if (elem.isOperator) {
118 return; 118 return;
119 } 119 }
120 DartType returnType = elem.returnType; 120 DartType returnType = elem.returnType;
121 if (returnType != null && returnType.isVoid) { 121 if (returnType != null && returnType.isVoid) {
122 if (excludeVoidReturn) { 122 if (excludeVoidReturn) {
123 return; 123 return;
124 } 124 }
125 } 125 }
126 } 126 }
127 if (elem.isSynthetic) {
128 if (elem is PropertyAccessorElement || elem is FieldElement) {
129 return;
130 }
131 }
127 } 132 }
128 request.suggestions.add( 133 request.suggestions.add(
129 createElementSuggestion(elem, relevance: CompletionRelevance.DEFAULT)) ; 134 createElementSuggestion(elem, relevance: CompletionRelevance.DEFAULT)) ;
130 }); 135 });
131 } 136 }
132 137
133 /** 138 /**
134 * Add suggestions for any inherited imported members. 139 * Add suggestions for any inherited imported members.
135 */ 140 */
136 void _addInheritedSuggestions(AstNode node) { 141 void _addInheritedSuggestions(AstNode node) {
137 var classDecl = node.getAncestor((p) => p is ClassDeclaration); 142 var classDecl = node.getAncestor((p) => p is ClassDeclaration);
138 if (classDecl is ClassDeclaration) { 143 if (classDecl is ClassDeclaration) {
139 // Build a list of inherited types that are imported 144 // Build a list of inherited types that are imported
140 // and include any inherited imported members 145 // and include any inherited imported members
141 List<String> inheritedTypes = new List<String>(); 146 List<String> inheritedTypes = new List<String>();
142 visitInheritedTypes(classDecl, (_) { 147 visitInheritedTypes(classDecl, (_) {
143 // local declarations are handled by the local computer 148 // local declarations are handled by the local computer
144 }, (String typeName) { 149 }, (String typeName) {
145 inheritedTypes.add(typeName); 150 inheritedTypes.add(typeName);
146 }); 151 });
147 HashSet<String> visited = new HashSet<String>(); 152 HashSet<String> visited = new HashSet<String>();
148 while (inheritedTypes.length > 0) { 153 while (inheritedTypes.length > 0) {
149 String name = inheritedTypes.removeLast(); 154 String name = inheritedTypes.removeLast();
150 ClassElement elem = cache.importedClassMap[name]; 155 ClassElement elem = cache.importedClassMap[name];
151 if (visited.add(name) && elem != null) { 156 if (visited.add(name) && elem != null) {
157 _addElementSuggestions(elem.fields);
152 _addElementSuggestions(elem.accessors); 158 _addElementSuggestions(elem.accessors);
153 _addElementSuggestions(elem.methods); 159 _addElementSuggestions(elem.methods);
154 elem.allSupertypes.forEach((InterfaceType type) { 160 elem.allSupertypes.forEach((InterfaceType type) {
155 if (visited.add(type.name)) { 161 if (visited.add(type.name) && type.element != null) {
156 _addElementSuggestions(type.accessors); 162 _addElementSuggestions(type.element.fields);
157 _addElementSuggestions(type.methods); 163 _addElementSuggestions(type.element.accessors);
164 _addElementSuggestions(type.element.methods);
158 } 165 }
159 }); 166 });
160 } 167 }
161 } 168 }
162 } 169 }
163 } 170 }
164 171
165 /** 172 /**
166 * Add top level suggestions from the cache. 173 * Add top level suggestions from the cache.
167 * To reduce the number of suggestions sent to the client, 174 * To reduce the number of suggestions sent to the client,
(...skipping 26 matching lines...) Expand all
194 addFilteredSuggestions(cache.importedTypeSuggestions); 201 addFilteredSuggestions(cache.importedTypeSuggestions);
195 addFilteredSuggestions(cache.libraryPrefixSuggestions); 202 addFilteredSuggestions(cache.libraryPrefixSuggestions);
196 if (!typesOnly) { 203 if (!typesOnly) {
197 addFilteredSuggestions(cache.otherImportedSuggestions); 204 addFilteredSuggestions(cache.otherImportedSuggestions);
198 if (!excludeVoidReturn) { 205 if (!excludeVoidReturn) {
199 addFilteredSuggestions(cache.importedVoidReturnSuggestions); 206 addFilteredSuggestions(cache.importedVoidReturnSuggestions);
200 } 207 }
201 } 208 }
202 } 209 }
203 } 210 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/completion/local_computer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698