| // 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: 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'; |
| |
| const jsonEncoder = const JsonEncoder.withIndent(' '); |
| |
| class ApplyWorkspaceEditParams implements ToJsonable { |
| static const jsonHandler = const LspJsonHandler( |
| ApplyWorkspaceEditParams.canParse, ApplyWorkspaceEditParams.fromJson); |
| |
| ApplyWorkspaceEditParams(this.label, 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 new ApplyWorkspaceEditParams(label, 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() { |
| Map<String, dynamic> __result = {}; |
| 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 ==(other) { |
| if (other is ApplyWorkspaceEditParams) { |
| return label == other.label && edit == other.edit && true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| int 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 = const LspJsonHandler( |
| ApplyWorkspaceEditResponse.canParse, ApplyWorkspaceEditResponse.fromJson); |
| |
| ApplyWorkspaceEditResponse(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 new ApplyWorkspaceEditResponse(applied, 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() { |
| Map<String, dynamic> __result = {}; |
| __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 ==(other) { |
| if (other is ApplyWorkspaceEditResponse) { |
| return applied == other.applied && |
| failureReason == other.failureReason && |
| true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| int 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 = |
| const LspJsonHandler(CancelParams.canParse, CancelParams.fromJson); |
| |
| CancelParams(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 |
| ? new Either2<num, String>.t1(json['id']) |
| : (json['id'] is String |
| ? new Either2<num, String>.t2(json['id']) |
| : (throw '''${json['id']} was not one of (num, String)''')); |
| return new CancelParams(id); |
| } |
| |
| /// The request id to cancel. |
| final Either2<num, String> id; |
| |
| Map<String, dynamic> toJson() { |
| Map<String, dynamic> __result = {}; |
| __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 ==(other) { |
| if (other is CancelParams) { |
| return id == other.id && true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| int 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 = const LspJsonHandler( |
| ClientCapabilities.canParse, ClientCapabilities.fromJson); |
| |
| ClientCapabilities(this.workspace, this.textDocument, this.experimental); |
| static ClientCapabilities fromJson(Map<String, dynamic> json) { |
| final workspace = json['workspace'] != null |
| ? WorkspaceClientCapabilities.fromJson(json['workspace']) |
| : null; |
| final textDocument = json['textDocument'] != null |
| ? TextDocumentClientCapabilities.fromJson(json['textDocument']) |
| : null; |
| final experimental = json['experimental']; |
| return new ClientCapabilities(workspace, textDocument, experimental); |
| } |
| |
| /// Experimental client capabilities. |
| final dynamic experimental; |
| |
| /// Text document specific client capabilities. |
| final TextDocumentClientCapabilities textDocument; |
| |
| /// Workspace specific client capabilities. |
| final WorkspaceClientCapabilities workspace; |
| |
| Map<String, dynamic> toJson() { |
| Map<String, dynamic> __result = {}; |
| if (workspace != null) { |
| __result['workspace'] = workspace; |
| } |
| if (textDocument != null) { |
| __result['textDocument'] = textDocument; |
| } |
| 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 && |
| !(WorkspaceClientCapabilities.canParse( |
| obj['workspace'], reporter))) { |
| reporter.reportError("must be of type WorkspaceClientCapabilities"); |
| 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('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 ==(other) { |
| if (other is ClientCapabilities) { |
| return workspace == other.workspace && |
| textDocument == other.textDocument && |
| experimental == other.experimental && |
| true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| int hash = 0; |
| hash = JenkinsSmiHash.combine(hash, workspace.hashCode); |
| hash = JenkinsSmiHash.combine(hash, textDocument.hashCode); |
| hash = JenkinsSmiHash.combine(hash, experimental.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 = |
| const LspJsonHandler(CodeAction.canParse, CodeAction.fromJson); |
| |
| CodeAction(this.title, this.kind, this.diagnostics, 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 edit = |
| json['edit'] != null ? WorkspaceEdit.fromJson(json['edit']) : null; |
| final command = |
| json['command'] != null ? Command.fromJson(json['command']) : null; |
| return new CodeAction(title, kind, diagnostics, edit, 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; |
| |
| /// 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() { |
| Map<String, dynamic> __result = {}; |
| __result['title'] = title ?? (throw 'title is required but was not set'); |
| if (kind != null) { |
| __result['kind'] = kind; |
| } |
| if (diagnostics != null) { |
| __result['diagnostics'] = diagnostics; |
| } |
| 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('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 ==(other) { |
| if (other is CodeAction) { |
| return title == other.title && |
| kind == other.kind && |
| listEqual(diagnostics, other.diagnostics, |
| (Diagnostic a, Diagnostic b) => a == b) && |
| edit == other.edit && |
| command == other.command && |
| true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| int hash = 0; |
| hash = JenkinsSmiHash.combine(hash, title.hashCode); |
| hash = JenkinsSmiHash.combine(hash, kind.hashCode); |
| hash = JenkinsSmiHash.combine(hash, diagnostics.hashCode); |
| hash = JenkinsSmiHash.combine(hash, edit.hashCode); |
| hash = JenkinsSmiHash.combine(hash, command.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 = const LspJsonHandler( |
| CodeActionContext.canParse, CodeActionContext.fromJson); |
| |
| CodeActionContext(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 new CodeActionContext(diagnostics, only); |
| } |
| |
| /// An array of diagnostics. |
| 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() { |
| Map<String, dynamic> __result = {}; |
| __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 ==(other) { |
| if (other is 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 { |
| int hash = 0; |
| hash = JenkinsSmiHash.combine(hash, diagnostics.hashCode); |
| hash = JenkinsSmiHash.combine(hash, only.hashCode); |
| 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; |
| } |
| |
| /// Base kind for quickfix actions: 'quickfix' |
| static const QuickFix = const CodeActionKind('quickfix'); |
| |
| /// Base kind for refactoring actions: 'refactor' |
| static const Refactor = const 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 = const CodeActionKind('refactor.extract'); |
| |
| /// Base kind for refactoring inline actions: 'refactor.inline' |
| /// |
| /// Example inline actions: |
| /// |
| /// - Inline function |
| /// - Inline variable |
| /// - Inline constant |
| /// - ... |
| static const RefactorInline = const 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 = const CodeActionKind('refactor.rewrite'); |
| |
| /// Base kind for source actions: `source` |
| /// |
| /// Source code actions apply to the entire file. |
| static const Source = const CodeActionKind('source'); |
| |
| /// Base kind for an organize imports source action: `source.organizeImports` |
| static const SourceOrganizeImports = |
| const CodeActionKind('source.organizeImports'); |
| |
| Object toJson() => _value; |
| |
| @override |
| String toString() => _value.toString(); |
| |
| @override |
| get hashCode => _value.hashCode; |
| |
| bool operator ==(o) => o is CodeActionKind && o._value == _value; |
| } |
| |
| /// Code Action options. |
| class CodeActionOptions implements ToJsonable { |
| static const jsonHandler = const LspJsonHandler( |
| CodeActionOptions.canParse, CodeActionOptions.fromJson); |
| |
| CodeActionOptions(this.codeActionKinds); |
| 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(); |
| return new CodeActionOptions(codeActionKinds); |
| } |
| |
| /// 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; |
| |
| Map<String, dynamic> toJson() { |
| Map<String, dynamic> __result = {}; |
| if (codeActionKinds != null) { |
| __result['codeActionKinds'] = codeActionKinds; |
| } |
| 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(); |
| } |
| return true; |
| } else { |
| reporter.reportError("must be of type CodeActionOptions"); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(other) { |
| if (other is CodeActionOptions) { |
| return listEqual(codeActionKinds, other.codeActionKinds, |
| (CodeActionKind a, CodeActionKind b) => a == b) && |
| true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| int hash = 0; |
| hash = JenkinsSmiHash.combine(hash, codeActionKinds.hashCode); |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Params for the CodeActionRequest |
| class CodeActionParams implements ToJsonable { |
| static const jsonHandler = const LspJsonHandler( |
| CodeActionParams.canParse, CodeActionParams.fromJson); |
| |
| CodeActionParams(this.textDocument, this.range, this.context) { |
| 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; |
| return new CodeActionParams(textDocument, range, context); |
| } |
| |
| /// Context carrying additional information. |
| final CodeActionContext context; |
| |
| /// The range for which the command was invoked. |
| final Range range; |
| |
| /// The document in which the command was invoked. |
| final TextDocumentIdentifier textDocument; |
| |
| Map<String, dynamic> toJson() { |
| Map<String, dynamic> __result = {}; |
| __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'); |
| 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(); |
| } |
| return true; |
| } else { |
| reporter.reportError("must be of type CodeActionParams"); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(other) { |
| if (other is CodeActionParams) { |
| return textDocument == other.textDocument && |
| range == other.range && |
| context == other.context && |
| true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| int hash = 0; |
| hash = JenkinsSmiHash.combine(hash, textDocument.hashCode); |
| hash = JenkinsSmiHash.combine(hash, range.hashCode); |
| hash = JenkinsSmiHash.combine(hash, context.hashCode); |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class CodeActionRegistrationOptions |
| implements TextDocumentRegistrationOptions, CodeActionOptions, ToJsonable { |
| static const jsonHandler = const LspJsonHandler( |
| CodeActionRegistrationOptions.canParse, |
| CodeActionRegistrationOptions.fromJson); |
| |
| CodeActionRegistrationOptions(this.documentSelector, this.codeActionKinds); |
| 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(); |
| return new CodeActionRegistrationOptions(documentSelector, codeActionKinds); |
| } |
| |
| /// 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; |
| |
| Map<String, dynamic> toJson() { |
| Map<String, dynamic> __result = {}; |
| __result['documentSelector'] = documentSelector; |
| if (codeActionKinds != null) { |
| __result['codeActionKinds'] = codeActionKinds; |
| } |
| 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(); |
| } |
| return true; |
| } else { |
| reporter.reportError("must be of type CodeActionRegistrationOptions"); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(other) { |
| if (other is CodeActionRegistrationOptions) { |
| return documentSelector == other.documentSelector && |
| listEqual(codeActionKinds, other.codeActionKinds, |
| (CodeActionKind a, CodeActionKind b) => a == b) && |
| true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| int hash = 0; |
| hash = JenkinsSmiHash.combine(hash, documentSelector.hashCode); |
| hash = JenkinsSmiHash.combine(hash, codeActionKinds.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 = |
| const LspJsonHandler(CodeLens.canParse, CodeLens.fromJson); |
| |
| CodeLens(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 new CodeLens(range, command, 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() { |
| Map<String, dynamic> __result = {}; |
| __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 ==(other) { |
| if (other is CodeLens) { |
| return range == other.range && |
| command == other.command && |
| data == other.data && |
| true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| int 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()); |
| } |
| |
| /// Code Lens options. |
| class CodeLensOptions implements ToJsonable { |
| static const jsonHandler = |
| const LspJsonHandler(CodeLensOptions.canParse, CodeLensOptions.fromJson); |
| |
| CodeLensOptions(this.resolveProvider); |
| static CodeLensOptions fromJson(Map<String, dynamic> json) { |
| final resolveProvider = json['resolveProvider']; |
| return new CodeLensOptions(resolveProvider); |
| } |
| |
| /// Code lens has a resolve provider as well. |
| final bool resolveProvider; |
| |
| Map<String, dynamic> toJson() { |
| Map<String, dynamic> __result = {}; |
| if (resolveProvider != null) { |
| __result['resolveProvider'] = resolveProvider; |
| } |
| 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(); |
| } |
| return true; |
| } else { |
| reporter.reportError("must be of type CodeLensOptions"); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(other) { |
| if (other is CodeLensOptions) { |
| return resolveProvider == other.resolveProvider && true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| int hash = 0; |
| hash = JenkinsSmiHash.combine(hash, resolveProvider.hashCode); |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class CodeLensParams implements ToJsonable { |
| static const jsonHandler = |
| const LspJsonHandler(CodeLensParams.canParse, CodeLensParams.fromJson); |
| |
| CodeLensParams(this.textDocument) { |
| 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; |
| return new CodeLensParams(textDocument); |
| } |
| |
| /// The document to request code lens for. |
| final TextDocumentIdentifier textDocument; |
| |
| Map<String, dynamic> toJson() { |
| Map<String, dynamic> __result = {}; |
| __result['textDocument'] = |
| textDocument ?? (throw 'textDocument is required but was not set'); |
| 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(); |
| } |
| return true; |
| } else { |
| reporter.reportError("must be of type CodeLensParams"); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(other) { |
| if (other is CodeLensParams) { |
| return textDocument == other.textDocument && true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| int hash = 0; |
| hash = JenkinsSmiHash.combine(hash, textDocument.hashCode); |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class CodeLensRegistrationOptions |
| implements TextDocumentRegistrationOptions, ToJsonable { |
| static const jsonHandler = const LspJsonHandler( |
| CodeLensRegistrationOptions.canParse, |
| CodeLensRegistrationOptions.fromJson); |
| |
| CodeLensRegistrationOptions(this.resolveProvider, this.documentSelector); |
| static CodeLensRegistrationOptions fromJson(Map<String, dynamic> json) { |
| final resolveProvider = json['resolveProvider']; |
| final documentSelector = json['documentSelector'] |
| ?.map((item) => item != null ? DocumentFilter.fromJson(item) : null) |
| ?.cast<DocumentFilter>() |
| ?.toList(); |
| return new CodeLensRegistrationOptions(resolveProvider, documentSelector); |
| } |
| |
| /// 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; |
| |
| Map<String, dynamic> toJson() { |
| Map<String, dynamic> __result = {}; |
| if (resolveProvider != null) { |
| __result['resolveProvider'] = resolveProvider; |
| } |
| __result['documentSelector'] = documentSelector; |
| 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('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(); |
| } |
| return true; |
| } else { |
| reporter.reportError("must be of type CodeLensRegistrationOptions"); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(other) { |
| if (other is CodeLensRegistrationOptions) { |
| return resolveProvider == other.resolveProvider && |
| documentSelector == other.documentSelector && |
| true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| int hash = 0; |
| hash = JenkinsSmiHash.combine(hash, resolveProvider.hashCode); |
| hash = JenkinsSmiHash.combine(hash, documentSelector.hashCode); |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Represents a color in RGBA space. |
| class Color implements ToJsonable { |
| static const jsonHandler = |
| const LspJsonHandler(Color.canParse, Color.fromJson); |
| |
| Color(this.red, this.green, this.blue, 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 new Color(red, green, blue, 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() { |
| Map<String, dynamic> __result = {}; |
| __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 ==(other) { |
| if (other is Color) { |
| return red == other.red && |
| green == other.green && |
| blue == other.blue && |
| alpha == other.alpha && |
| true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| int 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 = const LspJsonHandler( |
| ColorInformation.canParse, ColorInformation.fromJson); |
| |
| ColorInformation(this.range, 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 new ColorInformation(range, 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() { |
| Map<String, dynamic> __result = {}; |
| __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 ==(other) { |
| if (other is ColorInformation) { |
| return range == other.range && color == other.color && true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| int 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 = const LspJsonHandler( |
| ColorPresentation.canParse, ColorPresentation.fromJson); |
| |
| ColorPresentation(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 new ColorPresentation(label, textEdit, 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() { |
| Map<String, dynamic> __result = {}; |
| __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 ==(other) { |
| if (other is 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 { |
| int hash = 0; |
| hash = JenkinsSmiHash.combine(hash, label.hashCode); |
| hash = JenkinsSmiHash.combine(hash, textEdit.hashCode); |
| hash = JenkinsSmiHash.combine(hash, additionalTextEdits.hashCode); |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class ColorPresentationParams implements ToJsonable { |
| static const jsonHandler = const LspJsonHandler( |
| ColorPresentationParams.canParse, ColorPresentationParams.fromJson); |
| |
| ColorPresentationParams(this.textDocument, this.color, this.range) { |
| 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; |
| return new ColorPresentationParams(textDocument, color, range); |
| } |
| |
| /// The color information to request presentations for. |
| final Color color; |
| |
| /// The range where the color would be inserted. Serves as a context. |
| final Range range; |
| |
| /// The text document. |
| final TextDocumentIdentifier textDocument; |
| |
| Map<String, dynamic> toJson() { |
| Map<String, dynamic> __result = {}; |
| __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'); |
| 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(); |
| } |
| return true; |
| } else { |
| reporter.reportError("must be of type ColorPresentationParams"); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(other) { |
| if (other is ColorPresentationParams) { |
| return textDocument == other.textDocument && |
| color == other.color && |
| range == other.range && |
| true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| int hash = 0; |
| hash = JenkinsSmiHash.combine(hash, textDocument.hashCode); |
| hash = JenkinsSmiHash.combine(hash, color.hashCode); |
| hash = JenkinsSmiHash.combine(hash, range.hashCode); |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Color provider options. |
| class ColorProviderOptions implements ToJsonable { |
| static const jsonHandler = const LspJsonHandler( |
| ColorProviderOptions.canParse, ColorProviderOptions.fromJson); |
| |
| static ColorProviderOptions fromJson(Map<String, dynamic> json) { |
| return new ColorProviderOptions(); |
| } |
| |
| Map<String, dynamic> toJson() { |
| Map<String, dynamic> __result = {}; |
| return __result; |
| } |
| |
| static bool canParse(Object obj, LspJsonReporter reporter) { |
| if (obj is Map<String, dynamic>) { |
| return true; |
| } else { |
| reporter.reportError("must be of type ColorProviderOptions"); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(other) { |
| if (other is ColorProviderOptions) { |
| return true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| int hash = 0; |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class Command implements ToJsonable { |
| static const jsonHandler = |
| const LspJsonHandler(Command.canParse, Command.fromJson); |
| |
| Command(this.title, this.command, this.arguments) { |
| if (title == null) { |
| throw 'title is required but was not provided'; |
| } |
| if (command == null) { |
| throw 'command is required but was not provided'; |
| } |
| } |
| static Command fromJson(Map<String, dynamic> json) { |
| final title = json['title']; |
| final command = json['command']; |
| final arguments = |
| json['arguments']?.map((item) => item)?.cast<dynamic>()?.toList(); |
| return new Command(title, command, arguments); |
| } |
| |
| /// Arguments that the command handler should be invoked with. |
| final List<dynamic> arguments; |
| |
| /// The identifier of the actual command handler. |
| final String command; |
| |
| /// Title of the command, like `save`. |
| final String title; |
| |
| Map<String, dynamic> toJson() { |
| Map<String, dynamic> __result = {}; |
| __result['title'] = title ?? (throw 'title is required but was not set'); |
| __result['command'] = |
| command ?? (throw 'command is required but was not set'); |
| if (arguments != null) { |
| __result['arguments'] = arguments; |
| } |
| 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('command'); |
| try { |
| if (!obj.containsKey('command')) { |
| reporter.reportError("must not be undefined"); |
| return false; |
| } |
| if (obj['command'] == null) { |
| reporter.reportError("must not be null"); |
| return false; |
| } |
| if (!(obj['command'] is String)) { |
| reporter.reportError("must be of type String"); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('arguments'); |
| try { |
| if (obj['arguments'] != null && |
| !((obj['arguments'] is List && |
| (obj['arguments'].every((item) => true))))) { |
| reporter.reportError("must be of type List<dynamic>"); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| return true; |
| } else { |
| reporter.reportError("must be of type Command"); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(other) { |
| if (other is Command) { |
| return title == other.title && |
| command == other.command && |
| listEqual( |
| arguments, other.arguments, (dynamic a, dynamic b) => a == b) && |
| true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| int hash = 0; |
| hash = JenkinsSmiHash.combine(hash, title.hashCode); |
| hash = JenkinsSmiHash.combine(hash, command.hashCode); |
| hash = JenkinsSmiHash.combine(hash, arguments.hashCode); |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @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 = const LspJsonHandler( |
| CompletionContext.canParse, CompletionContext.fromJson); |
| |
| CompletionContext(this.triggerKind, this.triggerCharacter) { |
| if (triggerKind == null) { |
| throw 'triggerKind is required but was not provided'; |
| } |
| } |
| static CompletionContext fromJson(Map<String, dynamic> json) { |
| final triggerKind = json['triggerKind'] != null |
| ? CompletionTriggerKind.fromJson(json['triggerKind']) |
| : null; |
| final triggerCharacter = json['triggerCharacter']; |
| return new CompletionContext(triggerKind, triggerCharacter); |
| } |
| |
| /// 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, dynamic> toJson() { |
| Map<String, dynamic> __result = {}; |
| __result['triggerKind'] = |
| triggerKind ?? (throw 'triggerKind is required but was not set'); |
| if (triggerCharacter != null) { |
| __result['triggerCharacter'] = triggerCharacter; |
| } |
| return __result; |
| } |
| |
| static bool canParse(Object obj, LspJsonReporter reporter) { |
| if (obj is Map<String, dynamic>) { |
| reporter.push('triggerKind'); |
| try { |
| if (!obj.containsKey('triggerKind')) { |
| reporter.reportError("must not be undefined"); |
| return false; |
| } |
| if (obj['triggerKind'] == null) { |
| reporter.reportError("must not be null"); |
| return false; |
| } |
| if (!(CompletionTriggerKind.canParse(obj['triggerKind'], reporter))) { |
| reporter.reportError("must be of type CompletionTriggerKind"); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('triggerCharacter'); |
| try { |
| if (obj['triggerCharacter'] != null && |
| !(obj['triggerCharacter'] is String)) { |
| reporter.reportError("must be of type String"); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| return true; |
| } else { |
| reporter.reportError("must be of type CompletionContext"); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(other) { |
| if (other is CompletionContext) { |
| return triggerKind == other.triggerKind && |
| triggerCharacter == other.triggerCharacter && |
| true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| int hash = 0; |
| hash = JenkinsSmiHash.combine(hash, triggerKind.hashCode); |
| hash = JenkinsSmiHash.combine(hash, triggerCharacter.hashCode); |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class CompletionItem implements ToJsonable { |
| static const jsonHandler = |
| const LspJsonHandler(CompletionItem.canParse, CompletionItem.fromJson); |
| |
| CompletionItem( |
| this.label, |
| this.kind, |
| this.detail, |
| this.documentation, |
| this.deprecated, |
| this.preselect, |
| this.sortText, |
| this.filterText, |
| this.insertText, |
| this.insertTextFormat, |
| this.textEdit, |
| this.additionalTextEdits, |
| this.commitCharacters, |
| this.command, |
| this.data) { |
| if (label == null) { |
| throw 'label is required but was not provided'; |
| } |
| } |
| static CompletionItem fromJson(Map<String, dynamic> json) { |
| final label = json['label']; |
| final kind = |
| json['kind'] != null ? CompletionItemKind.fromJson(json['kind']) : null; |
| final detail = json['detail']; |
| final documentation = json['documentation'] is String |
| ? new Either2<String, MarkupContent>.t1(json['documentation']) |
| : (MarkupContent.canParse(json['documentation'], nullLspJsonReporter) |
| ? new Either2<String, MarkupContent>.t2( |
| json['documentation'] != null |
| ? MarkupContent.fromJson(json['documentation']) |
| : null) |
| : (json['documentation'] == null |
| ? null |
| : (throw '''${json['documentation']} was not one of (String, MarkupContent)'''))); |
| final deprecated = json['deprecated']; |
| final preselect = json['preselect']; |
| final sortText = json['sortText']; |
| final filterText = json['filterText']; |
| final insertText = json['insertText']; |
| final insertTextFormat = json['insertTextFormat'] != null |
| ? InsertTextFormat.fromJson(json['insertTextFormat']) |
| : null; |
| 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(); |
| final commitCharacters = |
| json['commitCharacters']?.map((item) => item)?.cast<String>()?.toList(); |
| final command = |
| json['command'] != null ? Command.fromJson(json['command']) : null; |
| final data = json['data'] != null |
| ? CompletionItemResolutionInfo.fromJson(json['data']) |
| : null; |
| return new CompletionItem( |
| label, |
| kind, |
| detail, |
| documentation, |
| deprecated, |
| preselect, |
| sortText, |
| filterText, |
| insertText, |
| insertTextFormat, |
| textEdit, |
| additionalTextEdits, |
| commitCharacters, |
| command, |
| data); |
| } |
| |
| /// 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. |
| 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<String, MarkupContent> documentation; |
| |
| /// A string that should be used when filtering a set of completion items. |
| /// When `falsy` the label is used. |
| final String filterText; |
| |
| /// A string that should be inserted into a document when selecting this |
| /// completion. When `falsy` the label is used. |
| /// |
| /// 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`. |
| final InsertTextFormat insertTextFormat; |
| |
| /// 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. By default also the text that is |
| /// inserted when selecting this completion. |
| final String label; |
| |
| /// 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. |
| final String sortText; |
| |
| /// 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. |
| final TextEdit textEdit; |
| |
| Map<String, dynamic> toJson() { |
| Map<String, dynamic> __result = {}; |
| __result['label'] = label ?? (throw 'label is required but was not set'); |
| if (kind != null) { |
| __result['kind'] = kind; |
| } |
| if (detail != null) { |
| __result['detail'] = detail; |
| } |
| if (documentation != null) { |
| __result['documentation'] = documentation; |
| } |
| if (deprecated != null) { |
| __result['deprecated'] = deprecated; |
| } |
| if (preselect != null) { |
| __result['preselect'] = preselect; |
| } |
| if (sortText != null) { |
| __result['sortText'] = sortText; |
| } |
| if (filterText != null) { |
| __result['filterText'] = filterText; |
| } |
| if (insertText != null) { |
| __result['insertText'] = insertText; |
| } |
| if (insertTextFormat != null) { |
| __result['insertTextFormat'] = insertTextFormat; |
| } |
| if (textEdit != null) { |
| __result['textEdit'] = textEdit; |
| } |
| if (additionalTextEdits != null) { |
| __result['additionalTextEdits'] = additionalTextEdits; |
| } |
| if (commitCharacters != null) { |
| __result['commitCharacters'] = commitCharacters; |
| } |
| 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('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('kind'); |
| try { |
| if (obj['kind'] != null && |
| !(CompletionItemKind.canParse(obj['kind'], reporter))) { |
| reporter.reportError("must be of type CompletionItemKind"); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('detail'); |
| try { |
| if (obj['detail'] != null && !(obj['detail'] is String)) { |
| reporter.reportError("must be of type String"); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('documentation'); |
| try { |
| if (obj['documentation'] != null && |
| !((obj['documentation'] is String || |
| MarkupContent.canParse(obj['documentation'], reporter)))) { |
| reporter |
| .reportError("must be of type Either2<String, MarkupContent>"); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('deprecated'); |
| try { |
| if (obj['deprecated'] != null && !(obj['deprecated'] is bool)) { |
| reporter.reportError("must be of type bool"); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('preselect'); |
| try { |
| if (obj['preselect'] != null && !(obj['preselect'] is bool)) { |
| reporter.reportError("must be of type bool"); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('sortText'); |
| try { |
| if (obj['sortText'] != null && !(obj['sortText'] is String)) { |
| reporter.reportError("must be of type String"); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('filterText'); |
| try { |
| if (obj['filterText'] != null && !(obj['filterText'] is String)) { |
| reporter.reportError("must be of type String"); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('insertText'); |
| try { |
| if (obj['insertText'] != null && !(obj['insertText'] is String)) { |
| reporter.reportError("must be of type String"); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('insertTextFormat'); |
| try { |
| if (obj['insertTextFormat'] != null && |
| !(InsertTextFormat.canParse(obj['insertTextFormat'], reporter))) { |
| reporter.reportError("must be of type InsertTextFormat"); |
| 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(); |
| } |
| reporter.push('commitCharacters'); |
| try { |
| if (obj['commitCharacters'] != null && |
| !((obj['commitCharacters'] is List && |
| (obj['commitCharacters'].every((item) => item is String))))) { |
| reporter.reportError("must be of type List<String>"); |
| 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 && |
| !(CompletionItemResolutionInfo.canParse(obj['data'], reporter))) { |
| reporter.reportError("must be of type CompletionItemResolutionInfo"); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| return true; |
| } else { |
| reporter.reportError("must be of type CompletionItem"); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(other) { |
| if (other is CompletionItem) { |
| return label == other.label && |
| kind == other.kind && |
| detail == other.detail && |
| documentation == other.documentation && |
| deprecated == other.deprecated && |
| preselect == other.preselect && |
| sortText == other.sortText && |
| filterText == other.filterText && |
| insertText == other.insertText && |
| insertTextFormat == other.insertTextFormat && |
| textEdit == other.textEdit && |
| listEqual(additionalTextEdits, other.additionalTextEdits, |
| (TextEdit a, TextEdit b) => a == b) && |
| listEqual(commitCharacters, other.commitCharacters, |
| (String a, String b) => a == b) && |
| command == other.command && |
| data == other.data && |
| true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| int hash = 0; |
| hash = JenkinsSmiHash.combine(hash, label.hashCode); |
| hash = JenkinsSmiHash.combine(hash, kind.hashCode); |
| hash = JenkinsSmiHash.combine(hash, detail.hashCode); |
| hash = JenkinsSmiHash.combine(hash, documentation.hashCode); |
| hash = JenkinsSmiHash.combine(hash, deprecated.hashCode); |
| hash = JenkinsSmiHash.combine(hash, preselect.hashCode); |
| hash = JenkinsSmiHash.combine(hash, sortText.hashCode); |
| hash = JenkinsSmiHash.combine(hash, filterText.hashCode); |
| hash = JenkinsSmiHash.combine(hash, insertText.hashCode); |
| hash = JenkinsSmiHash.combine(hash, insertTextFormat.hashCode); |
| hash = JenkinsSmiHash.combine(hash, textEdit.hashCode); |
| hash = JenkinsSmiHash.combine(hash, additionalTextEdits.hashCode); |
| hash = JenkinsSmiHash.combine(hash, commitCharacters.hashCode); |
| hash = JenkinsSmiHash.combine(hash, command.hashCode); |
| hash = JenkinsSmiHash.combine(hash, data.hashCode); |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The kind of a completion entry. |
| class CompletionItemKind { |
| const CompletionItemKind(this._value); |
| const CompletionItemKind.fromJson(this._value); |
| |
| final num _value; |
| |
| static bool canParse(Object obj, LspJsonReporter reporter) { |
| return obj is num; |
| } |
| |
| static const Text = const CompletionItemKind(1); |
| static const Method = const CompletionItemKind(2); |
| static const Function = const CompletionItemKind(3); |
| static const Constructor = const CompletionItemKind(4); |
| static const Field = const CompletionItemKind(5); |
| static const Variable = const CompletionItemKind(6); |
| static const Class = const CompletionItemKind(7); |
| static const Interface = const CompletionItemKind(8); |
| static const Module = const CompletionItemKind(9); |
| static const Property = const CompletionItemKind(10); |
| static const Unit = const CompletionItemKind(11); |
| static const Value = const CompletionItemKind(12); |
| static const Enum = const CompletionItemKind(13); |
| static const Keyword = const CompletionItemKind(14); |
| static const Snippet = const CompletionItemKind(15); |
| static const Color = const CompletionItemKind(16); |
| static const File = const CompletionItemKind(17); |
| static const Reference = const CompletionItemKind(18); |
| static const Folder = const CompletionItemKind(19); |
| static const EnumMember = const CompletionItemKind(20); |
| static const Constant = const CompletionItemKind(21); |
| static const Struct = const CompletionItemKind(22); |
| static const Event = const CompletionItemKind(23); |
| static const Operator = const CompletionItemKind(24); |
| static const TypeParameter = const CompletionItemKind(25); |
| |
| Object toJson() => _value; |
| |
| @override |
| String toString() => _value.toString(); |
| |
| @override |
| get hashCode => _value.hashCode; |
| |
| bool operator ==(o) => o is CompletionItemKind && o._value == _value; |
| } |
| |
| /// Represents a collection of completion items ([CompletionItem]) to be |
| /// presented in the editor. |
| class CompletionList implements ToJsonable { |
| static const jsonHandler = |
| const LspJsonHandler(CompletionList.canParse, CompletionList.fromJson); |
| |
| CompletionList(this.isIncomplete, this.items) { |
| if (isIncomplete == null) { |
| throw 'isIncomplete is required but was not provided'; |
| } |
| if (items == null) { |
| throw 'items is required but was not provided'; |
| } |
| } |
| static CompletionList fromJson(Map<String, dynamic> json) { |
| final isIncomplete = json['isIncomplete']; |
| final items = json['items'] |
| ?.map((item) => item != null ? CompletionItem.fromJson(item) : null) |
| ?.cast<CompletionItem>() |
| ?.toList(); |
| return new CompletionList(isIncomplete, items); |
| } |
| |
| /// This list it not complete. Further typing should result in recomputing |
| /// this list. |
| final bool isIncomplete; |
| |
| /// The completion items. |
| final List<CompletionItem> items; |
| |
| Map<String, dynamic> toJson() { |
| Map<String, dynamic> __result = {}; |
| __result['isIncomplete'] = |
| isIncomplete ?? (throw 'isIncomplete is required but was not set'); |
| __result['items'] = items ?? (throw 'items is required but was not set'); |
| return __result; |
| } |
| |
| static bool canParse(Object obj, LspJsonReporter reporter) { |
| if (obj is Map<String, dynamic>) { |
| reporter.push('isIncomplete'); |
| try { |
| if (!obj.containsKey('isIncomplete')) { |
| reporter.reportError("must not be undefined"); |
| return false; |
| } |
| if (obj['isIncomplete'] == null) { |
| reporter.reportError("must not be null"); |
| return false; |
| } |
| if (!(obj['isIncomplete'] is bool)) { |
| reporter.reportError("must be of type bool"); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| reporter.push('items'); |
| try { |
| if (!obj.containsKey('items')) { |
| reporter.reportError("must not be undefined"); |
| return false; |
| } |
| if (obj['items'] == null) { |
| reporter.reportError("must not be null"); |
| return false; |
| } |
| if (!((obj['items'] is List && |
| (obj['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 ==(other) { |
| if (other is CompletionList) { |
| return isIncomplete == other.isIncomplete && |
| listEqual(items, other.items, |
| (CompletionItem a, CompletionItem b) => a == b) && |
| true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| int hash = 0; |
| hash = JenkinsSmiHash.combine(hash, isIncomplete.hashCode); |
| hash = JenkinsSmiHash.combine(hash, items.hashCode); |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Completion options. |
| class CompletionOptions implements ToJsonable { |
| static const jsonHandler = const LspJsonHandler( |
| CompletionOptions.canParse, CompletionOptions.fromJson); |
| |
| CompletionOptions(this.resolveProvider, this.triggerCharacters); |
| static CompletionOptions fromJson(Map<String, dynamic> json) { |
| final resolveProvider = json['resolveProvider']; |
| final triggerCharacters = json['triggerCharacters'] |
| ?.map((item) => item) |
| ?.cast<String>() |
| ?.toList(); |
| return new CompletionOptions(resolveProvider, triggerCharacters); |
| } |
| |
| /// The server provides support to resolve additional information for a |
| /// completion item. |
| final bool resolveProvider; |
| |
| /// The characters that trigger completion automatically. |
| final List<String> triggerCharacters; |
| |
| Map<String, dynamic> toJson() { |
| Map<String, dynamic> __result = {}; |
| if (resolveProvider != null) { |
| __result['resolveProvider'] = resolveProvider; |
| } |
| if (triggerCharacters != null) { |
| __result['triggerCharacters'] = triggerCharacters; |
| } |
| 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('triggerCharacters'); |
| try { |
| if (obj['triggerCharacters'] != null && |
| !((obj['triggerCharacters'] is List && |
| (obj['triggerCharacters'].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 CompletionOptions"); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(other) { |
| if (other is CompletionOptions) { |
| return resolveProvider == other.resolveProvider && |
| listEqual(triggerCharacters, other.triggerCharacters, |
| (String a, String b) => a == b) && |
| true; |
| } |
| return false; |
| } |
| |
| @override |
| int get hashCode { |
| int hash = 0; |
| hash = JenkinsSmiHash.combine(hash, resolveProvider.hashCode); |
| hash = JenkinsSmiHash.combine(hash, triggerCharacters.hashCode); |
| return JenkinsSmiHash.finish(hash); |
| } |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class CompletionParams implements TextDocumentPositionParams, ToJsonable { |
| static const jsonHandler = const LspJsonHandler( |
| CompletionParams.canParse, CompletionParams.fromJson); |
| |
| CompletionParams(this.context, this.textDocument, this.position) { |
| if (textDocument == null) { |
| throw 'textDocument is required but was not provided'; |
| } |
| if (position == null) { |
| throw 'position is required but was not provided'; |
| } |
| } |
| static CompletionParams fromJson(Map<String, dynamic> json) { |
| final context = json['context'] != null |
| ? CompletionContext.fromJson(json['context']) |
| : null; |
| final textDocument = json['textDocument'] != null |
| ? TextDocumentIdentifier.fromJson(json['textDocument']) |
| : null; |
| final position = |
| json['position'] != null ? Position.fromJson(json['position']) : null; |
| return new CompletionParams(context, textDocument, position); |
| } |
| |
| /// The completion context. This is only available if the client specifies to |
| /// send this using `ClientCapabilities.textDocument.completion.contextSupport |
| /// === true` |
| final CompletionContext context; |
| |
| /// The position inside the text document. |
| final Position position; |
| |
| /// The text document. |
| final TextDocumentIdentifier textDocument; |
| |
| Map<String, dynamic> toJson() { |
| Map<String, dynamic> __result = {}; |
| if (context != null) { |
| __result['context'] = context; |
| } |
| __result['textDocument'] = |
| textDocument ?? (throw 'textDocument is required but was not set'); |
| __result['position'] = |
| position ?? (throw 'position is required but was not set'); |
| return __result; |
| } |
| |
| static bool canParse(Object obj, LspJsonReporter reporter) { |
| if (obj is Map<String, dynamic>) { |
| reporter.push('context'); |
| try { |
| if (obj['context'] != null && |
| !(CompletionContext.canParse(obj['context'], reporter))) { |
| reporter.reportError("must be of type CompletionContext"); |
| return false; |
| } |
| } finally { |
| reporter.pop(); |
| } |
| 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))) { |
|