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

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

Issue 967643002: throw exception to stop visiting (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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
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.invocation; 5 library services.completion.computer.dart.invocation;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart'; 9 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart';
10 import 'package:analysis_server/src/services/completion/local_declaration_visito r.dart'; 10 import 'package:analysis_server/src/services/completion/local_declaration_visito r.dart';
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 DartType typeFound; 139 DartType typeFound;
140 140
141 /** 141 /**
142 * Construct a new instance to search for a declaration 142 * Construct a new instance to search for a declaration
143 */ 143 */
144 _LocalBestTypeVisitor(this.targetName, int offset) : super(offset); 144 _LocalBestTypeVisitor(this.targetName, int offset) : super(offset);
145 145
146 @override 146 @override
147 void declaredClass(ClassDeclaration declaration) { 147 void declaredClass(ClassDeclaration declaration) {
148 if (declaration.name.name == targetName) { 148 if (declaration.name.name == targetName) {
149 finished = true;
150 // no type 149 // no type
150 finished();
151 } 151 }
152 } 152 }
153 153
154 @override 154 @override
155 void declaredClassTypeAlias(ClassTypeAlias declaration) { 155 void declaredClassTypeAlias(ClassTypeAlias declaration) {
156 if (declaration.name.name == targetName) { 156 if (declaration.name.name == targetName) {
157 finished = true;
158 // no type 157 // no type
158 finished();
159 } 159 }
160 } 160 }
161 161
162 @override 162 @override
163 void declaredField(FieldDeclaration fieldDecl, VariableDeclaration varDecl) { 163 void declaredField(FieldDeclaration fieldDecl, VariableDeclaration varDecl) {
164 if (varDecl.name.name == targetName) { 164 if (varDecl.name.name == targetName) {
165 finished = true;
166 // Type provided by the element in computeFull above 165 // Type provided by the element in computeFull above
166 finished();
167 } 167 }
168 } 168 }
169 169
170 @override 170 @override
171 void declaredFunction(FunctionDeclaration declaration) { 171 void declaredFunction(FunctionDeclaration declaration) {
172 if (declaration.name.name == targetName) { 172 if (declaration.name.name == targetName) {
173 finished = true;
174 TypeName typeName = declaration.returnType; 173 TypeName typeName = declaration.returnType;
175 if (typeName != null) { 174 if (typeName != null) {
176 typeFound = typeName.type; 175 typeFound = typeName.type;
177 } 176 }
177 finished();
178 } 178 }
179 } 179 }
180 180
181 @override 181 @override
182 void declaredFunctionTypeAlias(FunctionTypeAlias declaration) { 182 void declaredFunctionTypeAlias(FunctionTypeAlias declaration) {
183 if (declaration.name.name == targetName) { 183 if (declaration.name.name == targetName) {
184 finished = true;
185 TypeName typeName = declaration.returnType; 184 TypeName typeName = declaration.returnType;
186 if (typeName != null) { 185 if (typeName != null) {
187 typeFound = typeName.type; 186 typeFound = typeName.type;
188 } 187 }
188 finished();
189 } 189 }
190 } 190 }
191 191
192 @override 192 @override
193 void declaredLabel(Label label, bool isCaseLabel) { 193 void declaredLabel(Label label, bool isCaseLabel) {
194 if (label.label.name == targetName) { 194 if (label.label.name == targetName) {
195 finished = true;
196 // no type 195 // no type
196 finished();
197 } 197 }
198 } 198 }
199 199
200 @override 200 @override
201 void declaredLocalVar(SimpleIdentifier name, TypeName type) { 201 void declaredLocalVar(SimpleIdentifier name, TypeName type) {
202 if (name.name == targetName) { 202 if (name.name == targetName) {
203 finished = true;
204 typeFound = name.bestType; 203 typeFound = name.bestType;
204 finished();
205 } 205 }
206 } 206 }
207 207
208 @override 208 @override
209 void declaredMethod(MethodDeclaration declaration) { 209 void declaredMethod(MethodDeclaration declaration) {
210 if (declaration.name.name == targetName) { 210 if (declaration.name.name == targetName) {
211 finished = true;
212 TypeName typeName = declaration.returnType; 211 TypeName typeName = declaration.returnType;
213 if (typeName != null) { 212 if (typeName != null) {
214 typeFound = typeName.type; 213 typeFound = typeName.type;
215 } 214 }
215 finished();
216 } 216 }
217 } 217 }
218 218
219 @override 219 @override
220 void declaredParam(SimpleIdentifier name, TypeName type) { 220 void declaredParam(SimpleIdentifier name, TypeName type) {
221 if (name.name == targetName) { 221 if (name.name == targetName) {
222 finished = true;
223 // Type provided by the element in computeFull above 222 // Type provided by the element in computeFull above
223 finished();
224 } 224 }
225 } 225 }
226 226
227 @override 227 @override
228 void declaredTopLevelVar(VariableDeclarationList varList, 228 void declaredTopLevelVar(VariableDeclarationList varList,
229 VariableDeclaration varDecl) { 229 VariableDeclaration varDecl) {
230 if (varDecl.name.name == targetName) { 230 if (varDecl.name.name == targetName) {
231 finished = true;
232 // Type provided by the element in computeFull above 231 // Type provided by the element in computeFull above
232 finished();
233 } 233 }
234 } 234 }
235 } 235 }
236 236
237 /** 237 /**
238 * An [Element] visitor for determining the appropriate invocation/access 238 * An [Element] visitor for determining the appropriate invocation/access
239 * suggestions based upon the element for which the completion is requested. 239 * suggestions based upon the element for which the completion is requested.
240 */ 240 */
241 class _PrefixedIdentifierSuggestionBuilder extends 241 class _PrefixedIdentifierSuggestionBuilder extends
242 GeneralizingElementVisitor<Future<bool>> implements SuggestionBuilder { 242 GeneralizingElementVisitor<Future<bool>> implements SuggestionBuilder {
(...skipping 25 matching lines...) Expand all
268 if (element is! ClassElement) { 268 if (element is! ClassElement) {
269 if (type == null || type.isDynamic) { 269 if (type == null || type.isDynamic) {
270 // 270 //
271 // Given `g. int y = 0;`, the parser interprets `g` as a prefixed 271 // Given `g. int y = 0;`, the parser interprets `g` as a prefixed
272 // identifier with no type. 272 // identifier with no type.
273 // If the user is requesting completions for `g`, 273 // If the user is requesting completions for `g`,
274 // then check for a function, getter, or similar with a type. 274 // then check for a function, getter, or similar with a type.
275 // 275 //
276 _LocalBestTypeVisitor visitor = 276 _LocalBestTypeVisitor visitor =
277 new _LocalBestTypeVisitor(prefix.name, request.offset); 277 new _LocalBestTypeVisitor(prefix.name, request.offset);
278 prefix.accept(visitor); 278 if (visitor.visit(prefix)) {
279 type = visitor.typeFound; 279 type = visitor.typeFound;
280 }
280 } 281 }
281 if (type != null && !type.isDynamic) { 282 if (type != null && !type.isDynamic) {
282 InterfaceTypeSuggestionBuilder.suggestionsFor(request, type); 283 InterfaceTypeSuggestionBuilder.suggestionsFor(request, type);
283 return new Future.value(true); 284 return new Future.value(true);
284 } 285 }
285 } 286 }
286 if (element != null) { 287 if (element != null) {
287 return element.accept(this); 288 return element.accept(this);
288 } 289 }
289 } 290 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 } 345 }
345 return new Future.value(false); 346 return new Future.value(false);
346 } 347 }
347 348
348 @override 349 @override
349 Future<bool> visitVariableElement(VariableElement element) { 350 Future<bool> visitVariableElement(VariableElement element) {
350 InterfaceTypeSuggestionBuilder.suggestionsFor(request, element.type); 351 InterfaceTypeSuggestionBuilder.suggestionsFor(request, element.type);
351 return new Future.value(true); 352 return new Future.value(true);
352 } 353 }
353 } 354 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698