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

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

Issue 969113002: Reformat (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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.relevance; 5 library services.completion.computer.dart.relevance;
6 6
7 import 'package:analysis_server/src/protocol_server.dart' as protocol; 7 import 'package:analysis_server/src/protocol_server.dart' as protocol;
8 import 'package:analysis_server/src/protocol_server.dart' show 8 import 'package:analysis_server/src/protocol_server.dart'
9 CompletionSuggestion, CompletionSuggestionKind; 9 show CompletionSuggestion, CompletionSuggestionKind;
10 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart'; 10 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart';
11 import 'package:analyzer/src/generated/ast.dart'; 11 import 'package:analyzer/src/generated/ast.dart';
12 import 'package:analyzer/src/generated/element.dart'; 12 import 'package:analyzer/src/generated/element.dart';
13 13
14 /** 14 /**
15 * A map of <library>.<classname> to an ordered list of method names, 15 * A map of <library>.<classname> to an ordered list of method names,
16 * field names, getter names, and named constructors. 16 * field names, getter names, and named constructors.
17 * The names are ordered from most relevant to least relevant. 17 * The names are ordered from most relevant to least relevant.
18 * Names not listed are considered equally less relevant than those listed. 18 * Names not listed are considered equally less relevant than those listed.
19 */ 19 */
20 const Map<String, List<String>> defaultSelectorRelevance = const {// 20 const Map<String, List<String>> defaultSelectorRelevance = const {
21 //
21 // Sample implementation which updates the relevance of the following 22 // Sample implementation which updates the relevance of the following
22 // new Random().nextInt(...) 23 // new Random().nextInt(...)
23 // new Random().nextDouble(...) 24 // new Random().nextDouble(...)
24 // new Random().nextBool() - not commonly used thus omitted from list 25 // new Random().nextBool() - not commonly used thus omitted from list
25 // Entries should look something like this 26 // Entries should look something like this
26 // 'dart.math.Random': const ['nextInt', 'nextDouble'], 27 // 'dart.math.Random': const ['nextInt', 'nextDouble'],
27 // 'dart.async.Future': const ['value', 'wait'], 28 // 'dart.async.Future': const ['value', 'wait'],
28 }; 29 };
29 30
30 /** 31 /**
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 _updateInvocationRelevance(request, type, libElem); 78 _updateInvocationRelevance(request, type, libElem);
78 } 79 }
79 } 80 }
80 } 81 }
81 } 82 }
82 83
83 /** 84 /**
84 * Adjusts the relevance of all method suggestions based upon the given 85 * Adjusts the relevance of all method suggestions based upon the given
85 * target type and library. 86 * target type and library.
86 */ 87 */
87 void _updateInvocationRelevance(DartCompletionRequest request, DartType type, 88 void _updateInvocationRelevance(
88 LibraryElement libElem) { 89 DartCompletionRequest request, DartType type, LibraryElement libElem) {
89 String typeName = type.name; 90 String typeName = type.name;
90 List<String> selectors = selectorRelevance['${libElem.name}.${typeName}']; 91 List<String> selectors = selectorRelevance['${libElem.name}.${typeName}'];
91 if (selectors != null) { 92 if (selectors != null) {
92 for (CompletionSuggestion suggestion in request.suggestions) { 93 for (CompletionSuggestion suggestion in request.suggestions) {
93 protocol.Element element = suggestion.element; 94 protocol.Element element = suggestion.element;
94 if (element != null && 95 if (element != null &&
95 (element.kind == protocol.ElementKind.CONSTRUCTOR || 96 (element.kind == protocol.ElementKind.CONSTRUCTOR ||
96 element.kind == protocol.ElementKind.FIELD || 97 element.kind == protocol.ElementKind.FIELD ||
97 element.kind == protocol.ElementKind.GETTER || 98 element.kind == protocol.ElementKind.GETTER ||
98 element.kind == protocol.ElementKind.METHOD || 99 element.kind == protocol.ElementKind.METHOD ||
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 DartType visitPropertyAccess(PropertyAccess node) { 152 DartType visitPropertyAccess(PropertyAccess node) {
152 if (node.propertyName == entity) { 153 if (node.propertyName == entity) {
153 Expression target = node.realTarget; 154 Expression target = node.realTarget;
154 if (target != null) { 155 if (target != null) {
155 return target.bestType; 156 return target.bestType;
156 } 157 }
157 } 158 }
158 return null; 159 return null;
159 } 160 }
160 } 161 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698