| 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.arglist; | 5 library services.completion.computer.dart.arglist; |
| 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 hide Element, ElementKind; | 10 hide Element, ElementKind; |
| 11 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; | 11 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; |
| 12 import 'package:analysis_server/src/services/completion/local_declaration_visito
r.dart'; | 12 import 'package:analysis_server/src/services/completion/local_declaration_visito
r.dart'; |
| 13 import 'package:analyzer/src/generated/ast.dart'; | 13 import 'package:analyzer/src/generated/ast.dart'; |
| 14 import 'package:analyzer/src/generated/scanner.dart'; | 14 import 'package:analyzer/src/generated/scanner.dart'; |
| 15 | 15 |
| 16 /** | 16 /** |
| 17 * A computer for calculating `completion.getSuggestions` request results | 17 * A computer for calculating `completion.getSuggestions` request results |
| 18 * when the cursor position is inside the arguments to a method call. | 18 * when the cursor position is inside the arguments to a method call. |
| 19 */ | 19 */ |
| 20 class ArgListComputer extends DartCompletionComputer { | 20 class ArgListComputer extends DartCompletionComputer { |
| 21 _ArgListSuggestionBuilder builder; | 21 _ArgListSuggestionBuilder builder; |
| 22 | 22 |
| 23 @override | 23 @override |
| 24 bool computeFast(DartCompletionRequest request) { | 24 bool computeFast(DartCompletionRequest request) { |
| 25 builder = request.node.accept(new _ArgListAstVisitor(request)); | 25 builder = |
| 26 request.target.containingNode.accept(new _ArgListAstVisitor(request)); |
| 26 return builder == null; | 27 return builder == null; |
| 27 } | 28 } |
| 28 | 29 |
| 29 @override | 30 @override |
| 30 Future<bool> computeFull(DartCompletionRequest request) { | 31 Future<bool> computeFull(DartCompletionRequest request) { |
| 31 if (builder != null) { | 32 if (builder != null) { |
| 32 return builder.compute(request.node); | 33 return builder.compute(request.target.containingNode); |
| 33 } | 34 } |
| 34 return new Future.value(false); | 35 return new Future.value(false); |
| 35 } | 36 } |
| 36 } | 37 } |
| 37 | 38 |
| 38 /** | 39 /** |
| 39 * A visitor for determining whether an argument list suggestion is needed | 40 * A visitor for determining whether an argument list suggestion is needed |
| 40 * and instantiating the builder to create the suggestion. | 41 * and instantiating the builder to create the suggestion. |
| 41 */ | 42 */ |
| 42 class _ArgListAstVisitor | 43 class _ArgListAstVisitor |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 if (id != null) { | 193 if (id != null) { |
| 193 String name = id.name; | 194 String name = id.name; |
| 194 if (name != null && name.length > 0) { | 195 if (name != null && name.length > 0) { |
| 195 return name; | 196 return name; |
| 196 } | 197 } |
| 197 } | 198 } |
| 198 } | 199 } |
| 199 return 'dynamic'; | 200 return 'dynamic'; |
| 200 } | 201 } |
| 201 } | 202 } |
| OLD | NEW |