blob: 736dda02b31963739996ebf91709d5f9ab58a3e7 [file]
// Copyright (c) 2018, 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.
// This file has been automatically generated. Please do not edit it manually.
// To regenerate the file, use the script
// "pkg/analysis_server/tool/lsp_spec/generate_all.dart".
// ignore_for_file: annotate_overrides
// ignore_for_file: prefer_is_not_operator
// ignore_for_file: unnecessary_parenthesis
import 'dart:core' hide deprecated;
import 'dart:core' as core show deprecated;
import 'dart:convert' show JsonEncoder;
import 'package:analysis_server/lsp_protocol/protocol_custom_generated.dart';
import 'package:analysis_server/lsp_protocol/protocol_special.dart';
import 'package:analysis_server/src/lsp/json_parsing.dart';
import 'package:analysis_server/src/protocol/protocol_internal.dart';
const jsonEncoder = JsonEncoder.withIndent(' ');
/// A special text edit with an additional change annotation.
/// @since 3.16.0.
class AnnotatedTextEdit implements TextEdit, ToJsonable {
static const jsonHandler = LspJsonHandler(
AnnotatedTextEdit.canParse,
AnnotatedTextEdit.fromJson,
);
AnnotatedTextEdit({
required this.annotationId,
required this.newText,
required this.range,
});
static AnnotatedTextEdit fromJson(Map<String, Object?> json) {
final annotationIdJson = json['annotationId'];
final annotationId = annotationIdJson as String;
final newTextJson = json['newText'];
final newText = newTextJson as String;
final rangeJson = json['range'];
final range = Range.fromJson(rangeJson as Map<String, Object?>);
return AnnotatedTextEdit(
annotationId: annotationId,
newText: newText,
range: range,
);
}
/// The actual annotation identifier.
final String annotationId;
/// The string to be inserted. For delete operations use an empty string.
final String newText;
/// The range of the text document to be manipulated. To insert text into a
/// document create a range where start === end.
final Range range;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['annotationId'] = annotationId;
result['newText'] = newText;
result['range'] = range.toJson();
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('annotationId');
try {
if (!obj.containsKey('annotationId')) {
reporter.reportError('must not be undefined');
return false;
}
final annotationId = obj['annotationId'];
if (annotationId == null) {
reporter.reportError('must not be null');
return false;
}
if (!(annotationId is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
reporter.push('newText');
try {
if (!obj.containsKey('newText')) {
reporter.reportError('must not be undefined');
return false;
}
final newText = obj['newText'];
if (newText == null) {
reporter.reportError('must not be null');
return false;
}
if (!(newText is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
reporter.push('range');
try {
if (!obj.containsKey('range')) {
reporter.reportError('must not be undefined');
return false;
}
final range = obj['range'];
if (range == null) {
reporter.reportError('must not be null');
return false;
}
if (!(Range.canParse(range, reporter))) {
reporter.reportError('must be of type Range');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type AnnotatedTextEdit');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is AnnotatedTextEdit && other.runtimeType == AnnotatedTextEdit) {
return annotationId == other.annotationId &&
newText == other.newText &&
range == other.range &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
annotationId,
newText,
range,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class ApplyWorkspaceEditParams implements ToJsonable {
static const jsonHandler = LspJsonHandler(
ApplyWorkspaceEditParams.canParse,
ApplyWorkspaceEditParams.fromJson,
);
ApplyWorkspaceEditParams({
required this.edit,
this.label,
});
static ApplyWorkspaceEditParams fromJson(Map<String, Object?> json) {
final editJson = json['edit'];
final edit = WorkspaceEdit.fromJson(editJson as Map<String, Object?>);
final labelJson = json['label'];
final label = labelJson as String?;
return ApplyWorkspaceEditParams(
edit: edit,
label: label,
);
}
/// The edits to apply.
final WorkspaceEdit edit;
/// An optional label of the workspace edit. This label is presented in the
/// user interface for example on an undo stack to undo the workspace edit.
final String? label;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['edit'] = edit.toJson();
if (label != null) {
result['label'] = label;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('edit');
try {
if (!obj.containsKey('edit')) {
reporter.reportError('must not be undefined');
return false;
}
final edit = obj['edit'];
if (edit == null) {
reporter.reportError('must not be null');
return false;
}
if (!(WorkspaceEdit.canParse(edit, reporter))) {
reporter.reportError('must be of type WorkspaceEdit');
return false;
}
} finally {
reporter.pop();
}
reporter.push('label');
try {
final label = obj['label'];
if (label != null && !(label is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type ApplyWorkspaceEditParams');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is ApplyWorkspaceEditParams &&
other.runtimeType == ApplyWorkspaceEditParams) {
return edit == other.edit && label == other.label && true;
}
return false;
}
@override
int get hashCode => Object.hash(
edit,
label,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class ApplyWorkspaceEditResult implements ToJsonable {
static const jsonHandler = LspJsonHandler(
ApplyWorkspaceEditResult.canParse,
ApplyWorkspaceEditResult.fromJson,
);
ApplyWorkspaceEditResult({
required this.applied,
this.failedChange,
this.failureReason,
});
static ApplyWorkspaceEditResult fromJson(Map<String, Object?> json) {
final appliedJson = json['applied'];
final applied = appliedJson as bool;
final failedChangeJson = json['failedChange'];
final failedChange = failedChangeJson as int?;
final failureReasonJson = json['failureReason'];
final failureReason = failureReasonJson as String?;
return ApplyWorkspaceEditResult(
applied: applied,
failedChange: failedChange,
failureReason: failureReason,
);
}
/// Indicates whether the edit was applied or not.
final bool applied;
/// Depending on the client's failure handling strategy `failedChange` might
/// contain the index of the change that failed. This property is only
/// available if the client signals a `failureHandling` strategy in its client
/// capabilities.
final int? failedChange;
/// An optional textual description for why the edit was not applied. This may
/// be used by the server for diagnostic logging or to provide a suitable
/// error for a request that triggered the edit.
final String? failureReason;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['applied'] = applied;
if (failedChange != null) {
result['failedChange'] = failedChange;
}
if (failureReason != null) {
result['failureReason'] = failureReason;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('applied');
try {
if (!obj.containsKey('applied')) {
reporter.reportError('must not be undefined');
return false;
}
final applied = obj['applied'];
if (applied == null) {
reporter.reportError('must not be null');
return false;
}
if (!(applied is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
reporter.push('failedChange');
try {
final failedChange = obj['failedChange'];
if (failedChange != null && !(failedChange is int)) {
reporter.reportError('must be of type int');
return false;
}
} finally {
reporter.pop();
}
reporter.push('failureReason');
try {
final failureReason = obj['failureReason'];
if (failureReason != null && !(failureReason is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type ApplyWorkspaceEditResult');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is ApplyWorkspaceEditResult &&
other.runtimeType == ApplyWorkspaceEditResult) {
return applied == other.applied &&
failedChange == other.failedChange &&
failureReason == other.failureReason &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
applied,
failedChange,
failureReason,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class CallHierarchyClientCapabilities implements ToJsonable {
static const jsonHandler = LspJsonHandler(
CallHierarchyClientCapabilities.canParse,
CallHierarchyClientCapabilities.fromJson,
);
CallHierarchyClientCapabilities({
this.dynamicRegistration,
});
static CallHierarchyClientCapabilities fromJson(Map<String, Object?> json) {
final dynamicRegistrationJson = json['dynamicRegistration'];
final dynamicRegistration = dynamicRegistrationJson as bool?;
return CallHierarchyClientCapabilities(
dynamicRegistration: dynamicRegistration,
);
}
/// Whether implementation supports dynamic registration. If this is set to
/// `true` the client supports the new `(TextDocumentRegistrationOptions &
/// StaticRegistrationOptions)` return value for the corresponding server
/// capability as well.
final bool? dynamicRegistration;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (dynamicRegistration != null) {
result['dynamicRegistration'] = dynamicRegistration;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('dynamicRegistration');
try {
final dynamicRegistration = obj['dynamicRegistration'];
if (dynamicRegistration != null && !(dynamicRegistration is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CallHierarchyClientCapabilities');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CallHierarchyClientCapabilities &&
other.runtimeType == CallHierarchyClientCapabilities) {
return dynamicRegistration == other.dynamicRegistration && true;
}
return false;
}
@override
int get hashCode => dynamicRegistration.hashCode;
@override
String toString() => jsonEncoder.convert(toJson());
}
class CallHierarchyIncomingCall implements ToJsonable {
static const jsonHandler = LspJsonHandler(
CallHierarchyIncomingCall.canParse,
CallHierarchyIncomingCall.fromJson,
);
CallHierarchyIncomingCall({
required this.from,
required this.fromRanges,
});
static CallHierarchyIncomingCall fromJson(Map<String, Object?> json) {
final fromJson = json['from'];
final from = CallHierarchyItem.fromJson(fromJson as Map<String, Object?>);
final fromRangesJson = json['fromRanges'];
final fromRanges = (fromRangesJson as List<Object?>)
.map((item) => Range.fromJson(item as Map<String, Object?>))
.toList();
return CallHierarchyIncomingCall(
from: from,
fromRanges: fromRanges,
);
}
/// The item that makes the call.
final CallHierarchyItem from;
/// The ranges at which the calls appear. This is relative to the caller
/// denoted by [`this.from`](#CallHierarchyIncomingCall.from).
final List<Range> fromRanges;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['from'] = from.toJson();
result['fromRanges'] = fromRanges.map((item) => item.toJson()).toList();
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('from');
try {
if (!obj.containsKey('from')) {
reporter.reportError('must not be undefined');
return false;
}
final from = obj['from'];
if (from == null) {
reporter.reportError('must not be null');
return false;
}
if (!(CallHierarchyItem.canParse(from, reporter))) {
reporter.reportError('must be of type CallHierarchyItem');
return false;
}
} finally {
reporter.pop();
}
reporter.push('fromRanges');
try {
if (!obj.containsKey('fromRanges')) {
reporter.reportError('must not be undefined');
return false;
}
final fromRanges = obj['fromRanges'];
if (fromRanges == null) {
reporter.reportError('must not be null');
return false;
}
if (!((fromRanges is List<Object?> &&
(fromRanges.every((item) => Range.canParse(item, reporter)))))) {
reporter.reportError('must be of type List<Range>');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CallHierarchyIncomingCall');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CallHierarchyIncomingCall &&
other.runtimeType == CallHierarchyIncomingCall) {
return from == other.from &&
listEqual(
fromRanges, other.fromRanges, (Range a, Range b) => a == b) &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
from,
lspHashCode(fromRanges),
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class CallHierarchyIncomingCallsParams
implements PartialResultParams, WorkDoneProgressParams, ToJsonable {
static const jsonHandler = LspJsonHandler(
CallHierarchyIncomingCallsParams.canParse,
CallHierarchyIncomingCallsParams.fromJson,
);
CallHierarchyIncomingCallsParams({
required this.item,
this.partialResultToken,
this.workDoneToken,
});
static CallHierarchyIncomingCallsParams fromJson(Map<String, Object?> json) {
final itemJson = json['item'];
final item = CallHierarchyItem.fromJson(itemJson as Map<String, Object?>);
final partialResultTokenJson = json['partialResultToken'];
final partialResultToken = partialResultTokenJson == null
? null
: (partialResultTokenJson is int
? Either2<int, String>.t1(partialResultTokenJson)
: (partialResultTokenJson is String
? Either2<int, String>.t2(partialResultTokenJson)
: (throw '''$partialResultTokenJson was not one of (int, String)''')));
final workDoneTokenJson = json['workDoneToken'];
final workDoneToken = workDoneTokenJson == null
? null
: (workDoneTokenJson is int
? Either2<int, String>.t1(workDoneTokenJson)
: (workDoneTokenJson is String
? Either2<int, String>.t2(workDoneTokenJson)
: (throw '''$workDoneTokenJson was not one of (int, String)''')));
return CallHierarchyIncomingCallsParams(
item: item,
partialResultToken: partialResultToken,
workDoneToken: workDoneToken,
);
}
final CallHierarchyItem item;
/// An optional token that a server can use to report partial results (e.g.
/// streaming) to the client.
final Either2<int, String>? partialResultToken;
/// An optional token that a server can use to report work done progress.
final Either2<int, String>? workDoneToken;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['item'] = item.toJson();
if (partialResultToken != null) {
result['partialResultToken'] = partialResultToken;
}
if (workDoneToken != null) {
result['workDoneToken'] = workDoneToken;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('item');
try {
if (!obj.containsKey('item')) {
reporter.reportError('must not be undefined');
return false;
}
final item = obj['item'];
if (item == null) {
reporter.reportError('must not be null');
return false;
}
if (!(CallHierarchyItem.canParse(item, reporter))) {
reporter.reportError('must be of type CallHierarchyItem');
return false;
}
} finally {
reporter.pop();
}
reporter.push('partialResultToken');
try {
final partialResultToken = obj['partialResultToken'];
if (partialResultToken != null &&
!((partialResultToken is int || partialResultToken is String))) {
reporter.reportError('must be of type Either2<int, String>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('workDoneToken');
try {
final workDoneToken = obj['workDoneToken'];
if (workDoneToken != null &&
!((workDoneToken is int || workDoneToken is String))) {
reporter.reportError('must be of type Either2<int, String>');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CallHierarchyIncomingCallsParams');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CallHierarchyIncomingCallsParams &&
other.runtimeType == CallHierarchyIncomingCallsParams) {
return item == other.item &&
partialResultToken == other.partialResultToken &&
workDoneToken == other.workDoneToken &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
item,
partialResultToken,
workDoneToken,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class CallHierarchyItem implements ToJsonable {
static const jsonHandler = LspJsonHandler(
CallHierarchyItem.canParse,
CallHierarchyItem.fromJson,
);
CallHierarchyItem({
this.data,
this.detail,
required this.kind,
required this.name,
required this.range,
required this.selectionRange,
this.tags,
required this.uri,
});
static CallHierarchyItem fromJson(Map<String, Object?> json) {
final dataJson = json['data'];
final data = dataJson;
final detailJson = json['detail'];
final detail = detailJson as String?;
final kindJson = json['kind'];
final kind = SymbolKind.fromJson(kindJson as int);
final nameJson = json['name'];
final name = nameJson as String;
final rangeJson = json['range'];
final range = Range.fromJson(rangeJson as Map<String, Object?>);
final selectionRangeJson = json['selectionRange'];
final selectionRange =
Range.fromJson(selectionRangeJson as Map<String, Object?>);
final tagsJson = json['tags'];
final tags = (tagsJson as List<Object?>?)
?.map((item) => SymbolTag.fromJson(item as int))
.toList();
final uriJson = json['uri'];
final uri = uriJson as String;
return CallHierarchyItem(
data: data,
detail: detail,
kind: kind,
name: name,
range: range,
selectionRange: selectionRange,
tags: tags,
uri: uri,
);
}
/// A data entry field that is preserved between a call hierarchy prepare and
/// incoming calls or outgoing calls requests.
final Object? data;
/// More detail for this item, e.g. the signature of a function.
final String? detail;
/// The kind of this item.
final SymbolKind kind;
/// The name of this item.
final String name;
/// The range enclosing this symbol not including leading/trailing whitespace
/// but everything else, e.g. comments and code.
final Range range;
/// The range that should be selected and revealed when this symbol is being
/// picked, e.g. the name of a function. Must be contained by the
/// [`range`](#CallHierarchyItem.range).
final Range selectionRange;
/// Tags for this item.
final List<SymbolTag>? tags;
/// The resource identifier of this item.
final String uri;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (data != null) {
result['data'] = data;
}
if (detail != null) {
result['detail'] = detail;
}
result['kind'] = kind.toJson();
result['name'] = name;
result['range'] = range.toJson();
result['selectionRange'] = selectionRange.toJson();
if (tags != null) {
result['tags'] = tags?.map((item) => item.toJson()).toList();
}
result['uri'] = uri;
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('detail');
try {
final detail = obj['detail'];
if (detail != null && !(detail is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
reporter.push('kind');
try {
if (!obj.containsKey('kind')) {
reporter.reportError('must not be undefined');
return false;
}
final kind = obj['kind'];
if (kind == null) {
reporter.reportError('must not be null');
return false;
}
if (!(SymbolKind.canParse(kind, reporter))) {
reporter.reportError('must be of type SymbolKind');
return false;
}
} finally {
reporter.pop();
}
reporter.push('name');
try {
if (!obj.containsKey('name')) {
reporter.reportError('must not be undefined');
return false;
}
final name = obj['name'];
if (name == null) {
reporter.reportError('must not be null');
return false;
}
if (!(name is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
reporter.push('range');
try {
if (!obj.containsKey('range')) {
reporter.reportError('must not be undefined');
return false;
}
final range = obj['range'];
if (range == null) {
reporter.reportError('must not be null');
return false;
}
if (!(Range.canParse(range, reporter))) {
reporter.reportError('must be of type Range');
return false;
}
} finally {
reporter.pop();
}
reporter.push('selectionRange');
try {
if (!obj.containsKey('selectionRange')) {
reporter.reportError('must not be undefined');
return false;
}
final selectionRange = obj['selectionRange'];
if (selectionRange == null) {
reporter.reportError('must not be null');
return false;
}
if (!(Range.canParse(selectionRange, reporter))) {
reporter.reportError('must be of type Range');
return false;
}
} finally {
reporter.pop();
}
reporter.push('tags');
try {
final tags = obj['tags'];
if (tags != null &&
!((tags is List<Object?> &&
(tags.every((item) => SymbolTag.canParse(item, reporter)))))) {
reporter.reportError('must be of type List<SymbolTag>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('uri');
try {
if (!obj.containsKey('uri')) {
reporter.reportError('must not be undefined');
return false;
}
final uri = obj['uri'];
if (uri == null) {
reporter.reportError('must not be null');
return false;
}
if (!(uri is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CallHierarchyItem');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CallHierarchyItem && other.runtimeType == CallHierarchyItem) {
return data == other.data &&
detail == other.detail &&
kind == other.kind &&
name == other.name &&
range == other.range &&
selectionRange == other.selectionRange &&
listEqual(tags, other.tags, (SymbolTag a, SymbolTag b) => a == b) &&
uri == other.uri &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
data,
detail,
kind,
name,
range,
selectionRange,
lspHashCode(tags),
uri,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class CallHierarchyOptions implements WorkDoneProgressOptions, ToJsonable {
static const jsonHandler = LspJsonHandler(
CallHierarchyOptions.canParse,
CallHierarchyOptions.fromJson,
);
CallHierarchyOptions({
this.workDoneProgress,
});
static CallHierarchyOptions fromJson(Map<String, Object?> json) {
if (CallHierarchyRegistrationOptions.canParse(json, nullLspJsonReporter)) {
return CallHierarchyRegistrationOptions.fromJson(json);
}
final workDoneProgressJson = json['workDoneProgress'];
final workDoneProgress = workDoneProgressJson as bool?;
return CallHierarchyOptions(
workDoneProgress: workDoneProgress,
);
}
final bool? workDoneProgress;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (workDoneProgress != null) {
result['workDoneProgress'] = workDoneProgress;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('workDoneProgress');
try {
final workDoneProgress = obj['workDoneProgress'];
if (workDoneProgress != null && !(workDoneProgress is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CallHierarchyOptions');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CallHierarchyOptions &&
other.runtimeType == CallHierarchyOptions) {
return workDoneProgress == other.workDoneProgress && true;
}
return false;
}
@override
int get hashCode => workDoneProgress.hashCode;
@override
String toString() => jsonEncoder.convert(toJson());
}
class CallHierarchyOutgoingCall implements ToJsonable {
static const jsonHandler = LspJsonHandler(
CallHierarchyOutgoingCall.canParse,
CallHierarchyOutgoingCall.fromJson,
);
CallHierarchyOutgoingCall({
required this.fromRanges,
required this.to,
});
static CallHierarchyOutgoingCall fromJson(Map<String, Object?> json) {
final fromRangesJson = json['fromRanges'];
final fromRanges = (fromRangesJson as List<Object?>)
.map((item) => Range.fromJson(item as Map<String, Object?>))
.toList();
final toJson = json['to'];
final to = CallHierarchyItem.fromJson(toJson as Map<String, Object?>);
return CallHierarchyOutgoingCall(
fromRanges: fromRanges,
to: to,
);
}
/// The range at which this item is called. This is the range relative to the
/// caller, e.g the item passed to `callHierarchy/outgoingCalls` request.
final List<Range> fromRanges;
/// The item that is called.
final CallHierarchyItem to;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['fromRanges'] = fromRanges.map((item) => item.toJson()).toList();
result['to'] = to.toJson();
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('fromRanges');
try {
if (!obj.containsKey('fromRanges')) {
reporter.reportError('must not be undefined');
return false;
}
final fromRanges = obj['fromRanges'];
if (fromRanges == null) {
reporter.reportError('must not be null');
return false;
}
if (!((fromRanges is List<Object?> &&
(fromRanges.every((item) => Range.canParse(item, reporter)))))) {
reporter.reportError('must be of type List<Range>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('to');
try {
if (!obj.containsKey('to')) {
reporter.reportError('must not be undefined');
return false;
}
final to = obj['to'];
if (to == null) {
reporter.reportError('must not be null');
return false;
}
if (!(CallHierarchyItem.canParse(to, reporter))) {
reporter.reportError('must be of type CallHierarchyItem');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CallHierarchyOutgoingCall');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CallHierarchyOutgoingCall &&
other.runtimeType == CallHierarchyOutgoingCall) {
return listEqual(
fromRanges, other.fromRanges, (Range a, Range b) => a == b) &&
to == other.to &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
lspHashCode(fromRanges),
to,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class CallHierarchyOutgoingCallsParams
implements PartialResultParams, WorkDoneProgressParams, ToJsonable {
static const jsonHandler = LspJsonHandler(
CallHierarchyOutgoingCallsParams.canParse,
CallHierarchyOutgoingCallsParams.fromJson,
);
CallHierarchyOutgoingCallsParams({
required this.item,
this.partialResultToken,
this.workDoneToken,
});
static CallHierarchyOutgoingCallsParams fromJson(Map<String, Object?> json) {
final itemJson = json['item'];
final item = CallHierarchyItem.fromJson(itemJson as Map<String, Object?>);
final partialResultTokenJson = json['partialResultToken'];
final partialResultToken = partialResultTokenJson == null
? null
: (partialResultTokenJson is int
? Either2<int, String>.t1(partialResultTokenJson)
: (partialResultTokenJson is String
? Either2<int, String>.t2(partialResultTokenJson)
: (throw '''$partialResultTokenJson was not one of (int, String)''')));
final workDoneTokenJson = json['workDoneToken'];
final workDoneToken = workDoneTokenJson == null
? null
: (workDoneTokenJson is int
? Either2<int, String>.t1(workDoneTokenJson)
: (workDoneTokenJson is String
? Either2<int, String>.t2(workDoneTokenJson)
: (throw '''$workDoneTokenJson was not one of (int, String)''')));
return CallHierarchyOutgoingCallsParams(
item: item,
partialResultToken: partialResultToken,
workDoneToken: workDoneToken,
);
}
final CallHierarchyItem item;
/// An optional token that a server can use to report partial results (e.g.
/// streaming) to the client.
final Either2<int, String>? partialResultToken;
/// An optional token that a server can use to report work done progress.
final Either2<int, String>? workDoneToken;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['item'] = item.toJson();
if (partialResultToken != null) {
result['partialResultToken'] = partialResultToken;
}
if (workDoneToken != null) {
result['workDoneToken'] = workDoneToken;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('item');
try {
if (!obj.containsKey('item')) {
reporter.reportError('must not be undefined');
return false;
}
final item = obj['item'];
if (item == null) {
reporter.reportError('must not be null');
return false;
}
if (!(CallHierarchyItem.canParse(item, reporter))) {
reporter.reportError('must be of type CallHierarchyItem');
return false;
}
} finally {
reporter.pop();
}
reporter.push('partialResultToken');
try {
final partialResultToken = obj['partialResultToken'];
if (partialResultToken != null &&
!((partialResultToken is int || partialResultToken is String))) {
reporter.reportError('must be of type Either2<int, String>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('workDoneToken');
try {
final workDoneToken = obj['workDoneToken'];
if (workDoneToken != null &&
!((workDoneToken is int || workDoneToken is String))) {
reporter.reportError('must be of type Either2<int, String>');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CallHierarchyOutgoingCallsParams');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CallHierarchyOutgoingCallsParams &&
other.runtimeType == CallHierarchyOutgoingCallsParams) {
return item == other.item &&
partialResultToken == other.partialResultToken &&
workDoneToken == other.workDoneToken &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
item,
partialResultToken,
workDoneToken,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class CallHierarchyPrepareParams
implements TextDocumentPositionParams, WorkDoneProgressParams, ToJsonable {
static const jsonHandler = LspJsonHandler(
CallHierarchyPrepareParams.canParse,
CallHierarchyPrepareParams.fromJson,
);
CallHierarchyPrepareParams({
required this.position,
required this.textDocument,
this.workDoneToken,
});
static CallHierarchyPrepareParams fromJson(Map<String, Object?> json) {
final positionJson = json['position'];
final position = Position.fromJson(positionJson as Map<String, Object?>);
final textDocumentJson = json['textDocument'];
final textDocument = TextDocumentIdentifier.fromJson(
textDocumentJson as Map<String, Object?>);
final workDoneTokenJson = json['workDoneToken'];
final workDoneToken = workDoneTokenJson == null
? null
: (workDoneTokenJson is int
? Either2<int, String>.t1(workDoneTokenJson)
: (workDoneTokenJson is String
? Either2<int, String>.t2(workDoneTokenJson)
: (throw '''$workDoneTokenJson was not one of (int, String)''')));
return CallHierarchyPrepareParams(
position: position,
textDocument: textDocument,
workDoneToken: workDoneToken,
);
}
/// The position inside the text document.
final Position position;
/// The text document.
final TextDocumentIdentifier textDocument;
/// An optional token that a server can use to report work done progress.
final Either2<int, String>? workDoneToken;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['position'] = position.toJson();
result['textDocument'] = textDocument.toJson();
if (workDoneToken != null) {
result['workDoneToken'] = workDoneToken;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('position');
try {
if (!obj.containsKey('position')) {
reporter.reportError('must not be undefined');
return false;
}
final position = obj['position'];
if (position == null) {
reporter.reportError('must not be null');
return false;
}
if (!(Position.canParse(position, reporter))) {
reporter.reportError('must be of type Position');
return false;
}
} finally {
reporter.pop();
}
reporter.push('textDocument');
try {
if (!obj.containsKey('textDocument')) {
reporter.reportError('must not be undefined');
return false;
}
final textDocument = obj['textDocument'];
if (textDocument == null) {
reporter.reportError('must not be null');
return false;
}
if (!(TextDocumentIdentifier.canParse(textDocument, reporter))) {
reporter.reportError('must be of type TextDocumentIdentifier');
return false;
}
} finally {
reporter.pop();
}
reporter.push('workDoneToken');
try {
final workDoneToken = obj['workDoneToken'];
if (workDoneToken != null &&
!((workDoneToken is int || workDoneToken is String))) {
reporter.reportError('must be of type Either2<int, String>');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CallHierarchyPrepareParams');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CallHierarchyPrepareParams &&
other.runtimeType == CallHierarchyPrepareParams) {
return position == other.position &&
textDocument == other.textDocument &&
workDoneToken == other.workDoneToken &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
position,
textDocument,
workDoneToken,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class CallHierarchyRegistrationOptions
implements
CallHierarchyOptions,
StaticRegistrationOptions,
TextDocumentRegistrationOptions,
ToJsonable {
static const jsonHandler = LspJsonHandler(
CallHierarchyRegistrationOptions.canParse,
CallHierarchyRegistrationOptions.fromJson,
);
CallHierarchyRegistrationOptions({
this.documentSelector,
this.id,
this.workDoneProgress,
});
static CallHierarchyRegistrationOptions fromJson(Map<String, Object?> json) {
final documentSelectorJson = json['documentSelector'];
final documentSelector = (documentSelectorJson as List<Object?>?)
?.map(
(item) => TextDocumentFilter.fromJson(item as Map<String, Object?>))
.toList();
final idJson = json['id'];
final id = idJson as String?;
final workDoneProgressJson = json['workDoneProgress'];
final workDoneProgress = workDoneProgressJson as bool?;
return CallHierarchyRegistrationOptions(
documentSelector: documentSelector,
id: id,
workDoneProgress: workDoneProgress,
);
}
/// A document selector to identify the scope of the registration. If set to
/// null the document selector provided on the client side will be used.
final List<TextDocumentFilter>? documentSelector;
/// The id used to register the request. The id can be used to deregister the
/// request again. See also Registration#id.
final String? id;
final bool? workDoneProgress;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['documentSelector'] = documentSelector;
if (id != null) {
result['id'] = id;
}
if (workDoneProgress != null) {
result['workDoneProgress'] = workDoneProgress;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('documentSelector');
try {
if (!obj.containsKey('documentSelector')) {
reporter.reportError('must not be undefined');
return false;
}
final documentSelector = obj['documentSelector'];
if (documentSelector != null &&
!((documentSelector is List<Object?> &&
(documentSelector.every(
(item) => TextDocumentFilter.canParse(item, reporter)))))) {
reporter.reportError('must be of type List<TextDocumentFilter>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('id');
try {
final id = obj['id'];
if (id != null && !(id is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
reporter.push('workDoneProgress');
try {
final workDoneProgress = obj['workDoneProgress'];
if (workDoneProgress != null && !(workDoneProgress is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CallHierarchyRegistrationOptions');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CallHierarchyRegistrationOptions &&
other.runtimeType == CallHierarchyRegistrationOptions) {
return listEqual(documentSelector, other.documentSelector,
(TextDocumentFilter a, TextDocumentFilter b) => a == b) &&
id == other.id &&
workDoneProgress == other.workDoneProgress &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
lspHashCode(documentSelector),
id,
workDoneProgress,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class CancelParams implements ToJsonable {
static const jsonHandler = LspJsonHandler(
CancelParams.canParse,
CancelParams.fromJson,
);
CancelParams({
required this.id,
});
static CancelParams fromJson(Map<String, Object?> json) {
final idJson = json['id'];
final id = idJson is int
? Either2<int, String>.t1(idJson)
: (idJson is String
? Either2<int, String>.t2(idJson)
: (throw '''$idJson was not one of (int, String)'''));
return CancelParams(
id: id,
);
}
/// The request id to cancel.
final Either2<int, String> id;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['id'] = id;
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('id');
try {
if (!obj.containsKey('id')) {
reporter.reportError('must not be undefined');
return false;
}
final id = obj['id'];
if (id == null) {
reporter.reportError('must not be null');
return false;
}
if (!((id is int || id is String))) {
reporter.reportError('must be of type Either2<int, String>');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CancelParams');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CancelParams && other.runtimeType == CancelParams) {
return id == other.id && true;
}
return false;
}
@override
int get hashCode => id.hashCode;
@override
String toString() => jsonEncoder.convert(toJson());
}
/// Additional information that describes document changes.
/// @since 3.16.0
class ChangeAnnotation implements ToJsonable {
static const jsonHandler = LspJsonHandler(
ChangeAnnotation.canParse,
ChangeAnnotation.fromJson,
);
ChangeAnnotation({
this.description,
required this.label,
this.needsConfirmation,
});
static ChangeAnnotation fromJson(Map<String, Object?> json) {
final descriptionJson = json['description'];
final description = descriptionJson as String?;
final labelJson = json['label'];
final label = labelJson as String;
final needsConfirmationJson = json['needsConfirmation'];
final needsConfirmation = needsConfirmationJson as bool?;
return ChangeAnnotation(
description: description,
label: label,
needsConfirmation: needsConfirmation,
);
}
/// A human-readable string which is rendered less prominent in the user
/// interface.
final String? description;
/// A human-readable string describing the actual change. The string is
/// rendered prominent in the user interface.
final String label;
/// A flag which indicates that user confirmation is needed before applying
/// the change.
final bool? needsConfirmation;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (description != null) {
result['description'] = description;
}
result['label'] = label;
if (needsConfirmation != null) {
result['needsConfirmation'] = needsConfirmation;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('description');
try {
final description = obj['description'];
if (description != null && !(description is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
reporter.push('label');
try {
if (!obj.containsKey('label')) {
reporter.reportError('must not be undefined');
return false;
}
final label = obj['label'];
if (label == null) {
reporter.reportError('must not be null');
return false;
}
if (!(label is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
reporter.push('needsConfirmation');
try {
final needsConfirmation = obj['needsConfirmation'];
if (needsConfirmation != null && !(needsConfirmation is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type ChangeAnnotation');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is ChangeAnnotation && other.runtimeType == ChangeAnnotation) {
return description == other.description &&
label == other.label &&
needsConfirmation == other.needsConfirmation &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
description,
label,
needsConfirmation,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class ClientCapabilities implements ToJsonable {
static const jsonHandler = LspJsonHandler(
ClientCapabilities.canParse,
ClientCapabilities.fromJson,
);
ClientCapabilities({
this.experimental,
this.general,
this.notebookDocument,
this.textDocument,
this.window,
this.workspace,
});
static ClientCapabilities fromJson(Map<String, Object?> json) {
final experimentalJson = json['experimental'];
final experimental = experimentalJson;
final generalJson = json['general'];
final general = generalJson != null
? GeneralClientCapabilities.fromJson(
generalJson as Map<String, Object?>)
: null;
final notebookDocumentJson = json['notebookDocument'];
final notebookDocument = notebookDocumentJson != null
? NotebookDocumentClientCapabilities.fromJson(
notebookDocumentJson as Map<String, Object?>)
: null;
final textDocumentJson = json['textDocument'];
final textDocument = textDocumentJson != null
? TextDocumentClientCapabilities.fromJson(
textDocumentJson as Map<String, Object?>)
: null;
final windowJson = json['window'];
final window = windowJson != null
? WindowClientCapabilities.fromJson(windowJson as Map<String, Object?>)
: null;
final workspaceJson = json['workspace'];
final workspace = workspaceJson != null
? WorkspaceClientCapabilities.fromJson(
workspaceJson as Map<String, Object?>)
: null;
return ClientCapabilities(
experimental: experimental,
general: general,
notebookDocument: notebookDocument,
textDocument: textDocument,
window: window,
workspace: workspace,
);
}
/// Experimental client capabilities.
final Object? experimental;
/// General client capabilities.
/// @since 3.16.0
final GeneralClientCapabilities? general;
/// Capabilities specific to the notebook document support.
/// @since 3.17.0
final NotebookDocumentClientCapabilities? notebookDocument;
/// Text document specific client capabilities.
final TextDocumentClientCapabilities? textDocument;
/// Window specific client capabilities.
final WindowClientCapabilities? window;
/// Workspace specific client capabilities.
final WorkspaceClientCapabilities? workspace;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (experimental != null) {
result['experimental'] = experimental;
}
if (general != null) {
result['general'] = general?.toJson();
}
if (notebookDocument != null) {
result['notebookDocument'] = notebookDocument?.toJson();
}
if (textDocument != null) {
result['textDocument'] = textDocument?.toJson();
}
if (window != null) {
result['window'] = window?.toJson();
}
if (workspace != null) {
result['workspace'] = workspace?.toJson();
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('general');
try {
final general = obj['general'];
if (general != null &&
!(GeneralClientCapabilities.canParse(general, reporter))) {
reporter.reportError('must be of type GeneralClientCapabilities');
return false;
}
} finally {
reporter.pop();
}
reporter.push('notebookDocument');
try {
final notebookDocument = obj['notebookDocument'];
if (notebookDocument != null &&
!(NotebookDocumentClientCapabilities.canParse(
notebookDocument, reporter))) {
reporter.reportError(
'must be of type NotebookDocumentClientCapabilities');
return false;
}
} finally {
reporter.pop();
}
reporter.push('textDocument');
try {
final textDocument = obj['textDocument'];
if (textDocument != null &&
!(TextDocumentClientCapabilities.canParse(
textDocument, reporter))) {
reporter
.reportError('must be of type TextDocumentClientCapabilities');
return false;
}
} finally {
reporter.pop();
}
reporter.push('window');
try {
final window = obj['window'];
if (window != null &&
!(WindowClientCapabilities.canParse(window, reporter))) {
reporter.reportError('must be of type WindowClientCapabilities');
return false;
}
} finally {
reporter.pop();
}
reporter.push('workspace');
try {
final workspace = obj['workspace'];
if (workspace != null &&
!(WorkspaceClientCapabilities.canParse(workspace, reporter))) {
reporter.reportError('must be of type WorkspaceClientCapabilities');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type ClientCapabilities');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is ClientCapabilities &&
other.runtimeType == ClientCapabilities) {
return experimental == other.experimental &&
general == other.general &&
notebookDocument == other.notebookDocument &&
textDocument == other.textDocument &&
window == other.window &&
workspace == other.workspace &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
experimental,
general,
notebookDocument,
textDocument,
window,
workspace,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
/// A code action represents a change that can be performed in code, e.g. to fix
/// a problem or to refactor code.
///
/// A CodeAction must set either `edit` and/or a `command`. If both are
/// supplied, the `edit` is applied first, then the `command` is executed.
class CodeAction implements ToJsonable {
static const jsonHandler = LspJsonHandler(
CodeAction.canParse,
CodeAction.fromJson,
);
CodeAction({
this.command,
this.data,
this.diagnostics,
this.disabled,
this.edit,
this.isPreferred,
this.kind,
required this.title,
});
static CodeAction fromJson(Map<String, Object?> json) {
final commandJson = json['command'];
final command = commandJson != null
? Command.fromJson(commandJson as Map<String, Object?>)
: null;
final dataJson = json['data'];
final data = dataJson;
final diagnosticsJson = json['diagnostics'];
final diagnostics = (diagnosticsJson as List<Object?>?)
?.map((item) => Diagnostic.fromJson(item as Map<String, Object?>))
.toList();
final disabledJson = json['disabled'];
final disabled = disabledJson != null
? CodeActionDisabled.fromJson(disabledJson as Map<String, Object?>)
: null;
final editJson = json['edit'];
final edit = editJson != null
? WorkspaceEdit.fromJson(editJson as Map<String, Object?>)
: null;
final isPreferredJson = json['isPreferred'];
final isPreferred = isPreferredJson as bool?;
final kindJson = json['kind'];
final kind =
kindJson != null ? CodeActionKind.fromJson(kindJson as String) : null;
final titleJson = json['title'];
final title = titleJson as String;
return CodeAction(
command: command,
data: data,
diagnostics: diagnostics,
disabled: disabled,
edit: edit,
isPreferred: isPreferred,
kind: kind,
title: title,
);
}
/// A command this code action executes. If a code action provides an edit and
/// a command, first the edit is executed and then the command.
final Command? command;
/// A data entry field that is preserved on a code action between a
/// `textDocument/codeAction` and a `codeAction/resolve` request.
/// @since 3.16.0
final Object? data;
/// The diagnostics that this code action resolves.
final List<Diagnostic>? diagnostics;
/// Marks that the code action cannot currently be applied.
///
/// Clients should follow the following guidelines regarding disabled code
/// actions:
///
/// - Disabled code actions are not shown in automatic lightbulbs code
/// action menus.
///
/// - Disabled actions are shown as faded out in the code action menu when
/// the user request a more specific type of code action, such as
/// refactorings.
///
/// - If the user has a keybinding that auto applies a code action and only
/// a disabled code actions are returned, the client should show the user
/// an error message with `reason` in the editor.
/// @since 3.16.0
final CodeActionDisabled? disabled;
/// The workspace edit this code action performs.
final WorkspaceEdit? edit;
/// Marks this as a preferred action. Preferred actions are used by the `auto
/// fix` command and can be targeted by keybindings.
///
/// A quick fix should be marked preferred if it properly addresses the
/// underlying error. A refactoring should be marked preferred if it is the
/// most reasonable choice of actions to take.
/// @since 3.15.0
final bool? isPreferred;
/// The kind of the code action.
///
/// Used to filter code actions.
final CodeActionKind? kind;
/// A short, human-readable, title for this code action.
final String title;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (command != null) {
result['command'] = command?.toJson();
}
if (data != null) {
result['data'] = data;
}
if (diagnostics != null) {
result['diagnostics'] =
diagnostics?.map((item) => item.toJson()).toList();
}
if (disabled != null) {
result['disabled'] = disabled?.toJson();
}
if (edit != null) {
result['edit'] = edit?.toJson();
}
if (isPreferred != null) {
result['isPreferred'] = isPreferred;
}
if (kind != null) {
result['kind'] = kind?.toJson();
}
result['title'] = title;
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('command');
try {
final command = obj['command'];
if (command != null && !(Command.canParse(command, reporter))) {
reporter.reportError('must be of type Command');
return false;
}
} finally {
reporter.pop();
}
reporter.push('diagnostics');
try {
final diagnostics = obj['diagnostics'];
if (diagnostics != null &&
!((diagnostics is List<Object?> &&
(diagnostics
.every((item) => Diagnostic.canParse(item, reporter)))))) {
reporter.reportError('must be of type List<Diagnostic>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('disabled');
try {
final disabled = obj['disabled'];
if (disabled != null &&
!(CodeActionDisabled.canParse(disabled, reporter))) {
reporter.reportError('must be of type CodeActionDisabled');
return false;
}
} finally {
reporter.pop();
}
reporter.push('edit');
try {
final edit = obj['edit'];
if (edit != null && !(WorkspaceEdit.canParse(edit, reporter))) {
reporter.reportError('must be of type WorkspaceEdit');
return false;
}
} finally {
reporter.pop();
}
reporter.push('isPreferred');
try {
final isPreferred = obj['isPreferred'];
if (isPreferred != null && !(isPreferred is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
reporter.push('kind');
try {
final kind = obj['kind'];
if (kind != null && !(CodeActionKind.canParse(kind, reporter))) {
reporter.reportError('must be of type CodeActionKind');
return false;
}
} finally {
reporter.pop();
}
reporter.push('title');
try {
if (!obj.containsKey('title')) {
reporter.reportError('must not be undefined');
return false;
}
final title = obj['title'];
if (title == null) {
reporter.reportError('must not be null');
return false;
}
if (!(title is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CodeAction');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CodeAction && other.runtimeType == CodeAction) {
return command == other.command &&
data == other.data &&
listEqual(diagnostics, other.diagnostics,
(Diagnostic a, Diagnostic b) => a == b) &&
disabled == other.disabled &&
edit == other.edit &&
isPreferred == other.isPreferred &&
kind == other.kind &&
title == other.title &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
command,
data,
lspHashCode(diagnostics),
disabled,
edit,
isPreferred,
kind,
title,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class CodeActionClientCapabilities implements ToJsonable {
static const jsonHandler = LspJsonHandler(
CodeActionClientCapabilities.canParse,
CodeActionClientCapabilities.fromJson,
);
CodeActionClientCapabilities({
this.codeActionLiteralSupport,
this.dataSupport,
this.disabledSupport,
this.dynamicRegistration,
this.honorsChangeAnnotations,
this.isPreferredSupport,
this.resolveSupport,
});
static CodeActionClientCapabilities fromJson(Map<String, Object?> json) {
final codeActionLiteralSupportJson = json['codeActionLiteralSupport'];
final codeActionLiteralSupport = codeActionLiteralSupportJson != null
? CodeActionClientCapabilitiesCodeActionLiteralSupport.fromJson(
codeActionLiteralSupportJson as Map<String, Object?>)
: null;
final dataSupportJson = json['dataSupport'];
final dataSupport = dataSupportJson as bool?;
final disabledSupportJson = json['disabledSupport'];
final disabledSupport = disabledSupportJson as bool?;
final dynamicRegistrationJson = json['dynamicRegistration'];
final dynamicRegistration = dynamicRegistrationJson as bool?;
final honorsChangeAnnotationsJson = json['honorsChangeAnnotations'];
final honorsChangeAnnotations = honorsChangeAnnotationsJson as bool?;
final isPreferredSupportJson = json['isPreferredSupport'];
final isPreferredSupport = isPreferredSupportJson as bool?;
final resolveSupportJson = json['resolveSupport'];
final resolveSupport = resolveSupportJson != null
? CodeActionClientCapabilitiesResolveSupport.fromJson(
resolveSupportJson as Map<String, Object?>)
: null;
return CodeActionClientCapabilities(
codeActionLiteralSupport: codeActionLiteralSupport,
dataSupport: dataSupport,
disabledSupport: disabledSupport,
dynamicRegistration: dynamicRegistration,
honorsChangeAnnotations: honorsChangeAnnotations,
isPreferredSupport: isPreferredSupport,
resolveSupport: resolveSupport,
);
}
/// The client supports code action literals as a valid response of the
/// `textDocument/codeAction` request.
/// @since 3.8.0
final CodeActionClientCapabilitiesCodeActionLiteralSupport?
codeActionLiteralSupport;
/// Whether code action supports the `data` property which is preserved
/// between a `textDocument/codeAction` and a `codeAction/resolve` request.
/// @since 3.16.0
final bool? dataSupport;
/// Whether code action supports the `disabled` property.
/// @since 3.16.0
final bool? disabledSupport;
/// Whether code action supports dynamic registration.
final bool? dynamicRegistration;
/// Whether the client honors the change annotations in text edits and
/// resource operations returned via the `CodeAction#edit` property by for
/// example presenting the workspace edit in the user interface and asking for
/// confirmation.
/// @since 3.16.0
final bool? honorsChangeAnnotations;
/// Whether code action supports the `isPreferred` property.
/// @since 3.15.0
final bool? isPreferredSupport;
/// Whether the client supports resolving additional code action properties
/// via a separate `codeAction/resolve` request.
/// @since 3.16.0
final CodeActionClientCapabilitiesResolveSupport? resolveSupport;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (codeActionLiteralSupport != null) {
result['codeActionLiteralSupport'] = codeActionLiteralSupport?.toJson();
}
if (dataSupport != null) {
result['dataSupport'] = dataSupport;
}
if (disabledSupport != null) {
result['disabledSupport'] = disabledSupport;
}
if (dynamicRegistration != null) {
result['dynamicRegistration'] = dynamicRegistration;
}
if (honorsChangeAnnotations != null) {
result['honorsChangeAnnotations'] = honorsChangeAnnotations;
}
if (isPreferredSupport != null) {
result['isPreferredSupport'] = isPreferredSupport;
}
if (resolveSupport != null) {
result['resolveSupport'] = resolveSupport?.toJson();
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('codeActionLiteralSupport');
try {
final codeActionLiteralSupport = obj['codeActionLiteralSupport'];
if (codeActionLiteralSupport != null &&
!(CodeActionClientCapabilitiesCodeActionLiteralSupport.canParse(
codeActionLiteralSupport, reporter))) {
reporter.reportError(
'must be of type CodeActionClientCapabilitiesCodeActionLiteralSupport');
return false;
}
} finally {
reporter.pop();
}
reporter.push('dataSupport');
try {
final dataSupport = obj['dataSupport'];
if (dataSupport != null && !(dataSupport is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
reporter.push('disabledSupport');
try {
final disabledSupport = obj['disabledSupport'];
if (disabledSupport != null && !(disabledSupport is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
reporter.push('dynamicRegistration');
try {
final dynamicRegistration = obj['dynamicRegistration'];
if (dynamicRegistration != null && !(dynamicRegistration is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
reporter.push('honorsChangeAnnotations');
try {
final honorsChangeAnnotations = obj['honorsChangeAnnotations'];
if (honorsChangeAnnotations != null &&
!(honorsChangeAnnotations is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
reporter.push('isPreferredSupport');
try {
final isPreferredSupport = obj['isPreferredSupport'];
if (isPreferredSupport != null && !(isPreferredSupport is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
reporter.push('resolveSupport');
try {
final resolveSupport = obj['resolveSupport'];
if (resolveSupport != null &&
!(CodeActionClientCapabilitiesResolveSupport.canParse(
resolveSupport, reporter))) {
reporter.reportError(
'must be of type CodeActionClientCapabilitiesResolveSupport');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CodeActionClientCapabilities');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CodeActionClientCapabilities &&
other.runtimeType == CodeActionClientCapabilities) {
return codeActionLiteralSupport == other.codeActionLiteralSupport &&
dataSupport == other.dataSupport &&
disabledSupport == other.disabledSupport &&
dynamicRegistration == other.dynamicRegistration &&
honorsChangeAnnotations == other.honorsChangeAnnotations &&
isPreferredSupport == other.isPreferredSupport &&
resolveSupport == other.resolveSupport &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
codeActionLiteralSupport,
dataSupport,
disabledSupport,
dynamicRegistration,
honorsChangeAnnotations,
isPreferredSupport,
resolveSupport,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class CodeActionClientCapabilitiesCodeActionLiteralSupport
implements ToJsonable {
static const jsonHandler = LspJsonHandler(
CodeActionClientCapabilitiesCodeActionLiteralSupport.canParse,
CodeActionClientCapabilitiesCodeActionLiteralSupport.fromJson,
);
CodeActionClientCapabilitiesCodeActionLiteralSupport({
required this.codeActionKind,
});
static CodeActionClientCapabilitiesCodeActionLiteralSupport fromJson(
Map<String, Object?> json) {
final codeActionKindJson = json['codeActionKind'];
final codeActionKind = CodeActionLiteralSupportCodeActionKind.fromJson(
codeActionKindJson as Map<String, Object?>);
return CodeActionClientCapabilitiesCodeActionLiteralSupport(
codeActionKind: codeActionKind,
);
}
/// The code action kind is supported with the following value set.
final CodeActionLiteralSupportCodeActionKind codeActionKind;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['codeActionKind'] = codeActionKind.toJson();
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('codeActionKind');
try {
if (!obj.containsKey('codeActionKind')) {
reporter.reportError('must not be undefined');
return false;
}
final codeActionKind = obj['codeActionKind'];
if (codeActionKind == null) {
reporter.reportError('must not be null');
return false;
}
if (!(CodeActionLiteralSupportCodeActionKind.canParse(
codeActionKind, reporter))) {
reporter.reportError(
'must be of type CodeActionLiteralSupportCodeActionKind');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError(
'must be of type CodeActionClientCapabilitiesCodeActionLiteralSupport');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CodeActionClientCapabilitiesCodeActionLiteralSupport &&
other.runtimeType ==
CodeActionClientCapabilitiesCodeActionLiteralSupport) {
return codeActionKind == other.codeActionKind && true;
}
return false;
}
@override
int get hashCode => codeActionKind.hashCode;
@override
String toString() => jsonEncoder.convert(toJson());
}
class CodeActionClientCapabilitiesResolveSupport implements ToJsonable {
static const jsonHandler = LspJsonHandler(
CodeActionClientCapabilitiesResolveSupport.canParse,
CodeActionClientCapabilitiesResolveSupport.fromJson,
);
CodeActionClientCapabilitiesResolveSupport({
required this.properties,
});
static CodeActionClientCapabilitiesResolveSupport fromJson(
Map<String, Object?> json) {
final propertiesJson = json['properties'];
final properties = (propertiesJson as List<Object?>)
.map((item) => item as String)
.toList();
return CodeActionClientCapabilitiesResolveSupport(
properties: properties,
);
}
/// The properties that a client can resolve lazily.
final List<String> properties;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['properties'] = properties;
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('properties');
try {
if (!obj.containsKey('properties')) {
reporter.reportError('must not be undefined');
return false;
}
final properties = obj['properties'];
if (properties == null) {
reporter.reportError('must not be null');
return false;
}
if (!((properties is List<Object?> &&
(properties.every((item) => item is String))))) {
reporter.reportError('must be of type List<String>');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError(
'must be of type CodeActionClientCapabilitiesResolveSupport');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CodeActionClientCapabilitiesResolveSupport &&
other.runtimeType == CodeActionClientCapabilitiesResolveSupport) {
return listEqual(
properties, other.properties, (String a, String b) => a == b) &&
true;
}
return false;
}
@override
int get hashCode => lspHashCode(properties);
@override
String toString() => jsonEncoder.convert(toJson());
}
/// Contains additional diagnostic information about the context in which a code
/// action is run.
class CodeActionContext implements ToJsonable {
static const jsonHandler = LspJsonHandler(
CodeActionContext.canParse,
CodeActionContext.fromJson,
);
CodeActionContext({
required this.diagnostics,
this.only,
this.triggerKind,
});
static CodeActionContext fromJson(Map<String, Object?> json) {
final diagnosticsJson = json['diagnostics'];
final diagnostics = (diagnosticsJson as List<Object?>)
.map((item) => Diagnostic.fromJson(item as Map<String, Object?>))
.toList();
final onlyJson = json['only'];
final only = (onlyJson as List<Object?>?)
?.map((item) => CodeActionKind.fromJson(item as String))
.toList();
final triggerKindJson = json['triggerKind'];
final triggerKind = triggerKindJson != null
? CodeActionTriggerKind.fromJson(triggerKindJson as int)
: null;
return CodeActionContext(
diagnostics: diagnostics,
only: only,
triggerKind: triggerKind,
);
}
/// An array of diagnostics known on the client side overlapping the range
/// provided to the `textDocument/codeAction` request. They are provided so
/// that the server knows which errors are currently presented to the user for
/// the given range. There is no guarantee that these accurately reflect the
/// error state of the resource. The primary parameter to compute code actions
/// is the provided range.
final List<Diagnostic> diagnostics;
/// Requested kind of actions to return.
///
/// Actions not of this kind are filtered out by the client before being
/// shown. So servers can omit computing them.
final List<CodeActionKind>? only;
/// The reason why code actions were requested.
/// @since 3.17.0
final CodeActionTriggerKind? triggerKind;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['diagnostics'] = diagnostics.map((item) => item.toJson()).toList();
if (only != null) {
result['only'] = only?.map((item) => item.toJson()).toList();
}
if (triggerKind != null) {
result['triggerKind'] = triggerKind?.toJson();
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('diagnostics');
try {
if (!obj.containsKey('diagnostics')) {
reporter.reportError('must not be undefined');
return false;
}
final diagnostics = obj['diagnostics'];
if (diagnostics == null) {
reporter.reportError('must not be null');
return false;
}
if (!((diagnostics is List<Object?> &&
(diagnostics
.every((item) => Diagnostic.canParse(item, reporter)))))) {
reporter.reportError('must be of type List<Diagnostic>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('only');
try {
final only = obj['only'];
if (only != null &&
!((only is List<Object?> &&
(only.every(
(item) => CodeActionKind.canParse(item, reporter)))))) {
reporter.reportError('must be of type List<CodeActionKind>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('triggerKind');
try {
final triggerKind = obj['triggerKind'];
if (triggerKind != null &&
!(CodeActionTriggerKind.canParse(triggerKind, reporter))) {
reporter.reportError('must be of type CodeActionTriggerKind');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CodeActionContext');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CodeActionContext && other.runtimeType == CodeActionContext) {
return listEqual(diagnostics, other.diagnostics,
(Diagnostic a, Diagnostic b) => a == b) &&
listEqual(only, other.only,
(CodeActionKind a, CodeActionKind b) => a == b) &&
triggerKind == other.triggerKind &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
lspHashCode(diagnostics),
lspHashCode(only),
triggerKind,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class CodeActionDisabled implements ToJsonable {
static const jsonHandler = LspJsonHandler(
CodeActionDisabled.canParse,
CodeActionDisabled.fromJson,
);
CodeActionDisabled({
required this.reason,
});
static CodeActionDisabled fromJson(Map<String, Object?> json) {
final reasonJson = json['reason'];
final reason = reasonJson as String;
return CodeActionDisabled(
reason: reason,
);
}
/// Human readable description of why the code action is currently disabled.
///
/// This is displayed in the code actions UI.
final String reason;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['reason'] = reason;
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('reason');
try {
if (!obj.containsKey('reason')) {
reporter.reportError('must not be undefined');
return false;
}
final reason = obj['reason'];
if (reason == null) {
reporter.reportError('must not be null');
return false;
}
if (!(reason is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CodeActionDisabled');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CodeActionDisabled &&
other.runtimeType == CodeActionDisabled) {
return reason == other.reason && true;
}
return false;
}
@override
int get hashCode => reason.hashCode;
@override
String toString() => jsonEncoder.convert(toJson());
}
/// A set of predefined code action kinds.
class CodeActionKind implements ToJsonable {
const CodeActionKind(this._value);
const CodeActionKind.fromJson(this._value);
final String _value;
static bool canParse(Object? obj, LspJsonReporter reporter) {
return obj is String;
}
/// Empty kind.
static const Empty = CodeActionKind('');
/// Base kind for quickfix actions: 'quickfix'.
static const QuickFix = CodeActionKind('quickfix');
/// Base kind for refactoring actions: 'refactor'.
static const Refactor = CodeActionKind('refactor');
/// Base kind for refactoring extraction actions: 'refactor.extract'.
///
/// Example extract actions:
///
/// - Extract method
/// - Extract function
/// - Extract variable
/// - Extract interface from class
/// - ...
static const RefactorExtract = CodeActionKind('refactor.extract');
/// Base kind for refactoring inline actions: 'refactor.inline'.
///
/// Example inline actions:
///
/// - Inline function
/// - Inline variable
/// - Inline constant
/// - ...
static const RefactorInline = CodeActionKind('refactor.inline');
/// Base kind for refactoring rewrite actions: 'refactor.rewrite'.
///
/// Example rewrite actions:
///
/// - Convert JavaScript function to class
/// - Add or remove parameter
/// - Encapsulate field
/// - Make method static
/// - Move method to base class
/// - ...
static const RefactorRewrite = CodeActionKind('refactor.rewrite');
/// Base kind for source actions: `source`.
///
/// Source code actions apply to the entire file.
static const Source = CodeActionKind('source');
/// Base kind for a 'fix all' source action: `source.fixAll`.
/// 'Fix all' actions automatically fix errors that have a clear fix that do
/// not require user input. They should not suppress errors or perform unsafe
/// fixes such as generating new types or classes.
/// @since 3.17.0
static const SourceFixAll = CodeActionKind('source.fixAll');
/// Base kind for an organize imports source action: `source.organizeImports`.
static const SourceOrganizeImports = CodeActionKind('source.organizeImports');
Object toJson() => _value;
@override
String toString() => _value.toString();
@override
int get hashCode => _value.hashCode;
bool operator ==(Object other) =>
other is CodeActionKind && other._value == _value;
}
class CodeActionLiteralSupportCodeActionKind implements ToJsonable {
static const jsonHandler = LspJsonHandler(
CodeActionLiteralSupportCodeActionKind.canParse,
CodeActionLiteralSupportCodeActionKind.fromJson,
);
CodeActionLiteralSupportCodeActionKind({
required this.valueSet,
});
static CodeActionLiteralSupportCodeActionKind fromJson(
Map<String, Object?> json) {
final valueSetJson = json['valueSet'];
final valueSet = (valueSetJson as List<Object?>)
.map((item) => CodeActionKind.fromJson(item as String))
.toList();
return CodeActionLiteralSupportCodeActionKind(
valueSet: valueSet,
);
}
/// The code action kind values the client supports. When this property exists
/// the client also guarantees that it will handle values outside its set
/// gracefully and falls back to a default value when unknown.
final List<CodeActionKind> valueSet;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['valueSet'] = valueSet.map((item) => item.toJson()).toList();
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('valueSet');
try {
if (!obj.containsKey('valueSet')) {
reporter.reportError('must not be undefined');
return false;
}
final valueSet = obj['valueSet'];
if (valueSet == null) {
reporter.reportError('must not be null');
return false;
}
if (!((valueSet is List<Object?> &&
(valueSet
.every((item) => CodeActionKind.canParse(item, reporter)))))) {
reporter.reportError('must be of type List<CodeActionKind>');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError(
'must be of type CodeActionLiteralSupportCodeActionKind');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CodeActionLiteralSupportCodeActionKind &&
other.runtimeType == CodeActionLiteralSupportCodeActionKind) {
return listEqual(valueSet, other.valueSet,
(CodeActionKind a, CodeActionKind b) => a == b) &&
true;
}
return false;
}
@override
int get hashCode => lspHashCode(valueSet);
@override
String toString() => jsonEncoder.convert(toJson());
}
class CodeActionOptions implements WorkDoneProgressOptions, ToJsonable {
static const jsonHandler = LspJsonHandler(
CodeActionOptions.canParse,
CodeActionOptions.fromJson,
);
CodeActionOptions({
this.codeActionKinds,
this.resolveProvider,
this.workDoneProgress,
});
static CodeActionOptions fromJson(Map<String, Object?> json) {
if (CodeActionRegistrationOptions.canParse(json, nullLspJsonReporter)) {
return CodeActionRegistrationOptions.fromJson(json);
}
final codeActionKindsJson = json['codeActionKinds'];
final codeActionKinds = (codeActionKindsJson as List<Object?>?)
?.map((item) => CodeActionKind.fromJson(item as String))
.toList();
final resolveProviderJson = json['resolveProvider'];
final resolveProvider = resolveProviderJson as bool?;
final workDoneProgressJson = json['workDoneProgress'];
final workDoneProgress = workDoneProgressJson as bool?;
return CodeActionOptions(
codeActionKinds: codeActionKinds,
resolveProvider: resolveProvider,
workDoneProgress: workDoneProgress,
);
}
/// CodeActionKinds that this server may return.
///
/// The list of kinds may be generic, such as `CodeActionKind.Refactor`, or
/// the server may list out every specific kind they provide.
final List<CodeActionKind>? codeActionKinds;
/// The server provides support to resolve additional information for a code
/// action.
/// @since 3.16.0
final bool? resolveProvider;
final bool? workDoneProgress;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (codeActionKinds != null) {
result['codeActionKinds'] =
codeActionKinds?.map((item) => item.toJson()).toList();
}
if (resolveProvider != null) {
result['resolveProvider'] = resolveProvider;
}
if (workDoneProgress != null) {
result['workDoneProgress'] = workDoneProgress;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('codeActionKinds');
try {
final codeActionKinds = obj['codeActionKinds'];
if (codeActionKinds != null &&
!((codeActionKinds is List<Object?> &&
(codeActionKinds.every(
(item) => CodeActionKind.canParse(item, reporter)))))) {
reporter.reportError('must be of type List<CodeActionKind>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('resolveProvider');
try {
final resolveProvider = obj['resolveProvider'];
if (resolveProvider != null && !(resolveProvider is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
reporter.push('workDoneProgress');
try {
final workDoneProgress = obj['workDoneProgress'];
if (workDoneProgress != null && !(workDoneProgress is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CodeActionOptions');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CodeActionOptions && other.runtimeType == CodeActionOptions) {
return listEqual(codeActionKinds, other.codeActionKinds,
(CodeActionKind a, CodeActionKind b) => a == b) &&
resolveProvider == other.resolveProvider &&
workDoneProgress == other.workDoneProgress &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
lspHashCode(codeActionKinds),
resolveProvider,
workDoneProgress,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
/// Params for the CodeActionRequest
class CodeActionParams
implements PartialResultParams, WorkDoneProgressParams, ToJsonable {
static const jsonHandler = LspJsonHandler(
CodeActionParams.canParse,
CodeActionParams.fromJson,
);
CodeActionParams({
required this.context,
this.partialResultToken,
required this.range,
required this.textDocument,
this.workDoneToken,
});
static CodeActionParams fromJson(Map<String, Object?> json) {
final contextJson = json['context'];
final context =
CodeActionContext.fromJson(contextJson as Map<String, Object?>);
final partialResultTokenJson = json['partialResultToken'];
final partialResultToken = partialResultTokenJson == null
? null
: (partialResultTokenJson is int
? Either2<int, String>.t1(partialResultTokenJson)
: (partialResultTokenJson is String
? Either2<int, String>.t2(partialResultTokenJson)
: (throw '''$partialResultTokenJson was not one of (int, String)''')));
final rangeJson = json['range'];
final range = Range.fromJson(rangeJson as Map<String, Object?>);
final textDocumentJson = json['textDocument'];
final textDocument = TextDocumentIdentifier.fromJson(
textDocumentJson as Map<String, Object?>);
final workDoneTokenJson = json['workDoneToken'];
final workDoneToken = workDoneTokenJson == null
? null
: (workDoneTokenJson is int
? Either2<int, String>.t1(workDoneTokenJson)
: (workDoneTokenJson is String
? Either2<int, String>.t2(workDoneTokenJson)
: (throw '''$workDoneTokenJson was not one of (int, String)''')));
return CodeActionParams(
context: context,
partialResultToken: partialResultToken,
range: range,
textDocument: textDocument,
workDoneToken: workDoneToken,
);
}
/// Context carrying additional information.
final CodeActionContext context;
/// An optional token that a server can use to report partial results (e.g.
/// streaming) to the client.
final Either2<int, String>? partialResultToken;
/// The range for which the command was invoked.
final Range range;
/// The document in which the command was invoked.
final TextDocumentIdentifier textDocument;
/// An optional token that a server can use to report work done progress.
final Either2<int, String>? workDoneToken;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['context'] = context.toJson();
if (partialResultToken != null) {
result['partialResultToken'] = partialResultToken;
}
result['range'] = range.toJson();
result['textDocument'] = textDocument.toJson();
if (workDoneToken != null) {
result['workDoneToken'] = workDoneToken;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('context');
try {
if (!obj.containsKey('context')) {
reporter.reportError('must not be undefined');
return false;
}
final context = obj['context'];
if (context == null) {
reporter.reportError('must not be null');
return false;
}
if (!(CodeActionContext.canParse(context, reporter))) {
reporter.reportError('must be of type CodeActionContext');
return false;
}
} finally {
reporter.pop();
}
reporter.push('partialResultToken');
try {
final partialResultToken = obj['partialResultToken'];
if (partialResultToken != null &&
!((partialResultToken is int || partialResultToken is String))) {
reporter.reportError('must be of type Either2<int, String>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('range');
try {
if (!obj.containsKey('range')) {
reporter.reportError('must not be undefined');
return false;
}
final range = obj['range'];
if (range == null) {
reporter.reportError('must not be null');
return false;
}
if (!(Range.canParse(range, reporter))) {
reporter.reportError('must be of type Range');
return false;
}
} finally {
reporter.pop();
}
reporter.push('textDocument');
try {
if (!obj.containsKey('textDocument')) {
reporter.reportError('must not be undefined');
return false;
}
final textDocument = obj['textDocument'];
if (textDocument == null) {
reporter.reportError('must not be null');
return false;
}
if (!(TextDocumentIdentifier.canParse(textDocument, reporter))) {
reporter.reportError('must be of type TextDocumentIdentifier');
return false;
}
} finally {
reporter.pop();
}
reporter.push('workDoneToken');
try {
final workDoneToken = obj['workDoneToken'];
if (workDoneToken != null &&
!((workDoneToken is int || workDoneToken is String))) {
reporter.reportError('must be of type Either2<int, String>');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CodeActionParams');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CodeActionParams && other.runtimeType == CodeActionParams) {
return context == other.context &&
partialResultToken == other.partialResultToken &&
range == other.range &&
textDocument == other.textDocument &&
workDoneToken == other.workDoneToken &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
context,
partialResultToken,
range,
textDocument,
workDoneToken,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class CodeActionRegistrationOptions
implements CodeActionOptions, TextDocumentRegistrationOptions, ToJsonable {
static const jsonHandler = LspJsonHandler(
CodeActionRegistrationOptions.canParse,
CodeActionRegistrationOptions.fromJson,
);
CodeActionRegistrationOptions({
this.codeActionKinds,
this.documentSelector,
this.resolveProvider,
this.workDoneProgress,
});
static CodeActionRegistrationOptions fromJson(Map<String, Object?> json) {
final codeActionKindsJson = json['codeActionKinds'];
final codeActionKinds = (codeActionKindsJson as List<Object?>?)
?.map((item) => CodeActionKind.fromJson(item as String))
.toList();
final documentSelectorJson = json['documentSelector'];
final documentSelector = (documentSelectorJson as List<Object?>?)
?.map(
(item) => TextDocumentFilter.fromJson(item as Map<String, Object?>))
.toList();
final resolveProviderJson = json['resolveProvider'];
final resolveProvider = resolveProviderJson as bool?;
final workDoneProgressJson = json['workDoneProgress'];
final workDoneProgress = workDoneProgressJson as bool?;
return CodeActionRegistrationOptions(
codeActionKinds: codeActionKinds,
documentSelector: documentSelector,
resolveProvider: resolveProvider,
workDoneProgress: workDoneProgress,
);
}
/// CodeActionKinds that this server may return.
///
/// The list of kinds may be generic, such as `CodeActionKind.Refactor`, or
/// the server may list out every specific kind they provide.
final List<CodeActionKind>? codeActionKinds;
/// A document selector to identify the scope of the registration. If set to
/// null the document selector provided on the client side will be used.
final List<TextDocumentFilter>? documentSelector;
/// The server provides support to resolve additional information for a code
/// action.
/// @since 3.16.0
final bool? resolveProvider;
final bool? workDoneProgress;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (codeActionKinds != null) {
result['codeActionKinds'] =
codeActionKinds?.map((item) => item.toJson()).toList();
}
result['documentSelector'] = documentSelector;
if (resolveProvider != null) {
result['resolveProvider'] = resolveProvider;
}
if (workDoneProgress != null) {
result['workDoneProgress'] = workDoneProgress;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('codeActionKinds');
try {
final codeActionKinds = obj['codeActionKinds'];
if (codeActionKinds != null &&
!((codeActionKinds is List<Object?> &&
(codeActionKinds.every(
(item) => CodeActionKind.canParse(item, reporter)))))) {
reporter.reportError('must be of type List<CodeActionKind>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('documentSelector');
try {
if (!obj.containsKey('documentSelector')) {
reporter.reportError('must not be undefined');
return false;
}
final documentSelector = obj['documentSelector'];
if (documentSelector != null &&
!((documentSelector is List<Object?> &&
(documentSelector.every(
(item) => TextDocumentFilter.canParse(item, reporter)))))) {
reporter.reportError('must be of type List<TextDocumentFilter>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('resolveProvider');
try {
final resolveProvider = obj['resolveProvider'];
if (resolveProvider != null && !(resolveProvider is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
reporter.push('workDoneProgress');
try {
final workDoneProgress = obj['workDoneProgress'];
if (workDoneProgress != null && !(workDoneProgress is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CodeActionRegistrationOptions');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CodeActionRegistrationOptions &&
other.runtimeType == CodeActionRegistrationOptions) {
return listEqual(codeActionKinds, other.codeActionKinds,
(CodeActionKind a, CodeActionKind b) => a == b) &&
listEqual(documentSelector, other.documentSelector,
(TextDocumentFilter a, TextDocumentFilter b) => a == b) &&
resolveProvider == other.resolveProvider &&
workDoneProgress == other.workDoneProgress &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
lspHashCode(codeActionKinds),
lspHashCode(documentSelector),
resolveProvider,
workDoneProgress,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
/// The reason why code actions were requested.
/// @since 3.17.0
class CodeActionTriggerKind implements ToJsonable {
const CodeActionTriggerKind(this._value);
const CodeActionTriggerKind.fromJson(this._value);
final int _value;
static bool canParse(Object? obj, LspJsonReporter reporter) {
return obj is int;
}
/// Code actions were requested automatically.
///
/// This typically happens when current selection in a file changes, but can
/// also be triggered when file content changes.
static const Automatic = CodeActionTriggerKind(2);
/// Code actions were explicitly requested by the user or by an extension.
static const Invoked = CodeActionTriggerKind(1);
Object toJson() => _value;
@override
String toString() => _value.toString();
@override
int get hashCode => _value.hashCode;
bool operator ==(Object other) =>
other is CodeActionTriggerKind && other._value == _value;
}
/// Structure to capture a description for an error code.
/// @since 3.16.0
class CodeDescription implements ToJsonable {
static const jsonHandler = LspJsonHandler(
CodeDescription.canParse,
CodeDescription.fromJson,
);
CodeDescription({
required this.href,
});
static CodeDescription fromJson(Map<String, Object?> json) {
final hrefJson = json['href'];
final href = hrefJson as String;
return CodeDescription(
href: href,
);
}
/// An URI to open with more information about the diagnostic error.
final String href;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['href'] = href;
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('href');
try {
if (!obj.containsKey('href')) {
reporter.reportError('must not be undefined');
return false;
}
final href = obj['href'];
if (href == null) {
reporter.reportError('must not be null');
return false;
}
if (!(href is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CodeDescription');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CodeDescription && other.runtimeType == CodeDescription) {
return href == other.href && true;
}
return false;
}
@override
int get hashCode => href.hashCode;
@override
String toString() => jsonEncoder.convert(toJson());
}
/// A code lens represents a command that should be shown along with source
/// text, like the number of references, a way to run tests, etc.
///
/// A code lens is _unresolved_ when no command is associated to it. For
/// performance reasons the creation of a code lens and resolving should be done
/// in two stages.
class CodeLens implements ToJsonable {
static const jsonHandler = LspJsonHandler(
CodeLens.canParse,
CodeLens.fromJson,
);
CodeLens({
this.command,
this.data,
required this.range,
});
static CodeLens fromJson(Map<String, Object?> json) {
final commandJson = json['command'];
final command = commandJson != null
? Command.fromJson(commandJson as Map<String, Object?>)
: null;
final dataJson = json['data'];
final data = dataJson;
final rangeJson = json['range'];
final range = Range.fromJson(rangeJson as Map<String, Object?>);
return CodeLens(
command: command,
data: data,
range: range,
);
}
/// The command this code lens represents.
final Command? command;
/// A data entry field that is preserved on a code lens item between a code
/// lens and a code lens resolve request.
final Object? data;
/// The range in which this code lens is valid. Should only span a single
/// line.
final Range range;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (command != null) {
result['command'] = command?.toJson();
}
if (data != null) {
result['data'] = data;
}
result['range'] = range.toJson();
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('command');
try {
final command = obj['command'];
if (command != null && !(Command.canParse(command, reporter))) {
reporter.reportError('must be of type Command');
return false;
}
} finally {
reporter.pop();
}
reporter.push('range');
try {
if (!obj.containsKey('range')) {
reporter.reportError('must not be undefined');
return false;
}
final range = obj['range'];
if (range == null) {
reporter.reportError('must not be null');
return false;
}
if (!(Range.canParse(range, reporter))) {
reporter.reportError('must be of type Range');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CodeLens');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CodeLens && other.runtimeType == CodeLens) {
return command == other.command &&
data == other.data &&
range == other.range &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
command,
data,
range,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class CodeLensClientCapabilities implements ToJsonable {
static const jsonHandler = LspJsonHandler(
CodeLensClientCapabilities.canParse,
CodeLensClientCapabilities.fromJson,
);
CodeLensClientCapabilities({
this.dynamicRegistration,
});
static CodeLensClientCapabilities fromJson(Map<String, Object?> json) {
final dynamicRegistrationJson = json['dynamicRegistration'];
final dynamicRegistration = dynamicRegistrationJson as bool?;
return CodeLensClientCapabilities(
dynamicRegistration: dynamicRegistration,
);
}
/// Whether code lens supports dynamic registration.
final bool? dynamicRegistration;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (dynamicRegistration != null) {
result['dynamicRegistration'] = dynamicRegistration;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('dynamicRegistration');
try {
final dynamicRegistration = obj['dynamicRegistration'];
if (dynamicRegistration != null && !(dynamicRegistration is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CodeLensClientCapabilities');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CodeLensClientCapabilities &&
other.runtimeType == CodeLensClientCapabilities) {
return dynamicRegistration == other.dynamicRegistration && true;
}
return false;
}
@override
int get hashCode => dynamicRegistration.hashCode;
@override
String toString() => jsonEncoder.convert(toJson());
}
class CodeLensOptions implements WorkDoneProgressOptions, ToJsonable {
static const jsonHandler = LspJsonHandler(
CodeLensOptions.canParse,
CodeLensOptions.fromJson,
);
CodeLensOptions({
this.resolveProvider,
this.workDoneProgress,
});
static CodeLensOptions fromJson(Map<String, Object?> json) {
if (CodeLensRegistrationOptions.canParse(json, nullLspJsonReporter)) {
return CodeLensRegistrationOptions.fromJson(json);
}
final resolveProviderJson = json['resolveProvider'];
final resolveProvider = resolveProviderJson as bool?;
final workDoneProgressJson = json['workDoneProgress'];
final workDoneProgress = workDoneProgressJson as bool?;
return CodeLensOptions(
resolveProvider: resolveProvider,
workDoneProgress: workDoneProgress,
);
}
/// Code lens has a resolve provider as well.
final bool? resolveProvider;
final bool? workDoneProgress;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (resolveProvider != null) {
result['resolveProvider'] = resolveProvider;
}
if (workDoneProgress != null) {
result['workDoneProgress'] = workDoneProgress;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('resolveProvider');
try {
final resolveProvider = obj['resolveProvider'];
if (resolveProvider != null && !(resolveProvider is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
reporter.push('workDoneProgress');
try {
final workDoneProgress = obj['workDoneProgress'];
if (workDoneProgress != null && !(workDoneProgress is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CodeLensOptions');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CodeLensOptions && other.runtimeType == CodeLensOptions) {
return resolveProvider == other.resolveProvider &&
workDoneProgress == other.workDoneProgress &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
resolveProvider,
workDoneProgress,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class CodeLensParams
implements PartialResultParams, WorkDoneProgressParams, ToJsonable {
static const jsonHandler = LspJsonHandler(
CodeLensParams.canParse,
CodeLensParams.fromJson,
);
CodeLensParams({
this.partialResultToken,
required this.textDocument,
this.workDoneToken,
});
static CodeLensParams fromJson(Map<String, Object?> json) {
final partialResultTokenJson = json['partialResultToken'];
final partialResultToken = partialResultTokenJson == null
? null
: (partialResultTokenJson is int
? Either2<int, String>.t1(partialResultTokenJson)
: (partialResultTokenJson is String
? Either2<int, String>.t2(partialResultTokenJson)
: (throw '''$partialResultTokenJson was not one of (int, String)''')));
final textDocumentJson = json['textDocument'];
final textDocument = TextDocumentIdentifier.fromJson(
textDocumentJson as Map<String, Object?>);
final workDoneTokenJson = json['workDoneToken'];
final workDoneToken = workDoneTokenJson == null
? null
: (workDoneTokenJson is int
? Either2<int, String>.t1(workDoneTokenJson)
: (workDoneTokenJson is String
? Either2<int, String>.t2(workDoneTokenJson)
: (throw '''$workDoneTokenJson was not one of (int, String)''')));
return CodeLensParams(
partialResultToken: partialResultToken,
textDocument: textDocument,
workDoneToken: workDoneToken,
);
}
/// An optional token that a server can use to report partial results (e.g.
/// streaming) to the client.
final Either2<int, String>? partialResultToken;
/// The document to request code lens for.
final TextDocumentIdentifier textDocument;
/// An optional token that a server can use to report work done progress.
final Either2<int, String>? workDoneToken;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (partialResultToken != null) {
result['partialResultToken'] = partialResultToken;
}
result['textDocument'] = textDocument.toJson();
if (workDoneToken != null) {
result['workDoneToken'] = workDoneToken;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('partialResultToken');
try {
final partialResultToken = obj['partialResultToken'];
if (partialResultToken != null &&
!((partialResultToken is int || partialResultToken is String))) {
reporter.reportError('must be of type Either2<int, String>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('textDocument');
try {
if (!obj.containsKey('textDocument')) {
reporter.reportError('must not be undefined');
return false;
}
final textDocument = obj['textDocument'];
if (textDocument == null) {
reporter.reportError('must not be null');
return false;
}
if (!(TextDocumentIdentifier.canParse(textDocument, reporter))) {
reporter.reportError('must be of type TextDocumentIdentifier');
return false;
}
} finally {
reporter.pop();
}
reporter.push('workDoneToken');
try {
final workDoneToken = obj['workDoneToken'];
if (workDoneToken != null &&
!((workDoneToken is int || workDoneToken is String))) {
reporter.reportError('must be of type Either2<int, String>');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CodeLensParams');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CodeLensParams && other.runtimeType == CodeLensParams) {
return partialResultToken == other.partialResultToken &&
textDocument == other.textDocument &&
workDoneToken == other.workDoneToken &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
partialResultToken,
textDocument,
workDoneToken,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class CodeLensRegistrationOptions
implements CodeLensOptions, TextDocumentRegistrationOptions, ToJsonable {
static const jsonHandler = LspJsonHandler(
CodeLensRegistrationOptions.canParse,
CodeLensRegistrationOptions.fromJson,
);
CodeLensRegistrationOptions({
this.documentSelector,
this.resolveProvider,
this.workDoneProgress,
});
static CodeLensRegistrationOptions fromJson(Map<String, Object?> json) {
final documentSelectorJson = json['documentSelector'];
final documentSelector = (documentSelectorJson as List<Object?>?)
?.map(
(item) => TextDocumentFilter.fromJson(item as Map<String, Object?>))
.toList();
final resolveProviderJson = json['resolveProvider'];
final resolveProvider = resolveProviderJson as bool?;
final workDoneProgressJson = json['workDoneProgress'];
final workDoneProgress = workDoneProgressJson as bool?;
return CodeLensRegistrationOptions(
documentSelector: documentSelector,
resolveProvider: resolveProvider,
workDoneProgress: workDoneProgress,
);
}
/// A document selector to identify the scope of the registration. If set to
/// null the document selector provided on the client side will be used.
final List<TextDocumentFilter>? documentSelector;
/// Code lens has a resolve provider as well.
final bool? resolveProvider;
final bool? workDoneProgress;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['documentSelector'] = documentSelector;
if (resolveProvider != null) {
result['resolveProvider'] = resolveProvider;
}
if (workDoneProgress != null) {
result['workDoneProgress'] = workDoneProgress;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('documentSelector');
try {
if (!obj.containsKey('documentSelector')) {
reporter.reportError('must not be undefined');
return false;
}
final documentSelector = obj['documentSelector'];
if (documentSelector != null &&
!((documentSelector is List<Object?> &&
(documentSelector.every(
(item) => TextDocumentFilter.canParse(item, reporter)))))) {
reporter.reportError('must be of type List<TextDocumentFilter>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('resolveProvider');
try {
final resolveProvider = obj['resolveProvider'];
if (resolveProvider != null && !(resolveProvider is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
reporter.push('workDoneProgress');
try {
final workDoneProgress = obj['workDoneProgress'];
if (workDoneProgress != null && !(workDoneProgress is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CodeLensRegistrationOptions');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CodeLensRegistrationOptions &&
other.runtimeType == CodeLensRegistrationOptions) {
return listEqual(documentSelector, other.documentSelector,
(TextDocumentFilter a, TextDocumentFilter b) => a == b) &&
resolveProvider == other.resolveProvider &&
workDoneProgress == other.workDoneProgress &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
lspHashCode(documentSelector),
resolveProvider,
workDoneProgress,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class CodeLensWorkspaceClientCapabilities implements ToJsonable {
static const jsonHandler = LspJsonHandler(
CodeLensWorkspaceClientCapabilities.canParse,
CodeLensWorkspaceClientCapabilities.fromJson,
);
CodeLensWorkspaceClientCapabilities({
this.refreshSupport,
});
static CodeLensWorkspaceClientCapabilities fromJson(
Map<String, Object?> json) {
final refreshSupportJson = json['refreshSupport'];
final refreshSupport = refreshSupportJson as bool?;
return CodeLensWorkspaceClientCapabilities(
refreshSupport: refreshSupport,
);
}
/// Whether the client implementation supports a refresh request sent from the
/// server to the client.
///
/// Note that this event is global and will force the client to refresh all
/// code lenses currently shown. It should be used with absolute care and is
/// useful for situation where a server for example detect a project wide
/// change that requires such a calculation.
final bool? refreshSupport;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (refreshSupport != null) {
result['refreshSupport'] = refreshSupport;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('refreshSupport');
try {
final refreshSupport = obj['refreshSupport'];
if (refreshSupport != null && !(refreshSupport is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter
.reportError('must be of type CodeLensWorkspaceClientCapabilities');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CodeLensWorkspaceClientCapabilities &&
other.runtimeType == CodeLensWorkspaceClientCapabilities) {
return refreshSupport == other.refreshSupport && true;
}
return false;
}
@override
int get hashCode => refreshSupport.hashCode;
@override
String toString() => jsonEncoder.convert(toJson());
}
/// Represents a color in RGBA space.
class Color implements ToJsonable {
static const jsonHandler = LspJsonHandler(
Color.canParse,
Color.fromJson,
);
Color({
required this.alpha,
required this.blue,
required this.green,
required this.red,
});
static Color fromJson(Map<String, Object?> json) {
final alphaJson = json['alpha'];
final alpha = alphaJson as num;
final blueJson = json['blue'];
final blue = blueJson as num;
final greenJson = json['green'];
final green = greenJson as num;
final redJson = json['red'];
final red = redJson as num;
return Color(
alpha: alpha,
blue: blue,
green: green,
red: red,
);
}
/// The alpha component of this color in the range [0-1].
final num alpha;
/// The blue component of this color in the range [0-1].
final num blue;
/// The green component of this color in the range [0-1].
final num green;
/// The red component of this color in the range [0-1].
final num red;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['alpha'] = alpha;
result['blue'] = blue;
result['green'] = green;
result['red'] = red;
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('alpha');
try {
if (!obj.containsKey('alpha')) {
reporter.reportError('must not be undefined');
return false;
}
final alpha = obj['alpha'];
if (alpha == null) {
reporter.reportError('must not be null');
return false;
}
if (!(alpha is num)) {
reporter.reportError('must be of type num');
return false;
}
} finally {
reporter.pop();
}
reporter.push('blue');
try {
if (!obj.containsKey('blue')) {
reporter.reportError('must not be undefined');
return false;
}
final blue = obj['blue'];
if (blue == null) {
reporter.reportError('must not be null');
return false;
}
if (!(blue is num)) {
reporter.reportError('must be of type num');
return false;
}
} finally {
reporter.pop();
}
reporter.push('green');
try {
if (!obj.containsKey('green')) {
reporter.reportError('must not be undefined');
return false;
}
final green = obj['green'];
if (green == null) {
reporter.reportError('must not be null');
return false;
}
if (!(green is num)) {
reporter.reportError('must be of type num');
return false;
}
} finally {
reporter.pop();
}
reporter.push('red');
try {
if (!obj.containsKey('red')) {
reporter.reportError('must not be undefined');
return false;
}
final red = obj['red'];
if (red == null) {
reporter.reportError('must not be null');
return false;
}
if (!(red is num)) {
reporter.reportError('must be of type num');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type Color');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is Color && other.runtimeType == Color) {
return alpha == other.alpha &&
blue == other.blue &&
green == other.green &&
red == other.red &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
alpha,
blue,
green,
red,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class ColorInformation implements ToJsonable {
static const jsonHandler = LspJsonHandler(
ColorInformation.canParse,
ColorInformation.fromJson,
);
ColorInformation({
required this.color,
required this.range,
});
static ColorInformation fromJson(Map<String, Object?> json) {
final colorJson = json['color'];
final color = Color.fromJson(colorJson as Map<String, Object?>);
final rangeJson = json['range'];
final range = Range.fromJson(rangeJson as Map<String, Object?>);
return ColorInformation(
color: color,
range: range,
);
}
/// The actual color value for this color range.
final Color color;
/// The range in the document where this color appears.
final Range range;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['color'] = color.toJson();
result['range'] = range.toJson();
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('color');
try {
if (!obj.containsKey('color')) {
reporter.reportError('must not be undefined');
return false;
}
final color = obj['color'];
if (color == null) {
reporter.reportError('must not be null');
return false;
}
if (!(Color.canParse(color, reporter))) {
reporter.reportError('must be of type Color');
return false;
}
} finally {
reporter.pop();
}
reporter.push('range');
try {
if (!obj.containsKey('range')) {
reporter.reportError('must not be undefined');
return false;
}
final range = obj['range'];
if (range == null) {
reporter.reportError('must not be null');
return false;
}
if (!(Range.canParse(range, reporter))) {
reporter.reportError('must be of type Range');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type ColorInformation');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is ColorInformation && other.runtimeType == ColorInformation) {
return color == other.color && range == other.range && true;
}
return false;
}
@override
int get hashCode => Object.hash(
color,
range,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class ColorPresentation implements ToJsonable {
static const jsonHandler = LspJsonHandler(
ColorPresentation.canParse,
ColorPresentation.fromJson,
);
ColorPresentation({
this.additionalTextEdits,
required this.label,
this.textEdit,
});
static ColorPresentation fromJson(Map<String, Object?> json) {
final additionalTextEditsJson = json['additionalTextEdits'];
final additionalTextEdits = (additionalTextEditsJson as List<Object?>?)
?.map((item) => TextEdit.fromJson(item as Map<String, Object?>))
.toList();
final labelJson = json['label'];
final label = labelJson as String;
final textEditJson = json['textEdit'];
final textEdit = textEditJson != null
? TextEdit.fromJson(textEditJson as Map<String, Object?>)
: null;
return ColorPresentation(
additionalTextEdits: additionalTextEdits,
label: label,
textEdit: textEdit,
);
}
/// An optional array of additional text edits ([TextEdit]) that are applied
/// when selecting this color presentation. Edits must not overlap with the
/// main [edit](#ColorPresentation.textEdit) nor with themselves.
final List<TextEdit>? additionalTextEdits;
/// The label of this color presentation. It will be shown on the color picker
/// header. By default this is also the text that is inserted when selecting
/// this color presentation.
final String label;
/// An edit ([TextEdit]) which is applied to a document when selecting this
/// presentation for the color. When `falsy` the
/// [label](#ColorPresentation.label) is used.
final TextEdit? textEdit;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (additionalTextEdits != null) {
result['additionalTextEdits'] =
additionalTextEdits?.map((item) => item.toJson()).toList();
}
result['label'] = label;
if (textEdit != null) {
result['textEdit'] = textEdit?.toJson();
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('additionalTextEdits');
try {
final additionalTextEdits = obj['additionalTextEdits'];
if (additionalTextEdits != null &&
!((additionalTextEdits is List<Object?> &&
(additionalTextEdits
.every((item) => TextEdit.canParse(item, reporter)))))) {
reporter.reportError('must be of type List<TextEdit>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('label');
try {
if (!obj.containsKey('label')) {
reporter.reportError('must not be undefined');
return false;
}
final label = obj['label'];
if (label == null) {
reporter.reportError('must not be null');
return false;
}
if (!(label is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
reporter.push('textEdit');
try {
final textEdit = obj['textEdit'];
if (textEdit != null && !(TextEdit.canParse(textEdit, reporter))) {
reporter.reportError('must be of type TextEdit');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type ColorPresentation');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is ColorPresentation && other.runtimeType == ColorPresentation) {
return listEqual(additionalTextEdits, other.additionalTextEdits,
(TextEdit a, TextEdit b) => a == b) &&
label == other.label &&
textEdit == other.textEdit &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
lspHashCode(additionalTextEdits),
label,
textEdit,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class ColorPresentationParams
implements PartialResultParams, WorkDoneProgressParams, ToJsonable {
static const jsonHandler = LspJsonHandler(
ColorPresentationParams.canParse,
ColorPresentationParams.fromJson,
);
ColorPresentationParams({
required this.color,
this.partialResultToken,
required this.range,
required this.textDocument,
this.workDoneToken,
});
static ColorPresentationParams fromJson(Map<String, Object?> json) {
final colorJson = json['color'];
final color = Color.fromJson(colorJson as Map<String, Object?>);
final partialResultTokenJson = json['partialResultToken'];
final partialResultToken = partialResultTokenJson == null
? null
: (partialResultTokenJson is int
? Either2<int, String>.t1(partialResultTokenJson)
: (partialResultTokenJson is String
? Either2<int, String>.t2(partialResultTokenJson)
: (throw '''$partialResultTokenJson was not one of (int, String)''')));
final rangeJson = json['range'];
final range = Range.fromJson(rangeJson as Map<String, Object?>);
final textDocumentJson = json['textDocument'];
final textDocument = TextDocumentIdentifier.fromJson(
textDocumentJson as Map<String, Object?>);
final workDoneTokenJson = json['workDoneToken'];
final workDoneToken = workDoneTokenJson == null
? null
: (workDoneTokenJson is int
? Either2<int, String>.t1(workDoneTokenJson)
: (workDoneTokenJson is String
? Either2<int, String>.t2(workDoneTokenJson)
: (throw '''$workDoneTokenJson was not one of (int, String)''')));
return ColorPresentationParams(
color: color,
partialResultToken: partialResultToken,
range: range,
textDocument: textDocument,
workDoneToken: workDoneToken,
);
}
/// The color information to request presentations for.
final Color color;
/// An optional token that a server can use to report partial results (e.g.
/// streaming) to the client.
final Either2<int, String>? partialResultToken;
/// The range where the color would be inserted. Serves as a context.
final Range range;
/// The text document.
final TextDocumentIdentifier textDocument;
/// An optional token that a server can use to report work done progress.
final Either2<int, String>? workDoneToken;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['color'] = color.toJson();
if (partialResultToken != null) {
result['partialResultToken'] = partialResultToken;
}
result['range'] = range.toJson();
result['textDocument'] = textDocument.toJson();
if (workDoneToken != null) {
result['workDoneToken'] = workDoneToken;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('color');
try {
if (!obj.containsKey('color')) {
reporter.reportError('must not be undefined');
return false;
}
final color = obj['color'];
if (color == null) {
reporter.reportError('must not be null');
return false;
}
if (!(Color.canParse(color, reporter))) {
reporter.reportError('must be of type Color');
return false;
}
} finally {
reporter.pop();
}
reporter.push('partialResultToken');
try {
final partialResultToken = obj['partialResultToken'];
if (partialResultToken != null &&
!((partialResultToken is int || partialResultToken is String))) {
reporter.reportError('must be of type Either2<int, String>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('range');
try {
if (!obj.containsKey('range')) {
reporter.reportError('must not be undefined');
return false;
}
final range = obj['range'];
if (range == null) {
reporter.reportError('must not be null');
return false;
}
if (!(Range.canParse(range, reporter))) {
reporter.reportError('must be of type Range');
return false;
}
} finally {
reporter.pop();
}
reporter.push('textDocument');
try {
if (!obj.containsKey('textDocument')) {
reporter.reportError('must not be undefined');
return false;
}
final textDocument = obj['textDocument'];
if (textDocument == null) {
reporter.reportError('must not be null');
return false;
}
if (!(TextDocumentIdentifier.canParse(textDocument, reporter))) {
reporter.reportError('must be of type TextDocumentIdentifier');
return false;
}
} finally {
reporter.pop();
}
reporter.push('workDoneToken');
try {
final workDoneToken = obj['workDoneToken'];
if (workDoneToken != null &&
!((workDoneToken is int || workDoneToken is String))) {
reporter.reportError('must be of type Either2<int, String>');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type ColorPresentationParams');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is ColorPresentationParams &&
other.runtimeType == ColorPresentationParams) {
return color == other.color &&
partialResultToken == other.partialResultToken &&
range == other.range &&
textDocument == other.textDocument &&
workDoneToken == other.workDoneToken &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
color,
partialResultToken,
range,
textDocument,
workDoneToken,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class Command implements ToJsonable {
static const jsonHandler = LspJsonHandler(
Command.canParse,
Command.fromJson,
);
Command({
this.arguments,
required this.command,
required this.title,
});
static Command fromJson(Map<String, Object?> json) {
final argumentsJson = json['arguments'];
final arguments =
(argumentsJson as List<Object?>?)?.map((item) => item).toList();
final commandJson = json['command'];
final command = commandJson as String;
final titleJson = json['title'];
final title = titleJson as String;
return Command(
arguments: arguments,
command: command,
title: title,
);
}
/// Arguments that the command handler should be invoked with.
final List<Object?>? arguments;
/// The identifier of the actual command handler.
final String command;
/// Title of the command, like `save`.
final String title;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (arguments != null) {
result['arguments'] = arguments;
}
result['command'] = command;
result['title'] = title;
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('arguments');
try {
final arguments = obj['arguments'];
if (arguments != null &&
!((arguments is List<Object?> &&
(arguments.every((item) => true))))) {
reporter.reportError('must be of type List<Object?>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('command');
try {
if (!obj.containsKey('command')) {
reporter.reportError('must not be undefined');
return false;
}
final command = obj['command'];
if (command == null) {
reporter.reportError('must not be null');
return false;
}
if (!(command is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
reporter.push('title');
try {
if (!obj.containsKey('title')) {
reporter.reportError('must not be undefined');
return false;
}
final title = obj['title'];
if (title == null) {
reporter.reportError('must not be null');
return false;
}
if (!(title is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type Command');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is Command && other.runtimeType == Command) {
return listEqual(
arguments, other.arguments, (Object? a, Object? b) => a == b) &&
command == other.command &&
title == other.title &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
lspHashCode(arguments),
command,
title,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class CompletionClientCapabilities implements ToJsonable {
static const jsonHandler = LspJsonHandler(
CompletionClientCapabilities.canParse,
CompletionClientCapabilities.fromJson,
);
CompletionClientCapabilities({
this.completionItem,
this.completionItemKind,
this.completionList,
this.contextSupport,
this.dynamicRegistration,
this.insertTextMode,
});
static CompletionClientCapabilities fromJson(Map<String, Object?> json) {
final completionItemJson = json['completionItem'];
final completionItem = completionItemJson != null
? CompletionClientCapabilitiesCompletionItem.fromJson(
completionItemJson as Map<String, Object?>)
: null;
final completionItemKindJson = json['completionItemKind'];
final completionItemKind = completionItemKindJson != null
? CompletionClientCapabilitiesCompletionItemKind.fromJson(
completionItemKindJson as Map<String, Object?>)
: null;
final completionListJson = json['completionList'];
final completionList = completionListJson != null
? CompletionClientCapabilitiesCompletionList.fromJson(
completionListJson as Map<String, Object?>)
: null;
final contextSupportJson = json['contextSupport'];
final contextSupport = contextSupportJson as bool?;
final dynamicRegistrationJson = json['dynamicRegistration'];
final dynamicRegistration = dynamicRegistrationJson as bool?;
final insertTextModeJson = json['insertTextMode'];
final insertTextMode = insertTextModeJson != null
? InsertTextMode.fromJson(insertTextModeJson as int)
: null;
return CompletionClientCapabilities(
completionItem: completionItem,
completionItemKind: completionItemKind,
completionList: completionList,
contextSupport: contextSupport,
dynamicRegistration: dynamicRegistration,
insertTextMode: insertTextMode,
);
}
/// The client supports the following `CompletionItem` specific capabilities.
final CompletionClientCapabilitiesCompletionItem? completionItem;
final CompletionClientCapabilitiesCompletionItemKind? completionItemKind;
/// The client supports the following `CompletionList` specific capabilities.
/// @since 3.17.0
final CompletionClientCapabilitiesCompletionList? completionList;
/// The client supports to send additional context information for a
/// `textDocument/completion` request.
final bool? contextSupport;
/// Whether completion supports dynamic registration.
final bool? dynamicRegistration;
/// The client's default when the completion item doesn't provide a
/// `insertTextMode` property.
/// @since 3.17.0
final InsertTextMode? insertTextMode;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (completionItem != null) {
result['completionItem'] = completionItem?.toJson();
}
if (completionItemKind != null) {
result['completionItemKind'] = completionItemKind?.toJson();
}
if (completionList != null) {
result['completionList'] = completionList?.toJson();
}
if (contextSupport != null) {
result['contextSupport'] = contextSupport;
}
if (dynamicRegistration != null) {
result['dynamicRegistration'] = dynamicRegistration;
}
if (insertTextMode != null) {
result['insertTextMode'] = insertTextMode?.toJson();
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('completionItem');
try {
final completionItem = obj['completionItem'];
if (completionItem != null &&
!(CompletionClientCapabilitiesCompletionItem.canParse(
completionItem, reporter))) {
reporter.reportError(
'must be of type CompletionClientCapabilitiesCompletionItem');
return false;
}
} finally {
reporter.pop();
}
reporter.push('completionItemKind');
try {
final completionItemKind = obj['completionItemKind'];
if (completionItemKind != null &&
!(CompletionClientCapabilitiesCompletionItemKind.canParse(
completionItemKind, reporter))) {
reporter.reportError(
'must be of type CompletionClientCapabilitiesCompletionItemKind');
return false;
}
} finally {
reporter.pop();
}
reporter.push('completionList');
try {
final completionList = obj['completionList'];
if (completionList != null &&
!(CompletionClientCapabilitiesCompletionList.canParse(
completionList, reporter))) {
reporter.reportError(
'must be of type CompletionClientCapabilitiesCompletionList');
return false;
}
} finally {
reporter.pop();
}
reporter.push('contextSupport');
try {
final contextSupport = obj['contextSupport'];
if (contextSupport != null && !(contextSupport is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
reporter.push('dynamicRegistration');
try {
final dynamicRegistration = obj['dynamicRegistration'];
if (dynamicRegistration != null && !(dynamicRegistration is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
reporter.push('insertTextMode');
try {
final insertTextMode = obj['insertTextMode'];
if (insertTextMode != null &&
!(InsertTextMode.canParse(insertTextMode, reporter))) {
reporter.reportError('must be of type InsertTextMode');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CompletionClientCapabilities');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CompletionClientCapabilities &&
other.runtimeType == CompletionClientCapabilities) {
return completionItem == other.completionItem &&
completionItemKind == other.completionItemKind &&
completionList == other.completionList &&
contextSupport == other.contextSupport &&
dynamicRegistration == other.dynamicRegistration &&
insertTextMode == other.insertTextMode &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
completionItem,
completionItemKind,
completionList,
contextSupport,
dynamicRegistration,
insertTextMode,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class CompletionClientCapabilitiesCompletionItem implements ToJsonable {
static const jsonHandler = LspJsonHandler(
CompletionClientCapabilitiesCompletionItem.canParse,
CompletionClientCapabilitiesCompletionItem.fromJson,
);
CompletionClientCapabilitiesCompletionItem({
this.commitCharactersSupport,
this.deprecatedSupport,
this.documentationFormat,
this.insertReplaceSupport,
this.insertTextModeSupport,
this.labelDetailsSupport,
this.preselectSupport,
this.resolveSupport,
this.snippetSupport,
this.tagSupport,
});
static CompletionClientCapabilitiesCompletionItem fromJson(
Map<String, Object?> json) {
final commitCharactersSupportJson = json['commitCharactersSupport'];
final commitCharactersSupport = commitCharactersSupportJson as bool?;
final deprecatedSupportJson = json['deprecatedSupport'];
final deprecatedSupport = deprecatedSupportJson as bool?;
final documentationFormatJson = json['documentationFormat'];
final documentationFormat = (documentationFormatJson as List<Object?>?)
?.map((item) => MarkupKind.fromJson(item as String))
.toList();
final insertReplaceSupportJson = json['insertReplaceSupport'];
final insertReplaceSupport = insertReplaceSupportJson as bool?;
final insertTextModeSupportJson = json['insertTextModeSupport'];
final insertTextModeSupport = insertTextModeSupportJson != null
? CompletionItemInsertTextModeSupport.fromJson(
insertTextModeSupportJson as Map<String, Object?>)
: null;
final labelDetailsSupportJson = json['labelDetailsSupport'];
final labelDetailsSupport = labelDetailsSupportJson as bool?;
final preselectSupportJson = json['preselectSupport'];
final preselectSupport = preselectSupportJson as bool?;
final resolveSupportJson = json['resolveSupport'];
final resolveSupport = resolveSupportJson != null
? CompletionItemResolveSupport.fromJson(
resolveSupportJson as Map<String, Object?>)
: null;
final snippetSupportJson = json['snippetSupport'];
final snippetSupport = snippetSupportJson as bool?;
final tagSupportJson = json['tagSupport'];
final tagSupport = tagSupportJson != null
? CompletionItemTagSupport.fromJson(
tagSupportJson as Map<String, Object?>)
: null;
return CompletionClientCapabilitiesCompletionItem(
commitCharactersSupport: commitCharactersSupport,
deprecatedSupport: deprecatedSupport,
documentationFormat: documentationFormat,
insertReplaceSupport: insertReplaceSupport,
insertTextModeSupport: insertTextModeSupport,
labelDetailsSupport: labelDetailsSupport,
preselectSupport: preselectSupport,
resolveSupport: resolveSupport,
snippetSupport: snippetSupport,
tagSupport: tagSupport,
);
}
/// Client supports commit characters on a completion item.
final bool? commitCharactersSupport;
/// Client supports the deprecated property on a completion item.
final bool? deprecatedSupport;
/// Client supports the follow content formats for the documentation property.
/// The order describes the preferred format of the client.
final List<MarkupKind>? documentationFormat;
/// Client supports insert replace edit to control different behavior if a
/// completion item is inserted in the text or should replace text.
/// @since 3.16.0
final bool? insertReplaceSupport;
/// The client supports the `insertTextMode` property on a completion item to
/// override the whitespace handling mode as defined by the client (see
/// `insertTextMode`).
/// @since 3.16.0
final CompletionItemInsertTextModeSupport? insertTextModeSupport;
/// The client has support for completion item label details (see also
/// `CompletionItemLabelDetails`).
/// @since 3.17.0
final bool? labelDetailsSupport;
/// Client supports the preselect property on a completion item.
final bool? preselectSupport;
/// Indicates which properties a client can resolve lazily on a completion
/// item. Before version 3.16.0 only the predefined properties `documentation`
/// and `detail` could be resolved lazily.
/// @since 3.16.0
final CompletionItemResolveSupport? resolveSupport;
/// Client supports snippets as insert text.
///
/// A snippet can define tab stops and placeholders with `$1`, `$2` and
/// `${3:foo}`. `$0` defines the final tab stop, it defaults to the end of the
/// snippet. Placeholders with equal identifiers are linked, that is typing in
/// one will update others too.
final bool? snippetSupport;
/// Client supports the tag property on a completion item. Clients supporting
/// tags have to handle unknown tags gracefully. Clients especially need to
/// preserve unknown tags when sending a completion item back to the server in
/// a resolve call.
/// @since 3.15.0
final CompletionItemTagSupport? tagSupport;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (commitCharactersSupport != null) {
result['commitCharactersSupport'] = commitCharactersSupport;
}
if (deprecatedSupport != null) {
result['deprecatedSupport'] = deprecatedSupport;
}
if (documentationFormat != null) {
result['documentationFormat'] =
documentationFormat?.map((item) => item.toJson()).toList();
}
if (insertReplaceSupport != null) {
result['insertReplaceSupport'] = insertReplaceSupport;
}
if (insertTextModeSupport != null) {
result['insertTextModeSupport'] = insertTextModeSupport?.toJson();
}
if (labelDetailsSupport != null) {
result['labelDetailsSupport'] = labelDetailsSupport;
}
if (preselectSupport != null) {
result['preselectSupport'] = preselectSupport;
}
if (resolveSupport != null) {
result['resolveSupport'] = resolveSupport?.toJson();
}
if (snippetSupport != null) {
result['snippetSupport'] = snippetSupport;
}
if (tagSupport != null) {
result['tagSupport'] = tagSupport?.toJson();
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('commitCharactersSupport');
try {
final commitCharactersSupport = obj['commitCharactersSupport'];
if (commitCharactersSupport != null &&
!(commitCharactersSupport is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
reporter.push('deprecatedSupport');
try {
final deprecatedSupport = obj['deprecatedSupport'];
if (deprecatedSupport != null && !(deprecatedSupport is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
reporter.push('documentationFormat');
try {
final documentationFormat = obj['documentationFormat'];
if (documentationFormat != null &&
!((documentationFormat is List<Object?> &&
(documentationFormat
.every((item) => MarkupKind.canParse(item, reporter)))))) {
reporter.reportError('must be of type List<MarkupKind>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('insertReplaceSupport');
try {
final insertReplaceSupport = obj['insertReplaceSupport'];
if (insertReplaceSupport != null && !(insertReplaceSupport is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
reporter.push('insertTextModeSupport');
try {
final insertTextModeSupport = obj['insertTextModeSupport'];
if (insertTextModeSupport != null &&
!(CompletionItemInsertTextModeSupport.canParse(
insertTextModeSupport, reporter))) {
reporter.reportError(
'must be of type CompletionItemInsertTextModeSupport');
return false;
}
} finally {
reporter.pop();
}
reporter.push('labelDetailsSupport');
try {
final labelDetailsSupport = obj['labelDetailsSupport'];
if (labelDetailsSupport != null && !(labelDetailsSupport is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
reporter.push('preselectSupport');
try {
final preselectSupport = obj['preselectSupport'];
if (preselectSupport != null && !(preselectSupport is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
reporter.push('resolveSupport');
try {
final resolveSupport = obj['resolveSupport'];
if (resolveSupport != null &&
!(CompletionItemResolveSupport.canParse(
resolveSupport, reporter))) {
reporter.reportError('must be of type CompletionItemResolveSupport');
return false;
}
} finally {
reporter.pop();
}
reporter.push('snippetSupport');
try {
final snippetSupport = obj['snippetSupport'];
if (snippetSupport != null && !(snippetSupport is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
reporter.push('tagSupport');
try {
final tagSupport = obj['tagSupport'];
if (tagSupport != null &&
!(CompletionItemTagSupport.canParse(tagSupport, reporter))) {
reporter.reportError('must be of type CompletionItemTagSupport');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError(
'must be of type CompletionClientCapabilitiesCompletionItem');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CompletionClientCapabilitiesCompletionItem &&
other.runtimeType == CompletionClientCapabilitiesCompletionItem) {
return commitCharactersSupport == other.commitCharactersSupport &&
deprecatedSupport == other.deprecatedSupport &&
listEqual(documentationFormat, other.documentationFormat,
(MarkupKind a, MarkupKind b) => a == b) &&
insertReplaceSupport == other.insertReplaceSupport &&
insertTextModeSupport == other.insertTextModeSupport &&
labelDetailsSupport == other.labelDetailsSupport &&
preselectSupport == other.preselectSupport &&
resolveSupport == other.resolveSupport &&
snippetSupport == other.snippetSupport &&
tagSupport == other.tagSupport &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
commitCharactersSupport,
deprecatedSupport,
lspHashCode(documentationFormat),
insertReplaceSupport,
insertTextModeSupport,
labelDetailsSupport,
preselectSupport,
resolveSupport,
snippetSupport,
tagSupport,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class CompletionClientCapabilitiesCompletionItemKind implements ToJsonable {
static const jsonHandler = LspJsonHandler(
CompletionClientCapabilitiesCompletionItemKind.canParse,
CompletionClientCapabilitiesCompletionItemKind.fromJson,
);
CompletionClientCapabilitiesCompletionItemKind({
this.valueSet,
});
static CompletionClientCapabilitiesCompletionItemKind fromJson(
Map<String, Object?> json) {
final valueSetJson = json['valueSet'];
final valueSet = (valueSetJson as List<Object?>?)
?.map((item) => CompletionItemKind.fromJson(item as int))
.toList();
return CompletionClientCapabilitiesCompletionItemKind(
valueSet: valueSet,
);
}
/// The completion item kind values the client supports. When this property
/// exists the client also guarantees that it will handle values outside its
/// set gracefully and falls back to a default value when unknown.
///
/// If this property is not present the client only supports the completion
/// items kinds from `Text` to `Reference` as defined in the initial version
/// of the protocol.
final List<CompletionItemKind>? valueSet;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (valueSet != null) {
result['valueSet'] = valueSet?.map((item) => item.toJson()).toList();
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('valueSet');
try {
final valueSet = obj['valueSet'];
if (valueSet != null &&
!((valueSet is List<Object?> &&
(valueSet.every(
(item) => CompletionItemKind.canParse(item, reporter)))))) {
reporter.reportError('must be of type List<CompletionItemKind>');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError(
'must be of type CompletionClientCapabilitiesCompletionItemKind');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CompletionClientCapabilitiesCompletionItemKind &&
other.runtimeType == CompletionClientCapabilitiesCompletionItemKind) {
return listEqual(valueSet, other.valueSet,
(CompletionItemKind a, CompletionItemKind b) => a == b) &&
true;
}
return false;
}
@override
int get hashCode => lspHashCode(valueSet);
@override
String toString() => jsonEncoder.convert(toJson());
}
class CompletionClientCapabilitiesCompletionList implements ToJsonable {
static const jsonHandler = LspJsonHandler(
CompletionClientCapabilitiesCompletionList.canParse,
CompletionClientCapabilitiesCompletionList.fromJson,
);
CompletionClientCapabilitiesCompletionList({
this.itemDefaults,
});
static CompletionClientCapabilitiesCompletionList fromJson(
Map<String, Object?> json) {
final itemDefaultsJson = json['itemDefaults'];
final itemDefaults = (itemDefaultsJson as List<Object?>?)
?.map((item) => item as String)
.toList();
return CompletionClientCapabilitiesCompletionList(
itemDefaults: itemDefaults,
);
}
/// The client supports the the following itemDefaults on a completion list.
///
/// The value lists the supported property names of the
/// `CompletionList.itemDefaults` object. If omitted no properties are
/// supported.
/// @since 3.17.0
final List<String>? itemDefaults;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (itemDefaults != null) {
result['itemDefaults'] = itemDefaults;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('itemDefaults');
try {
final itemDefaults = obj['itemDefaults'];
if (itemDefaults != null &&
!((itemDefaults is List<Object?> &&
(itemDefaults.every((item) => item is String))))) {
reporter.reportError('must be of type List<String>');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError(
'must be of type CompletionClientCapabilitiesCompletionList');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CompletionClientCapabilitiesCompletionList &&
other.runtimeType == CompletionClientCapabilitiesCompletionList) {
return listEqual(itemDefaults, other.itemDefaults,
(String a, String b) => a == b) &&
true;
}
return false;
}
@override
int get hashCode => lspHashCode(itemDefaults);
@override
String toString() => jsonEncoder.convert(toJson());
}
/// Contains additional information about the context in which a completion
/// request is triggered.
class CompletionContext implements ToJsonable {
static const jsonHandler = LspJsonHandler(
CompletionContext.canParse,
CompletionContext.fromJson,
);
CompletionContext({
this.triggerCharacter,
required this.triggerKind,
});
static CompletionContext fromJson(Map<String, Object?> json) {
final triggerCharacterJson = json['triggerCharacter'];
final triggerCharacter = triggerCharacterJson as String?;
final triggerKindJson = json['triggerKind'];
final triggerKind = CompletionTriggerKind.fromJson(triggerKindJson as int);
return CompletionContext(
triggerCharacter: triggerCharacter,
triggerKind: triggerKind,
);
}
/// The trigger character (a single character) that has trigger code complete.
/// Is undefined if `triggerKind !== CompletionTriggerKind.TriggerCharacter`
final String? triggerCharacter;
/// How the completion was triggered.
final CompletionTriggerKind triggerKind;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (triggerCharacter != null) {
result['triggerCharacter'] = triggerCharacter;
}
result['triggerKind'] = triggerKind.toJson();
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('triggerCharacter');
try {
final triggerCharacter = obj['triggerCharacter'];
if (triggerCharacter != null && !(triggerCharacter is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
reporter.push('triggerKind');
try {
if (!obj.containsKey('triggerKind')) {
reporter.reportError('must not be undefined');
return false;
}
final triggerKind = obj['triggerKind'];
if (triggerKind == null) {
reporter.reportError('must not be null');
return false;
}
if (!(CompletionTriggerKind.canParse(triggerKind, reporter))) {
reporter.reportError('must be of type CompletionTriggerKind');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CompletionContext');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CompletionContext && other.runtimeType == CompletionContext) {
return triggerCharacter == other.triggerCharacter &&
triggerKind == other.triggerKind &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
triggerCharacter,
triggerKind,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class CompletionItem implements ToJsonable {
static const jsonHandler = LspJsonHandler(
CompletionItem.canParse,
CompletionItem.fromJson,
);
CompletionItem({
this.additionalTextEdits,
this.command,
this.commitCharacters,
this.data,
this.deprecated,
this.detail,
this.documentation,
this.filterText,
this.insertText,
this.insertTextFormat,
this.insertTextMode,
this.kind,
required this.label,
this.labelDetails,
this.preselect,
this.sortText,
this.tags,
this.textEdit,
this.textEditText,
});
static CompletionItem fromJson(Map<String, Object?> json) {
final additionalTextEditsJson = json['additionalTextEdits'];
final additionalTextEdits = (additionalTextEditsJson as List<Object?>?)
?.map((item) => TextEdit.fromJson(item as Map<String, Object?>))
.toList();
final commandJson = json['command'];
final command = commandJson != null
? Command.fromJson(commandJson as Map<String, Object?>)
: null;
final commitCharactersJson = json['commitCharacters'];
final commitCharacters = (commitCharactersJson as List<Object?>?)
?.map((item) => item as String)
.toList();
final dataJson = json['data'];
final data = dataJson != null
? CompletionItemResolutionInfo.fromJson(
dataJson as Map<String, Object?>)
: null;
final deprecatedJson = json['deprecated'];
final deprecated = deprecatedJson as bool?;
final detailJson = json['detail'];
final detail = detailJson as String?;
final documentationJson = json['documentation'];
final documentation = documentationJson == null
? null
: (MarkupContent.canParse(documentationJson, nullLspJsonReporter)
? Either2<MarkupContent, String>.t1(MarkupContent.fromJson(
documentationJson as Map<String, Object?>))
: (documentationJson is String
? Either2<MarkupContent, String>.t2(documentationJson)
: (throw '''$documentationJson was not one of (MarkupContent, String)''')));
final filterTextJson = json['filterText'];
final filterText = filterTextJson as String?;
final insertTextJson = json['insertText'];
final insertText = insertTextJson as String?;
final insertTextFormatJson = json['insertTextFormat'];
final insertTextFormat = insertTextFormatJson != null
? InsertTextFormat.fromJson(insertTextFormatJson as int)
: null;
final insertTextModeJson = json['insertTextMode'];
final insertTextMode = insertTextModeJson != null
? InsertTextMode.fromJson(insertTextModeJson as int)
: null;
final kindJson = json['kind'];
final kind =
kindJson != null ? CompletionItemKind.fromJson(kindJson as int) : null;
final labelJson = json['label'];
final label = labelJson as String;
final labelDetailsJson = json['labelDetails'];
final labelDetails = labelDetailsJson != null
? CompletionItemLabelDetails.fromJson(
labelDetailsJson as Map<String, Object?>)
: null;
final preselectJson = json['preselect'];
final preselect = preselectJson as bool?;
final sortTextJson = json['sortText'];
final sortText = sortTextJson as String?;
final tagsJson = json['tags'];
final tags = (tagsJson as List<Object?>?)
?.map((item) => CompletionItemTag.fromJson(item as int))
.toList();
final textEditJson = json['textEdit'];
final textEdit = textEditJson == null
? null
: (InsertReplaceEdit.canParse(textEditJson, nullLspJsonReporter)
? Either2<InsertReplaceEdit, TextEdit>.t1(
InsertReplaceEdit.fromJson(
textEditJson as Map<String, Object?>))
: (TextEdit.canParse(textEditJson, nullLspJsonReporter)
? Either2<InsertReplaceEdit, TextEdit>.t2(
TextEdit.fromJson(textEditJson as Map<String, Object?>))
: (throw '''$textEditJson was not one of (InsertReplaceEdit, TextEdit)''')));
final textEditTextJson = json['textEditText'];
final textEditText = textEditTextJson as String?;
return CompletionItem(
additionalTextEdits: additionalTextEdits,
command: command,
commitCharacters: commitCharacters,
data: data,
deprecated: deprecated,
detail: detail,
documentation: documentation,
filterText: filterText,
insertText: insertText,
insertTextFormat: insertTextFormat,
insertTextMode: insertTextMode,
kind: kind,
label: label,
labelDetails: labelDetails,
preselect: preselect,
sortText: sortText,
tags: tags,
textEdit: textEdit,
textEditText: textEditText,
);
}
/// An optional array of additional text edits that are applied when selecting
/// this completion. Edits must not overlap (including the same insert
/// position) with the main edit nor with themselves.
///
/// Additional text edits should be used to change text unrelated to the
/// current cursor position (for example adding an import statement at the top
/// of the file if the completion item will insert an unqualified type).
final List<TextEdit>? additionalTextEdits;
/// An optional command that is executed *after* inserting this completion.
/// *Note* that additional modifications to the current document should be
/// described with the additionalTextEdits-property.
final Command? command;
/// An optional set of characters that when pressed while this completion is
/// active will accept it first and then type that character. *Note* that all
/// commit characters should have `length=1` and that superfluous characters
/// will be ignored.
final List<String>? commitCharacters;
/// A data entry field that is preserved on a completion item between a
/// completion and a completion resolve request.
final CompletionItemResolutionInfo? data;
/// Indicates if this item is deprecated.
/// @deprecated Use `tags` instead if supported.
final bool? deprecated;
/// A human-readable string with additional information about this item, like
/// type or symbol information.
final String? detail;
/// A human-readable string that represents a doc-comment.
final Either2<MarkupContent, String>? documentation;
/// A string that should be used when filtering a set of completion items.
/// When `falsy` the label is used as the filter text for this item.
final String? filterText;
/// A string that should be inserted into a document when selecting this
/// completion. When `falsy` the label is used as the insert text for this
/// item.
///
/// The `insertText` is subject to interpretation by the client side. Some
/// tools might not take the string literally. For example VS Code when code
/// complete is requested in this example `con<cursor position>` and a
/// completion item with an `insertText` of `console` is provided it will only
/// insert `sole`. Therefore it is recommended to use `textEdit` instead since
/// it avoids additional client side interpretation.
final String? insertText;
/// The format of the insert text. The format applies to both the `insertText`
/// property and the `newText` property of a provided `textEdit`. If omitted
/// defaults to `InsertTextFormat.PlainText`.
///
/// Please note that the insertTextFormat doesn't apply to
/// `additionalTextEdits`.
final InsertTextFormat? insertTextFormat;
/// How whitespace and indentation is handled during completion item
/// insertion. If not provided the client's default value depends on the
/// `textDocument.completion.insertTextMode` client capability.
/// @since 3.16.0 @since 3.17.0 - support for
/// `textDocument.completion.insertTextMode`
final InsertTextMode? insertTextMode;
/// The kind of this completion item. Based of the kind an icon is chosen by
/// the editor. The standardized set of available values is defined in
/// `CompletionItemKind`.
final CompletionItemKind? kind;
/// The label of this completion item.
///
/// The label property is also by default the text that is inserted when
/// selecting this completion.
///
/// If label details are provided the label itself should be an unqualified
/// name of the completion item.
final String label;
/// Additional details for the label
/// @since 3.17.0
final CompletionItemLabelDetails? labelDetails;
/// Select this item when showing.
///
/// *Note* that only one completion item can be selected and that the tool /
/// client decides which item that is. The rule is that the *first* item of
/// those that match best is selected.
final bool? preselect;
/// A string that should be used when comparing this item with other items.
/// When `falsy` the label is used as the sort text for this item.
final String? sortText;
/// Tags for this completion item.
/// @since 3.15.0
final List<CompletionItemTag>? tags;
/// An edit which is applied to a document when selecting this completion.
/// When an edit is provided the value of `insertText` is ignored.
///
/// *Note:* The range of the edit must be a single line range and it must
/// contain the position at which completion has been requested.
///
/// Most editors support two different operations when accepting a completion
/// item. One is to insert a completion text and the other is to replace an
/// existing text with a completion text. Since this can usually not be
/// predetermined by a server it can report both ranges. Clients need to
/// signal support for `InsertReplaceEdit`s via the
/// `textDocument.completion.completionItem.insertReplaceSupport` client
/// capability property.
///
/// *Note 1:* The text edit's range as well as both ranges from an insert
/// replace edit must be a [single line] and they must contain the position at
/// which completion has been requested.
/// *Note 2:* If an `InsertReplaceEdit` is returned the edit's insert range
/// must be a prefix of the edit's replace range, that means it must be
/// contained and starting at the same position.
/// @since 3.16.0 additional type `InsertReplaceEdit`
final Either2<InsertReplaceEdit, TextEdit>? textEdit;
/// The edit text used if the completion item is part of a CompletionList and
/// CompletionList defines an item default for the text edit range.
///
/// Clients will only honor this property if they opt into completion list
/// item defaults using the capability `completionList.itemDefaults`.
///
/// If not provided and a list's default range is provided the label property
/// is used as a text.
/// @since 3.17.0
final String? textEditText;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (additionalTextEdits != null) {
result['additionalTextEdits'] =
additionalTextEdits?.map((item) => item.toJson()).toList();
}
if (command != null) {
result['command'] = command?.toJson();
}
if (commitCharacters != null) {
result['commitCharacters'] = commitCharacters;
}
if (data != null) {
result['data'] = data?.toJson();
}
if (deprecated != null) {
result['deprecated'] = deprecated;
}
if (detail != null) {
result['detail'] = detail;
}
if (documentation != null) {
result['documentation'] = documentation;
}
if (filterText != null) {
result['filterText'] = filterText;
}
if (insertText != null) {
result['insertText'] = insertText;
}
if (insertTextFormat != null) {
result['insertTextFormat'] = insertTextFormat?.toJson();
}
if (insertTextMode != null) {
result['insertTextMode'] = insertTextMode?.toJson();
}
if (kind != null) {
result['kind'] = kind?.toJson();
}
result['label'] = label;
if (labelDetails != null) {
result['labelDetails'] = labelDetails?.toJson();
}
if (preselect != null) {
result['preselect'] = preselect;
}
if (sortText != null) {
result['sortText'] = sortText;
}
if (tags != null) {
result['tags'] = tags?.map((item) => item.toJson()).toList();
}
if (textEdit != null) {
result['textEdit'] = textEdit;
}
if (textEditText != null) {
result['textEditText'] = textEditText;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('additionalTextEdits');
try {
final additionalTextEdits = obj['additionalTextEdits'];
if (additionalTextEdits != null &&
!((additionalTextEdits is List<Object?> &&
(additionalTextEdits
.every((item) => TextEdit.canParse(item, reporter)))))) {
reporter.reportError('must be of type List<TextEdit>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('command');
try {
final command = obj['command'];
if (command != null && !(Command.canParse(command, reporter))) {
reporter.reportError('must be of type Command');
return false;
}
} finally {
reporter.pop();
}
reporter.push('commitCharacters');
try {
final commitCharacters = obj['commitCharacters'];
if (commitCharacters != null &&
!((commitCharacters is List<Object?> &&
(commitCharacters.every((item) => item is String))))) {
reporter.reportError('must be of type List<String>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('data');
try {
final data = obj['data'];
if (data != null &&
!(CompletionItemResolutionInfo.canParse(data, reporter))) {
reporter.reportError('must be of type CompletionItemResolutionInfo');
return false;
}
} finally {
reporter.pop();
}
reporter.push('deprecated');
try {
final deprecated = obj['deprecated'];
if (deprecated != null && !(deprecated is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
reporter.push('detail');
try {
final detail = obj['detail'];
if (detail != null && !(detail is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
reporter.push('documentation');
try {
final documentation = obj['documentation'];
if (documentation != null &&
!((MarkupContent.canParse(documentation, reporter) ||
documentation is String))) {
reporter
.reportError('must be of type Either2<MarkupContent, String>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('filterText');
try {
final filterText = obj['filterText'];
if (filterText != null && !(filterText is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
reporter.push('insertText');
try {
final insertText = obj['insertText'];
if (insertText != null && !(insertText is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
reporter.push('insertTextFormat');
try {
final insertTextFormat = obj['insertTextFormat'];
if (insertTextFormat != null &&
!(InsertTextFormat.canParse(insertTextFormat, reporter))) {
reporter.reportError('must be of type InsertTextFormat');
return false;
}
} finally {
reporter.pop();
}
reporter.push('insertTextMode');
try {
final insertTextMode = obj['insertTextMode'];
if (insertTextMode != null &&
!(InsertTextMode.canParse(insertTextMode, reporter))) {
reporter.reportError('must be of type InsertTextMode');
return false;
}
} finally {
reporter.pop();
}
reporter.push('kind');
try {
final kind = obj['kind'];
if (kind != null && !(CompletionItemKind.canParse(kind, reporter))) {
reporter.reportError('must be of type CompletionItemKind');
return false;
}
} finally {
reporter.pop();
}
reporter.push('label');
try {
if (!obj.containsKey('label')) {
reporter.reportError('must not be undefined');
return false;
}
final label = obj['label'];
if (label == null) {
reporter.reportError('must not be null');
return false;
}
if (!(label is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
reporter.push('labelDetails');
try {
final labelDetails = obj['labelDetails'];
if (labelDetails != null &&
!(CompletionItemLabelDetails.canParse(labelDetails, reporter))) {
reporter.reportError('must be of type CompletionItemLabelDetails');
return false;
}
} finally {
reporter.pop();
}
reporter.push('preselect');
try {
final preselect = obj['preselect'];
if (preselect != null && !(preselect is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
reporter.push('sortText');
try {
final sortText = obj['sortText'];
if (sortText != null && !(sortText is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
reporter.push('tags');
try {
final tags = obj['tags'];
if (tags != null &&
!((tags is List<Object?> &&
(tags.every(
(item) => CompletionItemTag.canParse(item, reporter)))))) {
reporter.reportError('must be of type List<CompletionItemTag>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('textEdit');
try {
final textEdit = obj['textEdit'];
if (textEdit != null &&
!((InsertReplaceEdit.canParse(textEdit, reporter) ||
TextEdit.canParse(textEdit, reporter)))) {
reporter.reportError(
'must be of type Either2<InsertReplaceEdit, TextEdit>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('textEditText');
try {
final textEditText = obj['textEditText'];
if (textEditText != null && !(textEditText is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CompletionItem');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CompletionItem && other.runtimeType == CompletionItem) {
return listEqual(additionalTextEdits, other.additionalTextEdits,
(TextEdit a, TextEdit b) => a == b) &&
command == other.command &&
listEqual(commitCharacters, other.commitCharacters,
(String a, String b) => a == b) &&
data == other.data &&
deprecated == other.deprecated &&
detail == other.detail &&
documentation == other.documentation &&
filterText == other.filterText &&
insertText == other.insertText &&
insertTextFormat == other.insertTextFormat &&
insertTextMode == other.insertTextMode &&
kind == other.kind &&
label == other.label &&
labelDetails == other.labelDetails &&
preselect == other.preselect &&
sortText == other.sortText &&
listEqual(tags, other.tags,
(CompletionItemTag a, CompletionItemTag b) => a == b) &&
textEdit == other.textEdit &&
textEditText == other.textEditText &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
lspHashCode(additionalTextEdits),
command,
lspHashCode(commitCharacters),
data,
deprecated,
detail,
documentation,
filterText,
insertText,
insertTextFormat,
insertTextMode,
kind,
label,
labelDetails,
preselect,
sortText,
lspHashCode(tags),
textEdit,
textEditText,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class CompletionItemInsertTextModeSupport implements ToJsonable {
static const jsonHandler = LspJsonHandler(
CompletionItemInsertTextModeSupport.canParse,
CompletionItemInsertTextModeSupport.fromJson,
);
CompletionItemInsertTextModeSupport({
required this.valueSet,
});
static CompletionItemInsertTextModeSupport fromJson(
Map<String, Object?> json) {
final valueSetJson = json['valueSet'];
final valueSet = (valueSetJson as List<Object?>)
.map((item) => InsertTextMode.fromJson(item as int))
.toList();
return CompletionItemInsertTextModeSupport(
valueSet: valueSet,
);
}
final List<InsertTextMode> valueSet;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['valueSet'] = valueSet.map((item) => item.toJson()).toList();
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('valueSet');
try {
if (!obj.containsKey('valueSet')) {
reporter.reportError('must not be undefined');
return false;
}
final valueSet = obj['valueSet'];
if (valueSet == null) {
reporter.reportError('must not be null');
return false;
}
if (!((valueSet is List<Object?> &&
(valueSet
.every((item) => InsertTextMode.canParse(item, reporter)))))) {
reporter.reportError('must be of type List<InsertTextMode>');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter
.reportError('must be of type CompletionItemInsertTextModeSupport');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CompletionItemInsertTextModeSupport &&
other.runtimeType == CompletionItemInsertTextModeSupport) {
return listEqual(valueSet, other.valueSet,
(InsertTextMode a, InsertTextMode b) => a == b) &&
true;
}
return false;
}
@override
int get hashCode => lspHashCode(valueSet);
@override
String toString() => jsonEncoder.convert(toJson());
}
/// The kind of a completion entry.
class CompletionItemKind implements ToJsonable {
const CompletionItemKind(this._value);
const CompletionItemKind.fromJson(this._value);
final int _value;
static bool canParse(Object? obj, LspJsonReporter reporter) {
return obj is int;
}
static const Class = CompletionItemKind(7);
static const Color = CompletionItemKind(16);
static const Constant = CompletionItemKind(21);
static const Constructor = CompletionItemKind(4);
static const Enum = CompletionItemKind(13);
static const EnumMember = CompletionItemKind(20);
static const Event = CompletionItemKind(23);
static const Field = CompletionItemKind(5);
static const File = CompletionItemKind(17);
static const Folder = CompletionItemKind(19);
static const Function = CompletionItemKind(3);
static const Interface = CompletionItemKind(8);
static const Keyword = CompletionItemKind(14);
static const Method = CompletionItemKind(2);
static const Module = CompletionItemKind(9);
static const Operator = CompletionItemKind(24);
static const Property = CompletionItemKind(10);
static const Reference = CompletionItemKind(18);
static const Snippet = CompletionItemKind(15);
static const Struct = CompletionItemKind(22);
static const Text = CompletionItemKind(1);
static const TypeParameter = CompletionItemKind(25);
static const Unit = CompletionItemKind(11);
static const Value = CompletionItemKind(12);
static const Variable = CompletionItemKind(6);
Object toJson() => _value;
@override
String toString() => _value.toString();
@override
int get hashCode => _value.hashCode;
bool operator ==(Object other) =>
other is CompletionItemKind && other._value == _value;
}
/// Additional details for a completion item label.
/// @since 3.17.0
class CompletionItemLabelDetails implements ToJsonable {
static const jsonHandler = LspJsonHandler(
CompletionItemLabelDetails.canParse,
CompletionItemLabelDetails.fromJson,
);
CompletionItemLabelDetails({
this.description,
this.detail,
});
static CompletionItemLabelDetails fromJson(Map<String, Object?> json) {
final descriptionJson = json['description'];
final description = descriptionJson as String?;
final detailJson = json['detail'];
final detail = detailJson as String?;
return CompletionItemLabelDetails(
description: description,
detail: detail,
);
}
/// An optional string which is rendered less prominently after {@link
/// CompletionItemLabelDetails.detail}. Should be used for fully qualified
/// names or file path.
final String? description;
/// An optional string which is rendered less prominently directly after
/// {@link CompletionItem.label label}, without any spacing. Should be used
/// for function signatures or type annotations.
final String? detail;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (description != null) {
result['description'] = description;
}
if (detail != null) {
result['detail'] = detail;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('description');
try {
final description = obj['description'];
if (description != null && !(description is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
reporter.push('detail');
try {
final detail = obj['detail'];
if (detail != null && !(detail is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CompletionItemLabelDetails');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CompletionItemLabelDetails &&
other.runtimeType == CompletionItemLabelDetails) {
return description == other.description && detail == other.detail && true;
}
return false;
}
@override
int get hashCode => Object.hash(
description,
detail,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class CompletionItemResolveSupport implements ToJsonable {
static const jsonHandler = LspJsonHandler(
CompletionItemResolveSupport.canParse,
CompletionItemResolveSupport.fromJson,
);
CompletionItemResolveSupport({
required this.properties,
});
static CompletionItemResolveSupport fromJson(Map<String, Object?> json) {
final propertiesJson = json['properties'];
final properties = (propertiesJson as List<Object?>)
.map((item) => item as String)
.toList();
return CompletionItemResolveSupport(
properties: properties,
);
}
/// The properties that a client can resolve lazily.
final List<String> properties;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['properties'] = properties;
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('properties');
try {
if (!obj.containsKey('properties')) {
reporter.reportError('must not be undefined');
return false;
}
final properties = obj['properties'];
if (properties == null) {
reporter.reportError('must not be null');
return false;
}
if (!((properties is List<Object?> &&
(properties.every((item) => item is String))))) {
reporter.reportError('must be of type List<String>');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CompletionItemResolveSupport');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CompletionItemResolveSupport &&
other.runtimeType == CompletionItemResolveSupport) {
return listEqual(
properties, other.properties, (String a, String b) => a == b) &&
true;
}
return false;
}
@override
int get hashCode => lspHashCode(properties);
@override
String toString() => jsonEncoder.convert(toJson());
}
/// Completion item tags are extra annotations that tweak the rendering of a
/// completion item.
/// @since 3.15.0
class CompletionItemTag implements ToJsonable {
const CompletionItemTag(this._value);
const CompletionItemTag.fromJson(this._value);
final int _value;
static bool canParse(Object? obj, LspJsonReporter reporter) {
return obj is int;
}
/// Render a completion as obsolete, usually using a strike-out.
static const Deprecated = CompletionItemTag(1);
Object toJson() => _value;
@override
String toString() => _value.toString();
@override
int get hashCode => _value.hashCode;
bool operator ==(Object other) =>
other is CompletionItemTag && other._value == _value;
}
class CompletionItemTagSupport implements ToJsonable {
static const jsonHandler = LspJsonHandler(
CompletionItemTagSupport.canParse,
CompletionItemTagSupport.fromJson,
);
CompletionItemTagSupport({
required this.valueSet,
});
static CompletionItemTagSupport fromJson(Map<String, Object?> json) {
final valueSetJson = json['valueSet'];
final valueSet = (valueSetJson as List<Object?>)
.map((item) => CompletionItemTag.fromJson(item as int))
.toList();
return CompletionItemTagSupport(
valueSet: valueSet,
);
}
/// The tags supported by the client.
final List<CompletionItemTag> valueSet;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['valueSet'] = valueSet.map((item) => item.toJson()).toList();
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('valueSet');
try {
if (!obj.containsKey('valueSet')) {
reporter.reportError('must not be undefined');
return false;
}
final valueSet = obj['valueSet'];
if (valueSet == null) {
reporter.reportError('must not be null');
return false;
}
if (!((valueSet is List<Object?> &&
(valueSet.every(
(item) => CompletionItemTag.canParse(item, reporter)))))) {
reporter.reportError('must be of type List<CompletionItemTag>');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CompletionItemTagSupport');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CompletionItemTagSupport &&
other.runtimeType == CompletionItemTagSupport) {
return listEqual(valueSet, other.valueSet,
(CompletionItemTag a, CompletionItemTag b) => a == b) &&
true;
}
return false;
}
@override
int get hashCode => lspHashCode(valueSet);
@override
String toString() => jsonEncoder.convert(toJson());
}
/// Represents a collection of completion items ([CompletionItem]) to be
/// presented in the editor.
class CompletionList implements ToJsonable {
static const jsonHandler = LspJsonHandler(
CompletionList.canParse,
CompletionList.fromJson,
);
CompletionList({
required this.isIncomplete,
this.itemDefaults,
required this.items,
});
static CompletionList fromJson(Map<String, Object?> json) {
final isIncompleteJson = json['isIncomplete'];
final isIncomplete = isIncompleteJson as bool;
final itemDefaultsJson = json['itemDefaults'];
final itemDefaults = itemDefaultsJson != null
? CompletionListItemDefaults.fromJson(
itemDefaultsJson as Map<String, Object?>)
: null;
final itemsJson = json['items'];
final items = (itemsJson as List<Object?>)
.map((item) => CompletionItem.fromJson(item as Map<String, Object?>))
.toList();
return CompletionList(
isIncomplete: isIncomplete,
itemDefaults: itemDefaults,
items: items,
);
}
/// This list is not complete. Further typing should result in recomputing
/// this list.
///
/// Recomputed lists have all their items replaced (not appended) in the
/// incomplete completion sessions.
final bool isIncomplete;
/// In many cases the items of an actual completion result share the same
/// value for properties like `commitCharacters` or the range of a text edit.
/// A completion list can therefore define item defaults which will be used if
/// a completion item itself doesn't specify the value.
///
/// If a completion list specifies a default value and a completion item also
/// specifies a corresponding value the one from the item is used.
///
/// Servers are only allowed to return default values if the client signals
/// support for this via the `completionList.itemDefaults` capability.
/// @since 3.17.0
final CompletionListItemDefaults? itemDefaults;
/// The completion items.
final List<CompletionItem> items;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['isIncomplete'] = isIncomplete;
if (itemDefaults != null) {
result['itemDefaults'] = itemDefaults?.toJson();
}
result['items'] = items.map((item) => item.toJson()).toList();
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('isIncomplete');
try {
if (!obj.containsKey('isIncomplete')) {
reporter.reportError('must not be undefined');
return false;
}
final isIncomplete = obj['isIncomplete'];
if (isIncomplete == null) {
reporter.reportError('must not be null');
return false;
}
if (!(isIncomplete is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
reporter.push('itemDefaults');
try {
final itemDefaults = obj['itemDefaults'];
if (itemDefaults != null &&
!(CompletionListItemDefaults.canParse(itemDefaults, reporter))) {
reporter.reportError('must be of type CompletionListItemDefaults');
return false;
}
} finally {
reporter.pop();
}
reporter.push('items');
try {
if (!obj.containsKey('items')) {
reporter.reportError('must not be undefined');
return false;
}
final items = obj['items'];
if (items == null) {
reporter.reportError('must not be null');
return false;
}
if (!((items is List<Object?> &&
(items
.every((item) => CompletionItem.canParse(item, reporter)))))) {
reporter.reportError('must be of type List<CompletionItem>');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CompletionList');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CompletionList && other.runtimeType == CompletionList) {
return isIncomplete == other.isIncomplete &&
itemDefaults == other.itemDefaults &&
listEqual(items, other.items,
(CompletionItem a, CompletionItem b) => a == b) &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
isIncomplete,
itemDefaults,
lspHashCode(items),
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class CompletionListEditRange implements ToJsonable {
static const jsonHandler = LspJsonHandler(
CompletionListEditRange.canParse,
CompletionListEditRange.fromJson,
);
CompletionListEditRange({
required this.insert,
required this.replace,
});
static CompletionListEditRange fromJson(Map<String, Object?> json) {
final insertJson = json['insert'];
final insert = Range.fromJson(insertJson as Map<String, Object?>);
final replaceJson = json['replace'];
final replace = Range.fromJson(replaceJson as Map<String, Object?>);
return CompletionListEditRange(
insert: insert,
replace: replace,
);
}
final Range insert;
final Range replace;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['insert'] = insert.toJson();
result['replace'] = replace.toJson();
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('insert');
try {
if (!obj.containsKey('insert')) {
reporter.reportError('must not be undefined');
return false;
}
final insert = obj['insert'];
if (insert == null) {
reporter.reportError('must not be null');
return false;
}
if (!(Range.canParse(insert, reporter))) {
reporter.reportError('must be of type Range');
return false;
}
} finally {
reporter.pop();
}
reporter.push('replace');
try {
if (!obj.containsKey('replace')) {
reporter.reportError('must not be undefined');
return false;
}
final replace = obj['replace'];
if (replace == null) {
reporter.reportError('must not be null');
return false;
}
if (!(Range.canParse(replace, reporter))) {
reporter.reportError('must be of type Range');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CompletionListEditRange');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CompletionListEditRange &&
other.runtimeType == CompletionListEditRange) {
return insert == other.insert && replace == other.replace && true;
}
return false;
}
@override
int get hashCode => Object.hash(
insert,
replace,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class CompletionListItemDefaults implements ToJsonable {
static const jsonHandler = LspJsonHandler(
CompletionListItemDefaults.canParse,
CompletionListItemDefaults.fromJson,
);
CompletionListItemDefaults({
this.commitCharacters,
this.editRange,
this.insertTextFormat,
this.insertTextMode,
});
static CompletionListItemDefaults fromJson(Map<String, Object?> json) {
final commitCharactersJson = json['commitCharacters'];
final commitCharacters = (commitCharactersJson as List<Object?>?)
?.map((item) => item as String)
.toList();
final editRangeJson = json['editRange'];
final editRange = editRangeJson == null
? null
: (CompletionListEditRange.canParse(editRangeJson, nullLspJsonReporter)
? Either2<CompletionListEditRange, Range>.t1(
CompletionListEditRange.fromJson(
editRangeJson as Map<String, Object?>))
: (Range.canParse(editRangeJson, nullLspJsonReporter)
? Either2<CompletionListEditRange, Range>.t2(
Range.fromJson(editRangeJson as Map<String, Object?>))
: (throw '''$editRangeJson was not one of (CompletionListEditRange, Range)''')));
final insertTextFormatJson = json['insertTextFormat'];
final insertTextFormat = insertTextFormatJson != null
? InsertTextFormat.fromJson(insertTextFormatJson as int)
: null;
final insertTextModeJson = json['insertTextMode'];
final insertTextMode = insertTextModeJson != null
? InsertTextMode.fromJson(insertTextModeJson as int)
: null;
return CompletionListItemDefaults(
commitCharacters: commitCharacters,
editRange: editRange,
insertTextFormat: insertTextFormat,
insertTextMode: insertTextMode,
);
}
/// A default commit character set.
/// @since 3.17.0
final List<String>? commitCharacters;
/// A default edit range
/// @since 3.17.0
final Either2<CompletionListEditRange, Range>? editRange;
/// A default insert text format
/// @since 3.17.0
final InsertTextFormat? insertTextFormat;
/// A default insert text mode
/// @since 3.17.0
final InsertTextMode? insertTextMode;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (commitCharacters != null) {
result['commitCharacters'] = commitCharacters;
}
if (editRange != null) {
result['editRange'] = editRange;
}
if (insertTextFormat != null) {
result['insertTextFormat'] = insertTextFormat?.toJson();
}
if (insertTextMode != null) {
result['insertTextMode'] = insertTextMode?.toJson();
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('commitCharacters');
try {
final commitCharacters = obj['commitCharacters'];
if (commitCharacters != null &&
!((commitCharacters is List<Object?> &&
(commitCharacters.every((item) => item is String))))) {
reporter.reportError('must be of type List<String>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('editRange');
try {
final editRange = obj['editRange'];
if (editRange != null &&
!((CompletionListEditRange.canParse(editRange, reporter) ||
Range.canParse(editRange, reporter)))) {
reporter.reportError(
'must be of type Either2<CompletionListEditRange, Range>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('insertTextFormat');
try {
final insertTextFormat = obj['insertTextFormat'];
if (insertTextFormat != null &&
!(InsertTextFormat.canParse(insertTextFormat, reporter))) {
reporter.reportError('must be of type InsertTextFormat');
return false;
}
} finally {
reporter.pop();
}
reporter.push('insertTextMode');
try {
final insertTextMode = obj['insertTextMode'];
if (insertTextMode != null &&
!(InsertTextMode.canParse(insertTextMode, reporter))) {
reporter.reportError('must be of type InsertTextMode');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CompletionListItemDefaults');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CompletionListItemDefaults &&
other.runtimeType == CompletionListItemDefaults) {
return listEqual(commitCharacters, other.commitCharacters,
(String a, String b) => a == b) &&
editRange == other.editRange &&
insertTextFormat == other.insertTextFormat &&
insertTextMode == other.insertTextMode &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
lspHashCode(commitCharacters),
editRange,
insertTextFormat,
insertTextMode,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
/// Completion options.
class CompletionOptions implements WorkDoneProgressOptions, ToJsonable {
static const jsonHandler = LspJsonHandler(
CompletionOptions.canParse,
CompletionOptions.fromJson,
);
CompletionOptions({
this.allCommitCharacters,
this.completionItem,
this.resolveProvider,
this.triggerCharacters,
this.workDoneProgress,
});
static CompletionOptions fromJson(Map<String, Object?> json) {
if (CompletionRegistrationOptions.canParse(json, nullLspJsonReporter)) {
return CompletionRegistrationOptions.fromJson(json);
}
final allCommitCharactersJson = json['allCommitCharacters'];
final allCommitCharacters = (allCommitCharactersJson as List<Object?>?)
?.map((item) => item as String)
.toList();
final completionItemJson = json['completionItem'];
final completionItem = completionItemJson != null
? CompletionOptionsCompletionItem.fromJson(
completionItemJson as Map<String, Object?>)
: null;
final resolveProviderJson = json['resolveProvider'];
final resolveProvider = resolveProviderJson as bool?;
final triggerCharactersJson = json['triggerCharacters'];
final triggerCharacters = (triggerCharactersJson as List<Object?>?)
?.map((item) => item as String)
.toList();
final workDoneProgressJson = json['workDoneProgress'];
final workDoneProgress = workDoneProgressJson as bool?;
return CompletionOptions(
allCommitCharacters: allCommitCharacters,
completionItem: completionItem,
resolveProvider: resolveProvider,
triggerCharacters: triggerCharacters,
workDoneProgress: workDoneProgress,
);
}
/// The list of all possible characters that commit a completion. This field
/// can be used if clients don't support individual commit characters per
/// completion item. See client capability
/// `completion.completionItem.commitCharactersSupport`.
///
/// If a server provides both `allCommitCharacters` and commit characters on
/// an individual completion item the ones on the completion item win.
/// @since 3.2.0
final List<String>? allCommitCharacters;
/// The server supports the following `CompletionItem` specific capabilities.
/// @since 3.17.0
final CompletionOptionsCompletionItem? completionItem;
/// The server provides support to resolve additional information for a
/// completion item.
final bool? resolveProvider;
/// Most tools trigger completion request automatically without explicitly
/// requesting it using a keyboard shortcut (e.g. Ctrl+Space). Typically they
/// do so when the user starts to type an identifier. For example if the user
/// types `c` in a JavaScript file code complete will automatically pop up
/// present `console` besides others as a completion item. Characters that
/// make up identifiers don't need to be listed here.
///
/// If code complete should automatically be trigger on characters not being
/// valid inside an identifier (for example `.` in JavaScript) list them in
/// `triggerCharacters`.
final List<String>? triggerCharacters;
final bool? workDoneProgress;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (allCommitCharacters != null) {
result['allCommitCharacters'] = allCommitCharacters;
}
if (completionItem != null) {
result['completionItem'] = completionItem?.toJson();
}
if (resolveProvider != null) {
result['resolveProvider'] = resolveProvider;
}
if (triggerCharacters != null) {
result['triggerCharacters'] = triggerCharacters;
}
if (workDoneProgress != null) {
result['workDoneProgress'] = workDoneProgress;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('allCommitCharacters');
try {
final allCommitCharacters = obj['allCommitCharacters'];
if (allCommitCharacters != null &&
!((allCommitCharacters is List<Object?> &&
(allCommitCharacters.every((item) => item is String))))) {
reporter.reportError('must be of type List<String>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('completionItem');
try {
final completionItem = obj['completionItem'];
if (completionItem != null &&
!(CompletionOptionsCompletionItem.canParse(
completionItem, reporter))) {
reporter
.reportError('must be of type CompletionOptionsCompletionItem');
return false;
}
} finally {
reporter.pop();
}
reporter.push('resolveProvider');
try {
final resolveProvider = obj['resolveProvider'];
if (resolveProvider != null && !(resolveProvider is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
reporter.push('triggerCharacters');
try {
final triggerCharacters = obj['triggerCharacters'];
if (triggerCharacters != null &&
!((triggerCharacters is List<Object?> &&
(triggerCharacters.every((item) => item is String))))) {
reporter.reportError('must be of type List<String>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('workDoneProgress');
try {
final workDoneProgress = obj['workDoneProgress'];
if (workDoneProgress != null && !(workDoneProgress is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CompletionOptions');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CompletionOptions && other.runtimeType == CompletionOptions) {
return listEqual(allCommitCharacters, other.allCommitCharacters,
(String a, String b) => a == b) &&
completionItem == other.completionItem &&
resolveProvider == other.resolveProvider &&
listEqual(triggerCharacters, other.triggerCharacters,
(String a, String b) => a == b) &&
workDoneProgress == other.workDoneProgress &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
lspHashCode(allCommitCharacters),
completionItem,
resolveProvider,
lspHashCode(triggerCharacters),
workDoneProgress,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class CompletionOptionsCompletionItem implements ToJsonable {
static const jsonHandler = LspJsonHandler(
CompletionOptionsCompletionItem.canParse,
CompletionOptionsCompletionItem.fromJson,
);
CompletionOptionsCompletionItem({
this.labelDetailsSupport,
});
static CompletionOptionsCompletionItem fromJson(Map<String, Object?> json) {
final labelDetailsSupportJson = json['labelDetailsSupport'];
final labelDetailsSupport = labelDetailsSupportJson as bool?;
return CompletionOptionsCompletionItem(
labelDetailsSupport: labelDetailsSupport,
);
}
/// The server has support for completion item label details (see also
/// `CompletionItemLabelDetails`) when receiving a completion item in a
/// resolve call.
/// @since 3.17.0
final bool? labelDetailsSupport;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (labelDetailsSupport != null) {
result['labelDetailsSupport'] = labelDetailsSupport;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('labelDetailsSupport');
try {
final labelDetailsSupport = obj['labelDetailsSupport'];
if (labelDetailsSupport != null && !(labelDetailsSupport is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CompletionOptionsCompletionItem');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CompletionOptionsCompletionItem &&
other.runtimeType == CompletionOptionsCompletionItem) {
return labelDetailsSupport == other.labelDetailsSupport && true;
}
return false;
}
@override
int get hashCode => labelDetailsSupport.hashCode;
@override
String toString() => jsonEncoder.convert(toJson());
}
class CompletionParams
implements
PartialResultParams,
TextDocumentPositionParams,
WorkDoneProgressParams,
ToJsonable {
static const jsonHandler = LspJsonHandler(
CompletionParams.canParse,
CompletionParams.fromJson,
);
CompletionParams({
this.context,
this.partialResultToken,
required this.position,
required this.textDocument,
this.workDoneToken,
});
static CompletionParams fromJson(Map<String, Object?> json) {
final contextJson = json['context'];
final context = contextJson != null
? CompletionContext.fromJson(contextJson as Map<String, Object?>)
: null;
final partialResultTokenJson = json['partialResultToken'];
final partialResultToken = partialResultTokenJson == null
? null
: (partialResultTokenJson is int
? Either2<int, String>.t1(partialResultTokenJson)
: (partialResultTokenJson is String
? Either2<int, String>.t2(partialResultTokenJson)
: (throw '''$partialResultTokenJson was not one of (int, String)''')));
final positionJson = json['position'];
final position = Position.fromJson(positionJson as Map<String, Object?>);
final textDocumentJson = json['textDocument'];
final textDocument = TextDocumentIdentifier.fromJson(
textDocumentJson as Map<String, Object?>);
final workDoneTokenJson = json['workDoneToken'];
final workDoneToken = workDoneTokenJson == null
? null
: (workDoneTokenJson is int
? Either2<int, String>.t1(workDoneTokenJson)
: (workDoneTokenJson is String
? Either2<int, String>.t2(workDoneTokenJson)
: (throw '''$workDoneTokenJson was not one of (int, String)''')));
return CompletionParams(
context: context,
partialResultToken: partialResultToken,
position: position,
textDocument: textDocument,
workDoneToken: workDoneToken,
);
}
/// The completion context. This is only available if the client specifies to
/// send this using the client capability `completion.contextSupport === true`
final CompletionContext? context;
/// An optional token that a server can use to report partial results (e.g.
/// streaming) to the client.
final Either2<int, String>? partialResultToken;
/// The position inside the text document.
final Position position;
/// The text document.
final TextDocumentIdentifier textDocument;
/// An optional token that a server can use to report work done progress.
final Either2<int, String>? workDoneToken;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (context != null) {
result['context'] = context?.toJson();
}
if (partialResultToken != null) {
result['partialResultToken'] = partialResultToken;
}
result['position'] = position.toJson();
result['textDocument'] = textDocument.toJson();
if (workDoneToken != null) {
result['workDoneToken'] = workDoneToken;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('context');
try {
final context = obj['context'];
if (context != null &&
!(CompletionContext.canParse(context, reporter))) {
reporter.reportError('must be of type CompletionContext');
return false;
}
} finally {
reporter.pop();
}
reporter.push('partialResultToken');
try {
final partialResultToken = obj['partialResultToken'];
if (partialResultToken != null &&
!((partialResultToken is int || partialResultToken is String))) {
reporter.reportError('must be of type Either2<int, String>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('position');
try {
if (!obj.containsKey('position')) {
reporter.reportError('must not be undefined');
return false;
}
final position = obj['position'];
if (position == null) {
reporter.reportError('must not be null');
return false;
}
if (!(Position.canParse(position, reporter))) {
reporter.reportError('must be of type Position');
return false;
}
} finally {
reporter.pop();
}
reporter.push('textDocument');
try {
if (!obj.containsKey('textDocument')) {
reporter.reportError('must not be undefined');
return false;
}
final textDocument = obj['textDocument'];
if (textDocument == null) {
reporter.reportError('must not be null');
return false;
}
if (!(TextDocumentIdentifier.canParse(textDocument, reporter))) {
reporter.reportError('must be of type TextDocumentIdentifier');
return false;
}
} finally {
reporter.pop();
}
reporter.push('workDoneToken');
try {
final workDoneToken = obj['workDoneToken'];
if (workDoneToken != null &&
!((workDoneToken is int || workDoneToken is String))) {
reporter.reportError('must be of type Either2<int, String>');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CompletionParams');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CompletionParams && other.runtimeType == CompletionParams) {
return context == other.context &&
partialResultToken == other.partialResultToken &&
position == other.position &&
textDocument == other.textDocument &&
workDoneToken == other.workDoneToken &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
context,
partialResultToken,
position,
textDocument,
workDoneToken,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class CompletionRegistrationOptions
implements CompletionOptions, TextDocumentRegistrationOptions, ToJsonable {
static const jsonHandler = LspJsonHandler(
CompletionRegistrationOptions.canParse,
CompletionRegistrationOptions.fromJson,
);
CompletionRegistrationOptions({
this.allCommitCharacters,
this.completionItem,
this.documentSelector,
this.resolveProvider,
this.triggerCharacters,
this.workDoneProgress,
});
static CompletionRegistrationOptions fromJson(Map<String, Object?> json) {
final allCommitCharactersJson = json['allCommitCharacters'];
final allCommitCharacters = (allCommitCharactersJson as List<Object?>?)
?.map((item) => item as String)
.toList();
final completionItemJson = json['completionItem'];
final completionItem = completionItemJson != null
? CompletionOptionsCompletionItem.fromJson(
completionItemJson as Map<String, Object?>)
: null;
final documentSelectorJson = json['documentSelector'];
final documentSelector = (documentSelectorJson as List<Object?>?)
?.map(
(item) => TextDocumentFilter.fromJson(item as Map<String, Object?>))
.toList();
final resolveProviderJson = json['resolveProvider'];
final resolveProvider = resolveProviderJson as bool?;
final triggerCharactersJson = json['triggerCharacters'];
final triggerCharacters = (triggerCharactersJson as List<Object?>?)
?.map((item) => item as String)
.toList();
final workDoneProgressJson = json['workDoneProgress'];
final workDoneProgress = workDoneProgressJson as bool?;
return CompletionRegistrationOptions(
allCommitCharacters: allCommitCharacters,
completionItem: completionItem,
documentSelector: documentSelector,
resolveProvider: resolveProvider,
triggerCharacters: triggerCharacters,
workDoneProgress: workDoneProgress,
);
}
/// The list of all possible characters that commit a completion. This field
/// can be used if clients don't support individual commit characters per
/// completion item. See client capability
/// `completion.completionItem.commitCharactersSupport`.
///
/// If a server provides both `allCommitCharacters` and commit characters on
/// an individual completion item the ones on the completion item win.
/// @since 3.2.0
final List<String>? allCommitCharacters;
/// The server supports the following `CompletionItem` specific capabilities.
/// @since 3.17.0
final CompletionOptionsCompletionItem? completionItem;
/// A document selector to identify the scope of the registration. If set to
/// null the document selector provided on the client side will be used.
final List<TextDocumentFilter>? documentSelector;
/// The server provides support to resolve additional information for a
/// completion item.
final bool? resolveProvider;
/// Most tools trigger completion request automatically without explicitly
/// requesting it using a keyboard shortcut (e.g. Ctrl+Space). Typically they
/// do so when the user starts to type an identifier. For example if the user
/// types `c` in a JavaScript file code complete will automatically pop up
/// present `console` besides others as a completion item. Characters that
/// make up identifiers don't need to be listed here.
///
/// If code complete should automatically be trigger on characters not being
/// valid inside an identifier (for example `.` in JavaScript) list them in
/// `triggerCharacters`.
final List<String>? triggerCharacters;
final bool? workDoneProgress;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (allCommitCharacters != null) {
result['allCommitCharacters'] = allCommitCharacters;
}
if (completionItem != null) {
result['completionItem'] = completionItem?.toJson();
}
result['documentSelector'] = documentSelector;
if (resolveProvider != null) {
result['resolveProvider'] = resolveProvider;
}
if (triggerCharacters != null) {
result['triggerCharacters'] = triggerCharacters;
}
if (workDoneProgress != null) {
result['workDoneProgress'] = workDoneProgress;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('allCommitCharacters');
try {
final allCommitCharacters = obj['allCommitCharacters'];
if (allCommitCharacters != null &&
!((allCommitCharacters is List<Object?> &&
(allCommitCharacters.every((item) => item is String))))) {
reporter.reportError('must be of type List<String>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('completionItem');
try {
final completionItem = obj['completionItem'];
if (completionItem != null &&
!(CompletionOptionsCompletionItem.canParse(
completionItem, reporter))) {
reporter
.reportError('must be of type CompletionOptionsCompletionItem');
return false;
}
} finally {
reporter.pop();
}
reporter.push('documentSelector');
try {
if (!obj.containsKey('documentSelector')) {
reporter.reportError('must not be undefined');
return false;
}
final documentSelector = obj['documentSelector'];
if (documentSelector != null &&
!((documentSelector is List<Object?> &&
(documentSelector.every(
(item) => TextDocumentFilter.canParse(item, reporter)))))) {
reporter.reportError('must be of type List<TextDocumentFilter>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('resolveProvider');
try {
final resolveProvider = obj['resolveProvider'];
if (resolveProvider != null && !(resolveProvider is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
reporter.push('triggerCharacters');
try {
final triggerCharacters = obj['triggerCharacters'];
if (triggerCharacters != null &&
!((triggerCharacters is List<Object?> &&
(triggerCharacters.every((item) => item is String))))) {
reporter.reportError('must be of type List<String>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('workDoneProgress');
try {
final workDoneProgress = obj['workDoneProgress'];
if (workDoneProgress != null && !(workDoneProgress is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CompletionRegistrationOptions');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CompletionRegistrationOptions &&
other.runtimeType == CompletionRegistrationOptions) {
return listEqual(allCommitCharacters, other.allCommitCharacters,
(String a, String b) => a == b) &&
completionItem == other.completionItem &&
listEqual(documentSelector, other.documentSelector,
(TextDocumentFilter a, TextDocumentFilter b) => a == b) &&
resolveProvider == other.resolveProvider &&
listEqual(triggerCharacters, other.triggerCharacters,
(String a, String b) => a == b) &&
workDoneProgress == other.workDoneProgress &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
lspHashCode(allCommitCharacters),
completionItem,
lspHashCode(documentSelector),
resolveProvider,
lspHashCode(triggerCharacters),
workDoneProgress,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
/// How a completion was triggered
class CompletionTriggerKind implements ToJsonable {
const CompletionTriggerKind._(this._value);
const CompletionTriggerKind.fromJson(this._value);
final int _value;
static bool canParse(Object? obj, LspJsonReporter reporter) {
switch (obj) {
case 1:
case 2:
case 3:
return true;
}
return false;
}
/// Completion was triggered by typing an identifier (24x7 code complete),
/// manual invocation (e.g Ctrl+Space) or via API.
static const Invoked = CompletionTriggerKind._(1);
/// Completion was triggered by a trigger character specified by the
/// `triggerCharacters` properties of the `CompletionRegistrationOptions`.
static const TriggerCharacter = CompletionTriggerKind._(2);
/// Completion was re-triggered as the current completion list is incomplete.
static const TriggerForIncompleteCompletions = CompletionTriggerKind._(3);
Object toJson() => _value;
@override
String toString() => _value.toString();
@override
int get hashCode => _value.hashCode;
bool operator ==(Object other) =>
other is CompletionTriggerKind && other._value == _value;
}
class ConfigurationItem implements ToJsonable {
static const jsonHandler = LspJsonHandler(
ConfigurationItem.canParse,
ConfigurationItem.fromJson,
);
ConfigurationItem({
this.scopeUri,
this.section,
});
static ConfigurationItem fromJson(Map<String, Object?> json) {
final scopeUriJson = json['scopeUri'];
final scopeUri = scopeUriJson as String?;
final sectionJson = json['section'];
final section = sectionJson as String?;
return ConfigurationItem(
scopeUri: scopeUri,
section: section,
);
}
/// The scope to get the configuration section for.
final String? scopeUri;
/// The configuration section asked for.
final String? section;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (scopeUri != null) {
result['scopeUri'] = scopeUri;
}
if (section != null) {
result['section'] = section;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('scopeUri');
try {
final scopeUri = obj['scopeUri'];
if (scopeUri != null && !(scopeUri is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
reporter.push('section');
try {
final section = obj['section'];
if (section != null && !(section is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type ConfigurationItem');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is ConfigurationItem && other.runtimeType == ConfigurationItem) {
return scopeUri == other.scopeUri && section == other.section && true;
}
return false;
}
@override
int get hashCode => Object.hash(
scopeUri,
section,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class ConfigurationParams implements ToJsonable {
static const jsonHandler = LspJsonHandler(
ConfigurationParams.canParse,
ConfigurationParams.fromJson,
);
ConfigurationParams({
required this.items,
});
static ConfigurationParams fromJson(Map<String, Object?> json) {
final itemsJson = json['items'];
final items = (itemsJson as List<Object?>)
.map((item) => ConfigurationItem.fromJson(item as Map<String, Object?>))
.toList();
return ConfigurationParams(
items: items,
);
}
final List<ConfigurationItem> items;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['items'] = items.map((item) => item.toJson()).toList();
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('items');
try {
if (!obj.containsKey('items')) {
reporter.reportError('must not be undefined');
return false;
}
final items = obj['items'];
if (items == null) {
reporter.reportError('must not be null');
return false;
}
if (!((items is List<Object?> &&
(items.every(
(item) => ConfigurationItem.canParse(item, reporter)))))) {
reporter.reportError('must be of type List<ConfigurationItem>');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type ConfigurationParams');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is ConfigurationParams &&
other.runtimeType == ConfigurationParams) {
return listEqual(items, other.items,
(ConfigurationItem a, ConfigurationItem b) => a == b) &&
true;
}
return false;
}
@override
int get hashCode => lspHashCode(items);
@override
String toString() => jsonEncoder.convert(toJson());
}
/// Create file operation
class CreateFile implements ToJsonable {
static const jsonHandler = LspJsonHandler(
CreateFile.canParse,
CreateFile.fromJson,
);
CreateFile({
this.annotationId,
this.kind = 'create',
this.options,
required this.uri,
}) {
if (kind != 'create') {
throw 'kind may only be the literal \'create\'';
}
}
static CreateFile fromJson(Map<String, Object?> json) {
final annotationIdJson = json['annotationId'];
final annotationId = annotationIdJson as String?;
final kindJson = json['kind'];
final kind = kindJson as String;
final optionsJson = json['options'];
final options = optionsJson != null
? CreateFileOptions.fromJson(optionsJson as Map<String, Object?>)
: null;
final uriJson = json['uri'];
final uri = uriJson as String;
return CreateFile(
annotationId: annotationId,
kind: kind,
options: options,
uri: uri,
);
}
/// An optional annotation identifier describing the operation.
/// @since 3.16.0
final String? annotationId;
/// A create
final String kind;
/// Additional options
final CreateFileOptions? options;
/// The resource to create.
final String uri;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (annotationId != null) {
result['annotationId'] = annotationId;
}
result['kind'] = kind;
if (options != null) {
result['options'] = options?.toJson();
}
result['uri'] = uri;
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('annotationId');
try {
final annotationId = obj['annotationId'];
if (annotationId != null && !(annotationId is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
reporter.push('kind');
try {
if (!obj.containsKey('kind')) {
reporter.reportError('must not be undefined');
return false;
}
final kind = obj['kind'];
if (kind == null) {
reporter.reportError('must not be null');
return false;
}
if (!(kind == 'create')) {
reporter.reportError('must be the literal \'create\'');
return false;
}
} finally {
reporter.pop();
}
reporter.push('options');
try {
final options = obj['options'];
if (options != null &&
!(CreateFileOptions.canParse(options, reporter))) {
reporter.reportError('must be of type CreateFileOptions');
return false;
}
} finally {
reporter.pop();
}
reporter.push('uri');
try {
if (!obj.containsKey('uri')) {
reporter.reportError('must not be undefined');
return false;
}
final uri = obj['uri'];
if (uri == null) {
reporter.reportError('must not be null');
return false;
}
if (!(uri is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CreateFile');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CreateFile && other.runtimeType == CreateFile) {
return annotationId == other.annotationId &&
kind == other.kind &&
options == other.options &&
uri == other.uri &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
annotationId,
kind,
options,
uri,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
/// Options to create a file.
class CreateFileOptions implements ToJsonable {
static const jsonHandler = LspJsonHandler(
CreateFileOptions.canParse,
CreateFileOptions.fromJson,
);
CreateFileOptions({
this.ignoreIfExists,
this.overwrite,
});
static CreateFileOptions fromJson(Map<String, Object?> json) {
final ignoreIfExistsJson = json['ignoreIfExists'];
final ignoreIfExists = ignoreIfExistsJson as bool?;
final overwriteJson = json['overwrite'];
final overwrite = overwriteJson as bool?;
return CreateFileOptions(
ignoreIfExists: ignoreIfExists,
overwrite: overwrite,
);
}
/// Ignore if exists.
final bool? ignoreIfExists;
/// Overwrite existing file. Overwrite wins over `ignoreIfExists`
final bool? overwrite;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (ignoreIfExists != null) {
result['ignoreIfExists'] = ignoreIfExists;
}
if (overwrite != null) {
result['overwrite'] = overwrite;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('ignoreIfExists');
try {
final ignoreIfExists = obj['ignoreIfExists'];
if (ignoreIfExists != null && !(ignoreIfExists is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
reporter.push('overwrite');
try {
final overwrite = obj['overwrite'];
if (overwrite != null && !(overwrite is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CreateFileOptions');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CreateFileOptions && other.runtimeType == CreateFileOptions) {
return ignoreIfExists == other.ignoreIfExists &&
overwrite == other.overwrite &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
ignoreIfExists,
overwrite,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
/// The parameters sent in notifications/requests for user-initiated creation of
/// files.
/// @since 3.16.0
class CreateFilesParams implements ToJsonable {
static const jsonHandler = LspJsonHandler(
CreateFilesParams.canParse,
CreateFilesParams.fromJson,
);
CreateFilesParams({
required this.files,
});
static CreateFilesParams fromJson(Map<String, Object?> json) {
final filesJson = json['files'];
final files = (filesJson as List<Object?>)
.map((item) => FileCreate.fromJson(item as Map<String, Object?>))
.toList();
return CreateFilesParams(
files: files,
);
}
/// An array of all files/folders created in this operation.
final List<FileCreate> files;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['files'] = files.map((item) => item.toJson()).toList();
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('files');
try {
if (!obj.containsKey('files')) {
reporter.reportError('must not be undefined');
return false;
}
final files = obj['files'];
if (files == null) {
reporter.reportError('must not be null');
return false;
}
if (!((files is List<Object?> &&
(files.every((item) => FileCreate.canParse(item, reporter)))))) {
reporter.reportError('must be of type List<FileCreate>');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type CreateFilesParams');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is CreateFilesParams && other.runtimeType == CreateFilesParams) {
return listEqual(
files, other.files, (FileCreate a, FileCreate b) => a == b) &&
true;
}
return false;
}
@override
int get hashCode => lspHashCode(files);
@override
String toString() => jsonEncoder.convert(toJson());
}
class DeclarationClientCapabilities implements ToJsonable {
static const jsonHandler = LspJsonHandler(
DeclarationClientCapabilities.canParse,
DeclarationClientCapabilities.fromJson,
);
DeclarationClientCapabilities({
this.dynamicRegistration,
this.linkSupport,
});
static DeclarationClientCapabilities fromJson(Map<String, Object?> json) {
final dynamicRegistrationJson = json['dynamicRegistration'];
final dynamicRegistration = dynamicRegistrationJson as bool?;
final linkSupportJson = json['linkSupport'];
final linkSupport = linkSupportJson as bool?;
return DeclarationClientCapabilities(
dynamicRegistration: dynamicRegistration,
linkSupport: linkSupport,
);
}
/// Whether declaration supports dynamic registration. If this is set to
/// `true` the client supports the new `DeclarationRegistrationOptions` return
/// value for the corresponding server capability as well.
final bool? dynamicRegistration;
/// The client supports additional metadata in the form of declaration links.
final bool? linkSupport;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (dynamicRegistration != null) {
result['dynamicRegistration'] = dynamicRegistration;
}
if (linkSupport != null) {
result['linkSupport'] = linkSupport;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('dynamicRegistration');
try {
final dynamicRegistration = obj['dynamicRegistration'];
if (dynamicRegistration != null && !(dynamicRegistration is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
reporter.push('linkSupport');
try {
final linkSupport = obj['linkSupport'];
if (linkSupport != null && !(linkSupport is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DeclarationClientCapabilities');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DeclarationClientCapabilities &&
other.runtimeType == DeclarationClientCapabilities) {
return dynamicRegistration == other.dynamicRegistration &&
linkSupport == other.linkSupport &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
dynamicRegistration,
linkSupport,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class DeclarationOptions implements WorkDoneProgressOptions, ToJsonable {
static const jsonHandler = LspJsonHandler(
DeclarationOptions.canParse,
DeclarationOptions.fromJson,
);
DeclarationOptions({
this.workDoneProgress,
});
static DeclarationOptions fromJson(Map<String, Object?> json) {
if (DeclarationRegistrationOptions.canParse(json, nullLspJsonReporter)) {
return DeclarationRegistrationOptions.fromJson(json);
}
final workDoneProgressJson = json['workDoneProgress'];
final workDoneProgress = workDoneProgressJson as bool?;
return DeclarationOptions(
workDoneProgress: workDoneProgress,
);
}
final bool? workDoneProgress;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (workDoneProgress != null) {
result['workDoneProgress'] = workDoneProgress;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('workDoneProgress');
try {
final workDoneProgress = obj['workDoneProgress'];
if (workDoneProgress != null && !(workDoneProgress is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DeclarationOptions');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DeclarationOptions &&
other.runtimeType == DeclarationOptions) {
return workDoneProgress == other.workDoneProgress && true;
}
return false;
}
@override
int get hashCode => workDoneProgress.hashCode;
@override
String toString() => jsonEncoder.convert(toJson());
}
class DeclarationParams
implements
PartialResultParams,
TextDocumentPositionParams,
WorkDoneProgressParams,
ToJsonable {
static const jsonHandler = LspJsonHandler(
DeclarationParams.canParse,
DeclarationParams.fromJson,
);
DeclarationParams({
this.partialResultToken,
required this.position,
required this.textDocument,
this.workDoneToken,
});
static DeclarationParams fromJson(Map<String, Object?> json) {
final partialResultTokenJson = json['partialResultToken'];
final partialResultToken = partialResultTokenJson == null
? null
: (partialResultTokenJson is int
? Either2<int, String>.t1(partialResultTokenJson)
: (partialResultTokenJson is String
? Either2<int, String>.t2(partialResultTokenJson)
: (throw '''$partialResultTokenJson was not one of (int, String)''')));
final positionJson = json['position'];
final position = Position.fromJson(positionJson as Map<String, Object?>);
final textDocumentJson = json['textDocument'];
final textDocument = TextDocumentIdentifier.fromJson(
textDocumentJson as Map<String, Object?>);
final workDoneTokenJson = json['workDoneToken'];
final workDoneToken = workDoneTokenJson == null
? null
: (workDoneTokenJson is int
? Either2<int, String>.t1(workDoneTokenJson)
: (workDoneTokenJson is String
? Either2<int, String>.t2(workDoneTokenJson)
: (throw '''$workDoneTokenJson was not one of (int, String)''')));
return DeclarationParams(
partialResultToken: partialResultToken,
position: position,
textDocument: textDocument,
workDoneToken: workDoneToken,
);
}
/// An optional token that a server can use to report partial results (e.g.
/// streaming) to the client.
final Either2<int, String>? partialResultToken;
/// The position inside the text document.
final Position position;
/// The text document.
final TextDocumentIdentifier textDocument;
/// An optional token that a server can use to report work done progress.
final Either2<int, String>? workDoneToken;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (partialResultToken != null) {
result['partialResultToken'] = partialResultToken;
}
result['position'] = position.toJson();
result['textDocument'] = textDocument.toJson();
if (workDoneToken != null) {
result['workDoneToken'] = workDoneToken;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('partialResultToken');
try {
final partialResultToken = obj['partialResultToken'];
if (partialResultToken != null &&
!((partialResultToken is int || partialResultToken is String))) {
reporter.reportError('must be of type Either2<int, String>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('position');
try {
if (!obj.containsKey('position')) {
reporter.reportError('must not be undefined');
return false;
}
final position = obj['position'];
if (position == null) {
reporter.reportError('must not be null');
return false;
}
if (!(Position.canParse(position, reporter))) {
reporter.reportError('must be of type Position');
return false;
}
} finally {
reporter.pop();
}
reporter.push('textDocument');
try {
if (!obj.containsKey('textDocument')) {
reporter.reportError('must not be undefined');
return false;
}
final textDocument = obj['textDocument'];
if (textDocument == null) {
reporter.reportError('must not be null');
return false;
}
if (!(TextDocumentIdentifier.canParse(textDocument, reporter))) {
reporter.reportError('must be of type TextDocumentIdentifier');
return false;
}
} finally {
reporter.pop();
}
reporter.push('workDoneToken');
try {
final workDoneToken = obj['workDoneToken'];
if (workDoneToken != null &&
!((workDoneToken is int || workDoneToken is String))) {
reporter.reportError('must be of type Either2<int, String>');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DeclarationParams');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DeclarationParams && other.runtimeType == DeclarationParams) {
return partialResultToken == other.partialResultToken &&
position == other.position &&
textDocument == other.textDocument &&
workDoneToken == other.workDoneToken &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
partialResultToken,
position,
textDocument,
workDoneToken,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class DeclarationRegistrationOptions
implements
DeclarationOptions,
StaticRegistrationOptions,
TextDocumentRegistrationOptions,
ToJsonable {
static const jsonHandler = LspJsonHandler(
DeclarationRegistrationOptions.canParse,
DeclarationRegistrationOptions.fromJson,
);
DeclarationRegistrationOptions({
this.documentSelector,
this.id,
this.workDoneProgress,
});
static DeclarationRegistrationOptions fromJson(Map<String, Object?> json) {
final documentSelectorJson = json['documentSelector'];
final documentSelector = (documentSelectorJson as List<Object?>?)
?.map(
(item) => TextDocumentFilter.fromJson(item as Map<String, Object?>))
.toList();
final idJson = json['id'];
final id = idJson as String?;
final workDoneProgressJson = json['workDoneProgress'];
final workDoneProgress = workDoneProgressJson as bool?;
return DeclarationRegistrationOptions(
documentSelector: documentSelector,
id: id,
workDoneProgress: workDoneProgress,
);
}
/// A document selector to identify the scope of the registration. If set to
/// null the document selector provided on the client side will be used.
final List<TextDocumentFilter>? documentSelector;
/// The id used to register the request. The id can be used to deregister the
/// request again. See also Registration#id.
final String? id;
final bool? workDoneProgress;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['documentSelector'] = documentSelector;
if (id != null) {
result['id'] = id;
}
if (workDoneProgress != null) {
result['workDoneProgress'] = workDoneProgress;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('documentSelector');
try {
if (!obj.containsKey('documentSelector')) {
reporter.reportError('must not be undefined');
return false;
}
final documentSelector = obj['documentSelector'];
if (documentSelector != null &&
!((documentSelector is List<Object?> &&
(documentSelector.every(
(item) => TextDocumentFilter.canParse(item, reporter)))))) {
reporter.reportError('must be of type List<TextDocumentFilter>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('id');
try {
final id = obj['id'];
if (id != null && !(id is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
reporter.push('workDoneProgress');
try {
final workDoneProgress = obj['workDoneProgress'];
if (workDoneProgress != null && !(workDoneProgress is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DeclarationRegistrationOptions');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DeclarationRegistrationOptions &&
other.runtimeType == DeclarationRegistrationOptions) {
return listEqual(documentSelector, other.documentSelector,
(TextDocumentFilter a, TextDocumentFilter b) => a == b) &&
id == other.id &&
workDoneProgress == other.workDoneProgress &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
lspHashCode(documentSelector),
id,
workDoneProgress,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class DefinitionClientCapabilities implements ToJsonable {
static const jsonHandler = LspJsonHandler(
DefinitionClientCapabilities.canParse,
DefinitionClientCapabilities.fromJson,
);
DefinitionClientCapabilities({
this.dynamicRegistration,
this.linkSupport,
});
static DefinitionClientCapabilities fromJson(Map<String, Object?> json) {
final dynamicRegistrationJson = json['dynamicRegistration'];
final dynamicRegistration = dynamicRegistrationJson as bool?;
final linkSupportJson = json['linkSupport'];
final linkSupport = linkSupportJson as bool?;
return DefinitionClientCapabilities(
dynamicRegistration: dynamicRegistration,
linkSupport: linkSupport,
);
}
/// Whether definition supports dynamic registration.
final bool? dynamicRegistration;
/// The client supports additional metadata in the form of definition links.
/// @since 3.14.0
final bool? linkSupport;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (dynamicRegistration != null) {
result['dynamicRegistration'] = dynamicRegistration;
}
if (linkSupport != null) {
result['linkSupport'] = linkSupport;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('dynamicRegistration');
try {
final dynamicRegistration = obj['dynamicRegistration'];
if (dynamicRegistration != null && !(dynamicRegistration is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
reporter.push('linkSupport');
try {
final linkSupport = obj['linkSupport'];
if (linkSupport != null && !(linkSupport is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DefinitionClientCapabilities');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DefinitionClientCapabilities &&
other.runtimeType == DefinitionClientCapabilities) {
return dynamicRegistration == other.dynamicRegistration &&
linkSupport == other.linkSupport &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
dynamicRegistration,
linkSupport,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class DefinitionOptions implements WorkDoneProgressOptions, ToJsonable {
static const jsonHandler = LspJsonHandler(
DefinitionOptions.canParse,
DefinitionOptions.fromJson,
);
DefinitionOptions({
this.workDoneProgress,
});
static DefinitionOptions fromJson(Map<String, Object?> json) {
if (DefinitionRegistrationOptions.canParse(json, nullLspJsonReporter)) {
return DefinitionRegistrationOptions.fromJson(json);
}
final workDoneProgressJson = json['workDoneProgress'];
final workDoneProgress = workDoneProgressJson as bool?;
return DefinitionOptions(
workDoneProgress: workDoneProgress,
);
}
final bool? workDoneProgress;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (workDoneProgress != null) {
result['workDoneProgress'] = workDoneProgress;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('workDoneProgress');
try {
final workDoneProgress = obj['workDoneProgress'];
if (workDoneProgress != null && !(workDoneProgress is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DefinitionOptions');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DefinitionOptions && other.runtimeType == DefinitionOptions) {
return workDoneProgress == other.workDoneProgress && true;
}
return false;
}
@override
int get hashCode => workDoneProgress.hashCode;
@override
String toString() => jsonEncoder.convert(toJson());
}
class DefinitionParams
implements
PartialResultParams,
TextDocumentPositionParams,
WorkDoneProgressParams,
ToJsonable {
static const jsonHandler = LspJsonHandler(
DefinitionParams.canParse,
DefinitionParams.fromJson,
);
DefinitionParams({
this.partialResultToken,
required this.position,
required this.textDocument,
this.workDoneToken,
});
static DefinitionParams fromJson(Map<String, Object?> json) {
final partialResultTokenJson = json['partialResultToken'];
final partialResultToken = partialResultTokenJson == null
? null
: (partialResultTokenJson is int
? Either2<int, String>.t1(partialResultTokenJson)
: (partialResultTokenJson is String
? Either2<int, String>.t2(partialResultTokenJson)
: (throw '''$partialResultTokenJson was not one of (int, String)''')));
final positionJson = json['position'];
final position = Position.fromJson(positionJson as Map<String, Object?>);
final textDocumentJson = json['textDocument'];
final textDocument = TextDocumentIdentifier.fromJson(
textDocumentJson as Map<String, Object?>);
final workDoneTokenJson = json['workDoneToken'];
final workDoneToken = workDoneTokenJson == null
? null
: (workDoneTokenJson is int
? Either2<int, String>.t1(workDoneTokenJson)
: (workDoneTokenJson is String
? Either2<int, String>.t2(workDoneTokenJson)
: (throw '''$workDoneTokenJson was not one of (int, String)''')));
return DefinitionParams(
partialResultToken: partialResultToken,
position: position,
textDocument: textDocument,
workDoneToken: workDoneToken,
);
}
/// An optional token that a server can use to report partial results (e.g.
/// streaming) to the client.
final Either2<int, String>? partialResultToken;
/// The position inside the text document.
final Position position;
/// The text document.
final TextDocumentIdentifier textDocument;
/// An optional token that a server can use to report work done progress.
final Either2<int, String>? workDoneToken;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (partialResultToken != null) {
result['partialResultToken'] = partialResultToken;
}
result['position'] = position.toJson();
result['textDocument'] = textDocument.toJson();
if (workDoneToken != null) {
result['workDoneToken'] = workDoneToken;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('partialResultToken');
try {
final partialResultToken = obj['partialResultToken'];
if (partialResultToken != null &&
!((partialResultToken is int || partialResultToken is String))) {
reporter.reportError('must be of type Either2<int, String>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('position');
try {
if (!obj.containsKey('position')) {
reporter.reportError('must not be undefined');
return false;
}
final position = obj['position'];
if (position == null) {
reporter.reportError('must not be null');
return false;
}
if (!(Position.canParse(position, reporter))) {
reporter.reportError('must be of type Position');
return false;
}
} finally {
reporter.pop();
}
reporter.push('textDocument');
try {
if (!obj.containsKey('textDocument')) {
reporter.reportError('must not be undefined');
return false;
}
final textDocument = obj['textDocument'];
if (textDocument == null) {
reporter.reportError('must not be null');
return false;
}
if (!(TextDocumentIdentifier.canParse(textDocument, reporter))) {
reporter.reportError('must be of type TextDocumentIdentifier');
return false;
}
} finally {
reporter.pop();
}
reporter.push('workDoneToken');
try {
final workDoneToken = obj['workDoneToken'];
if (workDoneToken != null &&
!((workDoneToken is int || workDoneToken is String))) {
reporter.reportError('must be of type Either2<int, String>');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DefinitionParams');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DefinitionParams && other.runtimeType == DefinitionParams) {
return partialResultToken == other.partialResultToken &&
position == other.position &&
textDocument == other.textDocument &&
workDoneToken == other.workDoneToken &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
partialResultToken,
position,
textDocument,
workDoneToken,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class DefinitionRegistrationOptions
implements DefinitionOptions, TextDocumentRegistrationOptions, ToJsonable {
static const jsonHandler = LspJsonHandler(
DefinitionRegistrationOptions.canParse,
DefinitionRegistrationOptions.fromJson,
);
DefinitionRegistrationOptions({
this.documentSelector,
this.workDoneProgress,
});
static DefinitionRegistrationOptions fromJson(Map<String, Object?> json) {
final documentSelectorJson = json['documentSelector'];
final documentSelector = (documentSelectorJson as List<Object?>?)
?.map(
(item) => TextDocumentFilter.fromJson(item as Map<String, Object?>))
.toList();
final workDoneProgressJson = json['workDoneProgress'];
final workDoneProgress = workDoneProgressJson as bool?;
return DefinitionRegistrationOptions(
documentSelector: documentSelector,
workDoneProgress: workDoneProgress,
);
}
/// A document selector to identify the scope of the registration. If set to
/// null the document selector provided on the client side will be used.
final List<TextDocumentFilter>? documentSelector;
final bool? workDoneProgress;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['documentSelector'] = documentSelector;
if (workDoneProgress != null) {
result['workDoneProgress'] = workDoneProgress;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('documentSelector');
try {
if (!obj.containsKey('documentSelector')) {
reporter.reportError('must not be undefined');
return false;
}
final documentSelector = obj['documentSelector'];
if (documentSelector != null &&
!((documentSelector is List<Object?> &&
(documentSelector.every(
(item) => TextDocumentFilter.canParse(item, reporter)))))) {
reporter.reportError('must be of type List<TextDocumentFilter>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('workDoneProgress');
try {
final workDoneProgress = obj['workDoneProgress'];
if (workDoneProgress != null && !(workDoneProgress is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DefinitionRegistrationOptions');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DefinitionRegistrationOptions &&
other.runtimeType == DefinitionRegistrationOptions) {
return listEqual(documentSelector, other.documentSelector,
(TextDocumentFilter a, TextDocumentFilter b) => a == b) &&
workDoneProgress == other.workDoneProgress &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
lspHashCode(documentSelector),
workDoneProgress,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
/// Delete file operation
class DeleteFile implements ToJsonable {
static const jsonHandler = LspJsonHandler(
DeleteFile.canParse,
DeleteFile.fromJson,
);
DeleteFile({
this.annotationId,
this.kind = 'delete',
this.options,
required this.uri,
}) {
if (kind != 'delete') {
throw 'kind may only be the literal \'delete\'';
}
}
static DeleteFile fromJson(Map<String, Object?> json) {
final annotationIdJson = json['annotationId'];
final annotationId = annotationIdJson as String?;
final kindJson = json['kind'];
final kind = kindJson as String;
final optionsJson = json['options'];
final options = optionsJson != null
? DeleteFileOptions.fromJson(optionsJson as Map<String, Object?>)
: null;
final uriJson = json['uri'];
final uri = uriJson as String;
return DeleteFile(
annotationId: annotationId,
kind: kind,
options: options,
uri: uri,
);
}
/// An optional annotation identifier describing the operation.
/// @since 3.16.0
final String? annotationId;
/// A delete
final String kind;
/// Delete options.
final DeleteFileOptions? options;
/// The file to delete.
final String uri;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (annotationId != null) {
result['annotationId'] = annotationId;
}
result['kind'] = kind;
if (options != null) {
result['options'] = options?.toJson();
}
result['uri'] = uri;
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('annotationId');
try {
final annotationId = obj['annotationId'];
if (annotationId != null && !(annotationId is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
reporter.push('kind');
try {
if (!obj.containsKey('kind')) {
reporter.reportError('must not be undefined');
return false;
}
final kind = obj['kind'];
if (kind == null) {
reporter.reportError('must not be null');
return false;
}
if (!(kind == 'delete')) {
reporter.reportError('must be the literal \'delete\'');
return false;
}
} finally {
reporter.pop();
}
reporter.push('options');
try {
final options = obj['options'];
if (options != null &&
!(DeleteFileOptions.canParse(options, reporter))) {
reporter.reportError('must be of type DeleteFileOptions');
return false;
}
} finally {
reporter.pop();
}
reporter.push('uri');
try {
if (!obj.containsKey('uri')) {
reporter.reportError('must not be undefined');
return false;
}
final uri = obj['uri'];
if (uri == null) {
reporter.reportError('must not be null');
return false;
}
if (!(uri is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DeleteFile');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DeleteFile && other.runtimeType == DeleteFile) {
return annotationId == other.annotationId &&
kind == other.kind &&
options == other.options &&
uri == other.uri &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
annotationId,
kind,
options,
uri,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
/// Delete file options
class DeleteFileOptions implements ToJsonable {
static const jsonHandler = LspJsonHandler(
DeleteFileOptions.canParse,
DeleteFileOptions.fromJson,
);
DeleteFileOptions({
this.ignoreIfNotExists,
this.recursive,
});
static DeleteFileOptions fromJson(Map<String, Object?> json) {
final ignoreIfNotExistsJson = json['ignoreIfNotExists'];
final ignoreIfNotExists = ignoreIfNotExistsJson as bool?;
final recursiveJson = json['recursive'];
final recursive = recursiveJson as bool?;
return DeleteFileOptions(
ignoreIfNotExists: ignoreIfNotExists,
recursive: recursive,
);
}
/// Ignore the operation if the file doesn't exist.
final bool? ignoreIfNotExists;
/// Delete the content recursively if a folder is denoted.
final bool? recursive;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (ignoreIfNotExists != null) {
result['ignoreIfNotExists'] = ignoreIfNotExists;
}
if (recursive != null) {
result['recursive'] = recursive;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('ignoreIfNotExists');
try {
final ignoreIfNotExists = obj['ignoreIfNotExists'];
if (ignoreIfNotExists != null && !(ignoreIfNotExists is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
reporter.push('recursive');
try {
final recursive = obj['recursive'];
if (recursive != null && !(recursive is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DeleteFileOptions');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DeleteFileOptions && other.runtimeType == DeleteFileOptions) {
return ignoreIfNotExists == other.ignoreIfNotExists &&
recursive == other.recursive &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
ignoreIfNotExists,
recursive,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
/// The parameters sent in notifications/requests for user-initiated deletes of
/// files.
/// @since 3.16.0
class DeleteFilesParams implements ToJsonable {
static const jsonHandler = LspJsonHandler(
DeleteFilesParams.canParse,
DeleteFilesParams.fromJson,
);
DeleteFilesParams({
required this.files,
});
static DeleteFilesParams fromJson(Map<String, Object?> json) {
final filesJson = json['files'];
final files = (filesJson as List<Object?>)
.map((item) => FileDelete.fromJson(item as Map<String, Object?>))
.toList();
return DeleteFilesParams(
files: files,
);
}
/// An array of all files/folders deleted in this operation.
final List<FileDelete> files;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['files'] = files.map((item) => item.toJson()).toList();
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('files');
try {
if (!obj.containsKey('files')) {
reporter.reportError('must not be undefined');
return false;
}
final files = obj['files'];
if (files == null) {
reporter.reportError('must not be null');
return false;
}
if (!((files is List<Object?> &&
(files.every((item) => FileDelete.canParse(item, reporter)))))) {
reporter.reportError('must be of type List<FileDelete>');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DeleteFilesParams');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DeleteFilesParams && other.runtimeType == DeleteFilesParams) {
return listEqual(
files, other.files, (FileDelete a, FileDelete b) => a == b) &&
true;
}
return false;
}
@override
int get hashCode => lspHashCode(files);
@override
String toString() => jsonEncoder.convert(toJson());
}
class Diagnostic implements ToJsonable {
static const jsonHandler = LspJsonHandler(
Diagnostic.canParse,
Diagnostic.fromJson,
);
Diagnostic({
this.code,
this.codeDescription,
this.data,
required this.message,
required this.range,
this.relatedInformation,
this.severity,
this.source,
this.tags,
});
static Diagnostic fromJson(Map<String, Object?> json) {
final codeJson = json['code'];
final code = codeJson as String?;
final codeDescriptionJson = json['codeDescription'];
final codeDescription = codeDescriptionJson != null
? CodeDescription.fromJson(codeDescriptionJson as Map<String, Object?>)
: null;
final dataJson = json['data'];
final data = dataJson;
final messageJson = json['message'];
final message = messageJson as String;
final rangeJson = json['range'];
final range = Range.fromJson(rangeJson as Map<String, Object?>);
final relatedInformationJson = json['relatedInformation'];
final relatedInformation = (relatedInformationJson as List<Object?>?)
?.map((item) =>
DiagnosticRelatedInformation.fromJson(item as Map<String, Object?>))
.toList();
final severityJson = json['severity'];
final severity = severityJson != null
? DiagnosticSeverity.fromJson(severityJson as int)
: null;
final sourceJson = json['source'];
final source = sourceJson as String?;
final tagsJson = json['tags'];
final tags = (tagsJson as List<Object?>?)
?.map((item) => DiagnosticTag.fromJson(item as int))
.toList();
return Diagnostic(
code: code,
codeDescription: codeDescription,
data: data,
message: message,
range: range,
relatedInformation: relatedInformation,
severity: severity,
source: source,
tags: tags,
);
}
/// The diagnostic's code, which might appear in the user interface.
final String? code;
/// An optional property to describe the error code.
/// @since 3.16.0
final CodeDescription? codeDescription;
/// A data entry field that is preserved between a
/// `textDocument/publishDiagnostics` notification and
/// `textDocument/codeAction` request.
/// @since 3.16.0
final Object? data;
/// The diagnostic's message.
final String message;
/// The range at which the message applies.
final Range range;
/// An array of related diagnostic information, e.g. when symbol-names within
/// a scope collide all definitions can be marked via this property.
final List<DiagnosticRelatedInformation>? relatedInformation;
/// The diagnostic's severity. Can be omitted. If omitted it is up to the
/// client to interpret diagnostics as error, warning, info or hint.
final DiagnosticSeverity? severity;
/// A human-readable string describing the source of this diagnostic, e.g.
/// 'typescript' or 'super lint'.
final String? source;
/// Additional metadata about the diagnostic.
/// @since 3.15.0
final List<DiagnosticTag>? tags;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (code != null) {
result['code'] = code;
}
if (codeDescription != null) {
result['codeDescription'] = codeDescription?.toJson();
}
if (data != null) {
result['data'] = data;
}
result['message'] = message;
result['range'] = range.toJson();
if (relatedInformation != null) {
result['relatedInformation'] =
relatedInformation?.map((item) => item.toJson()).toList();
}
if (severity != null) {
result['severity'] = severity?.toJson();
}
if (source != null) {
result['source'] = source;
}
if (tags != null) {
result['tags'] = tags?.map((item) => item.toJson()).toList();
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('code');
try {
final code = obj['code'];
if (code != null && !(code is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
reporter.push('codeDescription');
try {
final codeDescription = obj['codeDescription'];
if (codeDescription != null &&
!(CodeDescription.canParse(codeDescription, reporter))) {
reporter.reportError('must be of type CodeDescription');
return false;
}
} finally {
reporter.pop();
}
reporter.push('message');
try {
if (!obj.containsKey('message')) {
reporter.reportError('must not be undefined');
return false;
}
final message = obj['message'];
if (message == null) {
reporter.reportError('must not be null');
return false;
}
if (!(message is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
reporter.push('range');
try {
if (!obj.containsKey('range')) {
reporter.reportError('must not be undefined');
return false;
}
final range = obj['range'];
if (range == null) {
reporter.reportError('must not be null');
return false;
}
if (!(Range.canParse(range, reporter))) {
reporter.reportError('must be of type Range');
return false;
}
} finally {
reporter.pop();
}
reporter.push('relatedInformation');
try {
final relatedInformation = obj['relatedInformation'];
if (relatedInformation != null &&
!((relatedInformation is List<Object?> &&
(relatedInformation.every((item) =>
DiagnosticRelatedInformation.canParse(item, reporter)))))) {
reporter.reportError(
'must be of type List<DiagnosticRelatedInformation>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('severity');
try {
final severity = obj['severity'];
if (severity != null &&
!(DiagnosticSeverity.canParse(severity, reporter))) {
reporter.reportError('must be of type DiagnosticSeverity');
return false;
}
} finally {
reporter.pop();
}
reporter.push('source');
try {
final source = obj['source'];
if (source != null && !(source is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
reporter.push('tags');
try {
final tags = obj['tags'];
if (tags != null &&
!((tags is List<Object?> &&
(tags.every(
(item) => DiagnosticTag.canParse(item, reporter)))))) {
reporter.reportError('must be of type List<DiagnosticTag>');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type Diagnostic');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is Diagnostic && other.runtimeType == Diagnostic) {
return code == other.code &&
codeDescription == other.codeDescription &&
data == other.data &&
message == other.message &&
range == other.range &&
listEqual(
relatedInformation,
other.relatedInformation,
(DiagnosticRelatedInformation a,
DiagnosticRelatedInformation b) =>
a == b) &&
severity == other.severity &&
source == other.source &&
listEqual(
tags, other.tags, (DiagnosticTag a, DiagnosticTag b) => a == b) &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
code,
codeDescription,
data,
message,
range,
lspHashCode(relatedInformation),
severity,
source,
lspHashCode(tags),
);
@override
String toString() => jsonEncoder.convert(toJson());
}
/// Client capabilities specific to diagnostic pull requests.
/// @since 3.17.0
class DiagnosticClientCapabilities implements ToJsonable {
static const jsonHandler = LspJsonHandler(
DiagnosticClientCapabilities.canParse,
DiagnosticClientCapabilities.fromJson,
);
DiagnosticClientCapabilities({
this.dynamicRegistration,
this.relatedDocumentSupport,
});
static DiagnosticClientCapabilities fromJson(Map<String, Object?> json) {
final dynamicRegistrationJson = json['dynamicRegistration'];
final dynamicRegistration = dynamicRegistrationJson as bool?;
final relatedDocumentSupportJson = json['relatedDocumentSupport'];
final relatedDocumentSupport = relatedDocumentSupportJson as bool?;
return DiagnosticClientCapabilities(
dynamicRegistration: dynamicRegistration,
relatedDocumentSupport: relatedDocumentSupport,
);
}
/// Whether implementation supports dynamic registration. If this is set to
/// `true` the client supports the new `(TextDocumentRegistrationOptions &
/// StaticRegistrationOptions)` return value for the corresponding server
/// capability as well.
final bool? dynamicRegistration;
/// Whether the clients supports related documents for document diagnostic
/// pulls.
final bool? relatedDocumentSupport;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (dynamicRegistration != null) {
result['dynamicRegistration'] = dynamicRegistration;
}
if (relatedDocumentSupport != null) {
result['relatedDocumentSupport'] = relatedDocumentSupport;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('dynamicRegistration');
try {
final dynamicRegistration = obj['dynamicRegistration'];
if (dynamicRegistration != null && !(dynamicRegistration is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
reporter.push('relatedDocumentSupport');
try {
final relatedDocumentSupport = obj['relatedDocumentSupport'];
if (relatedDocumentSupport != null &&
!(relatedDocumentSupport is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DiagnosticClientCapabilities');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DiagnosticClientCapabilities &&
other.runtimeType == DiagnosticClientCapabilities) {
return dynamicRegistration == other.dynamicRegistration &&
relatedDocumentSupport == other.relatedDocumentSupport &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
dynamicRegistration,
relatedDocumentSupport,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
/// Diagnostic options.
/// @since 3.17.0
class DiagnosticOptions implements WorkDoneProgressOptions, ToJsonable {
static const jsonHandler = LspJsonHandler(
DiagnosticOptions.canParse,
DiagnosticOptions.fromJson,
);
DiagnosticOptions({
this.identifier,
required this.interFileDependencies,
this.workDoneProgress,
required this.workspaceDiagnostics,
});
static DiagnosticOptions fromJson(Map<String, Object?> json) {
if (DiagnosticRegistrationOptions.canParse(json, nullLspJsonReporter)) {
return DiagnosticRegistrationOptions.fromJson(json);
}
final identifierJson = json['identifier'];
final identifier = identifierJson as String?;
final interFileDependenciesJson = json['interFileDependencies'];
final interFileDependencies = interFileDependenciesJson as bool;
final workDoneProgressJson = json['workDoneProgress'];
final workDoneProgress = workDoneProgressJson as bool?;
final workspaceDiagnosticsJson = json['workspaceDiagnostics'];
final workspaceDiagnostics = workspaceDiagnosticsJson as bool;
return DiagnosticOptions(
identifier: identifier,
interFileDependencies: interFileDependencies,
workDoneProgress: workDoneProgress,
workspaceDiagnostics: workspaceDiagnostics,
);
}
/// An optional identifier under which the diagnostics are managed by the
/// client.
final String? identifier;
/// Whether the language has inter file dependencies meaning that editing code
/// in one file can result in a different diagnostic set in another file.
/// Inter file dependencies are common for most programming languages and
/// typically uncommon for linters.
final bool interFileDependencies;
final bool? workDoneProgress;
/// The server provides support for workspace diagnostics as well.
final bool workspaceDiagnostics;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (identifier != null) {
result['identifier'] = identifier;
}
result['interFileDependencies'] = interFileDependencies;
if (workDoneProgress != null) {
result['workDoneProgress'] = workDoneProgress;
}
result['workspaceDiagnostics'] = workspaceDiagnostics;
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('identifier');
try {
final identifier = obj['identifier'];
if (identifier != null && !(identifier is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
reporter.push('interFileDependencies');
try {
if (!obj.containsKey('interFileDependencies')) {
reporter.reportError('must not be undefined');
return false;
}
final interFileDependencies = obj['interFileDependencies'];
if (interFileDependencies == null) {
reporter.reportError('must not be null');
return false;
}
if (!(interFileDependencies is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
reporter.push('workDoneProgress');
try {
final workDoneProgress = obj['workDoneProgress'];
if (workDoneProgress != null && !(workDoneProgress is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
reporter.push('workspaceDiagnostics');
try {
if (!obj.containsKey('workspaceDiagnostics')) {
reporter.reportError('must not be undefined');
return false;
}
final workspaceDiagnostics = obj['workspaceDiagnostics'];
if (workspaceDiagnostics == null) {
reporter.reportError('must not be null');
return false;
}
if (!(workspaceDiagnostics is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DiagnosticOptions');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DiagnosticOptions && other.runtimeType == DiagnosticOptions) {
return identifier == other.identifier &&
interFileDependencies == other.interFileDependencies &&
workDoneProgress == other.workDoneProgress &&
workspaceDiagnostics == other.workspaceDiagnostics &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
identifier,
interFileDependencies,
workDoneProgress,
workspaceDiagnostics,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
/// Diagnostic registration options.
/// @since 3.17.0
class DiagnosticRegistrationOptions
implements
DiagnosticOptions,
StaticRegistrationOptions,
TextDocumentRegistrationOptions,
ToJsonable {
static const jsonHandler = LspJsonHandler(
DiagnosticRegistrationOptions.canParse,
DiagnosticRegistrationOptions.fromJson,
);
DiagnosticRegistrationOptions({
this.documentSelector,
this.id,
this.identifier,
required this.interFileDependencies,
this.workDoneProgress,
required this.workspaceDiagnostics,
});
static DiagnosticRegistrationOptions fromJson(Map<String, Object?> json) {
final documentSelectorJson = json['documentSelector'];
final documentSelector = (documentSelectorJson as List<Object?>?)
?.map(
(item) => TextDocumentFilter.fromJson(item as Map<String, Object?>))
.toList();
final idJson = json['id'];
final id = idJson as String?;
final identifierJson = json['identifier'];
final identifier = identifierJson as String?;
final interFileDependenciesJson = json['interFileDependencies'];
final interFileDependencies = interFileDependenciesJson as bool;
final workDoneProgressJson = json['workDoneProgress'];
final workDoneProgress = workDoneProgressJson as bool?;
final workspaceDiagnosticsJson = json['workspaceDiagnostics'];
final workspaceDiagnostics = workspaceDiagnosticsJson as bool;
return DiagnosticRegistrationOptions(
documentSelector: documentSelector,
id: id,
identifier: identifier,
interFileDependencies: interFileDependencies,
workDoneProgress: workDoneProgress,
workspaceDiagnostics: workspaceDiagnostics,
);
}
/// A document selector to identify the scope of the registration. If set to
/// null the document selector provided on the client side will be used.
final List<TextDocumentFilter>? documentSelector;
/// The id used to register the request. The id can be used to deregister the
/// request again. See also Registration#id.
final String? id;
/// An optional identifier under which the diagnostics are managed by the
/// client.
final String? identifier;
/// Whether the language has inter file dependencies meaning that editing code
/// in one file can result in a different diagnostic set in another file.
/// Inter file dependencies are common for most programming languages and
/// typically uncommon for linters.
final bool interFileDependencies;
final bool? workDoneProgress;
/// The server provides support for workspace diagnostics as well.
final bool workspaceDiagnostics;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['documentSelector'] = documentSelector;
if (id != null) {
result['id'] = id;
}
if (identifier != null) {
result['identifier'] = identifier;
}
result['interFileDependencies'] = interFileDependencies;
if (workDoneProgress != null) {
result['workDoneProgress'] = workDoneProgress;
}
result['workspaceDiagnostics'] = workspaceDiagnostics;
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('documentSelector');
try {
if (!obj.containsKey('documentSelector')) {
reporter.reportError('must not be undefined');
return false;
}
final documentSelector = obj['documentSelector'];
if (documentSelector != null &&
!((documentSelector is List<Object?> &&
(documentSelector.every(
(item) => TextDocumentFilter.canParse(item, reporter)))))) {
reporter.reportError('must be of type List<TextDocumentFilter>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('id');
try {
final id = obj['id'];
if (id != null && !(id is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
reporter.push('identifier');
try {
final identifier = obj['identifier'];
if (identifier != null && !(identifier is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
reporter.push('interFileDependencies');
try {
if (!obj.containsKey('interFileDependencies')) {
reporter.reportError('must not be undefined');
return false;
}
final interFileDependencies = obj['interFileDependencies'];
if (interFileDependencies == null) {
reporter.reportError('must not be null');
return false;
}
if (!(interFileDependencies is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
reporter.push('workDoneProgress');
try {
final workDoneProgress = obj['workDoneProgress'];
if (workDoneProgress != null && !(workDoneProgress is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
reporter.push('workspaceDiagnostics');
try {
if (!obj.containsKey('workspaceDiagnostics')) {
reporter.reportError('must not be undefined');
return false;
}
final workspaceDiagnostics = obj['workspaceDiagnostics'];
if (workspaceDiagnostics == null) {
reporter.reportError('must not be null');
return false;
}
if (!(workspaceDiagnostics is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DiagnosticRegistrationOptions');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DiagnosticRegistrationOptions &&
other.runtimeType == DiagnosticRegistrationOptions) {
return listEqual(documentSelector, other.documentSelector,
(TextDocumentFilter a, TextDocumentFilter b) => a == b) &&
id == other.id &&
identifier == other.identifier &&
interFileDependencies == other.interFileDependencies &&
workDoneProgress == other.workDoneProgress &&
workspaceDiagnostics == other.workspaceDiagnostics &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
lspHashCode(documentSelector),
id,
identifier,
interFileDependencies,
workDoneProgress,
workspaceDiagnostics,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
/// Represents a related message and source code location for a diagnostic. This
/// should be used to point to code locations that cause or are related to a
/// diagnostics, e.g when duplicating a symbol in a scope.
class DiagnosticRelatedInformation implements ToJsonable {
static const jsonHandler = LspJsonHandler(
DiagnosticRelatedInformation.canParse,
DiagnosticRelatedInformation.fromJson,
);
DiagnosticRelatedInformation({
required this.location,
required this.message,
});
static DiagnosticRelatedInformation fromJson(Map<String, Object?> json) {
final locationJson = json['location'];
final location = Location.fromJson(locationJson as Map<String, Object?>);
final messageJson = json['message'];
final message = messageJson as String;
return DiagnosticRelatedInformation(
location: location,
message: message,
);
}
/// The location of this related diagnostic information.
final Location location;
/// The message of this related diagnostic information.
final String message;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['location'] = location.toJson();
result['message'] = message;
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('location');
try {
if (!obj.containsKey('location')) {
reporter.reportError('must not be undefined');
return false;
}
final location = obj['location'];
if (location == null) {
reporter.reportError('must not be null');
return false;
}
if (!(Location.canParse(location, reporter))) {
reporter.reportError('must be of type Location');
return false;
}
} finally {
reporter.pop();
}
reporter.push('message');
try {
if (!obj.containsKey('message')) {
reporter.reportError('must not be undefined');
return false;
}
final message = obj['message'];
if (message == null) {
reporter.reportError('must not be null');
return false;
}
if (!(message is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DiagnosticRelatedInformation');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DiagnosticRelatedInformation &&
other.runtimeType == DiagnosticRelatedInformation) {
return location == other.location && message == other.message && true;
}
return false;
}
@override
int get hashCode => Object.hash(
location,
message,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
/// Cancellation data returned from a diagnostic request.
/// @since 3.17.0
class DiagnosticServerCancellationData implements ToJsonable {
static const jsonHandler = LspJsonHandler(
DiagnosticServerCancellationData.canParse,
DiagnosticServerCancellationData.fromJson,
);
DiagnosticServerCancellationData({
required this.retriggerRequest,
});
static DiagnosticServerCancellationData fromJson(Map<String, Object?> json) {
final retriggerRequestJson = json['retriggerRequest'];
final retriggerRequest = retriggerRequestJson as bool;
return DiagnosticServerCancellationData(
retriggerRequest: retriggerRequest,
);
}
final bool retriggerRequest;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['retriggerRequest'] = retriggerRequest;
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('retriggerRequest');
try {
if (!obj.containsKey('retriggerRequest')) {
reporter.reportError('must not be undefined');
return false;
}
final retriggerRequest = obj['retriggerRequest'];
if (retriggerRequest == null) {
reporter.reportError('must not be null');
return false;
}
if (!(retriggerRequest is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DiagnosticServerCancellationData');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DiagnosticServerCancellationData &&
other.runtimeType == DiagnosticServerCancellationData) {
return retriggerRequest == other.retriggerRequest && true;
}
return false;
}
@override
int get hashCode => retriggerRequest.hashCode;
@override
String toString() => jsonEncoder.convert(toJson());
}
class DiagnosticSeverity implements ToJsonable {
const DiagnosticSeverity(this._value);
const DiagnosticSeverity.fromJson(this._value);
final int _value;
static bool canParse(Object? obj, LspJsonReporter reporter) {
return obj is int;
}
/// Reports an error.
static const Error = DiagnosticSeverity(1);
/// Reports a hint.
static const Hint = DiagnosticSeverity(4);
/// Reports an information.
static const Information = DiagnosticSeverity(3);
/// Reports a warning.
static const Warning = DiagnosticSeverity(2);
Object toJson() => _value;
@override
String toString() => _value.toString();
@override
int get hashCode => _value.hashCode;
bool operator ==(Object other) =>
other is DiagnosticSeverity && other._value == _value;
}
/// The diagnostic tags.
/// @since 3.15.0
class DiagnosticTag implements ToJsonable {
const DiagnosticTag(this._value);
const DiagnosticTag.fromJson(this._value);
final int _value;
static bool canParse(Object? obj, LspJsonReporter reporter) {
return obj is int;
}
/// Deprecated or obsolete code.
///
/// Clients are allowed to rendered diagnostics with this tag strike through.
static const Deprecated = DiagnosticTag(2);
/// Unused or unnecessary code.
///
/// Clients are allowed to render diagnostics with this tag faded out instead
/// of having an error squiggle.
static const Unnecessary = DiagnosticTag(1);
Object toJson() => _value;
@override
String toString() => _value.toString();
@override
int get hashCode => _value.hashCode;
bool operator ==(Object other) =>
other is DiagnosticTag && other._value == _value;
}
/// Workspace client capabilities specific to diagnostic pull requests.
/// @since 3.17.0
class DiagnosticWorkspaceClientCapabilities implements ToJsonable {
static const jsonHandler = LspJsonHandler(
DiagnosticWorkspaceClientCapabilities.canParse,
DiagnosticWorkspaceClientCapabilities.fromJson,
);
DiagnosticWorkspaceClientCapabilities({
this.refreshSupport,
});
static DiagnosticWorkspaceClientCapabilities fromJson(
Map<String, Object?> json) {
final refreshSupportJson = json['refreshSupport'];
final refreshSupport = refreshSupportJson as bool?;
return DiagnosticWorkspaceClientCapabilities(
refreshSupport: refreshSupport,
);
}
/// Whether the client implementation supports a refresh request sent from the
/// server to the client.
///
/// Note that this event is global and will force the client to refresh all
/// pulled diagnostics currently shown. It should be used with absolute care
/// and is useful for situation where a server for example detects a project
/// wide change that requires such a calculation.
final bool? refreshSupport;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (refreshSupport != null) {
result['refreshSupport'] = refreshSupport;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('refreshSupport');
try {
final refreshSupport = obj['refreshSupport'];
if (refreshSupport != null && !(refreshSupport is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter
.reportError('must be of type DiagnosticWorkspaceClientCapabilities');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DiagnosticWorkspaceClientCapabilities &&
other.runtimeType == DiagnosticWorkspaceClientCapabilities) {
return refreshSupport == other.refreshSupport && true;
}
return false;
}
@override
int get hashCode => refreshSupport.hashCode;
@override
String toString() => jsonEncoder.convert(toJson());
}
class DidChangeConfigurationClientCapabilities implements ToJsonable {
static const jsonHandler = LspJsonHandler(
DidChangeConfigurationClientCapabilities.canParse,
DidChangeConfigurationClientCapabilities.fromJson,
);
DidChangeConfigurationClientCapabilities({
this.dynamicRegistration,
});
static DidChangeConfigurationClientCapabilities fromJson(
Map<String, Object?> json) {
final dynamicRegistrationJson = json['dynamicRegistration'];
final dynamicRegistration = dynamicRegistrationJson as bool?;
return DidChangeConfigurationClientCapabilities(
dynamicRegistration: dynamicRegistration,
);
}
/// Did change configuration notification supports dynamic registration.
final bool? dynamicRegistration;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (dynamicRegistration != null) {
result['dynamicRegistration'] = dynamicRegistration;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('dynamicRegistration');
try {
final dynamicRegistration = obj['dynamicRegistration'];
if (dynamicRegistration != null && !(dynamicRegistration is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError(
'must be of type DidChangeConfigurationClientCapabilities');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DidChangeConfigurationClientCapabilities &&
other.runtimeType == DidChangeConfigurationClientCapabilities) {
return dynamicRegistration == other.dynamicRegistration && true;
}
return false;
}
@override
int get hashCode => dynamicRegistration.hashCode;
@override
String toString() => jsonEncoder.convert(toJson());
}
class DidChangeConfigurationParams implements ToJsonable {
static const jsonHandler = LspJsonHandler(
DidChangeConfigurationParams.canParse,
DidChangeConfigurationParams.fromJson,
);
DidChangeConfigurationParams({
this.settings,
});
static DidChangeConfigurationParams fromJson(Map<String, Object?> json) {
final settingsJson = json['settings'];
final settings = settingsJson;
return DidChangeConfigurationParams(
settings: settings,
);
}
/// The actual changed settings
final Object? settings;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['settings'] = settings;
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
return true;
} else {
reporter.reportError('must be of type DidChangeConfigurationParams');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DidChangeConfigurationParams &&
other.runtimeType == DidChangeConfigurationParams) {
return settings == other.settings && true;
}
return false;
}
@override
int get hashCode => settings.hashCode;
@override
String toString() => jsonEncoder.convert(toJson());
}
/// The params sent in a change notebook document notification.
/// @since 3.17.0
class DidChangeNotebookDocumentParams implements ToJsonable {
static const jsonHandler = LspJsonHandler(
DidChangeNotebookDocumentParams.canParse,
DidChangeNotebookDocumentParams.fromJson,
);
DidChangeNotebookDocumentParams({
required this.change,
required this.notebookDocument,
});
static DidChangeNotebookDocumentParams fromJson(Map<String, Object?> json) {
final changeJson = json['change'];
final change = NotebookDocumentChangeEvent.fromJson(
changeJson as Map<String, Object?>);
final notebookDocumentJson = json['notebookDocument'];
final notebookDocument = VersionedNotebookDocumentIdentifier.fromJson(
notebookDocumentJson as Map<String, Object?>);
return DidChangeNotebookDocumentParams(
change: change,
notebookDocument: notebookDocument,
);
}
/// The actual changes to the notebook document.
///
/// The change describes single state change to the notebook document. So it
/// moves a notebook document, its cells and its cell text document contents
/// from state S to S'.
///
/// To mirror the content of a notebook using change events use the following
/// approach:
/// - start with the same initial content
/// - apply the 'notebookDocument/didChange' notifications in the order
/// you receive them.
final NotebookDocumentChangeEvent change;
/// The notebook document that did change. The version number points to the
/// version after all provided changes have been applied.
final VersionedNotebookDocumentIdentifier notebookDocument;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['change'] = change.toJson();
result['notebookDocument'] = notebookDocument.toJson();
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('change');
try {
if (!obj.containsKey('change')) {
reporter.reportError('must not be undefined');
return false;
}
final change = obj['change'];
if (change == null) {
reporter.reportError('must not be null');
return false;
}
if (!(NotebookDocumentChangeEvent.canParse(change, reporter))) {
reporter.reportError('must be of type NotebookDocumentChangeEvent');
return false;
}
} finally {
reporter.pop();
}
reporter.push('notebookDocument');
try {
if (!obj.containsKey('notebookDocument')) {
reporter.reportError('must not be undefined');
return false;
}
final notebookDocument = obj['notebookDocument'];
if (notebookDocument == null) {
reporter.reportError('must not be null');
return false;
}
if (!(VersionedNotebookDocumentIdentifier.canParse(
notebookDocument, reporter))) {
reporter.reportError(
'must be of type VersionedNotebookDocumentIdentifier');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DidChangeNotebookDocumentParams');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DidChangeNotebookDocumentParams &&
other.runtimeType == DidChangeNotebookDocumentParams) {
return change == other.change &&
notebookDocument == other.notebookDocument &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
change,
notebookDocument,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class DidChangeTextDocumentParams implements ToJsonable {
static const jsonHandler = LspJsonHandler(
DidChangeTextDocumentParams.canParse,
DidChangeTextDocumentParams.fromJson,
);
DidChangeTextDocumentParams({
required this.contentChanges,
required this.textDocument,
});
static DidChangeTextDocumentParams fromJson(Map<String, Object?> json) {
final contentChangesJson = json['contentChanges'];
final contentChanges = (contentChangesJson as List<Object?>)
.map((item) => TextDocumentContentChangeEvent1.canParse(
item, nullLspJsonReporter)
? Either2<TextDocumentContentChangeEvent1, TextDocumentContentChangeEvent2>.t1(
TextDocumentContentChangeEvent1.fromJson(
item as Map<String, Object?>))
: (TextDocumentContentChangeEvent2.canParse(item, nullLspJsonReporter)
? Either2<TextDocumentContentChangeEvent1,
TextDocumentContentChangeEvent2>.t2(
TextDocumentContentChangeEvent2.fromJson(item as Map<String, Object?>))
: (throw '''$item was not one of (TextDocumentContentChangeEvent1, TextDocumentContentChangeEvent2)''')))
.toList();
final textDocumentJson = json['textDocument'];
final textDocument = VersionedTextDocumentIdentifier.fromJson(
textDocumentJson as Map<String, Object?>);
return DidChangeTextDocumentParams(
contentChanges: contentChanges,
textDocument: textDocument,
);
}
/// The actual content changes. The content changes describe single state
/// changes to the document. So if there are two content changes c1 (at array
/// index 0) and c2 (at array index 1) for a document in state S then c1 moves
/// the document from S to S' and c2 from S' to S''. So c1 is computed on the
/// state S and c2 is computed on the state S'.
///
/// To mirror the content of a document using change events use the following
/// approach:
/// - start with the same initial content
/// - apply the 'textDocument/didChange' notifications in the order you
/// receive them.
/// - apply the `TextDocumentContentChangeEvent`s in a single notification
/// in the order you receive them.
final List<
Either2<TextDocumentContentChangeEvent1,
TextDocumentContentChangeEvent2>> contentChanges;
/// The document that did change. The version number points to the version
/// after all provided content changes have been applied.
final VersionedTextDocumentIdentifier textDocument;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['contentChanges'] = contentChanges;
result['textDocument'] = textDocument.toJson();
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('contentChanges');
try {
if (!obj.containsKey('contentChanges')) {
reporter.reportError('must not be undefined');
return false;
}
final contentChanges = obj['contentChanges'];
if (contentChanges == null) {
reporter.reportError('must not be null');
return false;
}
if (!((contentChanges is List<Object?> &&
(contentChanges.every((item) =>
(TextDocumentContentChangeEvent1.canParse(item, reporter) ||
TextDocumentContentChangeEvent2.canParse(
item, reporter))))))) {
reporter.reportError(
'must be of type List<Either2<TextDocumentContentChangeEvent1, TextDocumentContentChangeEvent2>>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('textDocument');
try {
if (!obj.containsKey('textDocument')) {
reporter.reportError('must not be undefined');
return false;
}
final textDocument = obj['textDocument'];
if (textDocument == null) {
reporter.reportError('must not be null');
return false;
}
if (!(VersionedTextDocumentIdentifier.canParse(
textDocument, reporter))) {
reporter
.reportError('must be of type VersionedTextDocumentIdentifier');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DidChangeTextDocumentParams');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DidChangeTextDocumentParams &&
other.runtimeType == DidChangeTextDocumentParams) {
return listEqual(
contentChanges,
other.contentChanges,
(Either2<TextDocumentContentChangeEvent1,
TextDocumentContentChangeEvent2>
a,
Either2<TextDocumentContentChangeEvent1,
TextDocumentContentChangeEvent2>
b) =>
a == b) &&
textDocument == other.textDocument &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
lspHashCode(contentChanges),
textDocument,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class DidChangeWatchedFilesClientCapabilities implements ToJsonable {
static const jsonHandler = LspJsonHandler(
DidChangeWatchedFilesClientCapabilities.canParse,
DidChangeWatchedFilesClientCapabilities.fromJson,
);
DidChangeWatchedFilesClientCapabilities({
this.dynamicRegistration,
this.relativePatternSupport,
});
static DidChangeWatchedFilesClientCapabilities fromJson(
Map<String, Object?> json) {
final dynamicRegistrationJson = json['dynamicRegistration'];
final dynamicRegistration = dynamicRegistrationJson as bool?;
final relativePatternSupportJson = json['relativePatternSupport'];
final relativePatternSupport = relativePatternSupportJson as bool?;
return DidChangeWatchedFilesClientCapabilities(
dynamicRegistration: dynamicRegistration,
relativePatternSupport: relativePatternSupport,
);
}
/// Did change watched files notification supports dynamic registration.
/// Please note that the current protocol doesn't support static configuration
/// for file changes from the server side.
final bool? dynamicRegistration;
/// Whether the client has support for relative patterns or not.
/// @since 3.17.0
final bool? relativePatternSupport;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (dynamicRegistration != null) {
result['dynamicRegistration'] = dynamicRegistration;
}
if (relativePatternSupport != null) {
result['relativePatternSupport'] = relativePatternSupport;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('dynamicRegistration');
try {
final dynamicRegistration = obj['dynamicRegistration'];
if (dynamicRegistration != null && !(dynamicRegistration is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
reporter.push('relativePatternSupport');
try {
final relativePatternSupport = obj['relativePatternSupport'];
if (relativePatternSupport != null &&
!(relativePatternSupport is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError(
'must be of type DidChangeWatchedFilesClientCapabilities');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DidChangeWatchedFilesClientCapabilities &&
other.runtimeType == DidChangeWatchedFilesClientCapabilities) {
return dynamicRegistration == other.dynamicRegistration &&
relativePatternSupport == other.relativePatternSupport &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
dynamicRegistration,
relativePatternSupport,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class DidChangeWatchedFilesParams implements ToJsonable {
static const jsonHandler = LspJsonHandler(
DidChangeWatchedFilesParams.canParse,
DidChangeWatchedFilesParams.fromJson,
);
DidChangeWatchedFilesParams({
required this.changes,
});
static DidChangeWatchedFilesParams fromJson(Map<String, Object?> json) {
final changesJson = json['changes'];
final changes = (changesJson as List<Object?>)
.map((item) => FileEvent.fromJson(item as Map<String, Object?>))
.toList();
return DidChangeWatchedFilesParams(
changes: changes,
);
}
/// The actual file events.
final List<FileEvent> changes;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['changes'] = changes.map((item) => item.toJson()).toList();
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('changes');
try {
if (!obj.containsKey('changes')) {
reporter.reportError('must not be undefined');
return false;
}
final changes = obj['changes'];
if (changes == null) {
reporter.reportError('must not be null');
return false;
}
if (!((changes is List<Object?> &&
(changes.every((item) => FileEvent.canParse(item, reporter)))))) {
reporter.reportError('must be of type List<FileEvent>');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DidChangeWatchedFilesParams');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DidChangeWatchedFilesParams &&
other.runtimeType == DidChangeWatchedFilesParams) {
return listEqual(
changes, other.changes, (FileEvent a, FileEvent b) => a == b) &&
true;
}
return false;
}
@override
int get hashCode => lspHashCode(changes);
@override
String toString() => jsonEncoder.convert(toJson());
}
/// Describe options to be used when registering for file system change events.
class DidChangeWatchedFilesRegistrationOptions implements ToJsonable {
static const jsonHandler = LspJsonHandler(
DidChangeWatchedFilesRegistrationOptions.canParse,
DidChangeWatchedFilesRegistrationOptions.fromJson,
);
DidChangeWatchedFilesRegistrationOptions({
required this.watchers,
});
static DidChangeWatchedFilesRegistrationOptions fromJson(
Map<String, Object?> json) {
final watchersJson = json['watchers'];
final watchers = (watchersJson as List<Object?>)
.map((item) => FileSystemWatcher.fromJson(item as Map<String, Object?>))
.toList();
return DidChangeWatchedFilesRegistrationOptions(
watchers: watchers,
);
}
/// The watchers to register.
final List<FileSystemWatcher> watchers;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['watchers'] = watchers.map((item) => item.toJson()).toList();
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('watchers');
try {
if (!obj.containsKey('watchers')) {
reporter.reportError('must not be undefined');
return false;
}
final watchers = obj['watchers'];
if (watchers == null) {
reporter.reportError('must not be null');
return false;
}
if (!((watchers is List<Object?> &&
(watchers.every(
(item) => FileSystemWatcher.canParse(item, reporter)))))) {
reporter.reportError('must be of type List<FileSystemWatcher>');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError(
'must be of type DidChangeWatchedFilesRegistrationOptions');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DidChangeWatchedFilesRegistrationOptions &&
other.runtimeType == DidChangeWatchedFilesRegistrationOptions) {
return listEqual(watchers, other.watchers,
(FileSystemWatcher a, FileSystemWatcher b) => a == b) &&
true;
}
return false;
}
@override
int get hashCode => lspHashCode(watchers);
@override
String toString() => jsonEncoder.convert(toJson());
}
class DidChangeWorkspaceFoldersParams implements ToJsonable {
static const jsonHandler = LspJsonHandler(
DidChangeWorkspaceFoldersParams.canParse,
DidChangeWorkspaceFoldersParams.fromJson,
);
DidChangeWorkspaceFoldersParams({
required this.event,
});
static DidChangeWorkspaceFoldersParams fromJson(Map<String, Object?> json) {
final eventJson = json['event'];
final event =
WorkspaceFoldersChangeEvent.fromJson(eventJson as Map<String, Object?>);
return DidChangeWorkspaceFoldersParams(
event: event,
);
}
/// The actual workspace folder change event.
final WorkspaceFoldersChangeEvent event;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['event'] = event.toJson();
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('event');
try {
if (!obj.containsKey('event')) {
reporter.reportError('must not be undefined');
return false;
}
final event = obj['event'];
if (event == null) {
reporter.reportError('must not be null');
return false;
}
if (!(WorkspaceFoldersChangeEvent.canParse(event, reporter))) {
reporter.reportError('must be of type WorkspaceFoldersChangeEvent');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DidChangeWorkspaceFoldersParams');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DidChangeWorkspaceFoldersParams &&
other.runtimeType == DidChangeWorkspaceFoldersParams) {
return event == other.event && true;
}
return false;
}
@override
int get hashCode => event.hashCode;
@override
String toString() => jsonEncoder.convert(toJson());
}
/// The params sent in a close notebook document notification.
/// @since 3.17.0
class DidCloseNotebookDocumentParams implements ToJsonable {
static const jsonHandler = LspJsonHandler(
DidCloseNotebookDocumentParams.canParse,
DidCloseNotebookDocumentParams.fromJson,
);
DidCloseNotebookDocumentParams({
required this.cellTextDocuments,
required this.notebookDocument,
});
static DidCloseNotebookDocumentParams fromJson(Map<String, Object?> json) {
final cellTextDocumentsJson = json['cellTextDocuments'];
final cellTextDocuments = (cellTextDocumentsJson as List<Object?>)
.map((item) =>
TextDocumentIdentifier.fromJson(item as Map<String, Object?>))
.toList();
final notebookDocumentJson = json['notebookDocument'];
final notebookDocument = NotebookDocumentIdentifier.fromJson(
notebookDocumentJson as Map<String, Object?>);
return DidCloseNotebookDocumentParams(
cellTextDocuments: cellTextDocuments,
notebookDocument: notebookDocument,
);
}
/// The text documents that represent the content of a notebook cell that got
/// closed.
final List<TextDocumentIdentifier> cellTextDocuments;
/// The notebook document that got closed.
final NotebookDocumentIdentifier notebookDocument;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['cellTextDocuments'] =
cellTextDocuments.map((item) => item.toJson()).toList();
result['notebookDocument'] = notebookDocument.toJson();
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('cellTextDocuments');
try {
if (!obj.containsKey('cellTextDocuments')) {
reporter.reportError('must not be undefined');
return false;
}
final cellTextDocuments = obj['cellTextDocuments'];
if (cellTextDocuments == null) {
reporter.reportError('must not be null');
return false;
}
if (!((cellTextDocuments is List<Object?> &&
(cellTextDocuments.every(
(item) => TextDocumentIdentifier.canParse(item, reporter)))))) {
reporter.reportError('must be of type List<TextDocumentIdentifier>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('notebookDocument');
try {
if (!obj.containsKey('notebookDocument')) {
reporter.reportError('must not be undefined');
return false;
}
final notebookDocument = obj['notebookDocument'];
if (notebookDocument == null) {
reporter.reportError('must not be null');
return false;
}
if (!(NotebookDocumentIdentifier.canParse(
notebookDocument, reporter))) {
reporter.reportError('must be of type NotebookDocumentIdentifier');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DidCloseNotebookDocumentParams');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DidCloseNotebookDocumentParams &&
other.runtimeType == DidCloseNotebookDocumentParams) {
return listEqual(cellTextDocuments, other.cellTextDocuments,
(TextDocumentIdentifier a, TextDocumentIdentifier b) => a == b) &&
notebookDocument == other.notebookDocument &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
lspHashCode(cellTextDocuments),
notebookDocument,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class DidCloseTextDocumentParams implements ToJsonable {
static const jsonHandler = LspJsonHandler(
DidCloseTextDocumentParams.canParse,
DidCloseTextDocumentParams.fromJson,
);
DidCloseTextDocumentParams({
required this.textDocument,
});
static DidCloseTextDocumentParams fromJson(Map<String, Object?> json) {
final textDocumentJson = json['textDocument'];
final textDocument = TextDocumentIdentifier.fromJson(
textDocumentJson as Map<String, Object?>);
return DidCloseTextDocumentParams(
textDocument: textDocument,
);
}
/// The document that was closed.
final TextDocumentIdentifier textDocument;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['textDocument'] = textDocument.toJson();
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('textDocument');
try {
if (!obj.containsKey('textDocument')) {
reporter.reportError('must not be undefined');
return false;
}
final textDocument = obj['textDocument'];
if (textDocument == null) {
reporter.reportError('must not be null');
return false;
}
if (!(TextDocumentIdentifier.canParse(textDocument, reporter))) {
reporter.reportError('must be of type TextDocumentIdentifier');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DidCloseTextDocumentParams');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DidCloseTextDocumentParams &&
other.runtimeType == DidCloseTextDocumentParams) {
return textDocument == other.textDocument && true;
}
return false;
}
@override
int get hashCode => textDocument.hashCode;
@override
String toString() => jsonEncoder.convert(toJson());
}
/// The params sent in a open notebook document notification.
/// @since 3.17.0
class DidOpenNotebookDocumentParams implements ToJsonable {
static const jsonHandler = LspJsonHandler(
DidOpenNotebookDocumentParams.canParse,
DidOpenNotebookDocumentParams.fromJson,
);
DidOpenNotebookDocumentParams({
required this.cellTextDocuments,
required this.notebookDocument,
});
static DidOpenNotebookDocumentParams fromJson(Map<String, Object?> json) {
final cellTextDocumentsJson = json['cellTextDocuments'];
final cellTextDocuments = (cellTextDocumentsJson as List<Object?>)
.map((item) => TextDocumentItem.fromJson(item as Map<String, Object?>))
.toList();
final notebookDocumentJson = json['notebookDocument'];
final notebookDocument =
NotebookDocument.fromJson(notebookDocumentJson as Map<String, Object?>);
return DidOpenNotebookDocumentParams(
cellTextDocuments: cellTextDocuments,
notebookDocument: notebookDocument,
);
}
/// The text documents that represent the content of a notebook cell.
final List<TextDocumentItem> cellTextDocuments;
/// The notebook document that got opened.
final NotebookDocument notebookDocument;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['cellTextDocuments'] =
cellTextDocuments.map((item) => item.toJson()).toList();
result['notebookDocument'] = notebookDocument.toJson();
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('cellTextDocuments');
try {
if (!obj.containsKey('cellTextDocuments')) {
reporter.reportError('must not be undefined');
return false;
}
final cellTextDocuments = obj['cellTextDocuments'];
if (cellTextDocuments == null) {
reporter.reportError('must not be null');
return false;
}
if (!((cellTextDocuments is List<Object?> &&
(cellTextDocuments.every(
(item) => TextDocumentItem.canParse(item, reporter)))))) {
reporter.reportError('must be of type List<TextDocumentItem>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('notebookDocument');
try {
if (!obj.containsKey('notebookDocument')) {
reporter.reportError('must not be undefined');
return false;
}
final notebookDocument = obj['notebookDocument'];
if (notebookDocument == null) {
reporter.reportError('must not be null');
return false;
}
if (!(NotebookDocument.canParse(notebookDocument, reporter))) {
reporter.reportError('must be of type NotebookDocument');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DidOpenNotebookDocumentParams');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DidOpenNotebookDocumentParams &&
other.runtimeType == DidOpenNotebookDocumentParams) {
return listEqual(cellTextDocuments, other.cellTextDocuments,
(TextDocumentItem a, TextDocumentItem b) => a == b) &&
notebookDocument == other.notebookDocument &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
lspHashCode(cellTextDocuments),
notebookDocument,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class DidOpenTextDocumentParams implements ToJsonable {
static const jsonHandler = LspJsonHandler(
DidOpenTextDocumentParams.canParse,
DidOpenTextDocumentParams.fromJson,
);
DidOpenTextDocumentParams({
required this.textDocument,
});
static DidOpenTextDocumentParams fromJson(Map<String, Object?> json) {
final textDocumentJson = json['textDocument'];
final textDocument =
TextDocumentItem.fromJson(textDocumentJson as Map<String, Object?>);
return DidOpenTextDocumentParams(
textDocument: textDocument,
);
}
/// The document that was opened.
final TextDocumentItem textDocument;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['textDocument'] = textDocument.toJson();
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('textDocument');
try {
if (!obj.containsKey('textDocument')) {
reporter.reportError('must not be undefined');
return false;
}
final textDocument = obj['textDocument'];
if (textDocument == null) {
reporter.reportError('must not be null');
return false;
}
if (!(TextDocumentItem.canParse(textDocument, reporter))) {
reporter.reportError('must be of type TextDocumentItem');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DidOpenTextDocumentParams');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DidOpenTextDocumentParams &&
other.runtimeType == DidOpenTextDocumentParams) {
return textDocument == other.textDocument && true;
}
return false;
}
@override
int get hashCode => textDocument.hashCode;
@override
String toString() => jsonEncoder.convert(toJson());
}
/// The params sent in a save notebook document notification.
/// @since 3.17.0
class DidSaveNotebookDocumentParams implements ToJsonable {
static const jsonHandler = LspJsonHandler(
DidSaveNotebookDocumentParams.canParse,
DidSaveNotebookDocumentParams.fromJson,
);
DidSaveNotebookDocumentParams({
required this.notebookDocument,
});
static DidSaveNotebookDocumentParams fromJson(Map<String, Object?> json) {
final notebookDocumentJson = json['notebookDocument'];
final notebookDocument = NotebookDocumentIdentifier.fromJson(
notebookDocumentJson as Map<String, Object?>);
return DidSaveNotebookDocumentParams(
notebookDocument: notebookDocument,
);
}
/// The notebook document that got saved.
final NotebookDocumentIdentifier notebookDocument;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['notebookDocument'] = notebookDocument.toJson();
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('notebookDocument');
try {
if (!obj.containsKey('notebookDocument')) {
reporter.reportError('must not be undefined');
return false;
}
final notebookDocument = obj['notebookDocument'];
if (notebookDocument == null) {
reporter.reportError('must not be null');
return false;
}
if (!(NotebookDocumentIdentifier.canParse(
notebookDocument, reporter))) {
reporter.reportError('must be of type NotebookDocumentIdentifier');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DidSaveNotebookDocumentParams');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DidSaveNotebookDocumentParams &&
other.runtimeType == DidSaveNotebookDocumentParams) {
return notebookDocument == other.notebookDocument && true;
}
return false;
}
@override
int get hashCode => notebookDocument.hashCode;
@override
String toString() => jsonEncoder.convert(toJson());
}
class DidSaveTextDocumentParams implements ToJsonable {
static const jsonHandler = LspJsonHandler(
DidSaveTextDocumentParams.canParse,
DidSaveTextDocumentParams.fromJson,
);
DidSaveTextDocumentParams({
this.text,
required this.textDocument,
});
static DidSaveTextDocumentParams fromJson(Map<String, Object?> json) {
final textJson = json['text'];
final text = textJson as String?;
final textDocumentJson = json['textDocument'];
final textDocument = TextDocumentIdentifier.fromJson(
textDocumentJson as Map<String, Object?>);
return DidSaveTextDocumentParams(
text: text,
textDocument: textDocument,
);
}
/// Optional the content when saved. Depends on the includeText value when the
/// save notification was requested.
final String? text;
/// The document that was saved.
final TextDocumentIdentifier textDocument;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (text != null) {
result['text'] = text;
}
result['textDocument'] = textDocument.toJson();
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('text');
try {
final text = obj['text'];
if (text != null && !(text is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
reporter.push('textDocument');
try {
if (!obj.containsKey('textDocument')) {
reporter.reportError('must not be undefined');
return false;
}
final textDocument = obj['textDocument'];
if (textDocument == null) {
reporter.reportError('must not be null');
return false;
}
if (!(TextDocumentIdentifier.canParse(textDocument, reporter))) {
reporter.reportError('must be of type TextDocumentIdentifier');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DidSaveTextDocumentParams');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DidSaveTextDocumentParams &&
other.runtimeType == DidSaveTextDocumentParams) {
return text == other.text && textDocument == other.textDocument && true;
}
return false;
}
@override
int get hashCode => Object.hash(
text,
textDocument,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class DocumentColorClientCapabilities implements ToJsonable {
static const jsonHandler = LspJsonHandler(
DocumentColorClientCapabilities.canParse,
DocumentColorClientCapabilities.fromJson,
);
DocumentColorClientCapabilities({
this.dynamicRegistration,
});
static DocumentColorClientCapabilities fromJson(Map<String, Object?> json) {
final dynamicRegistrationJson = json['dynamicRegistration'];
final dynamicRegistration = dynamicRegistrationJson as bool?;
return DocumentColorClientCapabilities(
dynamicRegistration: dynamicRegistration,
);
}
/// Whether document color supports dynamic registration.
final bool? dynamicRegistration;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (dynamicRegistration != null) {
result['dynamicRegistration'] = dynamicRegistration;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('dynamicRegistration');
try {
final dynamicRegistration = obj['dynamicRegistration'];
if (dynamicRegistration != null && !(dynamicRegistration is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DocumentColorClientCapabilities');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DocumentColorClientCapabilities &&
other.runtimeType == DocumentColorClientCapabilities) {
return dynamicRegistration == other.dynamicRegistration && true;
}
return false;
}
@override
int get hashCode => dynamicRegistration.hashCode;
@override
String toString() => jsonEncoder.convert(toJson());
}
class DocumentColorOptions implements WorkDoneProgressOptions, ToJsonable {
static const jsonHandler = LspJsonHandler(
DocumentColorOptions.canParse,
DocumentColorOptions.fromJson,
);
DocumentColorOptions({
this.workDoneProgress,
});
static DocumentColorOptions fromJson(Map<String, Object?> json) {
if (DocumentColorRegistrationOptions.canParse(json, nullLspJsonReporter)) {
return DocumentColorRegistrationOptions.fromJson(json);
}
final workDoneProgressJson = json['workDoneProgress'];
final workDoneProgress = workDoneProgressJson as bool?;
return DocumentColorOptions(
workDoneProgress: workDoneProgress,
);
}
final bool? workDoneProgress;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (workDoneProgress != null) {
result['workDoneProgress'] = workDoneProgress;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('workDoneProgress');
try {
final workDoneProgress = obj['workDoneProgress'];
if (workDoneProgress != null && !(workDoneProgress is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DocumentColorOptions');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DocumentColorOptions &&
other.runtimeType == DocumentColorOptions) {
return workDoneProgress == other.workDoneProgress && true;
}
return false;
}
@override
int get hashCode => workDoneProgress.hashCode;
@override
String toString() => jsonEncoder.convert(toJson());
}
class DocumentColorParams
implements PartialResultParams, WorkDoneProgressParams, ToJsonable {
static const jsonHandler = LspJsonHandler(
DocumentColorParams.canParse,
DocumentColorParams.fromJson,
);
DocumentColorParams({
this.partialResultToken,
required this.textDocument,
this.workDoneToken,
});
static DocumentColorParams fromJson(Map<String, Object?> json) {
final partialResultTokenJson = json['partialResultToken'];
final partialResultToken = partialResultTokenJson == null
? null
: (partialResultTokenJson is int
? Either2<int, String>.t1(partialResultTokenJson)
: (partialResultTokenJson is String
? Either2<int, String>.t2(partialResultTokenJson)
: (throw '''$partialResultTokenJson was not one of (int, String)''')));
final textDocumentJson = json['textDocument'];
final textDocument = TextDocumentIdentifier.fromJson(
textDocumentJson as Map<String, Object?>);
final workDoneTokenJson = json['workDoneToken'];
final workDoneToken = workDoneTokenJson == null
? null
: (workDoneTokenJson is int
? Either2<int, String>.t1(workDoneTokenJson)
: (workDoneTokenJson is String
? Either2<int, String>.t2(workDoneTokenJson)
: (throw '''$workDoneTokenJson was not one of (int, String)''')));
return DocumentColorParams(
partialResultToken: partialResultToken,
textDocument: textDocument,
workDoneToken: workDoneToken,
);
}
/// An optional token that a server can use to report partial results (e.g.
/// streaming) to the client.
final Either2<int, String>? partialResultToken;
/// The text document.
final TextDocumentIdentifier textDocument;
/// An optional token that a server can use to report work done progress.
final Either2<int, String>? workDoneToken;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (partialResultToken != null) {
result['partialResultToken'] = partialResultToken;
}
result['textDocument'] = textDocument.toJson();
if (workDoneToken != null) {
result['workDoneToken'] = workDoneToken;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('partialResultToken');
try {
final partialResultToken = obj['partialResultToken'];
if (partialResultToken != null &&
!((partialResultToken is int || partialResultToken is String))) {
reporter.reportError('must be of type Either2<int, String>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('textDocument');
try {
if (!obj.containsKey('textDocument')) {
reporter.reportError('must not be undefined');
return false;
}
final textDocument = obj['textDocument'];
if (textDocument == null) {
reporter.reportError('must not be null');
return false;
}
if (!(TextDocumentIdentifier.canParse(textDocument, reporter))) {
reporter.reportError('must be of type TextDocumentIdentifier');
return false;
}
} finally {
reporter.pop();
}
reporter.push('workDoneToken');
try {
final workDoneToken = obj['workDoneToken'];
if (workDoneToken != null &&
!((workDoneToken is int || workDoneToken is String))) {
reporter.reportError('must be of type Either2<int, String>');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DocumentColorParams');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DocumentColorParams &&
other.runtimeType == DocumentColorParams) {
return partialResultToken == other.partialResultToken &&
textDocument == other.textDocument &&
workDoneToken == other.workDoneToken &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
partialResultToken,
textDocument,
workDoneToken,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class DocumentColorRegistrationOptions
implements
DocumentColorOptions,
StaticRegistrationOptions,
TextDocumentRegistrationOptions,
ToJsonable {
static const jsonHandler = LspJsonHandler(
DocumentColorRegistrationOptions.canParse,
DocumentColorRegistrationOptions.fromJson,
);
DocumentColorRegistrationOptions({
this.documentSelector,
this.id,
this.workDoneProgress,
});
static DocumentColorRegistrationOptions fromJson(Map<String, Object?> json) {
final documentSelectorJson = json['documentSelector'];
final documentSelector = (documentSelectorJson as List<Object?>?)
?.map(
(item) => TextDocumentFilter.fromJson(item as Map<String, Object?>))
.toList();
final idJson = json['id'];
final id = idJson as String?;
final workDoneProgressJson = json['workDoneProgress'];
final workDoneProgress = workDoneProgressJson as bool?;
return DocumentColorRegistrationOptions(
documentSelector: documentSelector,
id: id,
workDoneProgress: workDoneProgress,
);
}
/// A document selector to identify the scope of the registration. If set to
/// null the document selector provided on the client side will be used.
final List<TextDocumentFilter>? documentSelector;
/// The id used to register the request. The id can be used to deregister the
/// request again. See also Registration#id.
final String? id;
final bool? workDoneProgress;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['documentSelector'] = documentSelector;
if (id != null) {
result['id'] = id;
}
if (workDoneProgress != null) {
result['workDoneProgress'] = workDoneProgress;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('documentSelector');
try {
if (!obj.containsKey('documentSelector')) {
reporter.reportError('must not be undefined');
return false;
}
final documentSelector = obj['documentSelector'];
if (documentSelector != null &&
!((documentSelector is List<Object?> &&
(documentSelector.every(
(item) => TextDocumentFilter.canParse(item, reporter)))))) {
reporter.reportError('must be of type List<TextDocumentFilter>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('id');
try {
final id = obj['id'];
if (id != null && !(id is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
reporter.push('workDoneProgress');
try {
final workDoneProgress = obj['workDoneProgress'];
if (workDoneProgress != null && !(workDoneProgress is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DocumentColorRegistrationOptions');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DocumentColorRegistrationOptions &&
other.runtimeType == DocumentColorRegistrationOptions) {
return listEqual(documentSelector, other.documentSelector,
(TextDocumentFilter a, TextDocumentFilter b) => a == b) &&
id == other.id &&
workDoneProgress == other.workDoneProgress &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
lspHashCode(documentSelector),
id,
workDoneProgress,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
/// Parameters of the document diagnostic request.
/// @since 3.17.0
class DocumentDiagnosticParams
implements PartialResultParams, WorkDoneProgressParams, ToJsonable {
static const jsonHandler = LspJsonHandler(
DocumentDiagnosticParams.canParse,
DocumentDiagnosticParams.fromJson,
);
DocumentDiagnosticParams({
this.identifier,
this.partialResultToken,
this.previousResultId,
required this.textDocument,
this.workDoneToken,
});
static DocumentDiagnosticParams fromJson(Map<String, Object?> json) {
final identifierJson = json['identifier'];
final identifier = identifierJson as String?;
final partialResultTokenJson = json['partialResultToken'];
final partialResultToken = partialResultTokenJson == null
? null
: (partialResultTokenJson is int
? Either2<int, String>.t1(partialResultTokenJson)
: (partialResultTokenJson is String
? Either2<int, String>.t2(partialResultTokenJson)
: (throw '''$partialResultTokenJson was not one of (int, String)''')));
final previousResultIdJson = json['previousResultId'];
final previousResultId = previousResultIdJson as String?;
final textDocumentJson = json['textDocument'];
final textDocument = TextDocumentIdentifier.fromJson(
textDocumentJson as Map<String, Object?>);
final workDoneTokenJson = json['workDoneToken'];
final workDoneToken = workDoneTokenJson == null
? null
: (workDoneTokenJson is int
? Either2<int, String>.t1(workDoneTokenJson)
: (workDoneTokenJson is String
? Either2<int, String>.t2(workDoneTokenJson)
: (throw '''$workDoneTokenJson was not one of (int, String)''')));
return DocumentDiagnosticParams(
identifier: identifier,
partialResultToken: partialResultToken,
previousResultId: previousResultId,
textDocument: textDocument,
workDoneToken: workDoneToken,
);
}
/// The additional identifier provided during registration.
final String? identifier;
/// An optional token that a server can use to report partial results (e.g.
/// streaming) to the client.
final Either2<int, String>? partialResultToken;
/// The result id of a previous response if provided.
final String? previousResultId;
/// The text document.
final TextDocumentIdentifier textDocument;
/// An optional token that a server can use to report work done progress.
final Either2<int, String>? workDoneToken;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (identifier != null) {
result['identifier'] = identifier;
}
if (partialResultToken != null) {
result['partialResultToken'] = partialResultToken;
}
if (previousResultId != null) {
result['previousResultId'] = previousResultId;
}
result['textDocument'] = textDocument.toJson();
if (workDoneToken != null) {
result['workDoneToken'] = workDoneToken;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('identifier');
try {
final identifier = obj['identifier'];
if (identifier != null && !(identifier is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
reporter.push('partialResultToken');
try {
final partialResultToken = obj['partialResultToken'];
if (partialResultToken != null &&
!((partialResultToken is int || partialResultToken is String))) {
reporter.reportError('must be of type Either2<int, String>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('previousResultId');
try {
final previousResultId = obj['previousResultId'];
if (previousResultId != null && !(previousResultId is String)) {
reporter.reportError('must be of type String');
return false;
}
} finally {
reporter.pop();
}
reporter.push('textDocument');
try {
if (!obj.containsKey('textDocument')) {
reporter.reportError('must not be undefined');
return false;
}
final textDocument = obj['textDocument'];
if (textDocument == null) {
reporter.reportError('must not be null');
return false;
}
if (!(TextDocumentIdentifier.canParse(textDocument, reporter))) {
reporter.reportError('must be of type TextDocumentIdentifier');
return false;
}
} finally {
reporter.pop();
}
reporter.push('workDoneToken');
try {
final workDoneToken = obj['workDoneToken'];
if (workDoneToken != null &&
!((workDoneToken is int || workDoneToken is String))) {
reporter.reportError('must be of type Either2<int, String>');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DocumentDiagnosticParams');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DocumentDiagnosticParams &&
other.runtimeType == DocumentDiagnosticParams) {
return identifier == other.identifier &&
partialResultToken == other.partialResultToken &&
previousResultId == other.previousResultId &&
textDocument == other.textDocument &&
workDoneToken == other.workDoneToken &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
identifier,
partialResultToken,
previousResultId,
textDocument,
workDoneToken,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
/// The document diagnostic report kinds.
/// @since 3.17.0
class DocumentDiagnosticReportKind implements ToJsonable {
const DocumentDiagnosticReportKind(this._value);
const DocumentDiagnosticReportKind.fromJson(this._value);
final String _value;
static bool canParse(Object? obj, LspJsonReporter reporter) {
return obj is String;
}
/// A diagnostic report with a full set of problems.
static const Full = DocumentDiagnosticReportKind('full');
/// A report indicating that the last returned report is still accurate.
static const Unchanged = DocumentDiagnosticReportKind('unchanged');
Object toJson() => _value;
@override
String toString() => _value.toString();
@override
int get hashCode => _value.hashCode;
bool operator ==(Object other) =>
other is DocumentDiagnosticReportKind && other._value == _value;
}
/// A partial result for a document diagnostic report.
/// @since 3.17.0
class DocumentDiagnosticReportPartialResult implements ToJsonable {
static const jsonHandler = LspJsonHandler(
DocumentDiagnosticReportPartialResult.canParse,
DocumentDiagnosticReportPartialResult.fromJson,
);
DocumentDiagnosticReportPartialResult({
required this.relatedDocuments,
});
static DocumentDiagnosticReportPartialResult fromJson(
Map<String, Object?> json) {
final relatedDocumentsJson = json['relatedDocuments'];
final relatedDocuments = (relatedDocumentsJson as Map<Object, Object?>).map(
(key, value) => MapEntry(
key as String,
FullDocumentDiagnosticReport.canParse(value, nullLspJsonReporter)
? Either2<FullDocumentDiagnosticReport, UnchangedDocumentDiagnosticReport>.t1(
FullDocumentDiagnosticReport.fromJson(
value as Map<String, Object?>))
: (UnchangedDocumentDiagnosticReport.canParse(
value, nullLspJsonReporter)
? Either2<FullDocumentDiagnosticReport, UnchangedDocumentDiagnosticReport>.t2(
UnchangedDocumentDiagnosticReport.fromJson(
value as Map<String, Object?>))
: (throw '''$value was not one of (FullDocumentDiagnosticReport, UnchangedDocumentDiagnosticReport)'''))));
return DocumentDiagnosticReportPartialResult(
relatedDocuments: relatedDocuments,
);
}
final Map<
String,
Either2<FullDocumentDiagnosticReport,
UnchangedDocumentDiagnosticReport>> relatedDocuments;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['relatedDocuments'] = relatedDocuments;
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('relatedDocuments');
try {
if (!obj.containsKey('relatedDocuments')) {
reporter.reportError('must not be undefined');
return false;
}
final relatedDocuments = obj['relatedDocuments'];
if (relatedDocuments == null) {
reporter.reportError('must not be null');
return false;
}
if (!((relatedDocuments is Map &&
(relatedDocuments.keys.every((item) =>
item is String &&
relatedDocuments.values.every((item) =>
(FullDocumentDiagnosticReport.canParse(item, reporter) ||
UnchangedDocumentDiagnosticReport.canParse(
item, reporter)))))))) {
reporter.reportError(
'must be of type Map<String, Either2<FullDocumentDiagnosticReport, UnchangedDocumentDiagnosticReport>>');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter
.reportError('must be of type DocumentDiagnosticReportPartialResult');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DocumentDiagnosticReportPartialResult &&
other.runtimeType == DocumentDiagnosticReportPartialResult) {
return mapEqual(
relatedDocuments,
other.relatedDocuments,
(Either2<FullDocumentDiagnosticReport,
UnchangedDocumentDiagnosticReport>
a,
Either2<FullDocumentDiagnosticReport,
UnchangedDocumentDiagnosticReport>
b) =>
a == b) &&
true;
}
return false;
}
@override
int get hashCode => lspHashCode(relatedDocuments);
@override
String toString() => jsonEncoder.convert(toJson());
}
class DocumentFormattingClientCapabilities implements ToJsonable {
static const jsonHandler = LspJsonHandler(
DocumentFormattingClientCapabilities.canParse,
DocumentFormattingClientCapabilities.fromJson,
);
DocumentFormattingClientCapabilities({
this.dynamicRegistration,
});
static DocumentFormattingClientCapabilities fromJson(
Map<String, Object?> json) {
final dynamicRegistrationJson = json['dynamicRegistration'];
final dynamicRegistration = dynamicRegistrationJson as bool?;
return DocumentFormattingClientCapabilities(
dynamicRegistration: dynamicRegistration,
);
}
/// Whether formatting supports dynamic registration.
final bool? dynamicRegistration;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (dynamicRegistration != null) {
result['dynamicRegistration'] = dynamicRegistration;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('dynamicRegistration');
try {
final dynamicRegistration = obj['dynamicRegistration'];
if (dynamicRegistration != null && !(dynamicRegistration is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter
.reportError('must be of type DocumentFormattingClientCapabilities');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DocumentFormattingClientCapabilities &&
other.runtimeType == DocumentFormattingClientCapabilities) {
return dynamicRegistration == other.dynamicRegistration && true;
}
return false;
}
@override
int get hashCode => dynamicRegistration.hashCode;
@override
String toString() => jsonEncoder.convert(toJson());
}
class DocumentFormattingOptions implements WorkDoneProgressOptions, ToJsonable {
static const jsonHandler = LspJsonHandler(
DocumentFormattingOptions.canParse,
DocumentFormattingOptions.fromJson,
);
DocumentFormattingOptions({
this.workDoneProgress,
});
static DocumentFormattingOptions fromJson(Map<String, Object?> json) {
if (DocumentFormattingRegistrationOptions.canParse(
json, nullLspJsonReporter)) {
return DocumentFormattingRegistrationOptions.fromJson(json);
}
final workDoneProgressJson = json['workDoneProgress'];
final workDoneProgress = workDoneProgressJson as bool?;
return DocumentFormattingOptions(
workDoneProgress: workDoneProgress,
);
}
final bool? workDoneProgress;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (workDoneProgress != null) {
result['workDoneProgress'] = workDoneProgress;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('workDoneProgress');
try {
final workDoneProgress = obj['workDoneProgress'];
if (workDoneProgress != null && !(workDoneProgress is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DocumentFormattingOptions');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DocumentFormattingOptions &&
other.runtimeType == DocumentFormattingOptions) {
return workDoneProgress == other.workDoneProgress && true;
}
return false;
}
@override
int get hashCode => workDoneProgress.hashCode;
@override
String toString() => jsonEncoder.convert(toJson());
}
class DocumentFormattingParams implements WorkDoneProgressParams, ToJsonable {
static const jsonHandler = LspJsonHandler(
DocumentFormattingParams.canParse,
DocumentFormattingParams.fromJson,
);
DocumentFormattingParams({
required this.options,
required this.textDocument,
this.workDoneToken,
});
static DocumentFormattingParams fromJson(Map<String, Object?> json) {
final optionsJson = json['options'];
final options =
FormattingOptions.fromJson(optionsJson as Map<String, Object?>);
final textDocumentJson = json['textDocument'];
final textDocument = TextDocumentIdentifier.fromJson(
textDocumentJson as Map<String, Object?>);
final workDoneTokenJson = json['workDoneToken'];
final workDoneToken = workDoneTokenJson == null
? null
: (workDoneTokenJson is int
? Either2<int, String>.t1(workDoneTokenJson)
: (workDoneTokenJson is String
? Either2<int, String>.t2(workDoneTokenJson)
: (throw '''$workDoneTokenJson was not one of (int, String)''')));
return DocumentFormattingParams(
options: options,
textDocument: textDocument,
workDoneToken: workDoneToken,
);
}
/// The format options.
final FormattingOptions options;
/// The document to format.
final TextDocumentIdentifier textDocument;
/// An optional token that a server can use to report work done progress.
final Either2<int, String>? workDoneToken;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['options'] = options.toJson();
result['textDocument'] = textDocument.toJson();
if (workDoneToken != null) {
result['workDoneToken'] = workDoneToken;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('options');
try {
if (!obj.containsKey('options')) {
reporter.reportError('must not be undefined');
return false;
}
final options = obj['options'];
if (options == null) {
reporter.reportError('must not be null');
return false;
}
if (!(FormattingOptions.canParse(options, reporter))) {
reporter.reportError('must be of type FormattingOptions');
return false;
}
} finally {
reporter.pop();
}
reporter.push('textDocument');
try {
if (!obj.containsKey('textDocument')) {
reporter.reportError('must not be undefined');
return false;
}
final textDocument = obj['textDocument'];
if (textDocument == null) {
reporter.reportError('must not be null');
return false;
}
if (!(TextDocumentIdentifier.canParse(textDocument, reporter))) {
reporter.reportError('must be of type TextDocumentIdentifier');
return false;
}
} finally {
reporter.pop();
}
reporter.push('workDoneToken');
try {
final workDoneToken = obj['workDoneToken'];
if (workDoneToken != null &&
!((workDoneToken is int || workDoneToken is String))) {
reporter.reportError('must be of type Either2<int, String>');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DocumentFormattingParams');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DocumentFormattingParams &&
other.runtimeType == DocumentFormattingParams) {
return options == other.options &&
textDocument == other.textDocument &&
workDoneToken == other.workDoneToken &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
options,
textDocument,
workDoneToken,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class DocumentFormattingRegistrationOptions
implements
DocumentFormattingOptions,
TextDocumentRegistrationOptions,
ToJsonable {
static const jsonHandler = LspJsonHandler(
DocumentFormattingRegistrationOptions.canParse,
DocumentFormattingRegistrationOptions.fromJson,
);
DocumentFormattingRegistrationOptions({
this.documentSelector,
this.workDoneProgress,
});
static DocumentFormattingRegistrationOptions fromJson(
Map<String, Object?> json) {
final documentSelectorJson = json['documentSelector'];
final documentSelector = (documentSelectorJson as List<Object?>?)
?.map(
(item) => TextDocumentFilter.fromJson(item as Map<String, Object?>))
.toList();
final workDoneProgressJson = json['workDoneProgress'];
final workDoneProgress = workDoneProgressJson as bool?;
return DocumentFormattingRegistrationOptions(
documentSelector: documentSelector,
workDoneProgress: workDoneProgress,
);
}
/// A document selector to identify the scope of the registration. If set to
/// null the document selector provided on the client side will be used.
final List<TextDocumentFilter>? documentSelector;
final bool? workDoneProgress;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['documentSelector'] = documentSelector;
if (workDoneProgress != null) {
result['workDoneProgress'] = workDoneProgress;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('documentSelector');
try {
if (!obj.containsKey('documentSelector')) {
reporter.reportError('must not be undefined');
return false;
}
final documentSelector = obj['documentSelector'];
if (documentSelector != null &&
!((documentSelector is List<Object?> &&
(documentSelector.every(
(item) => TextDocumentFilter.canParse(item, reporter)))))) {
reporter.reportError('must be of type List<TextDocumentFilter>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('workDoneProgress');
try {
final workDoneProgress = obj['workDoneProgress'];
if (workDoneProgress != null && !(workDoneProgress is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter
.reportError('must be of type DocumentFormattingRegistrationOptions');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DocumentFormattingRegistrationOptions &&
other.runtimeType == DocumentFormattingRegistrationOptions) {
return listEqual(documentSelector, other.documentSelector,
(TextDocumentFilter a, TextDocumentFilter b) => a == b) &&
workDoneProgress == other.workDoneProgress &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
lspHashCode(documentSelector),
workDoneProgress,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
/// A document highlight is a range inside a text document which deserves
/// special attention. Usually a document highlight is visualized by changing
/// the background color of its range.
class DocumentHighlight implements ToJsonable {
static const jsonHandler = LspJsonHandler(
DocumentHighlight.canParse,
DocumentHighlight.fromJson,
);
DocumentHighlight({
this.kind,
required this.range,
});
static DocumentHighlight fromJson(Map<String, Object?> json) {
final kindJson = json['kind'];
final kind = kindJson != null
? DocumentHighlightKind.fromJson(kindJson as int)
: null;
final rangeJson = json['range'];
final range = Range.fromJson(rangeJson as Map<String, Object?>);
return DocumentHighlight(
kind: kind,
range: range,
);
}
/// The highlight kind, default is DocumentHighlightKind.Text.
final DocumentHighlightKind? kind;
/// The range this highlight applies to.
final Range range;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (kind != null) {
result['kind'] = kind?.toJson();
}
result['range'] = range.toJson();
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('kind');
try {
final kind = obj['kind'];
if (kind != null && !(DocumentHighlightKind.canParse(kind, reporter))) {
reporter.reportError('must be of type DocumentHighlightKind');
return false;
}
} finally {
reporter.pop();
}
reporter.push('range');
try {
if (!obj.containsKey('range')) {
reporter.reportError('must not be undefined');
return false;
}
final range = obj['range'];
if (range == null) {
reporter.reportError('must not be null');
return false;
}
if (!(Range.canParse(range, reporter))) {
reporter.reportError('must be of type Range');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DocumentHighlight');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DocumentHighlight && other.runtimeType == DocumentHighlight) {
return kind == other.kind && range == other.range && true;
}
return false;
}
@override
int get hashCode => Object.hash(
kind,
range,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class DocumentHighlightClientCapabilities implements ToJsonable {
static const jsonHandler = LspJsonHandler(
DocumentHighlightClientCapabilities.canParse,
DocumentHighlightClientCapabilities.fromJson,
);
DocumentHighlightClientCapabilities({
this.dynamicRegistration,
});
static DocumentHighlightClientCapabilities fromJson(
Map<String, Object?> json) {
final dynamicRegistrationJson = json['dynamicRegistration'];
final dynamicRegistration = dynamicRegistrationJson as bool?;
return DocumentHighlightClientCapabilities(
dynamicRegistration: dynamicRegistration,
);
}
/// Whether document highlight supports dynamic registration.
final bool? dynamicRegistration;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (dynamicRegistration != null) {
result['dynamicRegistration'] = dynamicRegistration;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('dynamicRegistration');
try {
final dynamicRegistration = obj['dynamicRegistration'];
if (dynamicRegistration != null && !(dynamicRegistration is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter
.reportError('must be of type DocumentHighlightClientCapabilities');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DocumentHighlightClientCapabilities &&
other.runtimeType == DocumentHighlightClientCapabilities) {
return dynamicRegistration == other.dynamicRegistration && true;
}
return false;
}
@override
int get hashCode => dynamicRegistration.hashCode;
@override
String toString() => jsonEncoder.convert(toJson());
}
/// A document highlight kind.
class DocumentHighlightKind implements ToJsonable {
const DocumentHighlightKind(this._value);
const DocumentHighlightKind.fromJson(this._value);
final int _value;
static bool canParse(Object? obj, LspJsonReporter reporter) {
return obj is int;
}
/// Read-access of a symbol, like reading a variable.
static const Read = DocumentHighlightKind(2);
/// A textual occurrence.
static const Text = DocumentHighlightKind(1);
/// Write-access of a symbol, like writing to a variable.
static const Write = DocumentHighlightKind(3);
Object toJson() => _value;
@override
String toString() => _value.toString();
@override
int get hashCode => _value.hashCode;
bool operator ==(Object other) =>
other is DocumentHighlightKind && other._value == _value;
}
class DocumentHighlightOptions implements WorkDoneProgressOptions, ToJsonable {
static const jsonHandler = LspJsonHandler(
DocumentHighlightOptions.canParse,
DocumentHighlightOptions.fromJson,
);
DocumentHighlightOptions({
this.workDoneProgress,
});
static DocumentHighlightOptions fromJson(Map<String, Object?> json) {
if (DocumentHighlightRegistrationOptions.canParse(
json, nullLspJsonReporter)) {
return DocumentHighlightRegistrationOptions.fromJson(json);
}
final workDoneProgressJson = json['workDoneProgress'];
final workDoneProgress = workDoneProgressJson as bool?;
return DocumentHighlightOptions(
workDoneProgress: workDoneProgress,
);
}
final bool? workDoneProgress;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (workDoneProgress != null) {
result['workDoneProgress'] = workDoneProgress;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('workDoneProgress');
try {
final workDoneProgress = obj['workDoneProgress'];
if (workDoneProgress != null && !(workDoneProgress is bool)) {
reporter.reportError('must be of type bool');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DocumentHighlightOptions');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DocumentHighlightOptions &&
other.runtimeType == DocumentHighlightOptions) {
return workDoneProgress == other.workDoneProgress && true;
}
return false;
}
@override
int get hashCode => workDoneProgress.hashCode;
@override
String toString() => jsonEncoder.convert(toJson());
}
class DocumentHighlightParams
implements
PartialResultParams,
TextDocumentPositionParams,
WorkDoneProgressParams,
ToJsonable {
static const jsonHandler = LspJsonHandler(
DocumentHighlightParams.canParse,
DocumentHighlightParams.fromJson,
);
DocumentHighlightParams({
this.partialResultToken,
required this.position,
required this.textDocument,
this.workDoneToken,
});
static DocumentHighlightParams fromJson(Map<String, Object?> json) {
final partialResultTokenJson = json['partialResultToken'];
final partialResultToken = partialResultTokenJson == null
? null
: (partialResultTokenJson is int
? Either2<int, String>.t1(partialResultTokenJson)
: (partialResultTokenJson is String
? Either2<int, String>.t2(partialResultTokenJson)
: (throw '''$partialResultTokenJson was not one of (int, String)''')));
final positionJson = json['position'];
final position = Position.fromJson(positionJson as Map<String, Object?>);
final textDocumentJson = json['textDocument'];
final textDocument = TextDocumentIdentifier.fromJson(
textDocumentJson as Map<String, Object?>);
final workDoneTokenJson = json['workDoneToken'];
final workDoneToken = workDoneTokenJson == null
? null
: (workDoneTokenJson is int
? Either2<int, String>.t1(workDoneTokenJson)
: (workDoneTokenJson is String
? Either2<int, String>.t2(workDoneTokenJson)
: (throw '''$workDoneTokenJson was not one of (int, String)''')));
return DocumentHighlightParams(
partialResultToken: partialResultToken,
position: position,
textDocument: textDocument,
workDoneToken: workDoneToken,
);
}
/// An optional token that a server can use to report partial results (e.g.
/// streaming) to the client.
final Either2<int, String>? partialResultToken;
/// The position inside the text document.
final Position position;
/// The text document.
final TextDocumentIdentifier textDocument;
/// An optional token that a server can use to report work done progress.
final Either2<int, String>? workDoneToken;
Map<String, Object?> toJson() {
var result = <String, Object?>{};
if (partialResultToken != null) {
result['partialResultToken'] = partialResultToken;
}
result['position'] = position.toJson();
result['textDocument'] = textDocument.toJson();
if (workDoneToken != null) {
result['workDoneToken'] = workDoneToken;
}
return result;
}
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
reporter.push('partialResultToken');
try {
final partialResultToken = obj['partialResultToken'];
if (partialResultToken != null &&
!((partialResultToken is int || partialResultToken is String))) {
reporter.reportError('must be of type Either2<int, String>');
return false;
}
} finally {
reporter.pop();
}
reporter.push('position');
try {
if (!obj.containsKey('position')) {
reporter.reportError('must not be undefined');
return false;
}
final position = obj['position'];
if (position == null) {
reporter.reportError('must not be null');
return false;
}
if (!(Position.canParse(position, reporter))) {
reporter.reportError('must be of type Position');
return false;
}
} finally {
reporter.pop();
}
reporter.push('textDocument');
try {
if (!obj.containsKey('textDocument')) {
reporter.reportError('must not be undefined');
return false;
}
final textDocument = obj['textDocument'];
if (textDocument == null) {
reporter.reportError('must not be null');
return false;
}
if (!(TextDocumentIdentifier.canParse(textDocument, reporter))) {
reporter.reportError('must be of type TextDocumentIdentifier');
return false;
}
} finally {
reporter.pop();
}
reporter.push('workDoneToken');
try {
final workDoneToken = obj['workDoneToken'];
if (workDoneToken != null &&
!((workDoneToken is int || workDoneToken is String))) {
reporter.reportError('must be of type Either2<int, String>');
return false;
}
} finally {
reporter.pop();
}
return true;
} else {
reporter.reportError('must be of type DocumentHighlightParams');
return false;
}
}
@override
bool operator ==(Object other) {
if (other is DocumentHighlightParams &&
other.runtimeType == DocumentHighlightParams) {
return partialResultToken == other.partialResultToken &&
position == other.position &&
textDocument == other.textDocument &&
workDoneToken == other.workDoneToken &&
true;
}
return false;
}
@override
int get hashCode => Object.hash(
partialResultToken,
position,
textDocument,
workDoneToken,
);
@override
String toString() => jsonEncoder.convert(toJson());
}
class DocumentHighlightRegistrationOptions