| // 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: deprecated_member_use |
| // ignore_for_file: deprecated_member_use_from_same_package |
| // ignore_for_file: unnecessary_brace_in_string_interps |
| // ignore_for_file: unused_import |
| // ignore_for_file: unused_shown_name |
| |
| 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' |
| show listEqual, mapEqual; |
| import 'package:analyzer/src/generated/utilities_general.dart'; |
| import 'package:meta/meta.dart'; |
| |
| const jsonEncoder = JsonEncoder.withIndent(' '); |
| |
| class ApplyWorkspaceEditParams implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| ApplyWorkspaceEditParams.canParse, ApplyWorkspaceEditParams.fromJson); |
| |
| ApplyWorkspaceEditParams({this.label, @required this.edit}) { |
| if (edit == null) { |
| throw 'edit is required but was not provided'; |
| } |
| } |
| static ApplyWorkspaceEditParams fromJson(Map<String, dynamic> json) { |
| final label = json['label']; |
| final edit = |
| json['edit'] != null ? WorkspaceEdit.fromJson(json['edit']) : null; |
| return ApplyWorkspaceEditParams(label: label, edit: edit); |
| } |
| |
| /// 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, dynamic> toJson() { |
| var __result = <String, dynamic>{}; |
| if (label != null) { |
| __result['label'] = label; |
| } |
| __result['edit'] = edit ?? (throw 'edit is required but was not set'); |
| return __result; |
| } |
| |
| static bool canParse(Object obj, LspJsonReporter reporter) { |
| if (obj is Map<String, dynamic>) { |
| reporter.push('label'); |
| try { |
| if (obj['label'] != null && !(obj['label'] is String)) { |
| reporter.reportError('must be of type String'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('edit'); |
| try { |
| if (!obj.containsKey('edit')) { |
| reporter.reportError('must not be undefined'); |
| return false; |
| } |
| if (obj['edit'] == null) { |
| reporter.reportError('must not be null'); |
| return false; |
| } |
| if (!(WorkspaceEdit.canParse(obj['edit'], reporter))) { |
| reporter.reportError('must be of type WorkspaceEdit'); |
| 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 label == other.label && edit == other.edit && true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| var hash = 0; |
| hash = JenkinsSmiHash.combine(hash, label.hashCode); |
| hash = JenkinsSmiHash.combine(hash, edit.hashCode); |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class ApplyWorkspaceEditResponse implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| ApplyWorkspaceEditResponse.canParse, ApplyWorkspaceEditResponse.fromJson); |
| |
| ApplyWorkspaceEditResponse({@required this.applied, this.failureReason}) { |
| if (applied == null) { |
| throw 'applied is required but was not provided'; |
| } |
| } |
| static ApplyWorkspaceEditResponse fromJson(Map<String, dynamic> json) { |
| final applied = json['applied']; |
| final failureReason = json['failureReason']; |
| return ApplyWorkspaceEditResponse( |
| applied: applied, failureReason: failureReason); |
| } |
| |
| /// Indicates whether the edit was applied or not. |
| final bool applied; |
| |
| /// An optional textual description for why the edit was not applied. This may |
| /// be used 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, dynamic> toJson() { |
| var __result = <String, dynamic>{}; |
| __result['applied'] = |
| applied ?? (throw 'applied is required but was not set'); |
| if (failureReason != null) { |
| __result['failureReason'] = failureReason; |
| } |
| return __result; |
| } |
| |
| static bool canParse(Object obj, LspJsonReporter reporter) { |
| if (obj is Map<String, dynamic>) { |
| reporter.push('applied'); |
| try { |
| if (!obj.containsKey('applied')) { |
| reporter.reportError('must not be undefined'); |
| return false; |
| } |
| if (obj['applied'] == null) { |
| reporter.reportError('must not be null'); |
| return false; |
| } |
| if (!(obj['applied'] is bool)) { |
| reporter.reportError('must be of type bool'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('failureReason'); |
| try { |
| if (obj['failureReason'] != null && !(obj['failureReason'] is String)) { |
| reporter.reportError('must be of type String'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| return true; |
| } else { |
| reporter.reportError('must be of type ApplyWorkspaceEditResponse'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| if (other is ApplyWorkspaceEditResponse && |
| other.runtimeType == ApplyWorkspaceEditResponse) { |
| return applied == other.applied && |
| failureReason == other.failureReason && |
| true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| var hash = 0; |
| hash = JenkinsSmiHash.combine(hash, applied.hashCode); |
| hash = JenkinsSmiHash.combine(hash, failureReason.hashCode); |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class CancelParams implements ToJsonable { |
| static const jsonHandler = |
| LspJsonHandler(CancelParams.canParse, CancelParams.fromJson); |
| |
| CancelParams({@required this.id}) { |
| if (id == null) { |
| throw 'id is required but was not provided'; |
| } |
| } |
| static CancelParams fromJson(Map<String, dynamic> json) { |
| final id = json['id'] is num |
| ? Either2<num, String>.t1(json['id']) |
| : (json['id'] is String |
| ? Either2<num, String>.t2(json['id']) |
| : (throw '''${json['id']} was not one of (num, String)''')); |
| return CancelParams(id: id); |
| } |
| |
| /// The request id to cancel. |
| final Either2<num, String> id; |
| |
| Map<String, dynamic> toJson() { |
| var __result = <String, dynamic>{}; |
| __result['id'] = id ?? (throw 'id is required but was not set'); |
| return __result; |
| } |
| |
| static bool canParse(Object obj, LspJsonReporter reporter) { |
| if (obj is Map<String, dynamic>) { |
| reporter.push('id'); |
| try { |
| if (!obj.containsKey('id')) { |
| reporter.reportError('must not be undefined'); |
| return false; |
| } |
| if (obj['id'] == null) { |
| reporter.reportError('must not be null'); |
| return false; |
| } |
| if (!((obj['id'] is num || obj['id'] is String))) { |
| reporter.reportError('must be of type Either2<num, 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 { |
| var hash = 0; |
| hash = JenkinsSmiHash.combine(hash, id.hashCode); |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class ClientCapabilities implements ToJsonable { |
| static const jsonHandler = |
| LspJsonHandler(ClientCapabilities.canParse, ClientCapabilities.fromJson); |
| |
| ClientCapabilities( |
| {this.workspace, this.textDocument, this.window, this.experimental}); |
| static ClientCapabilities fromJson(Map<String, dynamic> json) { |
| final workspace = json['workspace'] != null |
| ? ClientCapabilitiesWorkspace.fromJson(json['workspace']) |
| : null; |
| final textDocument = json['textDocument'] != null |
| ? TextDocumentClientCapabilities.fromJson(json['textDocument']) |
| : null; |
| final window = json['window'] != null |
| ? ClientCapabilitiesWindow.fromJson(json['window']) |
| : null; |
| final experimental = json['experimental']; |
| return ClientCapabilities( |
| workspace: workspace, |
| textDocument: textDocument, |
| window: window, |
| experimental: experimental); |
| } |
| |
| /// Experimental client capabilities. |
| final dynamic experimental; |
| |
| /// Text document specific client capabilities. |
| final TextDocumentClientCapabilities textDocument; |
| |
| /// Window specific client capabilities. |
| final ClientCapabilitiesWindow window; |
| |
| /// Workspace specific client capabilities. |
| final ClientCapabilitiesWorkspace workspace; |
| |
| Map<String, dynamic> toJson() { |
| var __result = <String, dynamic>{}; |
| if (workspace != null) { |
| __result['workspace'] = workspace; |
| } |
| if (textDocument != null) { |
| __result['textDocument'] = textDocument; |
| } |
| if (window != null) { |
| __result['window'] = window; |
| } |
| if (experimental != null) { |
| __result['experimental'] = experimental; |
| } |
| return __result; |
| } |
| |
| static bool canParse(Object obj, LspJsonReporter reporter) { |
| if (obj is Map<String, dynamic>) { |
| reporter.push('workspace'); |
| try { |
| if (obj['workspace'] != null && |
| !(ClientCapabilitiesWorkspace.canParse( |
| obj['workspace'], reporter))) { |
| reporter.reportError('must be of type ClientCapabilitiesWorkspace'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('textDocument'); |
| try { |
| if (obj['textDocument'] != null && |
| !(TextDocumentClientCapabilities.canParse( |
| obj['textDocument'], reporter))) { |
| reporter |
| .reportError('must be of type TextDocumentClientCapabilities'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('window'); |
| try { |
| if (obj['window'] != null && |
| !(ClientCapabilitiesWindow.canParse(obj['window'], reporter))) { |
| reporter.reportError('must be of type ClientCapabilitiesWindow'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('experimental'); |
| try { |
| if (obj['experimental'] != null && !(true)) { |
| reporter.reportError('must be of type dynamic'); |
| 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 workspace == other.workspace && |
| textDocument == other.textDocument && |
| window == other.window && |
| experimental == other.experimental && |
| true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| var hash = 0; |
| hash = JenkinsSmiHash.combine(hash, workspace.hashCode); |
| hash = JenkinsSmiHash.combine(hash, textDocument.hashCode); |
| hash = JenkinsSmiHash.combine(hash, window.hashCode); |
| hash = JenkinsSmiHash.combine(hash, experimental.hashCode); |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class ClientCapabilitiesWindow implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| ClientCapabilitiesWindow.canParse, ClientCapabilitiesWindow.fromJson); |
| |
| ClientCapabilitiesWindow({this.workDoneProgress}); |
| static ClientCapabilitiesWindow fromJson(Map<String, dynamic> json) { |
| final workDoneProgress = json['workDoneProgress']; |
| return ClientCapabilitiesWindow(workDoneProgress: workDoneProgress); |
| } |
| |
| /// Whether client supports handling progress notifications. If set servers |
| /// are allowed to report in `workDoneProgress` property in the request |
| /// specific server capabilities. |
| /// |
| /// Since 3.15.0 |
| final bool workDoneProgress; |
| |
| Map<String, dynamic> toJson() { |
| var __result = <String, dynamic>{}; |
| if (workDoneProgress != null) { |
| __result['workDoneProgress'] = workDoneProgress; |
| } |
| return __result; |
| } |
| |
| static bool canParse(Object obj, LspJsonReporter reporter) { |
| if (obj is Map<String, dynamic>) { |
| reporter.push('workDoneProgress'); |
| try { |
| if (obj['workDoneProgress'] != null && |
| !(obj['workDoneProgress'] is bool)) { |
| reporter.reportError('must be of type bool'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| return true; |
| } else { |
| reporter.reportError('must be of type ClientCapabilitiesWindow'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| if (other is ClientCapabilitiesWindow && |
| other.runtimeType == ClientCapabilitiesWindow) { |
| return workDoneProgress == other.workDoneProgress && true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| var hash = 0; |
| hash = JenkinsSmiHash.combine(hash, workDoneProgress.hashCode); |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class ClientCapabilitiesWorkspace implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| ClientCapabilitiesWorkspace.canParse, |
| ClientCapabilitiesWorkspace.fromJson); |
| |
| ClientCapabilitiesWorkspace( |
| {this.applyEdit, |
| this.workspaceEdit, |
| this.didChangeConfiguration, |
| this.didChangeWatchedFiles, |
| this.symbol, |
| this.executeCommand, |
| this.workspaceFolders, |
| this.configuration}); |
| static ClientCapabilitiesWorkspace fromJson(Map<String, dynamic> json) { |
| final applyEdit = json['applyEdit']; |
| final workspaceEdit = json['workspaceEdit'] != null |
| ? WorkspaceEditClientCapabilities.fromJson(json['workspaceEdit']) |
| : null; |
| final didChangeConfiguration = json['didChangeConfiguration'] != null |
| ? DidChangeConfigurationClientCapabilities.fromJson( |
| json['didChangeConfiguration']) |
| : null; |
| final didChangeWatchedFiles = json['didChangeWatchedFiles'] != null |
| ? DidChangeWatchedFilesClientCapabilities.fromJson( |
| json['didChangeWatchedFiles']) |
| : null; |
| final symbol = json['symbol'] != null |
| ? WorkspaceSymbolClientCapabilities.fromJson(json['symbol']) |
| : null; |
| final executeCommand = json['executeCommand'] != null |
| ? ExecuteCommandClientCapabilities.fromJson(json['executeCommand']) |
| : null; |
| final workspaceFolders = json['workspaceFolders']; |
| final configuration = json['configuration']; |
| return ClientCapabilitiesWorkspace( |
| applyEdit: applyEdit, |
| workspaceEdit: workspaceEdit, |
| didChangeConfiguration: didChangeConfiguration, |
| didChangeWatchedFiles: didChangeWatchedFiles, |
| symbol: symbol, |
| executeCommand: executeCommand, |
| workspaceFolders: workspaceFolders, |
| configuration: configuration); |
| } |
| |
| /// The client supports applying batch edits to the workspace by supporting |
| /// the request 'workspace/applyEdit' |
| final bool applyEdit; |
| |
| /// The client supports `workspace/configuration` requests. |
| /// |
| /// Since 3.6.0 |
| final bool configuration; |
| |
| /// Capabilities specific to the `workspace/didChangeConfiguration` |
| /// notification. |
| final DidChangeConfigurationClientCapabilities didChangeConfiguration; |
| |
| /// Capabilities specific to the `workspace/didChangeWatchedFiles` |
| /// notification. |
| final DidChangeWatchedFilesClientCapabilities didChangeWatchedFiles; |
| |
| /// Capabilities specific to the `workspace/executeCommand` request. |
| final ExecuteCommandClientCapabilities executeCommand; |
| |
| /// Capabilities specific to the `workspace/symbol` request. |
| final WorkspaceSymbolClientCapabilities symbol; |
| |
| /// Capabilities specific to `WorkspaceEdit`s |
| final WorkspaceEditClientCapabilities workspaceEdit; |
| |
| /// The client has support for workspace folders. |
| /// |
| /// Since 3.6.0 |
| final bool workspaceFolders; |
| |
| Map<String, dynamic> toJson() { |
| var __result = <String, dynamic>{}; |
| if (applyEdit != null) { |
| __result['applyEdit'] = applyEdit; |
| } |
| if (workspaceEdit != null) { |
| __result['workspaceEdit'] = workspaceEdit; |
| } |
| if (didChangeConfiguration != null) { |
| __result['didChangeConfiguration'] = didChangeConfiguration; |
| } |
| if (didChangeWatchedFiles != null) { |
| __result['didChangeWatchedFiles'] = didChangeWatchedFiles; |
| } |
| if (symbol != null) { |
| __result['symbol'] = symbol; |
| } |
| if (executeCommand != null) { |
| __result['executeCommand'] = executeCommand; |
| } |
| if (workspaceFolders != null) { |
| __result['workspaceFolders'] = workspaceFolders; |
| } |
| if (configuration != null) { |
| __result['configuration'] = configuration; |
| } |
| return __result; |
| } |
| |
| static bool canParse(Object obj, LspJsonReporter reporter) { |
| if (obj is Map<String, dynamic>) { |
| reporter.push('applyEdit'); |
| try { |
| if (obj['applyEdit'] != null && !(obj['applyEdit'] is bool)) { |
| reporter.reportError('must be of type bool'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('workspaceEdit'); |
| try { |
| if (obj['workspaceEdit'] != null && |
| !(WorkspaceEditClientCapabilities.canParse( |
| obj['workspaceEdit'], reporter))) { |
| reporter |
| .reportError('must be of type WorkspaceEditClientCapabilities'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('didChangeConfiguration'); |
| try { |
| if (obj['didChangeConfiguration'] != null && |
| !(DidChangeConfigurationClientCapabilities.canParse( |
| obj['didChangeConfiguration'], reporter))) { |
| reporter.reportError( |
| 'must be of type DidChangeConfigurationClientCapabilities'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('didChangeWatchedFiles'); |
| try { |
| if (obj['didChangeWatchedFiles'] != null && |
| !(DidChangeWatchedFilesClientCapabilities.canParse( |
| obj['didChangeWatchedFiles'], reporter))) { |
| reporter.reportError( |
| 'must be of type DidChangeWatchedFilesClientCapabilities'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('symbol'); |
| try { |
| if (obj['symbol'] != null && |
| !(WorkspaceSymbolClientCapabilities.canParse( |
| obj['symbol'], reporter))) { |
| reporter |
| .reportError('must be of type WorkspaceSymbolClientCapabilities'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('executeCommand'); |
| try { |
| if (obj['executeCommand'] != null && |
| !(ExecuteCommandClientCapabilities.canParse( |
| obj['executeCommand'], reporter))) { |
| reporter |
| .reportError('must be of type ExecuteCommandClientCapabilities'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('workspaceFolders'); |
| try { |
| if (obj['workspaceFolders'] != null && |
| !(obj['workspaceFolders'] is bool)) { |
| reporter.reportError('must be of type bool'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('configuration'); |
| try { |
| if (obj['configuration'] != null && !(obj['configuration'] is bool)) { |
| reporter.reportError('must be of type bool'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| return true; |
| } else { |
| reporter.reportError('must be of type ClientCapabilitiesWorkspace'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| if (other is ClientCapabilitiesWorkspace && |
| other.runtimeType == ClientCapabilitiesWorkspace) { |
| return applyEdit == other.applyEdit && |
| workspaceEdit == other.workspaceEdit && |
| didChangeConfiguration == other.didChangeConfiguration && |
| didChangeWatchedFiles == other.didChangeWatchedFiles && |
| symbol == other.symbol && |
| executeCommand == other.executeCommand && |
| workspaceFolders == other.workspaceFolders && |
| configuration == other.configuration && |
| true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| var hash = 0; |
| hash = JenkinsSmiHash.combine(hash, applyEdit.hashCode); |
| hash = JenkinsSmiHash.combine(hash, workspaceEdit.hashCode); |
| hash = JenkinsSmiHash.combine(hash, didChangeConfiguration.hashCode); |
| hash = JenkinsSmiHash.combine(hash, didChangeWatchedFiles.hashCode); |
| hash = JenkinsSmiHash.combine(hash, symbol.hashCode); |
| hash = JenkinsSmiHash.combine(hash, executeCommand.hashCode); |
| hash = JenkinsSmiHash.combine(hash, workspaceFolders.hashCode); |
| hash = JenkinsSmiHash.combine(hash, configuration.hashCode); |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @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( |
| {@required this.title, |
| this.kind, |
| this.diagnostics, |
| this.isPreferred, |
| this.edit, |
| this.command}) { |
| if (title == null) { |
| throw 'title is required but was not provided'; |
| } |
| } |
| static CodeAction fromJson(Map<String, dynamic> json) { |
| final title = json['title']; |
| final kind = |
| json['kind'] != null ? CodeActionKind.fromJson(json['kind']) : null; |
| final diagnostics = json['diagnostics'] |
| ?.map((item) => item != null ? Diagnostic.fromJson(item) : null) |
| ?.cast<Diagnostic>() |
| ?.toList(); |
| final isPreferred = json['isPreferred']; |
| final edit = |
| json['edit'] != null ? WorkspaceEdit.fromJson(json['edit']) : null; |
| final command = |
| json['command'] != null ? Command.fromJson(json['command']) : null; |
| return CodeAction( |
| title: title, |
| kind: kind, |
| diagnostics: diagnostics, |
| isPreferred: isPreferred, |
| edit: edit, |
| command: command); |
| } |
| |
| /// 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; |
| |
| /// The diagnostics that this code action resolves. |
| final List<Diagnostic> diagnostics; |
| |
| /// 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, dynamic> toJson() { |
| var __result = <String, dynamic>{}; |
| __result['title'] = title ?? (throw 'title is required but was not set'); |
| if (kind != null) { |
| __result['kind'] = kind; |
| } |
| if (diagnostics != null) { |
| __result['diagnostics'] = diagnostics; |
| } |
| if (isPreferred != null) { |
| __result['isPreferred'] = isPreferred; |
| } |
| if (edit != null) { |
| __result['edit'] = edit; |
| } |
| if (command != null) { |
| __result['command'] = command; |
| } |
| return __result; |
| } |
| |
| static bool canParse(Object obj, LspJsonReporter reporter) { |
| if (obj is Map<String, dynamic>) { |
| reporter.push('title'); |
| try { |
| if (!obj.containsKey('title')) { |
| reporter.reportError('must not be undefined'); |
| return false; |
| } |
| if (obj['title'] == null) { |
| reporter.reportError('must not be null'); |
| return false; |
| } |
| if (!(obj['title'] is String)) { |
| reporter.reportError('must be of type String'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('kind'); |
| try { |
| if (obj['kind'] != null && |
| !(CodeActionKind.canParse(obj['kind'], reporter))) { |
| reporter.reportError('must be of type CodeActionKind'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('diagnostics'); |
| try { |
| if (obj['diagnostics'] != null && |
| !((obj['diagnostics'] is List && |
| (obj['diagnostics'] |
| .every((item) => Diagnostic.canParse(item, reporter)))))) { |
| reporter.reportError('must be of type List<Diagnostic>'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('isPreferred'); |
| try { |
| if (obj['isPreferred'] != null && !(obj['isPreferred'] is bool)) { |
| reporter.reportError('must be of type bool'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('edit'); |
| try { |
| if (obj['edit'] != null && |
| !(WorkspaceEdit.canParse(obj['edit'], reporter))) { |
| reporter.reportError('must be of type WorkspaceEdit'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('command'); |
| try { |
| if (obj['command'] != null && |
| !(Command.canParse(obj['command'], reporter))) { |
| reporter.reportError('must be of type Command'); |
| 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 title == other.title && |
| kind == other.kind && |
| listEqual(diagnostics, other.diagnostics, |
| (Diagnostic a, Diagnostic b) => a == b) && |
| isPreferred == other.isPreferred && |
| edit == other.edit && |
| command == other.command && |
| true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| var hash = 0; |
| hash = JenkinsSmiHash.combine(hash, title.hashCode); |
| hash = JenkinsSmiHash.combine(hash, kind.hashCode); |
| hash = JenkinsSmiHash.combine(hash, lspHashCode(diagnostics)); |
| hash = JenkinsSmiHash.combine(hash, isPreferred.hashCode); |
| hash = JenkinsSmiHash.combine(hash, edit.hashCode); |
| hash = JenkinsSmiHash.combine(hash, command.hashCode); |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class CodeActionClientCapabilities implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CodeActionClientCapabilities.canParse, |
| CodeActionClientCapabilities.fromJson); |
| |
| CodeActionClientCapabilities( |
| {this.dynamicRegistration, |
| this.codeActionLiteralSupport, |
| this.isPreferredSupport}); |
| static CodeActionClientCapabilities fromJson(Map<String, dynamic> json) { |
| final dynamicRegistration = json['dynamicRegistration']; |
| final codeActionLiteralSupport = json['codeActionLiteralSupport'] != null |
| ? CodeActionClientCapabilitiesCodeActionLiteralSupport.fromJson( |
| json['codeActionLiteralSupport']) |
| : null; |
| final isPreferredSupport = json['isPreferredSupport']; |
| return CodeActionClientCapabilities( |
| dynamicRegistration: dynamicRegistration, |
| codeActionLiteralSupport: codeActionLiteralSupport, |
| isPreferredSupport: isPreferredSupport); |
| } |
| |
| /// 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 dynamic registration. |
| final bool dynamicRegistration; |
| |
| /// Whether code action supports the `isPreferred` property. @since 3.15.0 |
| final bool isPreferredSupport; |
| |
| Map<String, dynamic> toJson() { |
| var __result = <String, dynamic>{}; |
| if (dynamicRegistration != null) { |
| __result['dynamicRegistration'] = dynamicRegistration; |
| } |
| if (codeActionLiteralSupport != null) { |
| __result['codeActionLiteralSupport'] = codeActionLiteralSupport; |
| } |
| if (isPreferredSupport != null) { |
| __result['isPreferredSupport'] = isPreferredSupport; |
| } |
| return __result; |
| } |
| |
| static bool canParse(Object obj, LspJsonReporter reporter) { |
| if (obj is Map<String, dynamic>) { |
| reporter.push('dynamicRegistration'); |
| try { |
| if (obj['dynamicRegistration'] != null && |
| !(obj['dynamicRegistration'] is bool)) { |
| reporter.reportError('must be of type bool'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('codeActionLiteralSupport'); |
| try { |
| if (obj['codeActionLiteralSupport'] != null && |
| !(CodeActionClientCapabilitiesCodeActionLiteralSupport.canParse( |
| obj['codeActionLiteralSupport'], reporter))) { |
| reporter.reportError( |
| 'must be of type CodeActionClientCapabilitiesCodeActionLiteralSupport'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('isPreferredSupport'); |
| try { |
| if (obj['isPreferredSupport'] != null && |
| !(obj['isPreferredSupport'] is bool)) { |
| reporter.reportError('must be of type bool'); |
| 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 dynamicRegistration == other.dynamicRegistration && |
| codeActionLiteralSupport == other.codeActionLiteralSupport && |
| isPreferredSupport == other.isPreferredSupport && |
| true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| var hash = 0; |
| hash = JenkinsSmiHash.combine(hash, dynamicRegistration.hashCode); |
| hash = JenkinsSmiHash.combine(hash, codeActionLiteralSupport.hashCode); |
| hash = JenkinsSmiHash.combine(hash, isPreferredSupport.hashCode); |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class CodeActionClientCapabilitiesCodeActionKind implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CodeActionClientCapabilitiesCodeActionKind.canParse, |
| CodeActionClientCapabilitiesCodeActionKind.fromJson); |
| |
| CodeActionClientCapabilitiesCodeActionKind({@required this.valueSet}) { |
| if (valueSet == null) { |
| throw 'valueSet is required but was not provided'; |
| } |
| } |
| static CodeActionClientCapabilitiesCodeActionKind fromJson( |
| Map<String, dynamic> json) { |
| final valueSet = json['valueSet'] |
| ?.map((item) => item != null ? CodeActionKind.fromJson(item) : null) |
| ?.cast<CodeActionKind>() |
| ?.toList(); |
| return CodeActionClientCapabilitiesCodeActionKind(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, dynamic> toJson() { |
| var __result = <String, dynamic>{}; |
| __result['valueSet'] = |
| valueSet ?? (throw 'valueSet is required but was not set'); |
| return __result; |
| } |
| |
| static bool canParse(Object obj, LspJsonReporter reporter) { |
| if (obj is Map<String, dynamic>) { |
| reporter.push('valueSet'); |
| try { |
| if (!obj.containsKey('valueSet')) { |
| reporter.reportError('must not be undefined'); |
| return false; |
| } |
| if (obj['valueSet'] == null) { |
| reporter.reportError('must not be null'); |
| return false; |
| } |
| if (!((obj['valueSet'] is List && |
| (obj['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 CodeActionClientCapabilitiesCodeActionKind'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| if (other is CodeActionClientCapabilitiesCodeActionKind && |
| other.runtimeType == CodeActionClientCapabilitiesCodeActionKind) { |
| return listEqual(valueSet, other.valueSet, |
| (CodeActionKind a, CodeActionKind b) => a == b) && |
| true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| var hash = 0; |
| hash = JenkinsSmiHash.combine(hash, lspHashCode(valueSet)); |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class CodeActionClientCapabilitiesCodeActionLiteralSupport |
| implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CodeActionClientCapabilitiesCodeActionLiteralSupport.canParse, |
| CodeActionClientCapabilitiesCodeActionLiteralSupport.fromJson); |
| |
| CodeActionClientCapabilitiesCodeActionLiteralSupport( |
| {@required this.codeActionKind}) { |
| if (codeActionKind == null) { |
| throw 'codeActionKind is required but was not provided'; |
| } |
| } |
| static CodeActionClientCapabilitiesCodeActionLiteralSupport fromJson( |
| Map<String, dynamic> json) { |
| final codeActionKind = json['codeActionKind'] != null |
| ? CodeActionClientCapabilitiesCodeActionKind.fromJson( |
| json['codeActionKind']) |
| : null; |
| return CodeActionClientCapabilitiesCodeActionLiteralSupport( |
| codeActionKind: codeActionKind); |
| } |
| |
| /// The code action kind is supported with the following value set. |
| final CodeActionClientCapabilitiesCodeActionKind codeActionKind; |
| |
| Map<String, dynamic> toJson() { |
| var __result = <String, dynamic>{}; |
| __result['codeActionKind'] = |
| codeActionKind ?? (throw 'codeActionKind is required but was not set'); |
| return __result; |
| } |
| |
| static bool canParse(Object obj, LspJsonReporter reporter) { |
| if (obj is Map<String, dynamic>) { |
| reporter.push('codeActionKind'); |
| try { |
| if (!obj.containsKey('codeActionKind')) { |
| reporter.reportError('must not be undefined'); |
| return false; |
| } |
| if (obj['codeActionKind'] == null) { |
| reporter.reportError('must not be null'); |
| return false; |
| } |
| if (!(CodeActionClientCapabilitiesCodeActionKind.canParse( |
| obj['codeActionKind'], reporter))) { |
| reporter.reportError( |
| 'must be of type CodeActionClientCapabilitiesCodeActionKind'); |
| 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 { |
| var hash = 0; |
| hash = JenkinsSmiHash.combine(hash, codeActionKind.hashCode); |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @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}) { |
| if (diagnostics == null) { |
| throw 'diagnostics is required but was not provided'; |
| } |
| } |
| static CodeActionContext fromJson(Map<String, dynamic> json) { |
| final diagnostics = json['diagnostics'] |
| ?.map((item) => item != null ? Diagnostic.fromJson(item) : null) |
| ?.cast<Diagnostic>() |
| ?.toList(); |
| final only = json['only'] |
| ?.map((item) => item != null ? CodeActionKind.fromJson(item) : null) |
| ?.cast<CodeActionKind>() |
| ?.toList(); |
| return CodeActionContext(diagnostics: diagnostics, only: only); |
| } |
| |
| /// 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; |
| |
| Map<String, dynamic> toJson() { |
| var __result = <String, dynamic>{}; |
| __result['diagnostics'] = |
| diagnostics ?? (throw 'diagnostics is required but was not set'); |
| if (only != null) { |
| __result['only'] = only; |
| } |
| return __result; |
| } |
| |
| static bool canParse(Object obj, LspJsonReporter reporter) { |
| if (obj is Map<String, dynamic>) { |
| reporter.push('diagnostics'); |
| try { |
| if (!obj.containsKey('diagnostics')) { |
| reporter.reportError('must not be undefined'); |
| return false; |
| } |
| if (obj['diagnostics'] == null) { |
| reporter.reportError('must not be null'); |
| return false; |
| } |
| if (!((obj['diagnostics'] is List && |
| (obj['diagnostics'] |
| .every((item) => Diagnostic.canParse(item, reporter)))))) { |
| reporter.reportError('must be of type List<Diagnostic>'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('only'); |
| try { |
| if (obj['only'] != null && |
| !((obj['only'] is List && |
| (obj['only'].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 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) && |
| true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| var hash = 0; |
| hash = JenkinsSmiHash.combine(hash, lspHashCode(diagnostics)); |
| hash = JenkinsSmiHash.combine(hash, lspHashCode(only)); |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// A set of predefined code action kinds. |
| class CodeActionKind { |
| 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 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 o) => o is CodeActionKind && o._value == _value; |
| } |
| |
| class CodeActionOptions implements WorkDoneProgressOptions, ToJsonable { |
| static const jsonHandler = |
| LspJsonHandler(CodeActionOptions.canParse, CodeActionOptions.fromJson); |
| |
| CodeActionOptions({this.codeActionKinds, this.workDoneProgress}); |
| static CodeActionOptions fromJson(Map<String, dynamic> json) { |
| if (CodeActionRegistrationOptions.canParse(json, nullLspJsonReporter)) { |
| return CodeActionRegistrationOptions.fromJson(json); |
| } |
| final codeActionKinds = json['codeActionKinds'] |
| ?.map((item) => item != null ? CodeActionKind.fromJson(item) : null) |
| ?.cast<CodeActionKind>() |
| ?.toList(); |
| final workDoneProgress = json['workDoneProgress']; |
| return CodeActionOptions( |
| codeActionKinds: codeActionKinds, 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; |
| final bool workDoneProgress; |
| |
| Map<String, dynamic> toJson() { |
| var __result = <String, dynamic>{}; |
| if (codeActionKinds != null) { |
| __result['codeActionKinds'] = codeActionKinds; |
| } |
| if (workDoneProgress != null) { |
| __result['workDoneProgress'] = workDoneProgress; |
| } |
| return __result; |
| } |
| |
| static bool canParse(Object obj, LspJsonReporter reporter) { |
| if (obj is Map<String, dynamic>) { |
| reporter.push('codeActionKinds'); |
| try { |
| if (obj['codeActionKinds'] != null && |
| !((obj['codeActionKinds'] is List && |
| (obj['codeActionKinds'].every( |
| (item) => CodeActionKind.canParse(item, reporter)))))) { |
| reporter.reportError('must be of type List<CodeActionKind>'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('workDoneProgress'); |
| try { |
| if (obj['workDoneProgress'] != null && |
| !(obj['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) && |
| workDoneProgress == other.workDoneProgress && |
| true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| var hash = 0; |
| hash = JenkinsSmiHash.combine(hash, lspHashCode(codeActionKinds)); |
| hash = JenkinsSmiHash.combine(hash, workDoneProgress.hashCode); |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Params for the CodeActionRequest |
| class CodeActionParams |
| implements WorkDoneProgressParams, PartialResultParams, ToJsonable { |
| static const jsonHandler = |
| LspJsonHandler(CodeActionParams.canParse, CodeActionParams.fromJson); |
| |
| CodeActionParams( |
| {@required this.textDocument, |
| @required this.range, |
| @required this.context, |
| this.workDoneToken, |
| this.partialResultToken}) { |
| if (textDocument == null) { |
| throw 'textDocument is required but was not provided'; |
| } |
| if (range == null) { |
| throw 'range is required but was not provided'; |
| } |
| if (context == null) { |
| throw 'context is required but was not provided'; |
| } |
| } |
| static CodeActionParams fromJson(Map<String, dynamic> json) { |
| final textDocument = json['textDocument'] != null |
| ? TextDocumentIdentifier.fromJson(json['textDocument']) |
| : null; |
| final range = json['range'] != null ? Range.fromJson(json['range']) : null; |
| final context = json['context'] != null |
| ? CodeActionContext.fromJson(json['context']) |
| : null; |
| final workDoneToken = json['workDoneToken'] is num |
| ? Either2<num, String>.t1(json['workDoneToken']) |
| : (json['workDoneToken'] is String |
| ? Either2<num, String>.t2(json['workDoneToken']) |
| : (json['workDoneToken'] == null |
| ? null |
| : (throw '''${json['workDoneToken']} was not one of (num, String)'''))); |
| final partialResultToken = json['partialResultToken'] is num |
| ? Either2<num, String>.t1(json['partialResultToken']) |
| : (json['partialResultToken'] is String |
| ? Either2<num, String>.t2(json['partialResultToken']) |
| : (json['partialResultToken'] == null |
| ? null |
| : (throw '''${json['partialResultToken']} was not one of (num, String)'''))); |
| return CodeActionParams( |
| textDocument: textDocument, |
| range: range, |
| context: context, |
| workDoneToken: workDoneToken, |
| partialResultToken: partialResultToken); |
| } |
| |
| /// 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<num, 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<num, String> workDoneToken; |
| |
| Map<String, dynamic> toJson() { |
| var __result = <String, dynamic>{}; |
| __result['textDocument'] = |
| textDocument ?? (throw 'textDocument is required but was not set'); |
| __result['range'] = range ?? (throw 'range is required but was not set'); |
| __result['context'] = |
| context ?? (throw 'context is required but was not set'); |
| if (workDoneToken != null) { |
| __result['workDoneToken'] = workDoneToken; |
| } |
| if (partialResultToken != null) { |
| __result['partialResultToken'] = partialResultToken; |
| } |
| return __result; |
| } |
| |
| static bool canParse(Object obj, LspJsonReporter reporter) { |
| if (obj is Map<String, dynamic>) { |
| reporter.push('textDocument'); |
| try { |
| if (!obj.containsKey('textDocument')) { |
| reporter.reportError('must not be undefined'); |
| return false; |
| } |
| if (obj['textDocument'] == null) { |
| reporter.reportError('must not be null'); |
| return false; |
| } |
| if (!(TextDocumentIdentifier.canParse(obj['textDocument'], reporter))) { |
| reporter.reportError('must be of type TextDocumentIdentifier'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('range'); |
| try { |
| if (!obj.containsKey('range')) { |
| reporter.reportError('must not be undefined'); |
| return false; |
| } |
| if (obj['range'] == null) { |
| reporter.reportError('must not be null'); |
| return false; |
| } |
| if (!(Range.canParse(obj['range'], reporter))) { |
| reporter.reportError('must be of type Range'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('context'); |
| try { |
| if (!obj.containsKey('context')) { |
| reporter.reportError('must not be undefined'); |
| return false; |
| } |
| if (obj['context'] == null) { |
| reporter.reportError('must not be null'); |
| return false; |
| } |
| if (!(CodeActionContext.canParse(obj['context'], reporter))) { |
| reporter.reportError('must be of type CodeActionContext'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('workDoneToken'); |
| try { |
| if (obj['workDoneToken'] != null && |
| !((obj['workDoneToken'] is num || |
| obj['workDoneToken'] is String))) { |
| reporter.reportError('must be of type Either2<num, String>'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('partialResultToken'); |
| try { |
| if (obj['partialResultToken'] != null && |
| !((obj['partialResultToken'] is num || |
| obj['partialResultToken'] is String))) { |
| reporter.reportError('must be of type Either2<num, 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 textDocument == other.textDocument && |
| range == other.range && |
| context == other.context && |
| workDoneToken == other.workDoneToken && |
| partialResultToken == other.partialResultToken && |
| true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| var hash = 0; |
| hash = JenkinsSmiHash.combine(hash, textDocument.hashCode); |
| hash = JenkinsSmiHash.combine(hash, range.hashCode); |
| hash = JenkinsSmiHash.combine(hash, context.hashCode); |
| hash = JenkinsSmiHash.combine(hash, workDoneToken.hashCode); |
| hash = JenkinsSmiHash.combine(hash, partialResultToken.hashCode); |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class CodeActionRegistrationOptions |
| implements TextDocumentRegistrationOptions, CodeActionOptions, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CodeActionRegistrationOptions.canParse, |
| CodeActionRegistrationOptions.fromJson); |
| |
| CodeActionRegistrationOptions( |
| {this.documentSelector, this.codeActionKinds, this.workDoneProgress}); |
| static CodeActionRegistrationOptions fromJson(Map<String, dynamic> json) { |
| final documentSelector = json['documentSelector'] |
| ?.map((item) => item != null ? DocumentFilter.fromJson(item) : null) |
| ?.cast<DocumentFilter>() |
| ?.toList(); |
| final codeActionKinds = json['codeActionKinds'] |
| ?.map((item) => item != null ? CodeActionKind.fromJson(item) : null) |
| ?.cast<CodeActionKind>() |
| ?.toList(); |
| final workDoneProgress = json['workDoneProgress']; |
| return CodeActionRegistrationOptions( |
| documentSelector: documentSelector, |
| codeActionKinds: codeActionKinds, |
| 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<DocumentFilter> documentSelector; |
| final bool workDoneProgress; |
| |
| Map<String, dynamic> toJson() { |
| var __result = <String, dynamic>{}; |
| __result['documentSelector'] = documentSelector; |
| if (codeActionKinds != null) { |
| __result['codeActionKinds'] = codeActionKinds; |
| } |
| if (workDoneProgress != null) { |
| __result['workDoneProgress'] = workDoneProgress; |
| } |
| return __result; |
| } |
| |
| static bool canParse(Object obj, LspJsonReporter reporter) { |
| if (obj is Map<String, dynamic>) { |
| reporter.push('documentSelector'); |
| try { |
| if (!obj.containsKey('documentSelector')) { |
| reporter.reportError('must not be undefined'); |
| return false; |
| } |
| if (obj['documentSelector'] != null && |
| !((obj['documentSelector'] is List && |
| (obj['documentSelector'].every( |
| (item) => DocumentFilter.canParse(item, reporter)))))) { |
| reporter.reportError('must be of type List<DocumentFilter>'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('codeActionKinds'); |
| try { |
| if (obj['codeActionKinds'] != null && |
| !((obj['codeActionKinds'] is List && |
| (obj['codeActionKinds'].every( |
| (item) => CodeActionKind.canParse(item, reporter)))))) { |
| reporter.reportError('must be of type List<CodeActionKind>'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('workDoneProgress'); |
| try { |
| if (obj['workDoneProgress'] != null && |
| !(obj['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(documentSelector, other.documentSelector, |
| (DocumentFilter a, DocumentFilter b) => a == b) && |
| listEqual(codeActionKinds, other.codeActionKinds, |
| (CodeActionKind a, CodeActionKind b) => a == b) && |
| workDoneProgress == other.workDoneProgress && |
| true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| var hash = 0; |
| hash = JenkinsSmiHash.combine(hash, lspHashCode(documentSelector)); |
| hash = JenkinsSmiHash.combine(hash, lspHashCode(codeActionKinds)); |
| hash = JenkinsSmiHash.combine(hash, workDoneProgress.hashCode); |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @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({@required this.range, this.command, this.data}) { |
| if (range == null) { |
| throw 'range is required but was not provided'; |
| } |
| } |
| static CodeLens fromJson(Map<String, dynamic> json) { |
| final range = json['range'] != null ? Range.fromJson(json['range']) : null; |
| final command = |
| json['command'] != null ? Command.fromJson(json['command']) : null; |
| final data = json['data']; |
| return CodeLens(range: range, command: command, data: data); |
| } |
| |
| /// 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 dynamic data; |
| |
| /// The range in which this code lens is valid. Should only span a single |
| /// line. |
| final Range range; |
| |
| Map<String, dynamic> toJson() { |
| var __result = <String, dynamic>{}; |
| __result['range'] = range ?? (throw 'range is required but was not set'); |
| if (command != null) { |
| __result['command'] = command; |
| } |
| if (data != null) { |
| __result['data'] = data; |
| } |
| return __result; |
| } |
| |
| static bool canParse(Object obj, LspJsonReporter reporter) { |
| if (obj is Map<String, dynamic>) { |
| reporter.push('range'); |
| try { |
| if (!obj.containsKey('range')) { |
| reporter.reportError('must not be undefined'); |
| return false; |
| } |
| if (obj['range'] == null) { |
| reporter.reportError('must not be null'); |
| return false; |
| } |
| if (!(Range.canParse(obj['range'], reporter))) { |
| reporter.reportError('must be of type Range'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('command'); |
| try { |
| if (obj['command'] != null && |
| !(Command.canParse(obj['command'], reporter))) { |
| reporter.reportError('must be of type Command'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('data'); |
| try { |
| if (obj['data'] != null && !(true)) { |
| reporter.reportError('must be of type dynamic'); |
| 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 range == other.range && |
| command == other.command && |
| data == other.data && |
| true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| var hash = 0; |
| hash = JenkinsSmiHash.combine(hash, range.hashCode); |
| hash = JenkinsSmiHash.combine(hash, command.hashCode); |
| hash = JenkinsSmiHash.combine(hash, data.hashCode); |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @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, dynamic> json) { |
| final dynamicRegistration = json['dynamicRegistration']; |
| return CodeLensClientCapabilities(dynamicRegistration: dynamicRegistration); |
| } |
| |
| /// Whether code lens supports dynamic registration. |
| final bool dynamicRegistration; |
| |
| Map<String, dynamic> toJson() { |
| var __result = <String, dynamic>{}; |
| if (dynamicRegistration != null) { |
| __result['dynamicRegistration'] = dynamicRegistration; |
| } |
| return __result; |
| } |
| |
| static bool canParse(Object obj, LspJsonReporter reporter) { |
| if (obj is Map<String, dynamic>) { |
| reporter.push('dynamicRegistration'); |
| try { |
| if (obj['dynamicRegistration'] != null && |
| !(obj['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 { |
| var hash = 0; |
| hash = JenkinsSmiHash.combine(hash, dynamicRegistration.hashCode); |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @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, dynamic> json) { |
| if (CodeLensRegistrationOptions.canParse(json, nullLspJsonReporter)) { |
| return CodeLensRegistrationOptions.fromJson(json); |
| } |
| final resolveProvider = json['resolveProvider']; |
| final workDoneProgress = json['workDoneProgress']; |
| return CodeLensOptions( |
| resolveProvider: resolveProvider, workDoneProgress: workDoneProgress); |
| } |
| |
| /// Code lens has a resolve provider as well. |
| final bool resolveProvider; |
| final bool workDoneProgress; |
| |
| Map<String, dynamic> toJson() { |
| var __result = <String, dynamic>{}; |
| 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, dynamic>) { |
| reporter.push('resolveProvider'); |
| try { |
| if (obj['resolveProvider'] != null && |
| !(obj['resolveProvider'] is bool)) { |
| reporter.reportError('must be of type bool'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('workDoneProgress'); |
| try { |
| if (obj['workDoneProgress'] != null && |
| !(obj['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 { |
| var hash = 0; |
| hash = JenkinsSmiHash.combine(hash, resolveProvider.hashCode); |
| hash = JenkinsSmiHash.combine(hash, workDoneProgress.hashCode); |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class CodeLensParams |
| implements WorkDoneProgressParams, PartialResultParams, ToJsonable { |
| static const jsonHandler = |
| LspJsonHandler(CodeLensParams.canParse, CodeLensParams.fromJson); |
| |
| CodeLensParams( |
| {@required this.textDocument, |
| this.workDoneToken, |
| this.partialResultToken}) { |
| if (textDocument == null) { |
| throw 'textDocument is required but was not provided'; |
| } |
| } |
| static CodeLensParams fromJson(Map<String, dynamic> json) { |
| final textDocument = json['textDocument'] != null |
| ? TextDocumentIdentifier.fromJson(json['textDocument']) |
| : null; |
| final workDoneToken = json['workDoneToken'] is num |
| ? Either2<num, String>.t1(json['workDoneToken']) |
| : (json['workDoneToken'] is String |
| ? Either2<num, String>.t2(json['workDoneToken']) |
| : (json['workDoneToken'] == null |
| ? null |
| : (throw '''${json['workDoneToken']} was not one of (num, String)'''))); |
| final partialResultToken = json['partialResultToken'] is num |
| ? Either2<num, String>.t1(json['partialResultToken']) |
| : (json['partialResultToken'] is String |
| ? Either2<num, String>.t2(json['partialResultToken']) |
| : (json['partialResultToken'] == null |
| ? null |
| : (throw '''${json['partialResultToken']} was not one of (num, String)'''))); |
| return CodeLensParams( |
| textDocument: textDocument, |
| workDoneToken: workDoneToken, |
| partialResultToken: partialResultToken); |
| } |
| |
| /// An optional token that a server can use to report partial results (e.g. |
| /// streaming) to the client. |
| final Either2<num, 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<num, String> workDoneToken; |
| |
| Map<String, dynamic> toJson() { |
| var __result = <String, dynamic>{}; |
| __result['textDocument'] = |
| textDocument ?? (throw 'textDocument is required but was not set'); |
| if (workDoneToken != null) { |
| __result['workDoneToken'] = workDoneToken; |
| } |
| if (partialResultToken != null) { |
| __result['partialResultToken'] = partialResultToken; |
| } |
| return __result; |
| } |
| |
| static bool canParse(Object obj, LspJsonReporter reporter) { |
| if (obj is Map<String, dynamic>) { |
| reporter.push('textDocument'); |
| try { |
| if (!obj.containsKey('textDocument')) { |
| reporter.reportError('must not be undefined'); |
| return false; |
| } |
| if (obj['textDocument'] == null) { |
| reporter.reportError('must not be null'); |
| return false; |
| } |
| if (!(TextDocumentIdentifier.canParse(obj['textDocument'], reporter))) { |
| reporter.reportError('must be of type TextDocumentIdentifier'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('workDoneToken'); |
| try { |
| if (obj['workDoneToken'] != null && |
| !((obj['workDoneToken'] is num || |
| obj['workDoneToken'] is String))) { |
| reporter.reportError('must be of type Either2<num, String>'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('partialResultToken'); |
| try { |
| if (obj['partialResultToken'] != null && |
| !((obj['partialResultToken'] is num || |
| obj['partialResultToken'] is String))) { |
| reporter.reportError('must be of type Either2<num, 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 textDocument == other.textDocument && |
| workDoneToken == other.workDoneToken && |
| partialResultToken == other.partialResultToken && |
| true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| var hash = 0; |
| hash = JenkinsSmiHash.combine(hash, textDocument.hashCode); |
| hash = JenkinsSmiHash.combine(hash, workDoneToken.hashCode); |
| hash = JenkinsSmiHash.combine(hash, partialResultToken.hashCode); |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class CodeLensRegistrationOptions |
| implements TextDocumentRegistrationOptions, CodeLensOptions, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CodeLensRegistrationOptions.canParse, |
| CodeLensRegistrationOptions.fromJson); |
| |
| CodeLensRegistrationOptions( |
| {this.documentSelector, this.resolveProvider, this.workDoneProgress}); |
| static CodeLensRegistrationOptions fromJson(Map<String, dynamic> json) { |
| final documentSelector = json['documentSelector'] |
| ?.map((item) => item != null ? DocumentFilter.fromJson(item) : null) |
| ?.cast<DocumentFilter>() |
| ?.toList(); |
| final resolveProvider = json['resolveProvider']; |
| final workDoneProgress = json['workDoneProgress']; |
| 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<DocumentFilter> documentSelector; |
| |
| /// Code lens has a resolve provider as well. |
| final bool resolveProvider; |
| final bool workDoneProgress; |
| |
| Map<String, dynamic> toJson() { |
| var __result = <String, dynamic>{}; |
| __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, dynamic>) { |
| reporter.push('documentSelector'); |
| try { |
| if (!obj.containsKey('documentSelector')) { |
| reporter.reportError('must not be undefined'); |
| return false; |
| } |
| if (obj['documentSelector'] != null && |
| !((obj['documentSelector'] is List && |
| (obj['documentSelector'].every( |
| (item) => DocumentFilter.canParse(item, reporter)))))) { |
| reporter.reportError('must be of type List<DocumentFilter>'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('resolveProvider'); |
| try { |
| if (obj['resolveProvider'] != null && |
| !(obj['resolveProvider'] is bool)) { |
| reporter.reportError('must be of type bool'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('workDoneProgress'); |
| try { |
| if (obj['workDoneProgress'] != null && |
| !(obj['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, |
| (DocumentFilter a, DocumentFilter b) => a == b) && |
| resolveProvider == other.resolveProvider && |
| workDoneProgress == other.workDoneProgress && |
| true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| var hash = 0; |
| hash = JenkinsSmiHash.combine(hash, lspHashCode(documentSelector)); |
| hash = JenkinsSmiHash.combine(hash, resolveProvider.hashCode); |
| hash = JenkinsSmiHash.combine(hash, workDoneProgress.hashCode); |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @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.red, |
| @required this.green, |
| @required this.blue, |
| @required this.alpha}) { |
| if (red == null) { |
| throw 'red is required but was not provided'; |
| } |
| if (green == null) { |
| throw 'green is required but was not provided'; |
| } |
| if (blue == null) { |
| throw 'blue is required but was not provided'; |
| } |
| if (alpha == null) { |
| throw 'alpha is required but was not provided'; |
| } |
| } |
| static Color fromJson(Map<String, dynamic> json) { |
| final red = json['red']; |
| final green = json['green']; |
| final blue = json['blue']; |
| final alpha = json['alpha']; |
| return Color(red: red, green: green, blue: blue, alpha: alpha); |
| } |
| |
| /// 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, dynamic> toJson() { |
| var __result = <String, dynamic>{}; |
| __result['red'] = red ?? (throw 'red is required but was not set'); |
| __result['green'] = green ?? (throw 'green is required but was not set'); |
| __result['blue'] = blue ?? (throw 'blue is required but was not set'); |
| __result['alpha'] = alpha ?? (throw 'alpha is required but was not set'); |
| return __result; |
| } |
| |
| static bool canParse(Object obj, LspJsonReporter reporter) { |
| if (obj is Map<String, dynamic>) { |
| reporter.push('red'); |
| try { |
| if (!obj.containsKey('red')) { |
| reporter.reportError('must not be undefined'); |
| return false; |
| } |
| if (obj['red'] == null) { |
| reporter.reportError('must not be null'); |
| return false; |
| } |
| if (!(obj['red'] 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; |
| } |
| if (obj['green'] == null) { |
| reporter.reportError('must not be null'); |
| return false; |
| } |
| if (!(obj['green'] 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; |
| } |
| if (obj['blue'] == null) { |
| reporter.reportError('must not be null'); |
| return false; |
| } |
| if (!(obj['blue'] is num)) { |
| reporter.reportError('must be of type num'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('alpha'); |
| try { |
| if (!obj.containsKey('alpha')) { |
| reporter.reportError('must not be undefined'); |
| return false; |
| } |
| if (obj['alpha'] == null) { |
| reporter.reportError('must not be null'); |
| return false; |
| } |
| if (!(obj['alpha'] 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 red == other.red && |
| green == other.green && |
| blue == other.blue && |
| alpha == other.alpha && |
| true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| var hash = 0; |
| hash = JenkinsSmiHash.combine(hash, red.hashCode); |
| hash = JenkinsSmiHash.combine(hash, green.hashCode); |
| hash = JenkinsSmiHash.combine(hash, blue.hashCode); |
| hash = JenkinsSmiHash.combine(hash, alpha.hashCode); |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class ColorInformation implements ToJsonable { |
| static const jsonHandler = |
| LspJsonHandler(ColorInformation.canParse, ColorInformation.fromJson); |
| |
| ColorInformation({@required this.range, @required this.color}) { |
| if (range == null) { |
| throw 'range is required but was not provided'; |
| } |
| if (color == null) { |
| throw 'color is required but was not provided'; |
| } |
| } |
| static ColorInformation fromJson(Map<String, dynamic> json) { |
| final range = json['range'] != null ? Range.fromJson(json['range']) : null; |
| final color = json['color'] != null ? Color.fromJson(json['color']) : null; |
| return ColorInformation(range: range, color: color); |
| } |
| |
| /// 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, dynamic> toJson() { |
| var __result = <String, dynamic>{}; |
| __result['range'] = range ?? (throw 'range is required but was not set'); |
| __result['color'] = color ?? (throw 'color is required but was not set'); |
| return __result; |
| } |
| |
| static bool canParse(Object obj, LspJsonReporter reporter) { |
| if (obj is Map<String, dynamic>) { |
| reporter.push('range'); |
| try { |
| if (!obj.containsKey('range')) { |
| reporter.reportError('must not be undefined'); |
| return false; |
| } |
| if (obj['range'] == null) { |
| reporter.reportError('must not be null'); |
| return false; |
| } |
| if (!(Range.canParse(obj['range'], reporter))) { |
| reporter.reportError('must be of type Range'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('color'); |
| try { |
| if (!obj.containsKey('color')) { |
| reporter.reportError('must not be undefined'); |
| return false; |
| } |
| if (obj['color'] == null) { |
| reporter.reportError('must not be null'); |
| return false; |
| } |
| if (!(Color.canParse(obj['color'], reporter))) { |
| reporter.reportError('must be of type Color'); |
| 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 range == other.range && color == other.color && true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| var hash = 0; |
| hash = JenkinsSmiHash.combine(hash, range.hashCode); |
| hash = JenkinsSmiHash.combine(hash, color.hashCode); |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class ColorPresentation implements ToJsonable { |
| static const jsonHandler = |
| LspJsonHandler(ColorPresentation.canParse, ColorPresentation.fromJson); |
| |
| ColorPresentation( |
| {@required this.label, this.textEdit, this.additionalTextEdits}) { |
| if (label == null) { |
| throw 'label is required but was not provided'; |
| } |
| } |
| static ColorPresentation fromJson(Map<String, dynamic> json) { |
| final label = json['label']; |
| final textEdit = |
| json['textEdit'] != null ? TextEdit.fromJson(json['textEdit']) : null; |
| final additionalTextEdits = json['additionalTextEdits'] |
| ?.map((item) => item != null ? TextEdit.fromJson(item) : null) |
| ?.cast<TextEdit>() |
| ?.toList(); |
| return ColorPresentation( |
| label: label, |
| textEdit: textEdit, |
| additionalTextEdits: additionalTextEdits); |
| } |
| |
| /// 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, dynamic> toJson() { |
| var __result = <String, dynamic>{}; |
| __result['label'] = label ?? (throw 'label is required but was not set'); |
| if (textEdit != null) { |
| __result['textEdit'] = textEdit; |
| } |
| if (additionalTextEdits != null) { |
| __result['additionalTextEdits'] = additionalTextEdits; |
| } |
| return __result; |
| } |
| |
| static bool canParse(Object obj, LspJsonReporter reporter) { |
| if (obj is Map<String, dynamic>) { |
| reporter.push('label'); |
| try { |
| if (!obj.containsKey('label')) { |
| reporter.reportError('must not be undefined'); |
| return false; |
| } |
| if (obj['label'] == null) { |
| reporter.reportError('must not be null'); |
| return false; |
| } |
| if (!(obj['label'] is String)) { |
| reporter.reportError('must be of type String'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('textEdit'); |
| try { |
| if (obj['textEdit'] != null && |
| !(TextEdit.canParse(obj['textEdit'], reporter))) { |
| reporter.reportError('must be of type TextEdit'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('additionalTextEdits'); |
| try { |
| if (obj['additionalTextEdits'] != null && |
| !((obj['additionalTextEdits'] is List && |
| (obj['additionalTextEdits'] |
| .every((item) => TextEdit.canParse(item, reporter)))))) { |
| reporter.reportError('must be of type List<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 label == other.label && |
| textEdit == other.textEdit && |
| listEqual(additionalTextEdits, other.additionalTextEdits, |
| (TextEdit a, TextEdit b) => a == b) && |
| true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| var hash = 0; |
| hash = JenkinsSmiHash.combine(hash, label.hashCode); |
| hash = JenkinsSmiHash.combine(hash, textEdit.hashCode); |
| hash = JenkinsSmiHash.combine(hash, lspHashCode(additionalTextEdits)); |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class ColorPresentationParams |
| implements WorkDoneProgressParams, PartialResultParams, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| ColorPresentationParams.canParse, ColorPresentationParams.fromJson); |
| |
| ColorPresentationParams( |
| {@required this.textDocument, |
| @required this.color, |
| @required this.range, |
| this.workDoneToken, |
| this.partialResultToken}) { |
| if (textDocument == null) { |
| throw 'textDocument is required but was not provided'; |
| } |
| if (color == null) { |
| throw 'color is required but was not provided'; |
| } |
| if (range == null) { |
| throw 'range is required but was not provided'; |
| } |
| } |
| static ColorPresentationParams fromJson(Map<String, dynamic> json) { |
| final textDocument = json['textDocument'] != null |
| ? TextDocumentIdentifier.fromJson(json['textDocument']) |
| : null; |
| final color = json['color'] != null ? Color.fromJson(json['color']) : null; |
| final range = json['range'] != null ? Range.fromJson(json['range']) : null; |
| final workDoneToken = json['workDoneToken'] is num |
| ? Either2<num, String>.t1(json['workDoneToken']) |
| : (json['workDoneToken'] is String |
| ? Either2<num, String>.t2(json['workDoneToken']) |
| : (json['workDoneToken'] == null |
| ? null |
| : (throw '''${json['workDoneToken']} was not one of (num, String)'''))); |
| final partialResultToken = json['partialResultToken'] is num |
| ? Either2<num, String>.t1(json['partialResultToken']) |
| : (json['partialResultToken'] is String |
| ? Either2<num, String>.t2(json['partialResultToken']) |
| : (json['partialResultToken'] == null |
| ? null |
| : (throw '''${json['partialResultToken']} was not one of (num, String)'''))); |
| return ColorPresentationParams( |
| textDocument: textDocument, |
| color: color, |
| range: range, |
| workDoneToken: workDoneToken, |
| partialResultToken: partialResultToken); |
| } |
| |
| /// 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<num, 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<num, String> workDoneToken; |
| |
| Map<String, dynamic> toJson() { |
| var __result = <String, dynamic>{}; |
| __result['textDocument'] = |
| textDocument ?? (throw 'textDocument is required but was not set'); |
| __result['color'] = color ?? (throw 'color is required but was not set'); |
| __result['range'] = range ?? (throw 'range is required but was not set'); |
| if (workDoneToken != null) { |
| __result['workDoneToken'] = workDoneToken; |
| } |
| if (partialResultToken != null) { |
| __result['partialResultToken'] = partialResultToken; |
| } |
| return __result; |
| } |
| |
| static bool canParse(Object obj, LspJsonReporter reporter) { |
| if (obj is Map<String, dynamic>) { |
| reporter.push('textDocument'); |
| try { |
| if (!obj.containsKey('textDocument')) { |
| reporter.reportError('must not be undefined'); |
| return false; |
| } |
| if (obj['textDocument'] == null) { |
| reporter.reportError('must not be null'); |
| return false; |
| } |
| if (!(TextDocumentIdentifier.canParse(obj['textDocument'], reporter))) { |
| reporter.reportError('must be of type TextDocumentIdentifier'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('color'); |
| try { |
| if (!obj.containsKey('color')) { |
| reporter.reportError('must not be undefined'); |
| return false; |
| } |
| if (obj['color'] == null) { |
| reporter.reportError('must not be null'); |
| return false; |
| } |
| if (!(Color.canParse(obj['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; |
| } |
| if (obj['range'] == null) { |
| reporter.reportError('must not be null'); |
| return false; |
| } |
| if (!(Range.canParse(obj['range'], reporter))) { |
| reporter.reportError('must be of type Range'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('workDoneToken'); |
| try { |
| if (obj['workDoneToken'] != null && |
| !((obj['workDoneToken'] is num || |
| obj['workDoneToken'] is String))) { |
| reporter.reportError('must be of type Either2<num, String>'); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('partialResultToken'); |
| try { |
| if (obj['partialResultToken'] != null && |
| !((obj['partialResultToken'] is num || |
| obj['partialResultToken'] is String))) { |
| reporter.reportError('must be of type Either2<num, 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 textDocument == other.textDocument && |
| color == other.color && |
| range == other.range && |
| workDoneToken == other.workDoneToken && |
| partialResultToken == other.partialResultToken && |
| true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| var hash = 0; |
| hash = JenkinsSmiHash.combine(hash, textDocument.hashCode); |
| hash = JenkinsSmiHash.combine(hash, color.hashCode); |
| hash = JenkinsSmiHash.combine(hash, range.hashCode); |
| hash = JenkinsSmiHash.combine(hash, workDoneToken.hashCode); |
| hash = JenkinsSmiHash.combine(hash, partialResultToken.hashCode); |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |