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/dart/completion_manager.dart

Issue 1536823002: merge completion suggestions based upon relevance (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge Created 5 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
« no previous file with comments | « no previous file | pkg/analysis_server/test/domain_completion_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.dart.manager; 5 library services.completion.dart.manager;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/plugin/protocol/protocol.dart'; 9 import 'package:analysis_server/plugin/protocol/protocol.dart';
10 import 'package:analysis_server/src/provisional/completion/completion_core.dart' 10 import 'package:analysis_server/src/provisional/completion/completion_core.dart'
(...skipping 29 matching lines...) Expand all
40 40
41 DartCompletionRequestImpl dartRequest = 41 DartCompletionRequestImpl dartRequest =
42 await DartCompletionRequestImpl.from(request); 42 await DartCompletionRequestImpl.from(request);
43 43
44 // Don't suggest in comments. 44 // Don't suggest in comments.
45 if (dartRequest.target.isCommentText) { 45 if (dartRequest.target.isCommentText) {
46 return EMPTY_LIST; 46 return EMPTY_LIST;
47 } 47 }
48 48
49 // Request Dart specific completions from each contributor 49 // Request Dart specific completions from each contributor
50 List<CompletionSuggestion> suggestions = <CompletionSuggestion>[]; 50 Map<String, CompletionSuggestion> suggestionMap =
51 for (DartCompletionContributor c in dartCompletionPlugin.contributors) { 51 <String, CompletionSuggestion>{};
52 suggestions.addAll(await c.computeSuggestions(dartRequest)); 52 for (DartCompletionContributor contributor
53 in dartCompletionPlugin.contributors) {
54 for (CompletionSuggestion newSuggestion
55 in await contributor.computeSuggestions(dartRequest)) {
56 var oldSuggestion = suggestionMap.putIfAbsent(
57 newSuggestion.completion, () => newSuggestion);
58 if (newSuggestion != oldSuggestion &&
59 newSuggestion.relevance > oldSuggestion.relevance) {
60 suggestionMap[newSuggestion.completion] = newSuggestion;
61 }
62 }
53 } 63 }
54 return suggestions; 64 return suggestionMap.values.toList();
55 } 65 }
56 } 66 }
57 67
58 /** 68 /**
59 * The information about a requested list of completions within a Dart file. 69 * The information about a requested list of completions within a Dart file.
60 */ 70 */
61 class DartCompletionRequestImpl extends CompletionRequestImpl 71 class DartCompletionRequestImpl extends CompletionRequestImpl
62 implements DartCompletionRequest { 72 implements DartCompletionRequest {
63 /** 73 /**
64 * The [LibraryElement] representing dart:core 74 * The [LibraryElement] representing dart:core
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 if (dartRequest.target.maybeFunctionalArgument()) { 271 if (dartRequest.target.maybeFunctionalArgument()) {
262 AstNode node = dartRequest.target.containingNode.parent; 272 AstNode node = dartRequest.target.containingNode.parent;
263 if (node is Expression) { 273 if (node is Expression) {
264 await dartRequest.resolveExpression(node); 274 await dartRequest.resolveExpression(node);
265 } 275 }
266 } 276 }
267 277
268 return dartRequest; 278 return dartRequest;
269 } 279 }
270 } 280 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/test/domain_completion_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698