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

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

Issue 977223003: When target requires a function, propose a function reference, not an invocation (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge and update editor to process IDENTIFIER suggestions 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.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 9 import 'package:analysis_server/src/protocol.dart' as protocol
10 show Element, ElementKind; 10 show Element, ElementKind;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 optype.includeCaseLabelSuggestions) { 97 optype.includeCaseLabelSuggestions) {
98 _LabelVisitor labelVisitor = new _LabelVisitor(request, 98 _LabelVisitor labelVisitor = new _LabelVisitor(request,
99 optype.includeStatementLabelSuggestions, 99 optype.includeStatementLabelSuggestions,
100 optype.includeCaseLabelSuggestions); 100 optype.includeCaseLabelSuggestions);
101 labelVisitor.visit(request.node); 101 labelVisitor.visit(request.node);
102 } 102 }
103 if (optype.includeConstructorSuggestions) { 103 if (optype.includeConstructorSuggestions) {
104 new _ConstructorVisitor(request).visit(request.node); 104 new _ConstructorVisitor(request).visit(request.node);
105 } 105 }
106 106
107 // If the unit is not a part and does not reference any parts 107 // If target is an argument in an argument list
108 // then work is complete 108 // then suggestions may need to be adjusted
109 return !request.unit.directives.any((Directive directive) => 109 return request.target.argIndex == null;
110 directive is PartOfDirective || directive is PartDirective);
111 } 110 }
112 111
113 @override 112 @override
114 Future<bool> computeFull(DartCompletionRequest request) { 113 Future<bool> computeFull(DartCompletionRequest request) {
115 // TODO: implement computeFull 114 _updateSuggestions(request);
116 // include results from part files that are included in the library
117 return new Future.value(false); 115 return new Future.value(false);
118 } 116 }
117
118 /**
119 * If target is a function argument, suggest identifiers not invocations
120 */
121 void _updateSuggestions(DartCompletionRequest request) {
122 if (request.target.isFunctionalArgument()) {
123 request.convertInvocationsToIdentifiers();
124 }
125 }
119 } 126 }
120 127
121 /** 128 /**
122 * A visitor for collecting constructor suggestions. 129 * A visitor for collecting constructor suggestions.
123 */ 130 */
124 class _ConstructorVisitor extends LocalDeclarationVisitor { 131 class _ConstructorVisitor extends LocalDeclarationVisitor {
125 final DartCompletionRequest request; 132 final DartCompletionRequest request;
126 133
127 _ConstructorVisitor(DartCompletionRequest request) 134 _ConstructorVisitor(DartCompletionRequest request)
128 : super(request.offset), 135 : super(request.offset),
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 bool _isVoid(TypeName returnType) { 689 bool _isVoid(TypeName returnType) {
683 if (returnType != null) { 690 if (returnType != null) {
684 Identifier id = returnType.name; 691 Identifier id = returnType.name;
685 if (id != null && id.name == 'void') { 692 if (id != null && id.name == 'void') {
686 return true; 693 return true;
687 } 694 }
688 } 695 }
689 return false; 696 return false;
690 } 697 }
691 } 698 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698