Skip to content

Commit

Permalink
Switch all generated LSP classes to use named constructor arguments
Browse files Browse the repository at this point in the history
Change-Id: I111b58fa5d04314247d5f92650491cdeef6bd4a3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153841
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <danny@tuppeny.com>
  • Loading branch information
DanTup authored and commit-bot@chromium.org committed Jul 9, 2020
1 parent 6db0396 commit c4a2efd
Show file tree
Hide file tree
Showing 51 changed files with 1,880 additions and 1,318 deletions.
96 changes: 68 additions & 28 deletions pkg/analysis_server/lib/lsp_protocol/protocol_custom_generated.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,22 @@ import 'package:analysis_server/src/lsp/json_parsing.dart';
import 'package:analysis_server/src/protocol/protocol_internal.dart'
show listEqual, mapEqual;
import 'package:analyzer/src/generated/utilities_general.dart';
import 'package:meta/meta.dart';

const jsonEncoder = JsonEncoder.withIndent(' ');

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

AnalyzerStatusParams(this.isAnalyzing) {
AnalyzerStatusParams({@required this.isAnalyzing}) {
if (isAnalyzing == null) {
throw 'isAnalyzing is required but was not provided';
}
}
static AnalyzerStatusParams fromJson(Map<String, dynamic> json) {
final isAnalyzing = json['isAnalyzing'];
return AnalyzerStatusParams(isAnalyzing);
return AnalyzerStatusParams(isAnalyzing: isAnalyzing);
}

final bool isAnalyzing;
Expand Down Expand Up @@ -98,7 +99,7 @@ class ClosingLabel implements ToJsonable {
static const jsonHandler =
LspJsonHandler(ClosingLabel.canParse, ClosingLabel.fromJson);

ClosingLabel(this.range, this.label) {
ClosingLabel({@required this.range, @required this.label}) {
if (range == null) {
throw 'range is required but was not provided';
}
Expand All @@ -109,7 +110,7 @@ class ClosingLabel implements ToJsonable {
static ClosingLabel fromJson(Map<String, dynamic> json) {
final range = json['range'] != null ? Range.fromJson(json['range']) : null;
final label = json['label'];
return ClosingLabel(range, label);
return ClosingLabel(range: range, label: label);
}

final String label;
Expand Down Expand Up @@ -190,8 +191,13 @@ class CompletionItemResolutionInfo implements ToJsonable {
CompletionItemResolutionInfo.canParse,
CompletionItemResolutionInfo.fromJson);

CompletionItemResolutionInfo(this.file, this.offset, this.libId,
this.displayUri, this.rOffset, this.rLength) {
CompletionItemResolutionInfo(
{@required this.file,
@required this.offset,
@required this.libId,
@required this.displayUri,
@required this.rOffset,
@required this.rLength}) {
if (file == null) {
throw 'file is required but was not provided';
}
Expand Down Expand Up @@ -219,7 +225,12 @@ class CompletionItemResolutionInfo implements ToJsonable {
final rOffset = json['rOffset'];
final rLength = json['rLength'];
return CompletionItemResolutionInfo(
file, offset, libId, displayUri, rOffset, rLength);
file: file,
offset: offset,
libId: libId,
displayUri: displayUri,
rOffset: rOffset,
rLength: rLength);
}

final String displayUri;
Expand Down Expand Up @@ -389,14 +400,14 @@ class DartDiagnosticServer implements ToJsonable {
static const jsonHandler = LspJsonHandler(
DartDiagnosticServer.canParse, DartDiagnosticServer.fromJson);

DartDiagnosticServer(this.port) {
DartDiagnosticServer({@required this.port}) {
if (port == null) {
throw 'port is required but was not provided';
}
}
static DartDiagnosticServer fromJson(Map<String, dynamic> json) {
final port = json['port'];
return DartDiagnosticServer(port);
return DartDiagnosticServer(port: port);
}

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

Element(this.range, this.name, this.kind, this.parameters,
this.typeParameters, this.returnType) {
Element(
{this.range,
@required this.name,
@required this.kind,
this.parameters,
this.typeParameters,
this.returnType}) {
if (name == null) {
throw 'name is required but was not provided';
}
Expand All @@ -472,7 +488,13 @@ class Element implements ToJsonable {
final parameters = json['parameters'];
final typeParameters = json['typeParameters'];
final returnType = json['returnType'];
return Element(range, name, kind, parameters, typeParameters, returnType);
return Element(
range: range,
name: name,
kind: kind,
parameters: parameters,
typeParameters: typeParameters,
returnType: returnType);
}

final String kind;
Expand Down Expand Up @@ -616,15 +638,15 @@ class FlutterOutline implements ToJsonable {
LspJsonHandler(FlutterOutline.canParse, FlutterOutline.fromJson);

FlutterOutline(
this.kind,
{@required this.kind,
this.label,
this.className,
this.variableName,
this.attributes,
this.dartElement,
this.range,
this.codeRange,
this.children) {
@required this.range,
@required this.codeRange,
this.children}) {
if (kind == null) {
throw 'kind is required but was not provided';
}
Expand Down Expand Up @@ -655,8 +677,16 @@ class FlutterOutline implements ToJsonable {
?.map((item) => item != null ? FlutterOutline.fromJson(item) : null)
?.cast<FlutterOutline>()
?.toList();
return FlutterOutline(kind, label, className, variableName, attributes,
dartElement, range, codeRange, children);
return FlutterOutline(
kind: kind,
label: label,
className: className,
variableName: variableName,
attributes: attributes,
dartElement: dartElement,
range: range,
codeRange: codeRange,
children: children);
}

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

FlutterOutlineAttribute(this.name, this.label, this.valueRange) {
FlutterOutlineAttribute(
{@required this.name, @required this.label, this.valueRange}) {
if (name == null) {
throw 'name is required but was not provided';
}
Expand All @@ -875,7 +906,8 @@ class FlutterOutlineAttribute implements ToJsonable {
final label = json['label'];
final valueRange =
json['valueRange'] != null ? Range.fromJson(json['valueRange']) : null;
return FlutterOutlineAttribute(name, label, valueRange);
return FlutterOutlineAttribute(
name: name, label: label, valueRange: valueRange);
}

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

Outline(this.element, this.range, this.codeRange, this.children) {
Outline(
{@required this.element,
@required this.range,
@required this.codeRange,
this.children}) {
if (element == null) {
throw 'element is required but was not provided';
}
Expand All @@ -994,7 +1030,11 @@ class Outline implements ToJsonable {
?.map((item) => item != null ? Outline.fromJson(item) : null)
?.cast<Outline>()
?.toList();
return Outline(element, range, codeRange, children);
return Outline(
element: element,
range: range,
codeRange: codeRange,
children: children);
}

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

PublishClosingLabelsParams(this.uri, this.labels) {
PublishClosingLabelsParams({@required this.uri, @required this.labels}) {
if (uri == null) {
throw 'uri is required but was not provided';
}
Expand All @@ -1132,7 +1172,7 @@ class PublishClosingLabelsParams implements ToJsonable {
?.map((item) => item != null ? ClosingLabel.fromJson(item) : null)
?.cast<ClosingLabel>()
?.toList();
return PublishClosingLabelsParams(uri, labels);
return PublishClosingLabelsParams(uri: uri, labels: labels);
}

final List<ClosingLabel> labels;
Expand Down Expand Up @@ -1219,7 +1259,7 @@ class PublishFlutterOutlineParams implements ToJsonable {
PublishFlutterOutlineParams.canParse,
PublishFlutterOutlineParams.fromJson);

PublishFlutterOutlineParams(this.uri, this.outline) {
PublishFlutterOutlineParams({@required this.uri, @required this.outline}) {
if (uri == null) {
throw 'uri is required but was not provided';
}
Expand All @@ -1232,7 +1272,7 @@ class PublishFlutterOutlineParams implements ToJsonable {
final outline = json['outline'] != null
? FlutterOutline.fromJson(json['outline'])
: null;
return PublishFlutterOutlineParams(uri, outline);
return PublishFlutterOutlineParams(uri: uri, outline: outline);
}

final FlutterOutline outline;
Expand Down Expand Up @@ -1314,7 +1354,7 @@ class PublishOutlineParams implements ToJsonable {
static const jsonHandler = LspJsonHandler(
PublishOutlineParams.canParse, PublishOutlineParams.fromJson);

PublishOutlineParams(this.uri, this.outline) {
PublishOutlineParams({@required this.uri, @required this.outline}) {
if (uri == null) {
throw 'uri is required but was not provided';
}
Expand All @@ -1326,7 +1366,7 @@ class PublishOutlineParams implements ToJsonable {
final uri = json['uri'];
final outline =
json['outline'] != null ? Outline.fromJson(json['outline']) : null;
return PublishOutlineParams(uri, outline);
return PublishOutlineParams(uri: uri, outline: outline);
}

final Outline outline;
Expand Down
Loading

0 comments on commit c4a2efd

Please sign in to comment.