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

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

Issue 695773003: move import combinator suggestions into a separate computer (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 6 years, 1 month 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
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/completion/dart_completion_manager.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library services.completion.computer.dart.combinator;
6
7 import 'dart:async';
8
9 import 'package:analysis_server/src/protocol_server.dart' hide Element,
10 ElementKind;
11 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart';
12 import 'package:analysis_server/src/services/completion/suggestion_builder.dart' ;
13 import 'package:analyzer/src/generated/ast.dart';
14 import 'package:analyzer/src/generated/element.dart';
15
16 /**
17 * A computer for calculating `completion.getSuggestions` request results
18 * for the import combinators show and hide.
19 */
20
21 class CombinatorComputer extends DartCompletionComputer {
22
23 @override
24 bool computeFast(DartCompletionRequest request) {
25 return false;
26 }
27
28 @override
29 Future<bool> computeFull(DartCompletionRequest request) {
30 return request.node.accept(new _CombinatorAstVisitor(request));
31 }
32 }
33
34 /**
35 * A visitor for determining which imported classes and top level variables
36 * should be suggested and building those suggestions.
37 */
38 class _CombinatorAstVisitor extends GeneralizingAstVisitor<Future<bool>> {
39 final DartCompletionRequest request;
40
41 _CombinatorAstVisitor(this.request);
42
43 @override
44 Future<bool> visitCombinator(Combinator node) {
45 return _addCombinatorSuggestions(node);
46 }
47
48 @override
49 Future<bool> visitNode(AstNode node) {
50 return new Future.value(false);
51 }
52
53 @override
54 Future<bool> visitSimpleIdentifier(SimpleIdentifier node) {
55 return node.parent.accept(this);
56 }
57
58 Future _addCombinatorSuggestions(Combinator node) {
59 var directive = node.getAncestor((parent) => parent is NamespaceDirective);
60 if (directive is NamespaceDirective) {
61 LibraryElement library = directive.uriElement;
62 LibraryElementSuggestionBuilder.suggestionsFor(
63 request,
64 CompletionSuggestionKind.IDENTIFIER,
65 library);
66 return new Future.value(true);
67 }
68 return new Future.value(false);
69 }
70 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/completion/dart_completion_manager.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698