| 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.contributor.dart.local; | 5 library services.completion.contributor.dart.local; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/protocol.dart' as protocol | 9 import 'package:analysis_server/src/protocol.dart' as protocol |
| 10 show Element, ElementKind; | 10 show Element, ElementKind; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 * A contributor for calculating `completion.getSuggestions` request results | 80 * A contributor for calculating `completion.getSuggestions` request results |
| 81 * for the local library in which the completion is requested. | 81 * for the local library in which the completion is requested. |
| 82 */ | 82 */ |
| 83 class LocalReferenceContributor extends DartCompletionContributor { | 83 class LocalReferenceContributor extends DartCompletionContributor { |
| 84 @override | 84 @override |
| 85 bool computeFast(DartCompletionRequest request) { | 85 bool computeFast(DartCompletionRequest request) { |
| 86 OpType optype = request.optype; | 86 OpType optype = request.optype; |
| 87 | 87 |
| 88 // Collect suggestions from the specific child [AstNode] that contains | 88 // Collect suggestions from the specific child [AstNode] that contains |
| 89 // the completion offset and all of its parents recursively. | 89 // the completion offset and all of its parents recursively. |
| 90 if (optype.includeReturnValueSuggestions || | 90 if (!optype.isPrefixed) { |
| 91 optype.includeTypeNameSuggestions || | 91 if (optype.includeReturnValueSuggestions || |
| 92 optype.includeVoidReturnSuggestions) { | 92 optype.includeTypeNameSuggestions || |
| 93 _LocalVisitor localVisitor = | 93 optype.includeVoidReturnSuggestions) { |
| 94 new _LocalVisitor(request, request.offset, optype); | 94 _LocalVisitor localVisitor = |
| 95 localVisitor.visit(request.target.containingNode); | 95 new _LocalVisitor(request, request.offset, optype); |
| 96 } | 96 localVisitor.visit(request.target.containingNode); |
| 97 if (optype.includeStatementLabelSuggestions || | 97 } |
| 98 optype.includeCaseLabelSuggestions) { | 98 if (optype.includeStatementLabelSuggestions || |
| 99 _LabelVisitor labelVisitor = new _LabelVisitor(request, | 99 optype.includeCaseLabelSuggestions) { |
| 100 optype.includeStatementLabelSuggestions, | 100 _LabelVisitor labelVisitor = new _LabelVisitor(request, |
| 101 optype.includeCaseLabelSuggestions); | 101 optype.includeStatementLabelSuggestions, |
| 102 labelVisitor.visit(request.target.containingNode); | 102 optype.includeCaseLabelSuggestions); |
| 103 } | 103 labelVisitor.visit(request.target.containingNode); |
| 104 if (optype.includeConstructorSuggestions) { | 104 } |
| 105 new _ConstructorVisitor(request).visit(request.target.containingNode); | 105 if (optype.includeConstructorSuggestions) { |
| 106 new _ConstructorVisitor(request).visit(request.target.containingNode); |
| 107 } |
| 106 } | 108 } |
| 107 | 109 |
| 108 // If target is an argument in an argument list | 110 // If target is an argument in an argument list |
| 109 // then suggestions may need to be adjusted | 111 // then suggestions may need to be adjusted |
| 110 return request.target.argIndex == null; | 112 return request.target.argIndex == null; |
| 111 } | 113 } |
| 112 | 114 |
| 113 @override | 115 @override |
| 114 Future<bool> computeFull(DartCompletionRequest request) { | 116 Future<bool> computeFull(DartCompletionRequest request) { |
| 115 _updateSuggestions(request); | 117 _updateSuggestions(request); |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 bool _isVoid(TypeName returnType) { | 693 bool _isVoid(TypeName returnType) { |
| 692 if (returnType != null) { | 694 if (returnType != null) { |
| 693 Identifier id = returnType.name; | 695 Identifier id = returnType.name; |
| 694 if (id != null && id.name == 'void') { | 696 if (id != null && id.name == 'void') { |
| 695 return true; | 697 return true; |
| 696 } | 698 } |
| 697 } | 699 } |
| 698 return false; | 700 return false; |
| 699 } | 701 } |
| 700 } | 702 } |
| OLD | NEW |