Files
sdk/pkg/analyzer_plugin/lib/utilities/completion/relevance.dart
T
Brian Wilkerson 216b9d65d8 Change the range of values for features so that features are never disabled
I believe that this approach will make it much easier for us to make
changes to the ranking order for some suggestions without significantly
changing the ranking order of others. In particular, adding a negative
feature for a subset of suggestions (such as decreasing the rank of
methods named 'noSuchMethod') currently has the effect of decreasing the
rank of everything that isn't a method. This solved that problem by
giving all features a baseline of zero and allowing features to either
increment or decrement the rank from there.

This CL has minimal overall impact on ranking except in the following
areas (values are the inverse mrr):
- keyword void, which regresses from 150.766 to 237.838 (87.071 points)
- local function, which regresses from 24.941 to 173.016 (148.075 points)
- prefix, which improves from 386.455 to 361.611 (24.844 points)
- type parameter, which improves from 269.235 to 249.489 (19.746 points)

The change to 'keyword void' largely shows up in return types of function
declarations, but interestingly enough has little impact on the return
type of method declarations. We might be able to offset this by treating
`void` (and `dynamic`) as types rather than as keywords. I've added that
work item to the list.

The change to local functions doesn't appear to impact any individual
location significantly, and might not be significantly detrimental
because local functions are probably not all that common.

Change-Id: Ifc7002cd6a9d656792ad4ffd76d96df2ab50e4a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/181900
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-02-01 16:00:58 +00:00

70 lines
2.6 KiB
Dart

// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
// 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.
//
// Constant values used for relevance values when creating completion
// suggestions in Dart code.
//
const int DART_RELEVANCE_DEFAULT = 1000;
const int DART_RELEVANCE_HIGH = 2000;
const int DART_RELEVANCE_LOW = 500;
/// A name scope for constants that are related to the relevance of completion
/// suggestions. The values are required to be in the range [0, 1000].
abstract class Relevance {
/// The relevance used when suggesting a `call` method that is implied by a
/// type but isn't explicitly implemented in the type hierarchy.
static const int callFunction = 200;
/// The relevance used when suggesting a closure corresponding to a
/// function-typed parameter in an argument list.
static const int closure = 900;
/// The relevance used when suggesting a constructor.
static const int constructor = 900;
/// The relevance used when suggesting a field as a field formal parameter.
static const int fieldFormalParameter = 1000;
/// The relevance used when suggesting an import of a library other than
/// `dart:core`.
static const int import = 900;
/// The relevance used when suggesting an import of `dart:core`.
static const int importDartCore = 100;
/// The relevance used when suggesting a label.
static const int label = 1000;
/// The relevance used when suggesting the `loadLibrary` function from a
/// deferred imported library.
static const int loadLibrary = 200;
/// The relevance used when suggesting a named argument corresponding to a
/// named parameter that is not required.
static const int namedArgument = 900;
/// The relevance used when suggesting a named constructor.
static const int namedConstructor = 1000;
/// The relevance used when suggesting an override of an inherited member.
static const int override = 750;
/// The relevance used when suggesting a named argument corresponding to a
/// named parameter that is required.
static const int requiredNamedArgument = 950;
}
/// A name scope for constants that are related to the relevance of completion
/// suggestions. The values are required to be in the range [0, 1000].
abstract class RelevanceBoost {
/// The relevance boost used when suggesting anything other than an enum
/// constant from an available declaration set.
static const int availableDeclaration = 10;
/// The relevance boost used when suggesting an enum constant from an
/// available declaration set.
static const int availableEnumConstant = 250;
}