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

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

Issue 1060713005: rename completion computer to contributor (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.computer.dart.toplevel; 5 library services.completion.contributor.dart.toplevel;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analysis_server/src/protocol_server.dart' 10 import 'package:analysis_server/src/protocol_server.dart'
11 hide Element, ElementKind; 11 hide Element, ElementKind;
12 import 'package:analysis_server/src/services/completion/dart_completion_cache.da rt'; 12 import 'package:analysis_server/src/services/completion/dart_completion_cache.da rt';
13 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart'; 13 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart';
14 import 'package:analysis_server/src/services/completion/optype.dart'; 14 import 'package:analysis_server/src/services/completion/optype.dart';
15 import 'package:analysis_server/src/services/completion/suggestion_builder.dart' ; 15 import 'package:analysis_server/src/services/completion/suggestion_builder.dart' ;
16 import 'package:analyzer/src/generated/ast.dart'; 16 import 'package:analyzer/src/generated/ast.dart';
17 import 'package:analyzer/src/generated/element.dart'; 17 import 'package:analyzer/src/generated/element.dart';
18 18
19 /** 19 /**
20 * A computer for calculating imported class and top level variable 20 * A contributor for calculating imported class and top level variable
21 * `completion.getSuggestions` request results. 21 * `completion.getSuggestions` request results.
22 */ 22 */
23 class ImportedComputer extends DartCompletionComputer { 23 class ImportedReferenceContributor extends DartCompletionContributor {
24 bool shouldWaitForLowPrioritySuggestions; 24 bool shouldWaitForLowPrioritySuggestions;
25 bool suggestionsComputed; 25 bool suggestionsComputed;
26 _ImportedSuggestionBuilder builder; 26 _ImportedSuggestionBuilder builder;
27 27
28 ImportedComputer({this.shouldWaitForLowPrioritySuggestions: false}); 28 ImportedReferenceContributor({this.shouldWaitForLowPrioritySuggestions: false} );
29 29
30 @override 30 @override
31 bool computeFast(DartCompletionRequest request) { 31 bool computeFast(DartCompletionRequest request) {
32 OpType optype = request.optype; 32 OpType optype = request.optype;
33 if (optype.includeReturnValueSuggestions || 33 if (optype.includeReturnValueSuggestions ||
34 optype.includeTypeNameSuggestions || 34 optype.includeTypeNameSuggestions ||
35 optype.includeVoidReturnSuggestions || 35 optype.includeVoidReturnSuggestions ||
36 optype.includeConstructorSuggestions) { 36 optype.includeConstructorSuggestions) {
37 builder = new _ImportedSuggestionBuilder(request, optype); 37 builder = new _ImportedSuggestionBuilder(request, optype);
38 builder.shouldWaitForLowPrioritySuggestions = 38 builder.shouldWaitForLowPrioritySuggestions =
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 /** 183 /**
184 * Add suggestions for any inherited imported members. 184 * Add suggestions for any inherited imported members.
185 */ 185 */
186 void _addInheritedSuggestions(AstNode node) { 186 void _addInheritedSuggestions(AstNode node) {
187 var classDecl = node.getAncestor((p) => p is ClassDeclaration); 187 var classDecl = node.getAncestor((p) => p is ClassDeclaration);
188 if (classDecl is ClassDeclaration) { 188 if (classDecl is ClassDeclaration) {
189 // Build a list of inherited types that are imported 189 // Build a list of inherited types that are imported
190 // and include any inherited imported members 190 // and include any inherited imported members
191 List<String> inheritedTypes = new List<String>(); 191 List<String> inheritedTypes = new List<String>();
192 visitInheritedTypes(classDecl, (_) { 192 visitInheritedTypes(classDecl, (_) {
193 // local declarations are handled by the local computer 193 // local declarations are handled by the local reference contributor
194 }, (String typeName) { 194 }, (String typeName) {
195 inheritedTypes.add(typeName); 195 inheritedTypes.add(typeName);
196 }); 196 });
197 HashSet<String> visited = new HashSet<String>(); 197 HashSet<String> visited = new HashSet<String>();
198 while (inheritedTypes.length > 0) { 198 while (inheritedTypes.length > 0) {
199 String name = inheritedTypes.removeLast(); 199 String name = inheritedTypes.removeLast();
200 ClassElement elem = cache.importedClassMap[name]; 200 ClassElement elem = cache.importedClassMap[name];
201 if (visited.add(name) && elem != null) { 201 if (visited.add(name) && elem != null) {
202 _addElementSuggestions(elem.fields, 202 _addElementSuggestions(elem.fields,
203 relevance: DART_RELEVANCE_INHERITED_FIELD); 203 relevance: DART_RELEVANCE_INHERITED_FIELD);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 _addFilteredSuggestions(filterText, cache.libraryPrefixSuggestions); 253 _addFilteredSuggestions(filterText, cache.libraryPrefixSuggestions);
254 } 254 }
255 if (optype.includeReturnValueSuggestions) { 255 if (optype.includeReturnValueSuggestions) {
256 _addFilteredSuggestions(filterText, cache.otherImportedSuggestions); 256 _addFilteredSuggestions(filterText, cache.otherImportedSuggestions);
257 } 257 }
258 if (optype.includeVoidReturnSuggestions) { 258 if (optype.includeVoidReturnSuggestions) {
259 _addFilteredSuggestions(filterText, cache.importedVoidReturnSuggestions); 259 _addFilteredSuggestions(filterText, cache.importedVoidReturnSuggestions);
260 } 260 }
261 } 261 }
262 } 262 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698