[analysis_server] Don't show field modifiers in signature help for primary constructors
Fixes https://github.com/dart-lang/sdk/issues/63560 Change-Id: I2c93e4a1011075e103d9165d0664f588f3109c40 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/510821 Commit-Queue: Keerti Parthasarathy <keertip@google.com> Reviewed-by: Keerti Parthasarathy <keertip@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
committed by
dart-scoped@luci-project-accounts.iam.gserviceaccount.com
parent
44bb92f49a
commit
eb979c2f0c
@@ -1538,17 +1538,9 @@ lsp.SignatureHelp toSignatureHelp(
|
||||
? ' = ${p.defaultValueCode}'
|
||||
: '';
|
||||
|
||||
var hasFinal = p is FieldFormalParameterElement
|
||||
? (p.field?.isFinal ?? false)
|
||||
: p.isFinal;
|
||||
var hasVar = p is FieldFormalParameterElement && p.isDeclaring && !hasFinal;
|
||||
var prefix = p.isRequiredNamed ? 'required ' : '';
|
||||
|
||||
var prefixes = [
|
||||
if (hasFinal) 'final ',
|
||||
if (hasVar) 'var ',
|
||||
if (p.isRequiredNamed) 'required ',
|
||||
];
|
||||
return '${prefixes.join()}${p.type} ${p.displayName}$defaultCodeSuffix';
|
||||
return '$prefix${p.type} ${p.displayName}$defaultCodeSuffix';
|
||||
}
|
||||
|
||||
/// Gets the full signature label in the form
|
||||
|
||||
@@ -663,6 +663,8 @@ final a = A(^);
|
||||
);
|
||||
}
|
||||
|
||||
/// Keywords for declaraing parameters should not be shown because they don't
|
||||
/// change the parameters and are just visual noise.
|
||||
Future<void> test_params_final() async {
|
||||
var content = '''
|
||||
foo(final String s) {
|
||||
@@ -670,12 +672,12 @@ foo(final String s) {
|
||||
}
|
||||
''';
|
||||
|
||||
var expectedLabel = 'foo(final String s)';
|
||||
var expectedLabel = 'foo(String s)';
|
||||
|
||||
await _expectSignature(
|
||||
content,
|
||||
expectedLabel,
|
||||
expectedParams: [ParameterInformation(label: 'final String s')],
|
||||
expectedParams: [ParameterInformation(label: 'String s')],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -798,10 +800,10 @@ class A(final int x, var int y, int z);
|
||||
|
||||
final a = A(^);
|
||||
''';
|
||||
var expectedLabel = 'A(final int x, var int y, int z)';
|
||||
var expectedLabel = 'A(int x, int y, int z)';
|
||||
var expectedParams = [
|
||||
ParameterInformation(label: 'final int x'),
|
||||
ParameterInformation(label: 'var int y'),
|
||||
ParameterInformation(label: 'int x'),
|
||||
ParameterInformation(label: 'int y'),
|
||||
ParameterInformation(label: 'int z'),
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user