Skip to content

Commit

Permalink
Ensure we have a matcher score for every suggestion
Browse files Browse the repository at this point in the history
Change-Id: I1b2ae695deeaec05d11ca40d1367883667e4fee0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370300
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
  • Loading branch information
bwilkerson authored and Commit Queue committed Jun 10, 2024
1 parent 5e595d3 commit 7d7596f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class DeclarationHelper {

if (importElement.prefix case var importPrefix?) {
if (importPrefix is DeferredImportElementPrefix) {
var matcherScore = state.matcher.score(importedLibrary.displayName);
var matcherScore = state.matcher.score('loadLibrary');
if (matcherScore != -1) {
collector.addSuggestion(
LoadLibraryFunctionSuggestion(
Expand Down Expand Up @@ -1604,7 +1604,10 @@ class DeclarationHelper {

/// Adds a suggestion for the method `call` defined on the class `Function`.
void _suggestFunctionCall() {
collector.addSuggestion(FunctionCall(matcherScore: 0));
var matcherScore = state.matcher.score('call');
if (matcherScore != -1) {
collector.addSuggestion(FunctionCall(matcherScore: matcherScore));
}
}

/// Adds a suggestion for the local function represented by the [element].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'dart:math' as math;

import 'package:analysis_server/src/services/completion/dart/candidate_suggestion.dart';
import 'package:analysis_server/src/services/completion/dart/completion_state.dart';
import 'package:analysis_server/src/services/completion/dart/suggestion_collector.dart';
Expand Down Expand Up @@ -42,9 +44,10 @@ class OverrideHelper {
// Gracefully degrade if the overridden element has not been resolved.
if (element != null) {
var invokeSuper = interface.isSuperImplemented(name);
// TODO(keertip): Use both "override" and the name of the overridden
// member to compute the score.
var matcherScore = 0.0;
var matcherScore = math.max(
math.max(state.matcher.score('override'),
state.matcher.score('operator')),
state.matcher.score(element.displayName));
if (matcherScore != -1) {
collector.addSuggestion(
OverrideSuggestion(
Expand Down

0 comments on commit 7d7596f

Please sign in to comment.