| OLD | NEW |
| 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.local; | 5 library services.completion.computer.dart.local; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/protocol.dart' as protocol show Element, | 9 import 'package:analysis_server/src/protocol.dart' as protocol show Element, |
| 10 ElementKind; | 10 ElementKind; |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 visitNode(node); | 206 visitNode(node); |
| 207 } | 207 } |
| 208 | 208 |
| 209 @override | 209 @override |
| 210 visitMethodDeclaration(MethodDeclaration node) { | 210 visitMethodDeclaration(MethodDeclaration node) { |
| 211 _addParamListSuggestions(node.parameters); | 211 _addParamListSuggestions(node.parameters); |
| 212 visitNode(node); | 212 visitNode(node); |
| 213 } | 213 } |
| 214 | 214 |
| 215 @override | 215 @override |
| 216 visitMethodInvocation(MethodInvocation node) { |
| 217 // InvocationComputer adds suggestions for method selector |
| 218 Token period = node.period; |
| 219 if (period != null && period.offset < request.offset) { |
| 220 ArgumentList argumentList = node.argumentList; |
| 221 if (argumentList == null || request.offset <= argumentList.offset) { |
| 222 return; |
| 223 } |
| 224 } |
| 225 visitNode(node); |
| 226 } |
| 227 |
| 228 @override |
| 216 visitNamespaceDirective(NamespaceDirective node) { | 229 visitNamespaceDirective(NamespaceDirective node) { |
| 217 // No suggestions | 230 // No suggestions |
| 218 } | 231 } |
| 219 | 232 |
| 220 @override | 233 @override |
| 221 visitNode(AstNode node) { | 234 visitNode(AstNode node) { |
| 222 node.parent.accept(this); | 235 node.parent.accept(this); |
| 223 } | 236 } |
| 224 | 237 |
| 225 @override | 238 @override |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 csKind = CompletionSuggestionKind.SETTER; | 379 csKind = CompletionSuggestionKind.SETTER; |
| 367 } else { | 380 } else { |
| 368 if (excludeVoidReturn && _isVoid(classMbr.returnType)) { | 381 if (excludeVoidReturn && _isVoid(classMbr.returnType)) { |
| 369 return; | 382 return; |
| 370 } | 383 } |
| 371 kind = protocol.ElementKind.METHOD; | 384 kind = protocol.ElementKind.METHOD; |
| 372 csKind = CompletionSuggestionKind.METHOD; | 385 csKind = CompletionSuggestionKind.METHOD; |
| 373 } | 386 } |
| 374 CompletionSuggestion suggestion = | 387 CompletionSuggestion suggestion = |
| 375 _addSuggestion(classMbr.name, csKind, classMbr.returnType, node); | 388 _addSuggestion(classMbr.name, csKind, classMbr.returnType, node); |
| 376 suggestion.element = _createElement( | 389 if (suggestion != null) { |
| 377 kind, | 390 suggestion.element = _createElement( |
| 378 classMbr.name, | 391 kind, |
| 379 classMbr.returnType, | 392 classMbr.name, |
| 380 classMbr.isAbstract, | 393 classMbr.returnType, |
| 381 _isDeprecated(classMbr.metadata)); | 394 classMbr.isAbstract, |
| 395 _isDeprecated(classMbr.metadata)); |
| 396 } |
| 382 } | 397 } |
| 383 | 398 |
| 384 void _addParamListSuggestions(FormalParameterList paramList) { | 399 void _addParamListSuggestions(FormalParameterList paramList) { |
| 385 if (typesOnly) { | 400 if (typesOnly) { |
| 386 return; | 401 return; |
| 387 } | 402 } |
| 388 if (paramList != null) { | 403 if (paramList != null) { |
| 389 paramList.parameters.forEach((FormalParameter param) { | 404 paramList.parameters.forEach((FormalParameter param) { |
| 390 NormalFormalParameter normalParam; | 405 NormalFormalParameter normalParam; |
| 391 if (param is DefaultFormalParameter) { | 406 if (param is DefaultFormalParameter) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 415 if (suggestion != null) { | 430 if (suggestion != null) { |
| 416 suggestion.element = | 431 suggestion.element = |
| 417 _createElement(protocol.ElementKind.PARAMETER, identifier, type, false
, false); | 432 _createElement(protocol.ElementKind.PARAMETER, identifier, type, false
, false); |
| 418 } | 433 } |
| 419 } | 434 } |
| 420 | 435 |
| 421 CompletionSuggestion _addSuggestion(SimpleIdentifier id, | 436 CompletionSuggestion _addSuggestion(SimpleIdentifier id, |
| 422 CompletionSuggestionKind kind, TypeName typeName, ClassDeclaration classDe
cl) { | 437 CompletionSuggestionKind kind, TypeName typeName, ClassDeclaration classDe
cl) { |
| 423 if (id != null) { | 438 if (id != null) { |
| 424 String completion = id.name; | 439 String completion = id.name; |
| 425 if (completion != null && completion.length > 0) { | 440 if (completion != null && completion.length > 0 && completion != '_') { |
| 426 CompletionSuggestion suggestion = new CompletionSuggestion( | 441 CompletionSuggestion suggestion = new CompletionSuggestion( |
| 427 kind, | 442 kind, |
| 428 CompletionRelevance.DEFAULT, | 443 CompletionRelevance.DEFAULT, |
| 429 completion, | 444 completion, |
| 430 completion.length, | 445 completion.length, |
| 431 0, | 446 0, |
| 432 false, | 447 false, |
| 433 false); | 448 false); |
| 434 if (classDecl != null) { | 449 if (classDecl != null) { |
| 435 SimpleIdentifier identifier = classDecl.name; | 450 SimpleIdentifier identifier = classDecl.name; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 if (name == null || name.length <= 0) { | 558 if (name == null || name.length <= 0) { |
| 544 return DYNAMIC; | 559 return DYNAMIC; |
| 545 } | 560 } |
| 546 TypeArgumentList typeArgs = type.typeArguments; | 561 TypeArgumentList typeArgs = type.typeArguments; |
| 547 if (typeArgs != null) { | 562 if (typeArgs != null) { |
| 548 //TODO (danrubel) include type arguments | 563 //TODO (danrubel) include type arguments |
| 549 } | 564 } |
| 550 return name; | 565 return name; |
| 551 } | 566 } |
| 552 } | 567 } |
| OLD | NEW |