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

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

Issue 1072623002: refactor optype to better filter invocation/prefixed suggestions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 5 years, 8 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.contributor.dart.invocation; 5 library services.completion.contributor.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';
11 import 'package:analysis_server/src/services/completion/optype.dart'; 11 import 'package:analysis_server/src/services/completion/optype.dart';
12 import 'package:analysis_server/src/services/completion/suggestion_builder.dart' ; 12 import 'package:analysis_server/src/services/completion/suggestion_builder.dart' ;
13 import 'package:analyzer/src/generated/ast.dart'; 13 import 'package:analyzer/src/generated/ast.dart';
14 import 'package:analyzer/src/generated/element.dart'; 14 import 'package:analyzer/src/generated/element.dart';
15 15
16 import '../../protocol_server.dart' as protocol; 16 import '../../protocol_server.dart' as protocol;
17 import '../../protocol_server.dart' 17 import '../../protocol_server.dart'
18 show CompletionSuggestion, CompletionSuggestionKind; 18 show CompletionSuggestion, CompletionSuggestionKind;
19 19
20 /** 20 /**
21 * A contributor for calculating invocation / access suggestions 21 * A contributor for calculating invocation / access suggestions
22 * `completion.getSuggestions` request results. 22 * `completion.getSuggestions` request results.
23 */ 23 */
24 class PrefixedElementContributor extends DartCompletionContributor { 24 class PrefixedElementContributor extends DartCompletionContributor {
25 SuggestionBuilder builder; 25 SuggestionBuilder builder;
26 26
27 @override 27 @override
28 bool computeFast(DartCompletionRequest request) { 28 bool computeFast(DartCompletionRequest request) {
29 OpType optype = request.optype; 29 OpType optype = request.optype;
30 if (optype.includeInvocationSuggestions) { 30 if (optype.isPrefixed) {
31 builder = request.target.containingNode 31 builder = request.target.containingNode
32 .accept(new _InvocationAstVisitor(request)); 32 .accept(new _InvocationAstVisitor(request));
33 if (builder != null) { 33 if (builder != null) {
34 return builder.computeFast(request.target.containingNode); 34 return builder.computeFast(request.target.containingNode);
35 } 35 }
36 } 36 }
37 37
38 return true; 38 return true;
39 } 39 }
40 40
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 } 351 }
352 return new Future.value(false); 352 return new Future.value(false);
353 } 353 }
354 354
355 @override 355 @override
356 Future<bool> visitVariableElement(VariableElement element) { 356 Future<bool> visitVariableElement(VariableElement element) {
357 InterfaceTypeSuggestionBuilder.suggestionsFor(request, element.type); 357 InterfaceTypeSuggestionBuilder.suggestionsFor(request, element.type);
358 return new Future.value(true); 358 return new Future.value(true);
359 } 359 }
360 } 360 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698