Skip to content

Commit c4a2efd

Browse files
DanTupcommit-bot@chromium.org
authored andcommitted
Switch all generated LSP classes to use named constructor arguments
Change-Id: I111b58fa5d04314247d5f92650491cdeef6bd4a3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153841 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Danny Tuppeny <[email protected]>
1 parent 6db0396 commit c4a2efd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1880
-1318
lines changed

pkg/analysis_server/lib/lsp_protocol/protocol_custom_generated.dart

Lines changed: 68 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,22 @@ import 'package:analysis_server/src/lsp/json_parsing.dart';
2222
import 'package:analysis_server/src/protocol/protocol_internal.dart'
2323
show listEqual, mapEqual;
2424
import 'package:analyzer/src/generated/utilities_general.dart';
25+
import 'package:meta/meta.dart';
2526

2627
const jsonEncoder = JsonEncoder.withIndent(' ');
2728

2829
class AnalyzerStatusParams implements ToJsonable {
2930
static const jsonHandler = LspJsonHandler(
3031
AnalyzerStatusParams.canParse, AnalyzerStatusParams.fromJson);
3132

32-
AnalyzerStatusParams(this.isAnalyzing) {
33+
AnalyzerStatusParams({@required this.isAnalyzing}) {
3334
if (isAnalyzing == null) {
3435
throw 'isAnalyzing is required but was not provided';
3536
}
3637
}
3738
static AnalyzerStatusParams fromJson(Map<String, dynamic> json) {
3839
final isAnalyzing = json['isAnalyzing'];
39-
return AnalyzerStatusParams(isAnalyzing);
40+
return AnalyzerStatusParams(isAnalyzing: isAnalyzing);
4041
}
4142

4243
final bool isAnalyzing;
@@ -98,7 +99,7 @@ class ClosingLabel implements ToJsonable {
9899
static const jsonHandler =
99100
LspJsonHandler(ClosingLabel.canParse, ClosingLabel.fromJson);
100101

101-
ClosingLabel(this.range, this.label) {
102+
ClosingLabel({@required this.range, @required this.label}) {
102103
if (range == null) {
103104
throw 'range is required but was not provided';
104105
}
@@ -109,7 +110,7 @@ class ClosingLabel implements ToJsonable {
109110
static ClosingLabel fromJson(Map<String, dynamic> json) {
110111
final range = json['range'] != null ? Range.fromJson(json['range']) : null;
111112
final label = json['label'];
112-
return ClosingLabel(range, label);
113+
return ClosingLabel(range: range, label: label);
113114
}
114115

115116
final String label;
@@ -190,8 +191,13 @@ class CompletionItemResolutionInfo implements ToJsonable {
190191
CompletionItemResolutionInfo.canParse,
191192
CompletionItemResolutionInfo.fromJson);
192193

193-
CompletionItemResolutionInfo(this.file, this.offset, this.libId,
194-
this.displayUri, this.rOffset, this.rLength) {
194+
CompletionItemResolutionInfo(
195+
{@required this.file,
196+
@required this.offset,
197+
@required this.libId,
198+
@required this.displayUri,
199+
@required this.rOffset,
200+
@required this.rLength}) {
195201
if (file == null) {
196202
throw 'file is required but was not provided';
197203
}
@@ -219,7 +225,12 @@ class CompletionItemResolutionInfo implements ToJsonable {
219225
final rOffset = json['rOffset'];
220226
final rLength = json['rLength'];
221227
return CompletionItemResolutionInfo(
222-
file, offset, libId, displayUri, rOffset, rLength);
228+
file: file,
229+
offset: offset,
230+
libId: libId,
231+
displayUri: displayUri,
232+
rOffset: rOffset,
233+
rLength: rLength);
223234
}
224235

225236
final String displayUri;
@@ -389,14 +400,14 @@ class DartDiagnosticServer implements ToJsonable {
389400
static const jsonHandler = LspJsonHandler(
390401
DartDiagnosticServer.canParse, DartDiagnosticServer.fromJson);
391402

392-
DartDiagnosticServer(this.port) {
403+
DartDiagnosticServer({@required this.port}) {
393404
if (port == null) {
394405
throw 'port is required but was not provided';
395406
}
396407
}
397408
static DartDiagnosticServer fromJson(Map<String, dynamic> json) {
398409
final port = json['port'];
399-
return DartDiagnosticServer(port);
410+
return DartDiagnosticServer(port: port);
400411
}
401412

402413
final num port;
@@ -456,8 +467,13 @@ class DartDiagnosticServer implements ToJsonable {
456467
class Element implements ToJsonable {
457468
static const jsonHandler = LspJsonHandler(Element.canParse, Element.fromJson);
458469

459-
Element(this.range, this.name, this.kind, this.parameters,
460-
this.typeParameters, this.returnType) {
470+
Element(
471+
{this.range,
472+
@required this.name,
473+
@required this.kind,
474+
this.parameters,
475+
this.typeParameters,
476+
this.returnType}) {
461477
if (name == null) {
462478
throw 'name is required but was not provided';
463479
}
@@ -472,7 +488,13 @@ class Element implements ToJsonable {
472488
final parameters = json['parameters'];
473489
final typeParameters = json['typeParameters'];
474490
final returnType = json['returnType'];
475-
return Element(range, name, kind, parameters, typeParameters, returnType);
491+
return Element(
492+
range: range,
493+
name: name,
494+
kind: kind,
495+
parameters: parameters,
496+
typeParameters: typeParameters,
497+
returnType: returnType);
476498
}
477499

478500
final String kind;
@@ -616,15 +638,15 @@ class FlutterOutline implements ToJsonable {
616638
LspJsonHandler(FlutterOutline.canParse, FlutterOutline.fromJson);
617639

618640
FlutterOutline(
619-
this.kind,
641+
{@required this.kind,
620642
this.label,
621643
this.className,
622644
this.variableName,
623645
this.attributes,
624646
this.dartElement,
625-
this.range,
626-
this.codeRange,
627-
this.children) {
647+
@required this.range,
648+
@required this.codeRange,
649+
this.children}) {
628650
if (kind == null) {
629651
throw 'kind is required but was not provided';
630652
}
@@ -655,8 +677,16 @@ class FlutterOutline implements ToJsonable {
655677
?.map((item) => item != null ? FlutterOutline.fromJson(item) : null)
656678
?.cast<FlutterOutline>()
657679
?.toList();
658-
return FlutterOutline(kind, label, className, variableName, attributes,
659-
dartElement, range, codeRange, children);
680+
return FlutterOutline(
681+
kind: kind,
682+
label: label,
683+
className: className,
684+
variableName: variableName,
685+
attributes: attributes,
686+
dartElement: dartElement,
687+
range: range,
688+
codeRange: codeRange,
689+
children: children);
660690
}
661691

662692
final List<FlutterOutlineAttribute> attributes;
@@ -862,7 +892,8 @@ class FlutterOutlineAttribute implements ToJsonable {
862892
static const jsonHandler = LspJsonHandler(
863893
FlutterOutlineAttribute.canParse, FlutterOutlineAttribute.fromJson);
864894

865-
FlutterOutlineAttribute(this.name, this.label, this.valueRange) {
895+
FlutterOutlineAttribute(
896+
{@required this.name, @required this.label, this.valueRange}) {
866897
if (name == null) {
867898
throw 'name is required but was not provided';
868899
}
@@ -875,7 +906,8 @@ class FlutterOutlineAttribute implements ToJsonable {
875906
final label = json['label'];
876907
final valueRange =
877908
json['valueRange'] != null ? Range.fromJson(json['valueRange']) : null;
878-
return FlutterOutlineAttribute(name, label, valueRange);
909+
return FlutterOutlineAttribute(
910+
name: name, label: label, valueRange: valueRange);
879911
}
880912

881913
final String label;
@@ -973,7 +1005,11 @@ class FlutterOutlineAttribute implements ToJsonable {
9731005
class Outline implements ToJsonable {
9741006
static const jsonHandler = LspJsonHandler(Outline.canParse, Outline.fromJson);
9751007

976-
Outline(this.element, this.range, this.codeRange, this.children) {
1008+
Outline(
1009+
{@required this.element,
1010+
@required this.range,
1011+
@required this.codeRange,
1012+
this.children}) {
9771013
if (element == null) {
9781014
throw 'element is required but was not provided';
9791015
}
@@ -994,7 +1030,11 @@ class Outline implements ToJsonable {
9941030
?.map((item) => item != null ? Outline.fromJson(item) : null)
9951031
?.cast<Outline>()
9961032
?.toList();
997-
return Outline(element, range, codeRange, children);
1033+
return Outline(
1034+
element: element,
1035+
range: range,
1036+
codeRange: codeRange,
1037+
children: children);
9981038
}
9991039

10001040
final List<Outline> children;
@@ -1118,7 +1158,7 @@ class PublishClosingLabelsParams implements ToJsonable {
11181158
static const jsonHandler = LspJsonHandler(
11191159
PublishClosingLabelsParams.canParse, PublishClosingLabelsParams.fromJson);
11201160

1121-
PublishClosingLabelsParams(this.uri, this.labels) {
1161+
PublishClosingLabelsParams({@required this.uri, @required this.labels}) {
11221162
if (uri == null) {
11231163
throw 'uri is required but was not provided';
11241164
}
@@ -1132,7 +1172,7 @@ class PublishClosingLabelsParams implements ToJsonable {
11321172
?.map((item) => item != null ? ClosingLabel.fromJson(item) : null)
11331173
?.cast<ClosingLabel>()
11341174
?.toList();
1135-
return PublishClosingLabelsParams(uri, labels);
1175+
return PublishClosingLabelsParams(uri: uri, labels: labels);
11361176
}
11371177

11381178
final List<ClosingLabel> labels;
@@ -1219,7 +1259,7 @@ class PublishFlutterOutlineParams implements ToJsonable {
12191259
PublishFlutterOutlineParams.canParse,
12201260
PublishFlutterOutlineParams.fromJson);
12211261

1222-
PublishFlutterOutlineParams(this.uri, this.outline) {
1262+
PublishFlutterOutlineParams({@required this.uri, @required this.outline}) {
12231263
if (uri == null) {
12241264
throw 'uri is required but was not provided';
12251265
}
@@ -1232,7 +1272,7 @@ class PublishFlutterOutlineParams implements ToJsonable {
12321272
final outline = json['outline'] != null
12331273
? FlutterOutline.fromJson(json['outline'])
12341274
: null;
1235-
return PublishFlutterOutlineParams(uri, outline);
1275+
return PublishFlutterOutlineParams(uri: uri, outline: outline);
12361276
}
12371277

12381278
final FlutterOutline outline;
@@ -1314,7 +1354,7 @@ class PublishOutlineParams implements ToJsonable {
13141354
static const jsonHandler = LspJsonHandler(
13151355
PublishOutlineParams.canParse, PublishOutlineParams.fromJson);
13161356

1317-
PublishOutlineParams(this.uri, this.outline) {
1357+
PublishOutlineParams({@required this.uri, @required this.outline}) {
13181358
if (uri == null) {
13191359
throw 'uri is required but was not provided';
13201360
}
@@ -1326,7 +1366,7 @@ class PublishOutlineParams implements ToJsonable {
13261366
final uri = json['uri'];
13271367
final outline =
13281368
json['outline'] != null ? Outline.fromJson(json['outline']) : null;
1329-
return PublishOutlineParams(uri, outline);
1369+
return PublishOutlineParams(uri: uri, outline: outline);
13301370
}
13311371

13321372
final Outline outline;

0 commit comments

Comments
 (0)