Skip to content

Commit

Permalink
Correct LSP completion relevance to add maximum boost instead of all …
Browse files Browse the repository at this point in the history
…boosts

Equiv change to JetBrains/intellij-plugins#660.

Change-Id: I93192588de11afc1828b1f26e8f14f9b836cfd19
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/104982
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
  • Loading branch information
DanTup authored and commit-bot@chromium.org committed Jun 5, 2019
1 parent 42688f9 commit 94968f9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/analysis_server/lib/src/lsp/mapping.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.

import 'dart:collection';
import 'dart:math';

import 'package:analysis_server/lsp_protocol/protocol_custom_generated.dart'
as lsp;
Expand Down Expand Up @@ -159,10 +160,11 @@ lsp.CompletionItem declarationToCompletionItem(
final completionKind = declarationKindToCompletionItemKind(
supportedCompletionItemKinds, declaration.kind);

var itemRelevance = includedSuggestionSet.relevance;
var relevanceBoost = 0;
if (declaration.relevanceTags != null)
declaration.relevanceTags
.forEach((t) => itemRelevance += (tagBoosts[t] ?? 0));
declaration.relevanceTags.forEach(
(t) => relevanceBoost = max(relevanceBoost, tagBoosts[t] ?? 0));
final itemRelevance = includedSuggestionSet.relevance + relevanceBoost;

// Because we potentially send thousands of these items, we should minimise
// the generated JSON as much as possible - for example using nulls in place
Expand Down

0 comments on commit 94968f9

Please sign in to comment.