Skip to content

Commit dbfcf55

Browse files
DanTupCommit Queue
authored andcommitted
[analysis_server] Add isDeprecated flag to editable arguments
See flutter/devtools#8930 Change-Id: Ia23ff0659973971393e31bc6f00bd9104bd2c67c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/411686 Reviewed-by: Elliott Brooks <[email protected]> Commit-Queue: Brian Wilkerson <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 29993c8 commit dbfcf55

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed

pkg/analysis_server/lib/src/lsp/handlers/custom/editable_arguments/handler_editable_arguments.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ class EditableArgumentsHandler
239239
isRequired: parameter.isRequired,
240240
isNullable:
241241
parameter.type.nullabilitySuffix == NullabilitySuffix.question,
242+
isDeprecated: parameter.metadata2.hasDeprecated,
242243
isEditable: notEditableReason == null,
243244
notEditableReason: notEditableReason,
244245
);

pkg/analysis_server/test/shared/shared_editable_arguments_tests.dart

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ $content
7878
Object? defaultValue = anything,
7979
Object? isRequired = anything,
8080
Object? isNullable = anything,
81+
Object? isDeprecated = anything,
8182
Object? isEditable = anything,
8283
Object? notEditableReason = anything,
8384
Object? options = anything,
@@ -92,6 +93,7 @@ $content
9293
.having((arg) => arg.defaultValue, 'defaultValue', defaultValue)
9394
.having((arg) => arg.isRequired, 'isRequired', isRequired)
9495
.having((arg) => arg.isNullable, 'isNullable', isNullable)
96+
.having((arg) => arg.isDeprecated, 'isDeprecated', isDeprecated)
9597
.having((arg) => arg.isEditable, 'isEditable', isEditable)
9698
.having(
9799
(arg) => arg.notEditableReason,
@@ -349,6 +351,31 @@ class MyWidget extends StatelessWidget {
349351
);
350352
}
351353

354+
Future<void> test_isDeprecated() async {
355+
var result = await getEditableArgumentsFor('''
356+
class MyWidget extends StatelessWidget {
357+
/// Creates a MyWidget.
358+
const MyWidget(
359+
@deprecated
360+
int aDeprecated,
361+
int aNotDeprecated,
362+
);
363+
364+
@override
365+
Widget build(BuildContext context) => MyW^idget(1, 2);
366+
}
367+
''');
368+
expect(
369+
result,
370+
hasArgs(
371+
unorderedEquals([
372+
isArg('aDeprecated', isDeprecated: true),
373+
isArg('aNotDeprecated', isDeprecated: false),
374+
]),
375+
),
376+
);
377+
}
378+
352379
Future<void> test_isEditable_false_positional_optional() async {
353380
var result = await getEditableArgumentsFor(r'''
354381
class MyWidget extends StatelessWidget {

pkg/analysis_server/tool/lsp_spec/generate_all.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,11 @@ List<LspEntity> getCustomClasses() {
496496
'Whether this argument can be `null`.\n\nIt is possible for an '
497497
'argument to be required, but still allow an explicit `null`.',
498498
),
499+
field(
500+
'isDeprecated',
501+
type: 'boolean',
502+
comment: 'Whether the parameter is deprecated.',
503+
),
499504
field(
500505
'isEditable',
501506
type: 'boolean',

third_party/pkg/language_server_protocol/lib/protocol_custom_generated.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,6 +1457,9 @@ class EditableArgument implements ToJsonable {
14571457
/// parameter default or null.
14581458
final bool hasArgument;
14591459

1460+
/// Whether the parameter is deprecated.
1461+
final bool isDeprecated;
1462+
14601463
/// Whether this argument can be add/edited.
14611464
///
14621465
/// If not, notEditableReason will contain an explanation for why.
@@ -1503,6 +1506,7 @@ class EditableArgument implements ToJsonable {
15031506
this.displayValue,
15041507
this.documentation,
15051508
required this.hasArgument,
1509+
required this.isDeprecated,
15061510
required this.isEditable,
15071511
required this.isNullable,
15081512
required this.isRequired,
@@ -1518,6 +1522,7 @@ class EditableArgument implements ToJsonable {
15181522
displayValue,
15191523
documentation,
15201524
hasArgument,
1525+
isDeprecated,
15211526
isEditable,
15221527
isNullable,
15231528
isRequired,
@@ -1536,6 +1541,7 @@ class EditableArgument implements ToJsonable {
15361541
displayValue == other.displayValue &&
15371542
documentation == other.documentation &&
15381543
hasArgument == other.hasArgument &&
1544+
isDeprecated == other.isDeprecated &&
15391545
isEditable == other.isEditable &&
15401546
isNullable == other.isNullable &&
15411547
isRequired == other.isRequired &&
@@ -1559,6 +1565,7 @@ class EditableArgument implements ToJsonable {
15591565
result['documentation'] = documentation;
15601566
}
15611567
result['hasArgument'] = hasArgument;
1568+
result['isDeprecated'] = isDeprecated;
15621569
result['isEditable'] = isEditable;
15631570
result['isNullable'] = isNullable;
15641571
result['isRequired'] = isRequired;
@@ -1593,6 +1600,10 @@ class EditableArgument implements ToJsonable {
15931600
allowsUndefined: false, allowsNull: false)) {
15941601
return false;
15951602
}
1603+
if (!_canParseBool(obj, reporter, 'isDeprecated',
1604+
allowsUndefined: false, allowsNull: false)) {
1605+
return false;
1606+
}
15961607
if (!_canParseBool(obj, reporter, 'isEditable',
15971608
allowsUndefined: false, allowsNull: false)) {
15981609
return false;
@@ -1634,6 +1645,8 @@ class EditableArgument implements ToJsonable {
16341645
final documentation = documentationJson as String?;
16351646
final hasArgumentJson = json['hasArgument'];
16361647
final hasArgument = hasArgumentJson as bool;
1648+
final isDeprecatedJson = json['isDeprecated'];
1649+
final isDeprecated = isDeprecatedJson as bool;
16371650
final isEditableJson = json['isEditable'];
16381651
final isEditable = isEditableJson as bool;
16391652
final isNullableJson = json['isNullable'];
@@ -1656,6 +1669,7 @@ class EditableArgument implements ToJsonable {
16561669
displayValue: displayValue,
16571670
documentation: documentation,
16581671
hasArgument: hasArgument,
1672+
isDeprecated: isDeprecated,
16591673
isEditable: isEditable,
16601674
isNullable: isNullable,
16611675
isRequired: isRequired,

0 commit comments

Comments
 (0)