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

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

Issue 807743003: refactor optype to be computed once per refactoring request (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge and address comment Created 6 years 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 show Element, 9 import 'package:analysis_server/src/protocol.dart' as protocol show Element,
10 ElementKind; 10 ElementKind;
11 import 'package:analysis_server/src/protocol.dart' hide Element, ElementKind; 11 import 'package:analysis_server/src/protocol.dart' hide Element, ElementKind;
12 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart'; 12 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart';
13 import 'package:analysis_server/src/services/completion/local_declaration_visito r.dart'; 13 import 'package:analysis_server/src/services/completion/local_declaration_visito r.dart';
14 import 'package:analysis_server/src/services/completion/optype_ast_visitor.dart' ; 14 import 'package:analysis_server/src/services/completion/optype.dart';
15 import 'package:analyzer/src/generated/ast.dart'; 15 import 'package:analyzer/src/generated/ast.dart';
16 import 'package:analyzer/src/generated/scanner.dart'; 16 import 'package:analyzer/src/generated/scanner.dart';
17 17
18 /** 18 /**
19 * A computer for calculating `completion.getSuggestions` request results 19 * A computer for calculating `completion.getSuggestions` request results
20 * for the local library in which the completion is requested. 20 * for the local library in which the completion is requested.
21 */ 21 */
22 class LocalComputer extends DartCompletionComputer { 22 class LocalComputer extends DartCompletionComputer {
23 23
24 @override 24 @override
25 bool computeFast(DartCompletionRequest request) { 25 bool computeFast(DartCompletionRequest request) {
26 26 OpType optype = request.optype;
27 // Determine the type of suggestions to be made 27 if (optype.includeTopLevelSuggestions) {
28 OpTypeAstVisitor opTypeVisitor = new OpTypeAstVisitor(request.offset);
29 request.node.accept(opTypeVisitor);
30
31 // Build the suggestions
32 if (opTypeVisitor.includeTopLevelSuggestions) {
33 _LocalVisitor localVisitor = new _LocalVisitor(request, request.offset); 28 _LocalVisitor localVisitor = new _LocalVisitor(request, request.offset);
34 localVisitor.typesOnly = opTypeVisitor.includeOnlyTypeNameSuggestions; 29 localVisitor.typesOnly = optype.includeOnlyTypeNameSuggestions;
35 localVisitor.excludeVoidReturn = 30 localVisitor.excludeVoidReturn = !optype.includeVoidReturnSuggestions;
36 !opTypeVisitor.includeVoidReturnSuggestions;
37 31
38 // Collect suggestions from the specific child [AstNode] that contains 32 // Collect suggestions from the specific child [AstNode] that contains
39 // the completion offset and all of its parents recursively. 33 // the completion offset and all of its parents recursively.
40 request.node.accept(localVisitor); 34 request.node.accept(localVisitor);
41 } 35 }
42 36
43 // If the unit is not a part and does not reference any parts 37 // If the unit is not a part and does not reference any parts
44 // then work is complete 38 // then work is complete
45 return !request.unit.directives.any( 39 return !request.unit.directives.any(
46 (Directive directive) => 40 (Directive directive) =>
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 if (name == null || name.length <= 0) { 366 if (name == null || name.length <= 0) {
373 return DYNAMIC; 367 return DYNAMIC;
374 } 368 }
375 TypeArgumentList typeArgs = type.typeArguments; 369 TypeArgumentList typeArgs = type.typeArguments;
376 if (typeArgs != null) { 370 if (typeArgs != null) {
377 //TODO (danrubel) include type arguments 371 //TODO (danrubel) include type arguments
378 } 372 }
379 return name; 373 return name;
380 } 374 }
381 } 375 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698