| // 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". |
| |
| import 'dart:core' hide deprecated; |
| import 'dart:core' as core show deprecated; |
| import 'dart:convert' show JsonEncoder; |
| import 'package:analysis_server/lsp_protocol/protocol_custom_generated.dart'; |
| import 'package:analysis_server/lsp_protocol/protocol_special.dart'; |
| import 'package:analysis_server/src/lsp/json_parsing.dart'; |
| import 'package:analysis_server/src/protocol/protocol_internal.dart'; |
| |
| const jsonEncoder = JsonEncoder.withIndent(' '); |
| |
| /// Result for a request to resolve the incoming calls for a given |
| /// `CallHierarchyItem`. |
| /// |
| /// @since 3.16.0 |
| typedef CallHierarchyIncomingCallsResult = List<CallHierarchyIncomingCall>?; |
| |
| /// Result for a request to resolve the outgoing calls for a given |
| /// `CallHierarchyItem`. |
| /// |
| /// @since 3.16.0 |
| typedef CallHierarchyOutgoingCallsResult = List<CallHierarchyOutgoingCall>?; |
| |
| /// An identifier to refer to a change annotation stored with a workspace edit. |
| typedef ChangeAnnotationIdentifier = String; |
| |
| /// The declaration of a symbol representation as one or many locations. |
| typedef Declaration = Either2<List<Location>, Location>; |
| |
| /// Information about where a symbol is declared. |
| /// |
| /// Provides additional metadata over normal location declarations, including |
| /// the range of the declaring symbol. |
| /// |
| /// Servers should prefer returning `DeclarationLink` over `Declaration` if |
| /// supported by the client. |
| typedef DeclarationLink = LocationLink; |
| |
| /// The definition of a symbol represented as one or many locations. For most |
| /// programming languages there is only one location at which a symbol is |
| /// defined. |
| /// |
| /// Servers should prefer returning `DefinitionLink` over `Definition` if |
| /// supported by the client. |
| typedef Definition = Either2<List<Location>, Location>; |
| |
| /// Information about where a symbol is defined. |
| /// |
| /// Provides additional metadata over normal location definitions, including the |
| /// range of the defining symbol |
| typedef DefinitionLink = LocationLink; |
| |
| /// The result of a document diagnostic pull request. A report can either be a |
| /// full report containing all diagnostics for the requested document or an |
| /// unchanged report indicating that nothing has changed in terms of diagnostics |
| /// in comparison to the last pull request. |
| /// |
| /// @since 3.17.0 |
| typedef DocumentDiagnosticReport = Either2<RelatedFullDocumentDiagnosticReport, |
| RelatedUnchangedDocumentDiagnosticReport>; |
| |
| /// A document filter describes a top level text document or a notebook cell |
| /// document. |
| /// |
| /// @since 3.17.0 - proposed support for NotebookCellTextDocumentFilter. |
| typedef DocumentFilter |
| = Either2<NotebookCellTextDocumentFilter, TextDocumentFilter>; |
| |
| /// A document selector is the combination of one or many document filters. |
| /// |
| /// @sample `let sel:DocumentSelector = [{ language: 'typescript' }, { language: |
| /// 'json', pattern: '**∕tsconfig.json' }]`; |
| /// |
| /// The use of a string as a document filter is deprecated @since 3.16.0. |
| typedef DocumentSelector = List<Either2<TextDocumentFilterWithScheme, String>>; |
| |
| /// The glob pattern. Either a string pattern or a relative pattern. |
| /// |
| /// @since 3.17.0 |
| typedef GlobPattern = Either2<LspPattern, RelativePattern>; |
| |
| /// Inline value information can be provided by different means: |
| /// - directly as a text value (class InlineValueText). |
| /// - as a name to use for a variable lookup (class InlineValueVariableLookup) |
| /// - as an evaluatable expression (class InlineValueEvaluatableExpression) The |
| /// InlineValue types combines all inline value types into one type. |
| /// |
| /// @since 3.17.0 |
| typedef InlineValue = Either3<InlineValueEvaluatableExpression, InlineValueText, |
| InlineValueVariableLookup>; |
| |
| /// LSP arrays. |
| /// @since 3.17.0 |
| typedef LSPArray = List<LSPAny>; |
| |
| /// The glob pattern to watch relative to the base path. Glob patterns can have |
| /// the following syntax: |
| /// - `*` to match one or more characters in a path segment |
| /// - `?` to match on one character in a path segment |
| /// - `**` to match any number of path segments, including none |
| /// - `{}` to group conditions (e.g. `**/*.{ts,js}` matches all TypeScript and |
| /// JavaScript files) |
| /// - `[]` to declare a range of characters to match in a path segment (e.g., |
| /// `example.[0-9]` to match on `example.0`, `example.1`, …) |
| /// - `[!...]` to negate a range of characters to match in a path segment (e.g., |
| /// `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`) |
| /// |
| /// @since 3.17.0 |
| typedef LspPattern = String; |
| |
| /// A tagging type for string properties that are actually URIs |
| /// |
| /// @since 3.16.0 |
| typedef LspUri = String; |
| |
| /// A notebook document filter denotes a notebook document by different |
| /// properties. The properties will be match against the notebook's URI (same as |
| /// with documents) |
| /// |
| /// @since 3.17.0 |
| typedef NotebookDocumentFilter = Either3<NotebookDocumentFilter1, |
| NotebookDocumentFilter2, NotebookDocumentFilter3>; |
| typedef PrepareRenameResult |
| = Either3<PlaceholderAndRange, PrepareRenameResult2, Range>; |
| typedef ProgressToken = Either2<int, String>; |
| |
| /// Result for a request to provide commands for the given text document and |
| /// range. |
| typedef TextDocumentCodeActionResult = List<Either2<CodeAction, Command>>?; |
| |
| /// Result for a request to provide code lens for the given text document. |
| typedef TextDocumentCodeLensResult = List<CodeLens>?; |
| |
| /// Result for request to request completion at a given text document position. |
| /// The request's parameter is of type TextDocumentPosition the response is of |
| /// type [CompletionItem[]](#CompletionItem) or CompletionList or a Thenable |
| /// that resolves to such. |
| /// |
| /// The request can delay the computation of the `detail` and `documentation` |
| /// properties to the `completionItem/resolve` request. However, properties that |
| /// are needed for the initial sorting and filtering, like `sortText`, |
| /// `filterText`, `insertText`, and `textEdit`, must not be changed during |
| /// resolve. |
| typedef TextDocumentCompletionResult |
| = Either2<CompletionList, List<CompletionItem>>?; |
| |
| /// An event describing a change to a text document. If only a text is provided |
| /// it is considered to be the full content of the document. |
| typedef TextDocumentContentChangeEvent |
| = Either2<TextDocumentContentChangeEvent1, TextDocumentContentChangeEvent2>; |
| |
| /// Result for a request to resolve the type definition locations of a symbol at |
| /// a given text document position. The request's parameter is of type |
| /// TextDocumentPositionParams the response is of type Declaration or a typed |
| /// array of DeclarationLink or a Thenable that resolves to such. |
| typedef TextDocumentDeclarationResult |
| = Either2<Declaration, List<DeclarationLink>>?; |
| |
| /// Result for a request to resolve the definition location of a symbol at a |
| /// given text document position. The request's parameter is of type |
| /// TextDocumentPosition the response is of either type Definition or a typed |
| /// array of DefinitionLink or a Thenable that resolves to such. |
| typedef TextDocumentDefinitionResult |
| = Either2<Definition, List<DefinitionLink>>?; |
| |
| /// Result for request to resolve a DocumentHighlight for a given text document |
| /// position. The request's parameter is of type TextDocumentPosition the |
| /// request response is of type [DocumentHighlight[]] (#DocumentHighlight) or a |
| /// Thenable that resolves to such. |
| typedef TextDocumentDocumentHighlightResult = List<DocumentHighlight>?; |
| |
| /// Result for a request to provide document links |
| typedef TextDocumentDocumentLinkResult = List<DocumentLink>?; |
| |
| /// Result for a request to list all symbols found in a given text document. The |
| /// request's parameter is of type TextDocumentIdentifier the response is of |
| /// type [SymbolInformation[]](#SymbolInformation) or a Thenable that resolves |
| /// to such. |
| typedef TextDocumentDocumentSymbolResult |
| = Either2<List<DocumentSymbol>, List<SymbolInformation>>?; |
| |
| /// A document filter denotes a document by different properties like the |
| /// language, the scheme of its resource, or a glob-pattern that is applied to |
| /// the path. |
| /// |
| /// Glob patterns can have the following syntax: |
| /// - `*` to match one or more characters in a path segment |
| /// - `?` to match on one character in a path segment |
| /// - `**` to match any number of path segments, including none |
| /// - `{}` to group sub patterns into an OR expression. (e.g. `**/*.{ts,js}` |
| /// matches all TypeScript and JavaScript files) |
| /// - `[]` to declare a range of characters to match in a path segment (e.g., |
| /// `example.[0-9]` to match on `example.0`, `example.1`, …) |
| /// - `[!...]` to negate a range of characters to match in a path segment (e.g., |
| /// `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`) |
| /// |
| /// @sample A language filter that applies to typescript files on disk: `{ |
| /// language: 'typescript', scheme: 'file' }` |
| /// @sample A language filter that applies to all package.json paths: `{ |
| /// language: 'json', pattern: '**package.json' }` |
| /// |
| /// @since 3.17.0 |
| typedef TextDocumentFilter = Either3<TextDocumentFilter1, |
| TextDocumentFilterWithScheme, TextDocumentFilter3>; |
| |
| /// Result for a request to provide folding ranges in a document. The request's |
| /// parameter is of type FoldingRangeParams, the response is of type |
| /// FoldingRangeList or a Thenable that resolves to such. |
| typedef TextDocumentFoldingRangeResult = List<FoldingRange>?; |
| |
| /// Result for a request to to format a whole document. |
| typedef TextDocumentFormattingResult = List<TextEdit>?; |
| |
| /// Result for request to request hover information at a given text document |
| /// position. The request's parameter is of type TextDocumentPosition the |
| /// response is of type Hover or a Thenable that resolves to such. |
| typedef TextDocumentHoverResult = Hover?; |
| |
| /// Result for a request to resolve the implementation locations of a symbol at |
| /// a given text document position. The request's parameter is of type |
| /// TextDocumentPositionParams the response is of type Definition or a Thenable |
| /// that resolves to such. |
| typedef TextDocumentImplementationResult |
| = Either2<Definition, List<DefinitionLink>>?; |
| |
| /// Result for a request to provide inlay hints in a document. The request's |
| /// parameter is of type InlayHintsParams, the response is of type |
| /// [InlayHint[]](#InlayHint[]) or a Thenable that resolves to such. |
| /// |
| /// @since 3.17.0 |
| typedef TextDocumentInlayHintResult = List<InlayHint>?; |
| |
| /// Result for a request to provide inline values in a document. The request's |
| /// parameter is of type InlineValueParams, the response is of type |
| /// [InlineValue[]](#InlineValue[]) or a Thenable that resolves to such. |
| /// |
| /// @since 3.17.0 |
| typedef TextDocumentInlineValueResult = List<InlineValue>?; |
| |
| /// Result for a request to provide ranges that can be edited together. |
| /// |
| /// @since 3.16.0 |
| typedef TextDocumentLinkedEditingRangeResult = LinkedEditingRanges?; |
| |
| /// Result for a request to get the moniker of a symbol at a given text document |
| /// position. The request parameter is of type TextDocumentPositionParams. The |
| /// response is of type [Moniker[]](#Moniker[]) or `null`. |
| typedef TextDocumentMonikerResult = List<Moniker>?; |
| |
| /// Result for a request to format a document on type. |
| typedef TextDocumentOnTypeFormattingResult = List<TextEdit>?; |
| |
| /// Result for a request to result a `CallHierarchyItem` in a document at a |
| /// given position. Can be used as an input to an incoming or outgoing call |
| /// hierarchy. |
| /// |
| /// @since 3.16.0 |
| typedef TextDocumentPrepareCallHierarchyResult = List<CallHierarchyItem>?; |
| |
| /// Result for a request to test and perform the setup necessary for a rename. |
| /// |
| /// @since 3.16 - support for default behavior |
| typedef TextDocumentPrepareRenameResult = PrepareRenameResult?; |
| |
| /// Result for a request to result a `TypeHierarchyItem` in a document at a |
| /// given position. Can be used as an input to a subtypes or supertypes type |
| /// hierarchy. |
| /// |
| /// @since 3.17.0 |
| typedef TextDocumentPrepareTypeHierarchyResult = List<TypeHierarchyItem>?; |
| |
| /// Result for a request to to format a range in a document. |
| typedef TextDocumentRangeFormattingResult = List<TextEdit>?; |
| |
| /// Result for a request to resolve project-wide references for the symbol |
| /// denoted by the given text document position. The request's parameter is of |
| /// type ReferenceParams the response is of type [Location[]](#Location) or a |
| /// Thenable that resolves to such. |
| typedef TextDocumentReferencesResult = List<Location>?; |
| |
| /// Result for a request to rename a symbol. |
| typedef TextDocumentRenameResult = WorkspaceEdit?; |
| |
| /// Result for a request to provide selection ranges in a document. The |
| /// request's parameter is of type SelectionRangeParams, the response is of type |
| /// [SelectionRange[]](#SelectionRange[]) or a Thenable that resolves to such. |
| typedef TextDocumentSelectionRangeResult = List<SelectionRange>?; |
| |
| /// Result for @since 3.16.0 |
| typedef TextDocumentSemanticTokensFullDeltaResult |
| = Either2<SemanticTokens, SemanticTokensDelta>?; |
| |
| /// Result for @since 3.16.0 |
| typedef TextDocumentSemanticTokensFullResult = SemanticTokens?; |
| |
| /// Result for @since 3.16.0 |
| typedef TextDocumentSemanticTokensRangeResult = SemanticTokens?; |
| typedef TextDocumentSignatureHelpResult = SignatureHelp?; |
| |
| /// Result for a request to resolve the type definition locations of a symbol at |
| /// a given text document position. The request's parameter is of type |
| /// TextDocumentPositionParams the response is of type Definition or a Thenable |
| /// that resolves to such. |
| typedef TextDocumentTypeDefinitionResult |
| = Either2<Definition, List<DefinitionLink>>?; |
| |
| /// Result for a document will save request is sent from the client to the |
| /// server before the document is actually saved. The request can return an |
| /// array of TextEdits which will be applied to the text document before it is |
| /// saved. Please note that clients might drop results if computing the text |
| /// edits took too long or if a server constantly fails on this request. This is |
| /// done to keep the save fast and reliable. |
| typedef TextDocumentWillSaveWaitUntilResult = List<TextEdit>?; |
| |
| /// Result for a request to resolve the subtypes for a given |
| /// `TypeHierarchyItem`. |
| /// |
| /// @since 3.17.0 |
| typedef TypeHierarchySubtypesResult = List<TypeHierarchyItem>?; |
| |
| /// Result for a request to resolve the supertypes for a given |
| /// `TypeHierarchyItem`. |
| /// |
| /// @since 3.17.0 |
| typedef TypeHierarchySupertypesResult = List<TypeHierarchyItem>?; |
| |
| /// Result for the show message request is sent from the server to the client to |
| /// show a message and a set of options actions to the user. |
| typedef WindowShowMessageRequestResult = MessageActionItem?; |
| |
| /// A workspace diagnostic document report. |
| /// |
| /// @since 3.17.0 |
| typedef WorkspaceDocumentDiagnosticReport = Either2< |
| WorkspaceFullDocumentDiagnosticReport, |
| WorkspaceUnchangedDocumentDiagnosticReport>; |
| |
| /// Result for a request send from the client to the server to execute a |
| /// command. The request might return a workspace edit which the client will |
| /// apply to the workspace. |
| typedef WorkspaceExecuteCommandResult = LSPAny?; |
| |
| /// Result for a request to list project-wide symbols matching the query string |
| /// given by the WorkspaceSymbolParams. The response is of type |
| /// [SymbolInformation[]](#SymbolInformation) or a Thenable that resolves to |
| /// such. |
| /// |
| /// @since 3.17.0 - support for WorkspaceSymbol in the returned data. Clients |
| /// need to advertise support for WorkspaceSymbols via the client capability |
| /// `workspace.symbol.resolveSupport`. |
| typedef WorkspaceSymbolResult |
| = Either2<List<SymbolInformation>, List<WorkspaceSymbol>>?; |
| |
| /// Result for the will create files request is sent from the client to the |
| /// server before files are actually created as long as the creation is |
| /// triggered from within the client. |
| /// |
| /// @since 3.16.0 |
| typedef WorkspaceWillCreateFilesResult = WorkspaceEdit?; |
| |
| /// Result for the did delete files notification is sent from the client to the |
| /// server when files were deleted from within the client. |
| /// |
| /// @since 3.16.0 |
| typedef WorkspaceWillDeleteFilesResult = WorkspaceEdit?; |
| |
| /// Result for the will rename files request is sent from the client to the |
| /// server before files are actually renamed as long as the rename is triggered |
| /// from within the client. |
| /// |
| /// @since 3.16.0 |
| typedef WorkspaceWillRenameFilesResult = WorkspaceEdit?; |
| |
| /// Result for the `workspace/workspaceFolders` is sent from the server to the |
| /// client to fetch the open workspace folders. |
| typedef WorkspaceWorkspaceFoldersResult = List<WorkspaceFolder>?; |
| |
| /// A special text edit with an additional change annotation. |
| /// |
| /// @since 3.16.0. |
| class AnnotatedTextEdit implements TextEdit, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| AnnotatedTextEdit.canParse, |
| AnnotatedTextEdit.fromJson, |
| ); |
| |
| AnnotatedTextEdit({ |
| required this.annotationId, |
| required this.newText, |
| required this.range, |
| }); |
| static AnnotatedTextEdit fromJson(Map<String, Object?> json) { |
| final annotationIdJson = json['annotationId']; |
| final annotationId = annotationIdJson as String; |
| final newTextJson = json['newText']; |
| final newText = newTextJson as String; |
| final rangeJson = json['range']; |
| final range = Range.fromJson(rangeJson as Map<String, Object?>); |
| return AnnotatedTextEdit( |
| annotationId: annotationId, |
| newText: newText, |
| range: range, |
| ); |
| } |
| |
| /// The actual identifier of the change annotation |
| final ChangeAnnotationIdentifier annotationId; |
| |
| /// The string to be inserted. For delete operations use an empty string. |
| @override |
| final String newText; |
| |
| /// The range of the text document to be manipulated. To insert text into a |
| /// document create a range where start === end. |
| @override |
| final Range range; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['annotationId'] = annotationId; |
| result['newText'] = newText; |
| result['range'] = range.toJson(); |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseString(obj, reporter, 'annotationId', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseString(obj, reporter, 'newText', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseRange(obj, reporter, 'range', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type AnnotatedTextEdit'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is AnnotatedTextEdit && |
| other.runtimeType == AnnotatedTextEdit && |
| annotationId == other.annotationId && |
| newText == other.newText && |
| range == other.range; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| annotationId, |
| newText, |
| range, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The parameters passed via a apply workspace edit request. |
| class ApplyWorkspaceEditParams implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| ApplyWorkspaceEditParams.canParse, |
| ApplyWorkspaceEditParams.fromJson, |
| ); |
| |
| ApplyWorkspaceEditParams({ |
| required this.edit, |
| this.label, |
| }); |
| static ApplyWorkspaceEditParams fromJson(Map<String, Object?> json) { |
| final editJson = json['edit']; |
| final edit = WorkspaceEdit.fromJson(editJson as Map<String, Object?>); |
| final labelJson = json['label']; |
| final label = labelJson as String?; |
| return ApplyWorkspaceEditParams( |
| edit: edit, |
| label: label, |
| ); |
| } |
| |
| /// The edits to apply. |
| final WorkspaceEdit edit; |
| |
| /// An optional label of the workspace edit. This label is presented in the |
| /// user interface for example on an undo stack to undo the workspace edit. |
| final String? label; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['edit'] = edit.toJson(); |
| if (label != null) { |
| result['label'] = label; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseWorkspaceEdit(obj, reporter, 'edit', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseString(obj, reporter, 'label', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type ApplyWorkspaceEditParams'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is ApplyWorkspaceEditParams && |
| other.runtimeType == ApplyWorkspaceEditParams && |
| edit == other.edit && |
| label == other.label; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| edit, |
| label, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The result returned from the apply workspace edit request. |
| /// |
| /// @since 3.17 renamed from ApplyWorkspaceEditResponse |
| class ApplyWorkspaceEditResult implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| ApplyWorkspaceEditResult.canParse, |
| ApplyWorkspaceEditResult.fromJson, |
| ); |
| |
| ApplyWorkspaceEditResult({ |
| required this.applied, |
| this.failedChange, |
| this.failureReason, |
| }); |
| static ApplyWorkspaceEditResult fromJson(Map<String, Object?> json) { |
| final appliedJson = json['applied']; |
| final applied = appliedJson as bool; |
| final failedChangeJson = json['failedChange']; |
| final failedChange = failedChangeJson as int?; |
| final failureReasonJson = json['failureReason']; |
| final failureReason = failureReasonJson as String?; |
| return ApplyWorkspaceEditResult( |
| applied: applied, |
| failedChange: failedChange, |
| failureReason: failureReason, |
| ); |
| } |
| |
| /// Indicates whether the edit was applied or not. |
| final bool applied; |
| |
| /// Depending on the client's failure handling strategy `failedChange` might |
| /// contain the index of the change that failed. This property is only |
| /// available if the client signals a `failureHandlingStrategy` in its client |
| /// capabilities. |
| final int? failedChange; |
| |
| /// An optional textual description for why the edit was not applied. This may |
| /// be used by the server for diagnostic logging or to provide a suitable |
| /// error for a request that triggered the edit. |
| final String? failureReason; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['applied'] = applied; |
| if (failedChange != null) { |
| result['failedChange'] = failedChange; |
| } |
| if (failureReason != null) { |
| result['failureReason'] = failureReason; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseBool(obj, reporter, 'applied', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseInt(obj, reporter, 'failedChange', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseString(obj, reporter, 'failureReason', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type ApplyWorkspaceEditResult'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is ApplyWorkspaceEditResult && |
| other.runtimeType == ApplyWorkspaceEditResult && |
| applied == other.applied && |
| failedChange == other.failedChange && |
| failureReason == other.failureReason; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| applied, |
| failedChange, |
| failureReason, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// A base for all symbol information. |
| class BaseSymbolInformation implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| BaseSymbolInformation.canParse, |
| BaseSymbolInformation.fromJson, |
| ); |
| |
| BaseSymbolInformation({ |
| this.containerName, |
| required this.kind, |
| required this.name, |
| this.tags, |
| }); |
| static BaseSymbolInformation fromJson(Map<String, Object?> json) { |
| if (SymbolInformation.canParse(json, nullLspJsonReporter)) { |
| return SymbolInformation.fromJson(json); |
| } |
| if (WorkspaceSymbol.canParse(json, nullLspJsonReporter)) { |
| return WorkspaceSymbol.fromJson(json); |
| } |
| final containerNameJson = json['containerName']; |
| final containerName = containerNameJson as String?; |
| final kindJson = json['kind']; |
| final kind = SymbolKind.fromJson(kindJson as int); |
| final nameJson = json['name']; |
| final name = nameJson as String; |
| final tagsJson = json['tags']; |
| final tags = (tagsJson as List<Object?>?) |
| ?.map((item) => SymbolTag.fromJson(item as int)) |
| .toList(); |
| return BaseSymbolInformation( |
| containerName: containerName, |
| kind: kind, |
| name: name, |
| tags: tags, |
| ); |
| } |
| |
| /// The name of the symbol containing this symbol. This information is for |
| /// user interface purposes (e.g. to render a qualifier in the user interface |
| /// if necessary). It can't be used to re-infer a hierarchy for the document |
| /// symbols. |
| final String? containerName; |
| |
| /// The kind of this symbol. |
| final SymbolKind kind; |
| |
| /// The name of this symbol. |
| final String name; |
| |
| /// Tags for this symbol. |
| /// |
| /// @since 3.16.0 |
| final List<SymbolTag>? tags; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (containerName != null) { |
| result['containerName'] = containerName; |
| } |
| result['kind'] = kind.toJson(); |
| result['name'] = name; |
| if (tags != null) { |
| result['tags'] = tags?.map((item) => item.toJson()).toList(); |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseString(obj, reporter, 'containerName', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseSymbolKind(obj, reporter, 'kind', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseString(obj, reporter, 'name', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseListSymbolTag(obj, reporter, 'tags', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type BaseSymbolInformation'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is BaseSymbolInformation && |
| other.runtimeType == BaseSymbolInformation && |
| containerName == other.containerName && |
| kind == other.kind && |
| name == other.name && |
| listEqual(tags, other.tags, (SymbolTag a, SymbolTag b) => a == b); |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| containerName, |
| kind, |
| name, |
| lspHashCode(tags), |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// @since 3.16.0 |
| class CallHierarchyClientCapabilities implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CallHierarchyClientCapabilities.canParse, |
| CallHierarchyClientCapabilities.fromJson, |
| ); |
| |
| CallHierarchyClientCapabilities({ |
| this.dynamicRegistration, |
| }); |
| static CallHierarchyClientCapabilities fromJson(Map<String, Object?> json) { |
| final dynamicRegistrationJson = json['dynamicRegistration']; |
| final dynamicRegistration = dynamicRegistrationJson as bool?; |
| return CallHierarchyClientCapabilities( |
| dynamicRegistration: dynamicRegistration, |
| ); |
| } |
| |
| /// Whether implementation supports dynamic registration. If this is set to |
| /// `true` the client supports the new `(TextDocumentRegistrationOptions & |
| /// StaticRegistrationOptions)` return value for the corresponding server |
| /// capability as well. |
| final bool? dynamicRegistration; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (dynamicRegistration != null) { |
| result['dynamicRegistration'] = dynamicRegistration; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseBool(obj, reporter, 'dynamicRegistration', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CallHierarchyClientCapabilities'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CallHierarchyClientCapabilities && |
| other.runtimeType == CallHierarchyClientCapabilities && |
| dynamicRegistration == other.dynamicRegistration; |
| } |
| |
| @override |
| int get hashCode => dynamicRegistration.hashCode; |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Represents an incoming call, e.g. a caller of a method or constructor. |
| /// |
| /// @since 3.16.0 |
| class CallHierarchyIncomingCall implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CallHierarchyIncomingCall.canParse, |
| CallHierarchyIncomingCall.fromJson, |
| ); |
| |
| CallHierarchyIncomingCall({ |
| required this.from, |
| required this.fromRanges, |
| }); |
| static CallHierarchyIncomingCall fromJson(Map<String, Object?> json) { |
| final fromJson = json['from']; |
| final from = CallHierarchyItem.fromJson(fromJson as Map<String, Object?>); |
| final fromRangesJson = json['fromRanges']; |
| final fromRanges = (fromRangesJson as List<Object?>) |
| .map((item) => Range.fromJson(item as Map<String, Object?>)) |
| .toList(); |
| return CallHierarchyIncomingCall( |
| from: from, |
| fromRanges: fromRanges, |
| ); |
| } |
| |
| /// The item that makes the call. |
| final CallHierarchyItem from; |
| |
| /// The ranges at which the calls appear. This is relative to the caller |
| /// denoted by `this.from`. |
| final List<Range> fromRanges; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['from'] = from.toJson(); |
| result['fromRanges'] = fromRanges.map((item) => item.toJson()).toList(); |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseCallHierarchyItem(obj, reporter, 'from', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseListRange(obj, reporter, 'fromRanges', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CallHierarchyIncomingCall'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CallHierarchyIncomingCall && |
| other.runtimeType == CallHierarchyIncomingCall && |
| from == other.from && |
| listEqual(fromRanges, other.fromRanges, (Range a, Range b) => a == b); |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| from, |
| lspHashCode(fromRanges), |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The parameter of a `callHierarchy/incomingCalls` request. |
| /// |
| /// @since 3.16.0 |
| class CallHierarchyIncomingCallsParams |
| implements PartialResultParams, WorkDoneProgressParams, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CallHierarchyIncomingCallsParams.canParse, |
| CallHierarchyIncomingCallsParams.fromJson, |
| ); |
| |
| CallHierarchyIncomingCallsParams({ |
| required this.item, |
| this.partialResultToken, |
| this.workDoneToken, |
| }); |
| static CallHierarchyIncomingCallsParams fromJson(Map<String, Object?> json) { |
| final itemJson = json['item']; |
| final item = CallHierarchyItem.fromJson(itemJson as Map<String, Object?>); |
| final partialResultTokenJson = json['partialResultToken']; |
| final partialResultToken = partialResultTokenJson == null |
| ? null |
| : _eitherIntString(partialResultTokenJson); |
| final workDoneTokenJson = json['workDoneToken']; |
| final workDoneToken = |
| workDoneTokenJson == null ? null : _eitherIntString(workDoneTokenJson); |
| return CallHierarchyIncomingCallsParams( |
| item: item, |
| partialResultToken: partialResultToken, |
| workDoneToken: workDoneToken, |
| ); |
| } |
| |
| final CallHierarchyItem item; |
| |
| /// An optional token that a server can use to report partial results (e.g. |
| /// streaming) to the client. |
| @override |
| final ProgressToken? partialResultToken; |
| |
| /// An optional token that a server can use to report work done progress. |
| @override |
| final ProgressToken? workDoneToken; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['item'] = item.toJson(); |
| if (partialResultToken != null) { |
| result['partialResultToken'] = partialResultToken; |
| } |
| if (workDoneToken != null) { |
| result['workDoneToken'] = workDoneToken; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseCallHierarchyItem(obj, reporter, 'item', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseIntString(obj, reporter, 'partialResultToken', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseIntString(obj, reporter, 'workDoneToken', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CallHierarchyIncomingCallsParams'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CallHierarchyIncomingCallsParams && |
| other.runtimeType == CallHierarchyIncomingCallsParams && |
| item == other.item && |
| partialResultToken == other.partialResultToken && |
| workDoneToken == other.workDoneToken; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| item, |
| partialResultToken, |
| workDoneToken, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Represents programming constructs like functions or constructors in the |
| /// context of call hierarchy. |
| /// |
| /// @since 3.16.0 |
| class CallHierarchyItem implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CallHierarchyItem.canParse, |
| CallHierarchyItem.fromJson, |
| ); |
| |
| CallHierarchyItem({ |
| this.data, |
| this.detail, |
| required this.kind, |
| required this.name, |
| required this.range, |
| required this.selectionRange, |
| this.tags, |
| required this.uri, |
| }); |
| static CallHierarchyItem fromJson(Map<String, Object?> json) { |
| final dataJson = json['data']; |
| final data = dataJson; |
| final detailJson = json['detail']; |
| final detail = detailJson as String?; |
| final kindJson = json['kind']; |
| final kind = SymbolKind.fromJson(kindJson as int); |
| final nameJson = json['name']; |
| final name = nameJson as String; |
| final rangeJson = json['range']; |
| final range = Range.fromJson(rangeJson as Map<String, Object?>); |
| final selectionRangeJson = json['selectionRange']; |
| final selectionRange = |
| Range.fromJson(selectionRangeJson as Map<String, Object?>); |
| final tagsJson = json['tags']; |
| final tags = (tagsJson as List<Object?>?) |
| ?.map((item) => SymbolTag.fromJson(item as int)) |
| .toList(); |
| final uriJson = json['uri']; |
| final uri = uriJson as String; |
| return CallHierarchyItem( |
| data: data, |
| detail: detail, |
| kind: kind, |
| name: name, |
| range: range, |
| selectionRange: selectionRange, |
| tags: tags, |
| uri: uri, |
| ); |
| } |
| |
| /// A data entry field that is preserved between a call hierarchy prepare and |
| /// incoming calls or outgoing calls requests. |
| final LSPAny data; |
| |
| /// More detail for this item, e.g. the signature of a function. |
| final String? detail; |
| |
| /// The kind of this item. |
| final SymbolKind kind; |
| |
| /// The name of this item. |
| final String name; |
| |
| /// The range enclosing this symbol not including leading/trailing whitespace |
| /// but everything else, e.g. comments and code. |
| final Range range; |
| |
| /// The range that should be selected and revealed when this symbol is being |
| /// picked, e.g. the name of a function. Must be contained by the `range`. |
| final Range selectionRange; |
| |
| /// Tags for this item. |
| final List<SymbolTag>? tags; |
| |
| /// The resource identifier of this item. |
| final DocumentUri uri; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (data != null) { |
| result['data'] = data; |
| } |
| if (detail != null) { |
| result['detail'] = detail; |
| } |
| result['kind'] = kind.toJson(); |
| result['name'] = name; |
| result['range'] = range.toJson(); |
| result['selectionRange'] = selectionRange.toJson(); |
| if (tags != null) { |
| result['tags'] = tags?.map((item) => item.toJson()).toList(); |
| } |
| result['uri'] = uri; |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseString(obj, reporter, 'detail', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseSymbolKind(obj, reporter, 'kind', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseString(obj, reporter, 'name', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseRange(obj, reporter, 'range', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseRange(obj, reporter, 'selectionRange', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseListSymbolTag(obj, reporter, 'tags', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseString(obj, reporter, 'uri', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CallHierarchyItem'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CallHierarchyItem && |
| other.runtimeType == CallHierarchyItem && |
| data == other.data && |
| detail == other.detail && |
| kind == other.kind && |
| name == other.name && |
| range == other.range && |
| selectionRange == other.selectionRange && |
| listEqual(tags, other.tags, (SymbolTag a, SymbolTag b) => a == b) && |
| uri == other.uri; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| data, |
| detail, |
| kind, |
| name, |
| range, |
| selectionRange, |
| lspHashCode(tags), |
| uri, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Call hierarchy options used during static registration. |
| /// |
| /// @since 3.16.0 |
| class CallHierarchyOptions implements WorkDoneProgressOptions, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CallHierarchyOptions.canParse, |
| CallHierarchyOptions.fromJson, |
| ); |
| |
| CallHierarchyOptions({ |
| this.workDoneProgress, |
| }); |
| static CallHierarchyOptions fromJson(Map<String, Object?> json) { |
| if (CallHierarchyRegistrationOptions.canParse(json, nullLspJsonReporter)) { |
| return CallHierarchyRegistrationOptions.fromJson(json); |
| } |
| final workDoneProgressJson = json['workDoneProgress']; |
| final workDoneProgress = workDoneProgressJson as bool?; |
| return CallHierarchyOptions( |
| workDoneProgress: workDoneProgress, |
| ); |
| } |
| |
| @override |
| final bool? workDoneProgress; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (workDoneProgress != null) { |
| result['workDoneProgress'] = workDoneProgress; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseBool(obj, reporter, 'workDoneProgress', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CallHierarchyOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CallHierarchyOptions && |
| other.runtimeType == CallHierarchyOptions && |
| workDoneProgress == other.workDoneProgress; |
| } |
| |
| @override |
| int get hashCode => workDoneProgress.hashCode; |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Represents an outgoing call, e.g. calling a getter from a method or a method |
| /// from a constructor etc. |
| /// |
| /// @since 3.16.0 |
| class CallHierarchyOutgoingCall implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CallHierarchyOutgoingCall.canParse, |
| CallHierarchyOutgoingCall.fromJson, |
| ); |
| |
| CallHierarchyOutgoingCall({ |
| required this.fromRanges, |
| required this.to, |
| }); |
| static CallHierarchyOutgoingCall fromJson(Map<String, Object?> json) { |
| final fromRangesJson = json['fromRanges']; |
| final fromRanges = (fromRangesJson as List<Object?>) |
| .map((item) => Range.fromJson(item as Map<String, Object?>)) |
| .toList(); |
| final toJson = json['to']; |
| final to = CallHierarchyItem.fromJson(toJson as Map<String, Object?>); |
| return CallHierarchyOutgoingCall( |
| fromRanges: fromRanges, |
| to: to, |
| ); |
| } |
| |
| /// The range at which this item is called. This is the range relative to the |
| /// caller, e.g the item passed to `provideCallHierarchyOutgoingCalls` and not |
| /// `this.to`. |
| final List<Range> fromRanges; |
| |
| /// The item that is called. |
| final CallHierarchyItem to; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['fromRanges'] = fromRanges.map((item) => item.toJson()).toList(); |
| result['to'] = to.toJson(); |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseListRange(obj, reporter, 'fromRanges', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseCallHierarchyItem(obj, reporter, 'to', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CallHierarchyOutgoingCall'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CallHierarchyOutgoingCall && |
| other.runtimeType == CallHierarchyOutgoingCall && |
| listEqual(fromRanges, other.fromRanges, (Range a, Range b) => a == b) && |
| to == other.to; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| lspHashCode(fromRanges), |
| to, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The parameter of a `callHierarchy/outgoingCalls` request. |
| /// |
| /// @since 3.16.0 |
| class CallHierarchyOutgoingCallsParams |
| implements PartialResultParams, WorkDoneProgressParams, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CallHierarchyOutgoingCallsParams.canParse, |
| CallHierarchyOutgoingCallsParams.fromJson, |
| ); |
| |
| CallHierarchyOutgoingCallsParams({ |
| required this.item, |
| this.partialResultToken, |
| this.workDoneToken, |
| }); |
| static CallHierarchyOutgoingCallsParams fromJson(Map<String, Object?> json) { |
| final itemJson = json['item']; |
| final item = CallHierarchyItem.fromJson(itemJson as Map<String, Object?>); |
| final partialResultTokenJson = json['partialResultToken']; |
| final partialResultToken = partialResultTokenJson == null |
| ? null |
| : _eitherIntString(partialResultTokenJson); |
| final workDoneTokenJson = json['workDoneToken']; |
| final workDoneToken = |
| workDoneTokenJson == null ? null : _eitherIntString(workDoneTokenJson); |
| return CallHierarchyOutgoingCallsParams( |
| item: item, |
| partialResultToken: partialResultToken, |
| workDoneToken: workDoneToken, |
| ); |
| } |
| |
| final CallHierarchyItem item; |
| |
| /// An optional token that a server can use to report partial results (e.g. |
| /// streaming) to the client. |
| @override |
| final ProgressToken? partialResultToken; |
| |
| /// An optional token that a server can use to report work done progress. |
| @override |
| final ProgressToken? workDoneToken; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['item'] = item.toJson(); |
| if (partialResultToken != null) { |
| result['partialResultToken'] = partialResultToken; |
| } |
| if (workDoneToken != null) { |
| result['workDoneToken'] = workDoneToken; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseCallHierarchyItem(obj, reporter, 'item', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseIntString(obj, reporter, 'partialResultToken', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseIntString(obj, reporter, 'workDoneToken', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CallHierarchyOutgoingCallsParams'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CallHierarchyOutgoingCallsParams && |
| other.runtimeType == CallHierarchyOutgoingCallsParams && |
| item == other.item && |
| partialResultToken == other.partialResultToken && |
| workDoneToken == other.workDoneToken; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| item, |
| partialResultToken, |
| workDoneToken, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The parameter of a `textDocument/prepareCallHierarchy` request. |
| /// |
| /// @since 3.16.0 |
| class CallHierarchyPrepareParams |
| implements TextDocumentPositionParams, WorkDoneProgressParams, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CallHierarchyPrepareParams.canParse, |
| CallHierarchyPrepareParams.fromJson, |
| ); |
| |
| CallHierarchyPrepareParams({ |
| required this.position, |
| required this.textDocument, |
| this.workDoneToken, |
| }); |
| static CallHierarchyPrepareParams fromJson(Map<String, Object?> json) { |
| final positionJson = json['position']; |
| final position = Position.fromJson(positionJson as Map<String, Object?>); |
| final textDocumentJson = json['textDocument']; |
| final textDocument = TextDocumentIdentifier.fromJson( |
| textDocumentJson as Map<String, Object?>); |
| final workDoneTokenJson = json['workDoneToken']; |
| final workDoneToken = |
| workDoneTokenJson == null ? null : _eitherIntString(workDoneTokenJson); |
| return CallHierarchyPrepareParams( |
| position: position, |
| textDocument: textDocument, |
| workDoneToken: workDoneToken, |
| ); |
| } |
| |
| /// The position inside the text document. |
| @override |
| final Position position; |
| |
| /// The text document. |
| @override |
| final TextDocumentIdentifier textDocument; |
| |
| /// An optional token that a server can use to report work done progress. |
| @override |
| final ProgressToken? workDoneToken; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['position'] = position.toJson(); |
| result['textDocument'] = textDocument.toJson(); |
| if (workDoneToken != null) { |
| result['workDoneToken'] = workDoneToken; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParsePosition(obj, reporter, 'position', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseTextDocumentIdentifier(obj, reporter, 'textDocument', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseIntString(obj, reporter, 'workDoneToken', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CallHierarchyPrepareParams'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CallHierarchyPrepareParams && |
| other.runtimeType == CallHierarchyPrepareParams && |
| position == other.position && |
| textDocument == other.textDocument && |
| workDoneToken == other.workDoneToken; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| position, |
| textDocument, |
| workDoneToken, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Call hierarchy options used during static or dynamic registration. |
| /// |
| /// @since 3.16.0 |
| class CallHierarchyRegistrationOptions |
| implements |
| CallHierarchyOptions, |
| StaticRegistrationOptions, |
| TextDocumentRegistrationOptions, |
| ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CallHierarchyRegistrationOptions.canParse, |
| CallHierarchyRegistrationOptions.fromJson, |
| ); |
| |
| CallHierarchyRegistrationOptions({ |
| this.documentSelector, |
| this.id, |
| this.workDoneProgress, |
| }); |
| static CallHierarchyRegistrationOptions fromJson(Map<String, Object?> json) { |
| final documentSelectorJson = json['documentSelector']; |
| final documentSelector = (documentSelectorJson as List<Object?>?) |
| ?.map((item) => |
| TextDocumentFilterWithScheme.fromJson(item as Map<String, Object?>)) |
| .toList(); |
| final idJson = json['id']; |
| final id = idJson as String?; |
| final workDoneProgressJson = json['workDoneProgress']; |
| final workDoneProgress = workDoneProgressJson as bool?; |
| return CallHierarchyRegistrationOptions( |
| documentSelector: documentSelector, |
| id: id, |
| workDoneProgress: workDoneProgress, |
| ); |
| } |
| |
| /// A document selector to identify the scope of the registration. If set to |
| /// null the document selector provided on the client side will be used. |
| @override |
| final List<TextDocumentFilterWithScheme>? documentSelector; |
| |
| /// The id used to register the request. The id can be used to deregister the |
| /// request again. See also Registration#id. |
| @override |
| final String? id; |
| @override |
| final bool? workDoneProgress; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['documentSelector'] = documentSelector; |
| if (id != null) { |
| result['id'] = id; |
| } |
| if (workDoneProgress != null) { |
| result['workDoneProgress'] = workDoneProgress; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseListTextDocumentFilterWithScheme( |
| obj, reporter, 'documentSelector', |
| allowsUndefined: false, allowsNull: true)) { |
| return false; |
| } |
| if (!_canParseString(obj, reporter, 'id', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseBool(obj, reporter, 'workDoneProgress', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CallHierarchyRegistrationOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CallHierarchyRegistrationOptions && |
| other.runtimeType == CallHierarchyRegistrationOptions && |
| listEqual( |
| documentSelector, |
| other.documentSelector, |
| (TextDocumentFilterWithScheme a, TextDocumentFilterWithScheme b) => |
| a == b) && |
| id == other.id && |
| workDoneProgress == other.workDoneProgress; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| lspHashCode(documentSelector), |
| id, |
| workDoneProgress, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class CancelParams implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CancelParams.canParse, |
| CancelParams.fromJson, |
| ); |
| |
| CancelParams({ |
| required this.id, |
| }); |
| static CancelParams fromJson(Map<String, Object?> json) { |
| final idJson = json['id']; |
| final id = _eitherIntString(idJson); |
| return CancelParams( |
| id: id, |
| ); |
| } |
| |
| /// The request id to cancel. |
| final Either2<int, String> id; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['id'] = id; |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseIntString(obj, reporter, 'id', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CancelParams'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CancelParams && |
| other.runtimeType == CancelParams && |
| id == other.id; |
| } |
| |
| @override |
| int get hashCode => id.hashCode; |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Additional information that describes document changes. |
| /// |
| /// @since 3.16.0 |
| class ChangeAnnotation implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| ChangeAnnotation.canParse, |
| ChangeAnnotation.fromJson, |
| ); |
| |
| ChangeAnnotation({ |
| this.description, |
| required this.label, |
| this.needsConfirmation, |
| }); |
| static ChangeAnnotation fromJson(Map<String, Object?> json) { |
| final descriptionJson = json['description']; |
| final description = descriptionJson as String?; |
| final labelJson = json['label']; |
| final label = labelJson as String; |
| final needsConfirmationJson = json['needsConfirmation']; |
| final needsConfirmation = needsConfirmationJson as bool?; |
| return ChangeAnnotation( |
| description: description, |
| label: label, |
| needsConfirmation: needsConfirmation, |
| ); |
| } |
| |
| /// A human-readable string which is rendered less prominent in the user |
| /// interface. |
| final String? description; |
| |
| /// A human-readable string describing the actual change. The string is |
| /// rendered prominent in the user interface. |
| final String label; |
| |
| /// A flag which indicates that user confirmation is needed before applying |
| /// the change. |
| final bool? needsConfirmation; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (description != null) { |
| result['description'] = description; |
| } |
| result['label'] = label; |
| if (needsConfirmation != null) { |
| result['needsConfirmation'] = needsConfirmation; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseString(obj, reporter, 'description', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseString(obj, reporter, 'label', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseBool(obj, reporter, 'needsConfirmation', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type ChangeAnnotation'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is ChangeAnnotation && |
| other.runtimeType == ChangeAnnotation && |
| description == other.description && |
| label == other.label && |
| needsConfirmation == other.needsConfirmation; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| description, |
| label, |
| needsConfirmation, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Defines the capabilities provided by the client. |
| class ClientCapabilities implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| ClientCapabilities.canParse, |
| ClientCapabilities.fromJson, |
| ); |
| |
| ClientCapabilities({ |
| this.experimental, |
| this.general, |
| this.notebookDocument, |
| this.textDocument, |
| this.window, |
| this.workspace, |
| }); |
| static ClientCapabilities fromJson(Map<String, Object?> json) { |
| final experimentalJson = json['experimental']; |
| final experimental = experimentalJson; |
| final generalJson = json['general']; |
| final general = generalJson != null |
| ? GeneralClientCapabilities.fromJson( |
| generalJson as Map<String, Object?>) |
| : null; |
| final notebookDocumentJson = json['notebookDocument']; |
| final notebookDocument = notebookDocumentJson != null |
| ? NotebookDocumentClientCapabilities.fromJson( |
| notebookDocumentJson as Map<String, Object?>) |
| : null; |
| final textDocumentJson = json['textDocument']; |
| final textDocument = textDocumentJson != null |
| ? TextDocumentClientCapabilities.fromJson( |
| textDocumentJson as Map<String, Object?>) |
| : null; |
| final windowJson = json['window']; |
| final window = windowJson != null |
| ? WindowClientCapabilities.fromJson(windowJson as Map<String, Object?>) |
| : null; |
| final workspaceJson = json['workspace']; |
| final workspace = workspaceJson != null |
| ? WorkspaceClientCapabilities.fromJson( |
| workspaceJson as Map<String, Object?>) |
| : null; |
| return ClientCapabilities( |
| experimental: experimental, |
| general: general, |
| notebookDocument: notebookDocument, |
| textDocument: textDocument, |
| window: window, |
| workspace: workspace, |
| ); |
| } |
| |
| /// Experimental client capabilities. |
| final LSPAny experimental; |
| |
| /// General client capabilities. |
| /// |
| /// @since 3.16.0 |
| final GeneralClientCapabilities? general; |
| |
| /// Capabilities specific to the notebook document support. |
| /// |
| /// @since 3.17.0 |
| final NotebookDocumentClientCapabilities? notebookDocument; |
| |
| /// Text document specific client capabilities. |
| final TextDocumentClientCapabilities? textDocument; |
| |
| /// Window specific client capabilities. |
| final WindowClientCapabilities? window; |
| |
| /// Workspace specific client capabilities. |
| final WorkspaceClientCapabilities? workspace; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (experimental != null) { |
| result['experimental'] = experimental; |
| } |
| if (general != null) { |
| result['general'] = general?.toJson(); |
| } |
| if (notebookDocument != null) { |
| result['notebookDocument'] = notebookDocument?.toJson(); |
| } |
| if (textDocument != null) { |
| result['textDocument'] = textDocument?.toJson(); |
| } |
| if (window != null) { |
| result['window'] = window?.toJson(); |
| } |
| if (workspace != null) { |
| result['workspace'] = workspace?.toJson(); |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseGeneralClientCapabilities(obj, reporter, 'general', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseNotebookDocumentClientCapabilities( |
| obj, reporter, 'notebookDocument', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseTextDocumentClientCapabilities( |
| obj, reporter, 'textDocument', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseWindowClientCapabilities(obj, reporter, 'window', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseWorkspaceClientCapabilities(obj, reporter, 'workspace', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type ClientCapabilities'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is ClientCapabilities && |
| other.runtimeType == ClientCapabilities && |
| experimental == other.experimental && |
| general == other.general && |
| notebookDocument == other.notebookDocument && |
| textDocument == other.textDocument && |
| window == other.window && |
| workspace == other.workspace; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| experimental, |
| general, |
| notebookDocument, |
| textDocument, |
| window, |
| workspace, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// A code action represents a change that can be performed in code, e.g. to fix |
| /// a problem or to refactor code. |
| /// |
| /// A CodeAction must set either `edit` and/or a `command`. If both are |
| /// supplied, the `edit` is applied first, then the `command` is executed. |
| class CodeAction implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CodeAction.canParse, |
| CodeAction.fromJson, |
| ); |
| |
| CodeAction({ |
| this.command, |
| this.data, |
| this.diagnostics, |
| this.disabled, |
| this.edit, |
| this.isPreferred, |
| this.kind, |
| required this.title, |
| }); |
| static CodeAction fromJson(Map<String, Object?> json) { |
| final commandJson = json['command']; |
| final command = commandJson != null |
| ? Command.fromJson(commandJson as Map<String, Object?>) |
| : null; |
| final dataJson = json['data']; |
| final data = dataJson; |
| final diagnosticsJson = json['diagnostics']; |
| final diagnostics = (diagnosticsJson as List<Object?>?) |
| ?.map((item) => Diagnostic.fromJson(item as Map<String, Object?>)) |
| .toList(); |
| final disabledJson = json['disabled']; |
| final disabled = disabledJson != null |
| ? CodeActionDisabled.fromJson(disabledJson as Map<String, Object?>) |
| : null; |
| final editJson = json['edit']; |
| final edit = editJson != null |
| ? WorkspaceEdit.fromJson(editJson as Map<String, Object?>) |
| : null; |
| final isPreferredJson = json['isPreferred']; |
| final isPreferred = isPreferredJson as bool?; |
| final kindJson = json['kind']; |
| final kind = |
| kindJson != null ? CodeActionKind.fromJson(kindJson as String) : null; |
| final titleJson = json['title']; |
| final title = titleJson as String; |
| return CodeAction( |
| command: command, |
| data: data, |
| diagnostics: diagnostics, |
| disabled: disabled, |
| edit: edit, |
| isPreferred: isPreferred, |
| kind: kind, |
| title: title, |
| ); |
| } |
| |
| /// A command this code action executes. If a code action provides an edit and |
| /// a command, first the edit is executed and then the command. |
| final Command? command; |
| |
| /// A data entry field that is preserved on a code action between a |
| /// `textDocument/codeAction` and a `codeAction/resolve` request. |
| /// |
| /// @since 3.16.0 |
| final LSPAny data; |
| |
| /// The diagnostics that this code action resolves. |
| final List<Diagnostic>? diagnostics; |
| |
| /// Marks that the code action cannot currently be applied. |
| /// |
| /// Clients should follow the following guidelines regarding disabled code |
| /// actions: |
| /// |
| /// - Disabled code actions are not shown in automatic |
| /// [lightbulbs](https://code.visualstudio.com/docs/editor/editingevolved#_code-action) |
| /// code action menus. |
| /// |
| /// - Disabled actions are shown as faded out in the code action menu when |
| /// the user requests a more specific type |
| /// of code action, such as refactorings. |
| /// |
| /// - If the user has a |
| /// [keybinding](https://code.visualstudio.com/docs/editor/refactoring#_keybindings-for-code-actions) |
| /// that auto applies a code action and only disabled code actions are |
| /// returned, the client should show the user an |
| /// error message with `reason` in the editor. |
| /// |
| /// @since 3.16.0 |
| final CodeActionDisabled? disabled; |
| |
| /// The workspace edit this code action performs. |
| final WorkspaceEdit? edit; |
| |
| /// Marks this as a preferred action. Preferred actions are used by the `auto |
| /// fix` command and can be targeted by keybindings. |
| /// |
| /// A quick fix should be marked preferred if it properly addresses the |
| /// underlying error. A refactoring should be marked preferred if it is the |
| /// most reasonable choice of actions to take. |
| /// |
| /// @since 3.15.0 |
| final bool? isPreferred; |
| |
| /// The kind of the code action. |
| /// |
| /// Used to filter code actions. |
| final CodeActionKind? kind; |
| |
| /// A short, human-readable, title for this code action. |
| final String title; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (command != null) { |
| result['command'] = command?.toJson(); |
| } |
| if (data != null) { |
| result['data'] = data; |
| } |
| if (diagnostics != null) { |
| result['diagnostics'] = |
| diagnostics?.map((item) => item.toJson()).toList(); |
| } |
| if (disabled != null) { |
| result['disabled'] = disabled?.toJson(); |
| } |
| if (edit != null) { |
| result['edit'] = edit?.toJson(); |
| } |
| if (isPreferred != null) { |
| result['isPreferred'] = isPreferred; |
| } |
| if (kind != null) { |
| result['kind'] = kind?.toJson(); |
| } |
| result['title'] = title; |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseCommand(obj, reporter, 'command', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseListDiagnostic(obj, reporter, 'diagnostics', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseCodeActionDisabled(obj, reporter, 'disabled', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseWorkspaceEdit(obj, reporter, 'edit', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'isPreferred', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseCodeActionKind(obj, reporter, 'kind', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseString(obj, reporter, 'title', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CodeAction'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CodeAction && |
| other.runtimeType == CodeAction && |
| command == other.command && |
| data == other.data && |
| listEqual(diagnostics, other.diagnostics, |
| (Diagnostic a, Diagnostic b) => a == b) && |
| disabled == other.disabled && |
| edit == other.edit && |
| isPreferred == other.isPreferred && |
| kind == other.kind && |
| title == other.title; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| command, |
| data, |
| lspHashCode(diagnostics), |
| disabled, |
| edit, |
| isPreferred, |
| kind, |
| title, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The Client Capabilities of a CodeActionRequest. |
| class CodeActionClientCapabilities implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CodeActionClientCapabilities.canParse, |
| CodeActionClientCapabilities.fromJson, |
| ); |
| |
| CodeActionClientCapabilities({ |
| this.codeActionLiteralSupport, |
| this.dataSupport, |
| this.disabledSupport, |
| this.dynamicRegistration, |
| this.honorsChangeAnnotations, |
| this.isPreferredSupport, |
| this.resolveSupport, |
| }); |
| static CodeActionClientCapabilities fromJson(Map<String, Object?> json) { |
| final codeActionLiteralSupportJson = json['codeActionLiteralSupport']; |
| final codeActionLiteralSupport = codeActionLiteralSupportJson != null |
| ? CodeActionClientCapabilitiesCodeActionLiteralSupport.fromJson( |
| codeActionLiteralSupportJson as Map<String, Object?>) |
| : null; |
| final dataSupportJson = json['dataSupport']; |
| final dataSupport = dataSupportJson as bool?; |
| final disabledSupportJson = json['disabledSupport']; |
| final disabledSupport = disabledSupportJson as bool?; |
| final dynamicRegistrationJson = json['dynamicRegistration']; |
| final dynamicRegistration = dynamicRegistrationJson as bool?; |
| final honorsChangeAnnotationsJson = json['honorsChangeAnnotations']; |
| final honorsChangeAnnotations = honorsChangeAnnotationsJson as bool?; |
| final isPreferredSupportJson = json['isPreferredSupport']; |
| final isPreferredSupport = isPreferredSupportJson as bool?; |
| final resolveSupportJson = json['resolveSupport']; |
| final resolveSupport = resolveSupportJson != null |
| ? CodeActionClientCapabilitiesResolveSupport.fromJson( |
| resolveSupportJson as Map<String, Object?>) |
| : null; |
| return CodeActionClientCapabilities( |
| codeActionLiteralSupport: codeActionLiteralSupport, |
| dataSupport: dataSupport, |
| disabledSupport: disabledSupport, |
| dynamicRegistration: dynamicRegistration, |
| honorsChangeAnnotations: honorsChangeAnnotations, |
| isPreferredSupport: isPreferredSupport, |
| resolveSupport: resolveSupport, |
| ); |
| } |
| |
| /// The client support code action literals of type `CodeAction` as a valid |
| /// response of the `textDocument/codeAction` request. If the property is not |
| /// set the request can only return `Command` literals. |
| /// |
| /// @since 3.8.0 |
| final CodeActionClientCapabilitiesCodeActionLiteralSupport? |
| codeActionLiteralSupport; |
| |
| /// Whether code action supports the `data` property which is preserved |
| /// between a `textDocument/codeAction` and a `codeAction/resolve` request. |
| /// |
| /// @since 3.16.0 |
| final bool? dataSupport; |
| |
| /// Whether code action supports the `disabled` property. |
| /// |
| /// @since 3.16.0 |
| final bool? disabledSupport; |
| |
| /// Whether code action supports dynamic registration. |
| final bool? dynamicRegistration; |
| |
| /// Whether the client honors the change annotations in text edits and |
| /// resource operations returned via the `CodeAction#edit` property by for |
| /// example presenting the workspace edit in the user interface and asking for |
| /// confirmation. |
| /// |
| /// @since 3.16.0 |
| final bool? honorsChangeAnnotations; |
| |
| /// Whether code action supports the `isPreferred` property. |
| /// |
| /// @since 3.15.0 |
| final bool? isPreferredSupport; |
| |
| /// Whether the client supports resolving additional code action properties |
| /// via a separate `codeAction/resolve` request. |
| /// |
| /// @since 3.16.0 |
| final CodeActionClientCapabilitiesResolveSupport? resolveSupport; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (codeActionLiteralSupport != null) { |
| result['codeActionLiteralSupport'] = codeActionLiteralSupport?.toJson(); |
| } |
| if (dataSupport != null) { |
| result['dataSupport'] = dataSupport; |
| } |
| if (disabledSupport != null) { |
| result['disabledSupport'] = disabledSupport; |
| } |
| if (dynamicRegistration != null) { |
| result['dynamicRegistration'] = dynamicRegistration; |
| } |
| if (honorsChangeAnnotations != null) { |
| result['honorsChangeAnnotations'] = honorsChangeAnnotations; |
| } |
| if (isPreferredSupport != null) { |
| result['isPreferredSupport'] = isPreferredSupport; |
| } |
| if (resolveSupport != null) { |
| result['resolveSupport'] = resolveSupport?.toJson(); |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseCodeActionClientCapabilitiesCodeActionLiteralSupport( |
| obj, reporter, 'codeActionLiteralSupport', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'dataSupport', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'disabledSupport', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'dynamicRegistration', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'honorsChangeAnnotations', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'isPreferredSupport', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseCodeActionClientCapabilitiesResolveSupport( |
| obj, reporter, 'resolveSupport', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CodeActionClientCapabilities'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CodeActionClientCapabilities && |
| other.runtimeType == CodeActionClientCapabilities && |
| codeActionLiteralSupport == other.codeActionLiteralSupport && |
| dataSupport == other.dataSupport && |
| disabledSupport == other.disabledSupport && |
| dynamicRegistration == other.dynamicRegistration && |
| honorsChangeAnnotations == other.honorsChangeAnnotations && |
| isPreferredSupport == other.isPreferredSupport && |
| resolveSupport == other.resolveSupport; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| codeActionLiteralSupport, |
| dataSupport, |
| disabledSupport, |
| dynamicRegistration, |
| honorsChangeAnnotations, |
| isPreferredSupport, |
| resolveSupport, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class CodeActionClientCapabilitiesCodeActionLiteralSupport |
| implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CodeActionClientCapabilitiesCodeActionLiteralSupport.canParse, |
| CodeActionClientCapabilitiesCodeActionLiteralSupport.fromJson, |
| ); |
| |
| CodeActionClientCapabilitiesCodeActionLiteralSupport({ |
| required this.codeActionKind, |
| }); |
| static CodeActionClientCapabilitiesCodeActionLiteralSupport fromJson( |
| Map<String, Object?> json) { |
| final codeActionKindJson = json['codeActionKind']; |
| final codeActionKind = CodeActionLiteralSupportCodeActionKind.fromJson( |
| codeActionKindJson as Map<String, Object?>); |
| return CodeActionClientCapabilitiesCodeActionLiteralSupport( |
| codeActionKind: codeActionKind, |
| ); |
| } |
| |
| /// The code action kind is support with the following value set. |
| final CodeActionLiteralSupportCodeActionKind codeActionKind; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['codeActionKind'] = codeActionKind.toJson(); |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseCodeActionLiteralSupportCodeActionKind( |
| obj, reporter, 'codeActionKind', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError( |
| 'must be of type CodeActionClientCapabilitiesCodeActionLiteralSupport'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CodeActionClientCapabilitiesCodeActionLiteralSupport && |
| other.runtimeType == |
| CodeActionClientCapabilitiesCodeActionLiteralSupport && |
| codeActionKind == other.codeActionKind; |
| } |
| |
| @override |
| int get hashCode => codeActionKind.hashCode; |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class CodeActionClientCapabilitiesResolveSupport implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CodeActionClientCapabilitiesResolveSupport.canParse, |
| CodeActionClientCapabilitiesResolveSupport.fromJson, |
| ); |
| |
| CodeActionClientCapabilitiesResolveSupport({ |
| required this.properties, |
| }); |
| static CodeActionClientCapabilitiesResolveSupport fromJson( |
| Map<String, Object?> json) { |
| final propertiesJson = json['properties']; |
| final properties = (propertiesJson as List<Object?>) |
| .map((item) => item as String) |
| .toList(); |
| return CodeActionClientCapabilitiesResolveSupport( |
| properties: properties, |
| ); |
| } |
| |
| /// The properties that a client can resolve lazily. |
| final List<String> properties; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['properties'] = properties; |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseListString(obj, reporter, 'properties', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError( |
| 'must be of type CodeActionClientCapabilitiesResolveSupport'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CodeActionClientCapabilitiesResolveSupport && |
| other.runtimeType == CodeActionClientCapabilitiesResolveSupport && |
| listEqual(properties, other.properties, (String a, String b) => a == b); |
| } |
| |
| @override |
| int get hashCode => lspHashCode(properties); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Contains additional diagnostic information about the context in which a code |
| /// action is run. |
| class CodeActionContext implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CodeActionContext.canParse, |
| CodeActionContext.fromJson, |
| ); |
| |
| CodeActionContext({ |
| required this.diagnostics, |
| this.only, |
| this.triggerKind, |
| }); |
| static CodeActionContext fromJson(Map<String, Object?> json) { |
| final diagnosticsJson = json['diagnostics']; |
| final diagnostics = (diagnosticsJson as List<Object?>) |
| .map((item) => Diagnostic.fromJson(item as Map<String, Object?>)) |
| .toList(); |
| final onlyJson = json['only']; |
| final only = (onlyJson as List<Object?>?) |
| ?.map((item) => CodeActionKind.fromJson(item as String)) |
| .toList(); |
| final triggerKindJson = json['triggerKind']; |
| final triggerKind = triggerKindJson != null |
| ? CodeActionTriggerKind.fromJson(triggerKindJson as int) |
| : null; |
| return CodeActionContext( |
| diagnostics: diagnostics, |
| only: only, |
| triggerKind: triggerKind, |
| ); |
| } |
| |
| /// An array of diagnostics known on the client side overlapping the range |
| /// provided to the `textDocument/codeAction` request. They are provided so |
| /// that the server knows which errors are currently presented to the user for |
| /// the given range. There is no guarantee that these accurately reflect the |
| /// error state of the resource. The primary parameter to compute code actions |
| /// is the provided range. |
| final List<Diagnostic> diagnostics; |
| |
| /// Requested kind of actions to return. |
| /// |
| /// Actions not of this kind are filtered out by the client before being |
| /// shown. So servers can omit computing them. |
| final List<CodeActionKind>? only; |
| |
| /// The reason why code actions were requested. |
| /// |
| /// @since 3.17.0 |
| final CodeActionTriggerKind? triggerKind; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['diagnostics'] = diagnostics.map((item) => item.toJson()).toList(); |
| if (only != null) { |
| result['only'] = only?.map((item) => item.toJson()).toList(); |
| } |
| if (triggerKind != null) { |
| result['triggerKind'] = triggerKind?.toJson(); |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseListDiagnostic(obj, reporter, 'diagnostics', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseListCodeActionKind(obj, reporter, 'only', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseCodeActionTriggerKind(obj, reporter, 'triggerKind', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CodeActionContext'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CodeActionContext && |
| other.runtimeType == CodeActionContext && |
| listEqual(diagnostics, other.diagnostics, |
| (Diagnostic a, Diagnostic b) => a == b) && |
| listEqual( |
| only, other.only, (CodeActionKind a, CodeActionKind b) => a == b) && |
| triggerKind == other.triggerKind; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| lspHashCode(diagnostics), |
| lspHashCode(only), |
| triggerKind, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class CodeActionDisabled implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CodeActionDisabled.canParse, |
| CodeActionDisabled.fromJson, |
| ); |
| |
| CodeActionDisabled({ |
| required this.reason, |
| }); |
| static CodeActionDisabled fromJson(Map<String, Object?> json) { |
| final reasonJson = json['reason']; |
| final reason = reasonJson as String; |
| return CodeActionDisabled( |
| reason: reason, |
| ); |
| } |
| |
| /// Human readable description of why the code action is currently disabled. |
| /// |
| /// This is displayed in the code actions UI. |
| final String reason; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['reason'] = reason; |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseString(obj, reporter, 'reason', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CodeActionDisabled'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CodeActionDisabled && |
| other.runtimeType == CodeActionDisabled && |
| reason == other.reason; |
| } |
| |
| @override |
| int get hashCode => reason.hashCode; |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// A set of predefined code action kinds |
| class CodeActionKind implements ToJsonable { |
| const CodeActionKind(this._value); |
| const CodeActionKind.fromJson(this._value); |
| |
| final String _value; |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) => 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 auto-fix source actions: `source.fixAll`. |
| /// |
| /// Fix all actions automatically fix errors that have a clear fix that do not |
| /// require user input. They should not suppress errors or perform unsafe |
| /// fixes such as generating new types or classes. |
| /// |
| /// @since 3.15.0 |
| static const SourceFixAll = CodeActionKind('source.fixAll'); |
| |
| /// Base kind for an organize imports source action: `source.organizeImports` |
| static const SourceOrganizeImports = CodeActionKind('source.organizeImports'); |
| |
| @override |
| Object toJson() => _value; |
| |
| @override |
| String toString() => _value.toString(); |
| |
| @override |
| int get hashCode => _value.hashCode; |
| |
| @override |
| bool operator ==(Object other) => |
| other is CodeActionKind && other._value == _value; |
| } |
| |
| class CodeActionLiteralSupportCodeActionKind implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CodeActionLiteralSupportCodeActionKind.canParse, |
| CodeActionLiteralSupportCodeActionKind.fromJson, |
| ); |
| |
| CodeActionLiteralSupportCodeActionKind({ |
| required this.valueSet, |
| }); |
| static CodeActionLiteralSupportCodeActionKind fromJson( |
| Map<String, Object?> json) { |
| final valueSetJson = json['valueSet']; |
| final valueSet = (valueSetJson as List<Object?>) |
| .map((item) => CodeActionKind.fromJson(item as String)) |
| .toList(); |
| return CodeActionLiteralSupportCodeActionKind( |
| valueSet: valueSet, |
| ); |
| } |
| |
| /// The code action kind values the client supports. When this property exists |
| /// the client also guarantees that it will handle values outside its set |
| /// gracefully and falls back to a default value when unknown. |
| final List<CodeActionKind> valueSet; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['valueSet'] = valueSet.map((item) => item.toJson()).toList(); |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseListCodeActionKind(obj, reporter, 'valueSet', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError( |
| 'must be of type CodeActionLiteralSupportCodeActionKind'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CodeActionLiteralSupportCodeActionKind && |
| other.runtimeType == CodeActionLiteralSupportCodeActionKind && |
| listEqual(valueSet, other.valueSet, |
| (CodeActionKind a, CodeActionKind b) => a == b); |
| } |
| |
| @override |
| int get hashCode => lspHashCode(valueSet); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Provider options for a CodeActionRequest. |
| class CodeActionOptions implements WorkDoneProgressOptions, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CodeActionOptions.canParse, |
| CodeActionOptions.fromJson, |
| ); |
| |
| CodeActionOptions({ |
| this.codeActionKinds, |
| this.resolveProvider, |
| this.workDoneProgress, |
| }); |
| static CodeActionOptions fromJson(Map<String, Object?> json) { |
| if (CodeActionRegistrationOptions.canParse(json, nullLspJsonReporter)) { |
| return CodeActionRegistrationOptions.fromJson(json); |
| } |
| final codeActionKindsJson = json['codeActionKinds']; |
| final codeActionKinds = (codeActionKindsJson as List<Object?>?) |
| ?.map((item) => CodeActionKind.fromJson(item as String)) |
| .toList(); |
| final resolveProviderJson = json['resolveProvider']; |
| final resolveProvider = resolveProviderJson as bool?; |
| final workDoneProgressJson = json['workDoneProgress']; |
| final workDoneProgress = workDoneProgressJson as bool?; |
| return CodeActionOptions( |
| codeActionKinds: codeActionKinds, |
| resolveProvider: resolveProvider, |
| workDoneProgress: workDoneProgress, |
| ); |
| } |
| |
| /// CodeActionKinds that this server may return. |
| /// |
| /// The list of kinds may be generic, such as `CodeActionKind.Refactor`, or |
| /// the server may list out every specific kind they provide. |
| final List<CodeActionKind>? codeActionKinds; |
| |
| /// The server provides support to resolve additional information for a code |
| /// action. |
| /// |
| /// @since 3.16.0 |
| final bool? resolveProvider; |
| @override |
| final bool? workDoneProgress; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (codeActionKinds != null) { |
| result['codeActionKinds'] = |
| codeActionKinds?.map((item) => item.toJson()).toList(); |
| } |
| if (resolveProvider != null) { |
| result['resolveProvider'] = resolveProvider; |
| } |
| if (workDoneProgress != null) { |
| result['workDoneProgress'] = workDoneProgress; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseListCodeActionKind(obj, reporter, 'codeActionKinds', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'resolveProvider', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseBool(obj, reporter, 'workDoneProgress', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CodeActionOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CodeActionOptions && |
| other.runtimeType == CodeActionOptions && |
| listEqual(codeActionKinds, other.codeActionKinds, |
| (CodeActionKind a, CodeActionKind b) => a == b) && |
| resolveProvider == other.resolveProvider && |
| workDoneProgress == other.workDoneProgress; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| lspHashCode(codeActionKinds), |
| resolveProvider, |
| workDoneProgress, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The parameters of a CodeActionRequest. |
| class CodeActionParams |
| implements PartialResultParams, WorkDoneProgressParams, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CodeActionParams.canParse, |
| CodeActionParams.fromJson, |
| ); |
| |
| CodeActionParams({ |
| required this.context, |
| this.partialResultToken, |
| required this.range, |
| required this.textDocument, |
| this.workDoneToken, |
| }); |
| static CodeActionParams fromJson(Map<String, Object?> json) { |
| final contextJson = json['context']; |
| final context = |
| CodeActionContext.fromJson(contextJson as Map<String, Object?>); |
| final partialResultTokenJson = json['partialResultToken']; |
| final partialResultToken = partialResultTokenJson == null |
| ? null |
| : _eitherIntString(partialResultTokenJson); |
| final rangeJson = json['range']; |
| final range = Range.fromJson(rangeJson as Map<String, Object?>); |
| final textDocumentJson = json['textDocument']; |
| final textDocument = TextDocumentIdentifier.fromJson( |
| textDocumentJson as Map<String, Object?>); |
| final workDoneTokenJson = json['workDoneToken']; |
| final workDoneToken = |
| workDoneTokenJson == null ? null : _eitherIntString(workDoneTokenJson); |
| return CodeActionParams( |
| context: context, |
| partialResultToken: partialResultToken, |
| range: range, |
| textDocument: textDocument, |
| workDoneToken: workDoneToken, |
| ); |
| } |
| |
| /// Context carrying additional information. |
| final CodeActionContext context; |
| |
| /// An optional token that a server can use to report partial results (e.g. |
| /// streaming) to the client. |
| @override |
| final ProgressToken? 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. |
| @override |
| final ProgressToken? workDoneToken; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['context'] = context.toJson(); |
| if (partialResultToken != null) { |
| result['partialResultToken'] = partialResultToken; |
| } |
| result['range'] = range.toJson(); |
| result['textDocument'] = textDocument.toJson(); |
| if (workDoneToken != null) { |
| result['workDoneToken'] = workDoneToken; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseCodeActionContext(obj, reporter, 'context', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseIntString(obj, reporter, 'partialResultToken', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseRange(obj, reporter, 'range', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseTextDocumentIdentifier(obj, reporter, 'textDocument', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseIntString(obj, reporter, 'workDoneToken', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CodeActionParams'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CodeActionParams && |
| other.runtimeType == CodeActionParams && |
| context == other.context && |
| partialResultToken == other.partialResultToken && |
| range == other.range && |
| textDocument == other.textDocument && |
| workDoneToken == other.workDoneToken; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| context, |
| partialResultToken, |
| range, |
| textDocument, |
| workDoneToken, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Registration options for a CodeActionRequest. |
| class CodeActionRegistrationOptions |
| implements CodeActionOptions, TextDocumentRegistrationOptions, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CodeActionRegistrationOptions.canParse, |
| CodeActionRegistrationOptions.fromJson, |
| ); |
| |
| CodeActionRegistrationOptions({ |
| this.codeActionKinds, |
| this.documentSelector, |
| this.resolveProvider, |
| this.workDoneProgress, |
| }); |
| static CodeActionRegistrationOptions fromJson(Map<String, Object?> json) { |
| final codeActionKindsJson = json['codeActionKinds']; |
| final codeActionKinds = (codeActionKindsJson as List<Object?>?) |
| ?.map((item) => CodeActionKind.fromJson(item as String)) |
| .toList(); |
| final documentSelectorJson = json['documentSelector']; |
| final documentSelector = (documentSelectorJson as List<Object?>?) |
| ?.map((item) => |
| TextDocumentFilterWithScheme.fromJson(item as Map<String, Object?>)) |
| .toList(); |
| final resolveProviderJson = json['resolveProvider']; |
| final resolveProvider = resolveProviderJson as bool?; |
| final workDoneProgressJson = json['workDoneProgress']; |
| final workDoneProgress = workDoneProgressJson as bool?; |
| return CodeActionRegistrationOptions( |
| codeActionKinds: codeActionKinds, |
| documentSelector: documentSelector, |
| resolveProvider: resolveProvider, |
| workDoneProgress: workDoneProgress, |
| ); |
| } |
| |
| /// CodeActionKinds that this server may return. |
| /// |
| /// The list of kinds may be generic, such as `CodeActionKind.Refactor`, or |
| /// the server may list out every specific kind they provide. |
| @override |
| 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. |
| @override |
| final List<TextDocumentFilterWithScheme>? documentSelector; |
| |
| /// The server provides support to resolve additional information for a code |
| /// action. |
| /// |
| /// @since 3.16.0 |
| @override |
| final bool? resolveProvider; |
| @override |
| final bool? workDoneProgress; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (codeActionKinds != null) { |
| result['codeActionKinds'] = |
| codeActionKinds?.map((item) => item.toJson()).toList(); |
| } |
| result['documentSelector'] = documentSelector; |
| if (resolveProvider != null) { |
| result['resolveProvider'] = resolveProvider; |
| } |
| if (workDoneProgress != null) { |
| result['workDoneProgress'] = workDoneProgress; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseListCodeActionKind(obj, reporter, 'codeActionKinds', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseListTextDocumentFilterWithScheme( |
| obj, reporter, 'documentSelector', |
| allowsUndefined: false, allowsNull: true)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'resolveProvider', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseBool(obj, reporter, 'workDoneProgress', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CodeActionRegistrationOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CodeActionRegistrationOptions && |
| other.runtimeType == CodeActionRegistrationOptions && |
| listEqual(codeActionKinds, other.codeActionKinds, |
| (CodeActionKind a, CodeActionKind b) => a == b) && |
| listEqual( |
| documentSelector, |
| other.documentSelector, |
| (TextDocumentFilterWithScheme a, TextDocumentFilterWithScheme b) => |
| a == b) && |
| resolveProvider == other.resolveProvider && |
| workDoneProgress == other.workDoneProgress; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| lspHashCode(codeActionKinds), |
| lspHashCode(documentSelector), |
| resolveProvider, |
| workDoneProgress, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The reason why code actions were requested. |
| /// |
| /// @since 3.17.0 |
| class CodeActionTriggerKind implements ToJsonable { |
| const CodeActionTriggerKind(this._value); |
| const CodeActionTriggerKind.fromJson(this._value); |
| |
| final int _value; |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) => obj is int; |
| |
| /// Code actions were requested automatically. |
| /// |
| /// This typically happens when current selection in a file changes, but can |
| /// also be triggered when file content changes. |
| static const Automatic = CodeActionTriggerKind(2); |
| |
| /// Code actions were explicitly requested by the user or by an extension. |
| static const Invoked = CodeActionTriggerKind(1); |
| |
| @override |
| Object toJson() => _value; |
| |
| @override |
| String toString() => _value.toString(); |
| |
| @override |
| int get hashCode => _value.hashCode; |
| |
| @override |
| bool operator ==(Object other) => |
| other is CodeActionTriggerKind && other._value == _value; |
| } |
| |
| /// Structure to capture a description for an error code. |
| /// |
| /// @since 3.16.0 |
| class CodeDescription implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CodeDescription.canParse, |
| CodeDescription.fromJson, |
| ); |
| |
| CodeDescription({ |
| required this.href, |
| }); |
| static CodeDescription fromJson(Map<String, Object?> json) { |
| final hrefJson = json['href']; |
| final href = hrefJson as String; |
| return CodeDescription( |
| href: href, |
| ); |
| } |
| |
| /// An URI to open with more information about the diagnostic error. |
| final LspUri href; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['href'] = href; |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseString(obj, reporter, 'href', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CodeDescription'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CodeDescription && |
| other.runtimeType == CodeDescription && |
| href == other.href; |
| } |
| |
| @override |
| int get hashCode => href.hashCode; |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// A code lens represents a command that should be shown along with source |
| /// text, like the number of references, a way to run tests, etc. |
| /// |
| /// A code lens is _unresolved_ when no command is associated to it. For |
| /// performance reasons the creation of a code lens and resolving should be done |
| /// in two stages. |
| class CodeLens implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CodeLens.canParse, |
| CodeLens.fromJson, |
| ); |
| |
| CodeLens({ |
| this.command, |
| this.data, |
| required this.range, |
| }); |
| static CodeLens fromJson(Map<String, Object?> json) { |
| final commandJson = json['command']; |
| final command = commandJson != null |
| ? Command.fromJson(commandJson as Map<String, Object?>) |
| : null; |
| final dataJson = json['data']; |
| final data = dataJson; |
| final rangeJson = json['range']; |
| final range = Range.fromJson(rangeJson as Map<String, Object?>); |
| return CodeLens( |
| command: command, |
| data: data, |
| range: range, |
| ); |
| } |
| |
| /// The command this code lens represents. |
| final Command? command; |
| |
| /// A data entry field that is preserved on a code lens item between a |
| /// CodeLensRequest and a CodeLensResolveRequest |
| final LSPAny data; |
| |
| /// The range in which this code lens is valid. Should only span a single |
| /// line. |
| final Range range; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (command != null) { |
| result['command'] = command?.toJson(); |
| } |
| if (data != null) { |
| result['data'] = data; |
| } |
| result['range'] = range.toJson(); |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseCommand(obj, reporter, 'command', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseRange(obj, reporter, 'range', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CodeLens'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CodeLens && |
| other.runtimeType == CodeLens && |
| command == other.command && |
| data == other.data && |
| range == other.range; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| command, |
| data, |
| range, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The client capabilities of a CodeLensRequest. |
| class CodeLensClientCapabilities implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CodeLensClientCapabilities.canParse, |
| CodeLensClientCapabilities.fromJson, |
| ); |
| |
| CodeLensClientCapabilities({ |
| this.dynamicRegistration, |
| }); |
| static CodeLensClientCapabilities fromJson(Map<String, Object?> json) { |
| final dynamicRegistrationJson = json['dynamicRegistration']; |
| final dynamicRegistration = dynamicRegistrationJson as bool?; |
| return CodeLensClientCapabilities( |
| dynamicRegistration: dynamicRegistration, |
| ); |
| } |
| |
| /// Whether code lens supports dynamic registration. |
| final bool? dynamicRegistration; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (dynamicRegistration != null) { |
| result['dynamicRegistration'] = dynamicRegistration; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseBool(obj, reporter, 'dynamicRegistration', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CodeLensClientCapabilities'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CodeLensClientCapabilities && |
| other.runtimeType == CodeLensClientCapabilities && |
| dynamicRegistration == other.dynamicRegistration; |
| } |
| |
| @override |
| int get hashCode => dynamicRegistration.hashCode; |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Code Lens provider options of a CodeLensRequest. |
| class CodeLensOptions implements WorkDoneProgressOptions, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CodeLensOptions.canParse, |
| CodeLensOptions.fromJson, |
| ); |
| |
| CodeLensOptions({ |
| this.resolveProvider, |
| this.workDoneProgress, |
| }); |
| static CodeLensOptions fromJson(Map<String, Object?> json) { |
| if (CodeLensRegistrationOptions.canParse(json, nullLspJsonReporter)) { |
| return CodeLensRegistrationOptions.fromJson(json); |
| } |
| final resolveProviderJson = json['resolveProvider']; |
| final resolveProvider = resolveProviderJson as bool?; |
| final workDoneProgressJson = json['workDoneProgress']; |
| final workDoneProgress = workDoneProgressJson as bool?; |
| return CodeLensOptions( |
| resolveProvider: resolveProvider, |
| workDoneProgress: workDoneProgress, |
| ); |
| } |
| |
| /// Code lens has a resolve provider as well. |
| final bool? resolveProvider; |
| @override |
| final bool? workDoneProgress; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (resolveProvider != null) { |
| result['resolveProvider'] = resolveProvider; |
| } |
| if (workDoneProgress != null) { |
| result['workDoneProgress'] = workDoneProgress; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseBool(obj, reporter, 'resolveProvider', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseBool(obj, reporter, 'workDoneProgress', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CodeLensOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CodeLensOptions && |
| other.runtimeType == CodeLensOptions && |
| resolveProvider == other.resolveProvider && |
| workDoneProgress == other.workDoneProgress; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| resolveProvider, |
| workDoneProgress, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The parameters of a CodeLensRequest. |
| class CodeLensParams |
| implements PartialResultParams, WorkDoneProgressParams, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CodeLensParams.canParse, |
| CodeLensParams.fromJson, |
| ); |
| |
| CodeLensParams({ |
| this.partialResultToken, |
| required this.textDocument, |
| this.workDoneToken, |
| }); |
| static CodeLensParams fromJson(Map<String, Object?> json) { |
| final partialResultTokenJson = json['partialResultToken']; |
| final partialResultToken = partialResultTokenJson == null |
| ? null |
| : _eitherIntString(partialResultTokenJson); |
| final textDocumentJson = json['textDocument']; |
| final textDocument = TextDocumentIdentifier.fromJson( |
| textDocumentJson as Map<String, Object?>); |
| final workDoneTokenJson = json['workDoneToken']; |
| final workDoneToken = |
| workDoneTokenJson == null ? null : _eitherIntString(workDoneTokenJson); |
| return CodeLensParams( |
| partialResultToken: partialResultToken, |
| textDocument: textDocument, |
| workDoneToken: workDoneToken, |
| ); |
| } |
| |
| /// An optional token that a server can use to report partial results (e.g. |
| /// streaming) to the client. |
| @override |
| final ProgressToken? partialResultToken; |
| |
| /// The document to request code lens for. |
| final TextDocumentIdentifier textDocument; |
| |
| /// An optional token that a server can use to report work done progress. |
| @override |
| final ProgressToken? workDoneToken; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (partialResultToken != null) { |
| result['partialResultToken'] = partialResultToken; |
| } |
| result['textDocument'] = textDocument.toJson(); |
| if (workDoneToken != null) { |
| result['workDoneToken'] = workDoneToken; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseIntString(obj, reporter, 'partialResultToken', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseTextDocumentIdentifier(obj, reporter, 'textDocument', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseIntString(obj, reporter, 'workDoneToken', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CodeLensParams'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CodeLensParams && |
| other.runtimeType == CodeLensParams && |
| partialResultToken == other.partialResultToken && |
| textDocument == other.textDocument && |
| workDoneToken == other.workDoneToken; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| partialResultToken, |
| textDocument, |
| workDoneToken, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Registration options for a CodeLensRequest. |
| class CodeLensRegistrationOptions |
| implements CodeLensOptions, TextDocumentRegistrationOptions, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CodeLensRegistrationOptions.canParse, |
| CodeLensRegistrationOptions.fromJson, |
| ); |
| |
| CodeLensRegistrationOptions({ |
| this.documentSelector, |
| this.resolveProvider, |
| this.workDoneProgress, |
| }); |
| static CodeLensRegistrationOptions fromJson(Map<String, Object?> json) { |
| final documentSelectorJson = json['documentSelector']; |
| final documentSelector = (documentSelectorJson as List<Object?>?) |
| ?.map((item) => |
| TextDocumentFilterWithScheme.fromJson(item as Map<String, Object?>)) |
| .toList(); |
| final resolveProviderJson = json['resolveProvider']; |
| final resolveProvider = resolveProviderJson as bool?; |
| final workDoneProgressJson = json['workDoneProgress']; |
| final workDoneProgress = workDoneProgressJson as bool?; |
| return CodeLensRegistrationOptions( |
| documentSelector: documentSelector, |
| resolveProvider: resolveProvider, |
| workDoneProgress: workDoneProgress, |
| ); |
| } |
| |
| /// A document selector to identify the scope of the registration. If set to |
| /// null the document selector provided on the client side will be used. |
| @override |
| final List<TextDocumentFilterWithScheme>? documentSelector; |
| |
| /// Code lens has a resolve provider as well. |
| @override |
| final bool? resolveProvider; |
| @override |
| final bool? workDoneProgress; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['documentSelector'] = documentSelector; |
| if (resolveProvider != null) { |
| result['resolveProvider'] = resolveProvider; |
| } |
| if (workDoneProgress != null) { |
| result['workDoneProgress'] = workDoneProgress; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseListTextDocumentFilterWithScheme( |
| obj, reporter, 'documentSelector', |
| allowsUndefined: false, allowsNull: true)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'resolveProvider', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseBool(obj, reporter, 'workDoneProgress', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CodeLensRegistrationOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CodeLensRegistrationOptions && |
| other.runtimeType == CodeLensRegistrationOptions && |
| listEqual( |
| documentSelector, |
| other.documentSelector, |
| (TextDocumentFilterWithScheme a, TextDocumentFilterWithScheme b) => |
| a == b) && |
| resolveProvider == other.resolveProvider && |
| workDoneProgress == other.workDoneProgress; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| lspHashCode(documentSelector), |
| resolveProvider, |
| workDoneProgress, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// @since 3.16.0 |
| class CodeLensWorkspaceClientCapabilities implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CodeLensWorkspaceClientCapabilities.canParse, |
| CodeLensWorkspaceClientCapabilities.fromJson, |
| ); |
| |
| CodeLensWorkspaceClientCapabilities({ |
| this.refreshSupport, |
| }); |
| static CodeLensWorkspaceClientCapabilities fromJson( |
| Map<String, Object?> json) { |
| final refreshSupportJson = json['refreshSupport']; |
| final refreshSupport = refreshSupportJson as bool?; |
| return CodeLensWorkspaceClientCapabilities( |
| refreshSupport: refreshSupport, |
| ); |
| } |
| |
| /// Whether the client implementation supports a refresh request sent from the |
| /// server to the client. |
| /// |
| /// Note that this event is global and will force the client to refresh all |
| /// code lenses currently shown. It should be used with absolute care and is |
| /// useful for situation where a server for example detect a project wide |
| /// change that requires such a calculation. |
| final bool? refreshSupport; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (refreshSupport != null) { |
| result['refreshSupport'] = refreshSupport; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseBool(obj, reporter, 'refreshSupport', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter |
| .reportError('must be of type CodeLensWorkspaceClientCapabilities'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CodeLensWorkspaceClientCapabilities && |
| other.runtimeType == CodeLensWorkspaceClientCapabilities && |
| refreshSupport == other.refreshSupport; |
| } |
| |
| @override |
| int get hashCode => refreshSupport.hashCode; |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Represents a color in RGBA space. |
| class Color implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| Color.canParse, |
| Color.fromJson, |
| ); |
| |
| Color({ |
| required this.alpha, |
| required this.blue, |
| required this.green, |
| required this.red, |
| }); |
| static Color fromJson(Map<String, Object?> json) { |
| final alphaJson = json['alpha']; |
| final alpha = alphaJson as num; |
| final blueJson = json['blue']; |
| final blue = blueJson as num; |
| final greenJson = json['green']; |
| final green = greenJson as num; |
| final redJson = json['red']; |
| final red = redJson as num; |
| return Color( |
| alpha: alpha, |
| blue: blue, |
| green: green, |
| red: red, |
| ); |
| } |
| |
| /// The alpha component of this color in the range [0-1]. |
| final num alpha; |
| |
| /// The blue component of this color in the range [0-1]. |
| final num blue; |
| |
| /// The green component of this color in the range [0-1]. |
| final num green; |
| |
| /// The red component of this color in the range [0-1]. |
| final num red; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['alpha'] = alpha; |
| result['blue'] = blue; |
| result['green'] = green; |
| result['red'] = red; |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseNum(obj, reporter, 'alpha', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseNum(obj, reporter, 'blue', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseNum(obj, reporter, 'green', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseNum(obj, reporter, 'red', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type Color'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is Color && |
| other.runtimeType == Color && |
| alpha == other.alpha && |
| blue == other.blue && |
| green == other.green && |
| red == other.red; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| alpha, |
| blue, |
| green, |
| red, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Represents a color range from a document. |
| class ColorInformation implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| ColorInformation.canParse, |
| ColorInformation.fromJson, |
| ); |
| |
| ColorInformation({ |
| required this.color, |
| required this.range, |
| }); |
| static ColorInformation fromJson(Map<String, Object?> json) { |
| final colorJson = json['color']; |
| final color = Color.fromJson(colorJson as Map<String, Object?>); |
| final rangeJson = json['range']; |
| final range = Range.fromJson(rangeJson as Map<String, Object?>); |
| return ColorInformation( |
| color: color, |
| range: range, |
| ); |
| } |
| |
| /// The actual color value for this color range. |
| final Color color; |
| |
| /// The range in the document where this color appears. |
| final Range range; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['color'] = color.toJson(); |
| result['range'] = range.toJson(); |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseColor(obj, reporter, 'color', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseRange(obj, reporter, 'range', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type ColorInformation'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is ColorInformation && |
| other.runtimeType == ColorInformation && |
| color == other.color && |
| range == other.range; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| color, |
| range, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class ColorPresentation implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| ColorPresentation.canParse, |
| ColorPresentation.fromJson, |
| ); |
| |
| ColorPresentation({ |
| this.additionalTextEdits, |
| required this.label, |
| this.textEdit, |
| }); |
| static ColorPresentation fromJson(Map<String, Object?> json) { |
| final additionalTextEditsJson = json['additionalTextEdits']; |
| final additionalTextEdits = (additionalTextEditsJson as List<Object?>?) |
| ?.map((item) => TextEdit.fromJson(item as Map<String, Object?>)) |
| .toList(); |
| final labelJson = json['label']; |
| final label = labelJson as String; |
| final textEditJson = json['textEdit']; |
| final textEdit = textEditJson != null |
| ? TextEdit.fromJson(textEditJson as Map<String, Object?>) |
| : null; |
| return ColorPresentation( |
| additionalTextEdits: additionalTextEdits, |
| label: label, |
| textEdit: textEdit, |
| ); |
| } |
| |
| /// An optional array of additional text edits that are applied when selecting |
| /// this color presentation. Edits must not overlap with the main edit 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 which is applied to a document when selecting this presentation |
| /// for the color. When `falsy` the label is used. |
| final TextEdit? textEdit; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (additionalTextEdits != null) { |
| result['additionalTextEdits'] = |
| additionalTextEdits?.map((item) => item.toJson()).toList(); |
| } |
| result['label'] = label; |
| if (textEdit != null) { |
| result['textEdit'] = textEdit?.toJson(); |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseListTextEdit(obj, reporter, 'additionalTextEdits', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseString(obj, reporter, 'label', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseTextEdit(obj, reporter, 'textEdit', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type ColorPresentation'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is ColorPresentation && |
| other.runtimeType == ColorPresentation && |
| listEqual(additionalTextEdits, other.additionalTextEdits, |
| (TextEdit a, TextEdit b) => a == b) && |
| label == other.label && |
| textEdit == other.textEdit; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| lspHashCode(additionalTextEdits), |
| label, |
| textEdit, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Parameters for a ColorPresentationRequest. |
| class ColorPresentationParams |
| implements PartialResultParams, WorkDoneProgressParams, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| ColorPresentationParams.canParse, |
| ColorPresentationParams.fromJson, |
| ); |
| |
| ColorPresentationParams({ |
| required this.color, |
| this.partialResultToken, |
| required this.range, |
| required this.textDocument, |
| this.workDoneToken, |
| }); |
| static ColorPresentationParams fromJson(Map<String, Object?> json) { |
| final colorJson = json['color']; |
| final color = Color.fromJson(colorJson as Map<String, Object?>); |
| final partialResultTokenJson = json['partialResultToken']; |
| final partialResultToken = partialResultTokenJson == null |
| ? null |
| : _eitherIntString(partialResultTokenJson); |
| final rangeJson = json['range']; |
| final range = Range.fromJson(rangeJson as Map<String, Object?>); |
| final textDocumentJson = json['textDocument']; |
| final textDocument = TextDocumentIdentifier.fromJson( |
| textDocumentJson as Map<String, Object?>); |
| final workDoneTokenJson = json['workDoneToken']; |
| final workDoneToken = |
| workDoneTokenJson == null ? null : _eitherIntString(workDoneTokenJson); |
| return ColorPresentationParams( |
| color: color, |
| partialResultToken: partialResultToken, |
| range: range, |
| textDocument: textDocument, |
| workDoneToken: workDoneToken, |
| ); |
| } |
| |
| /// The color 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. |
| @override |
| final ProgressToken? 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. |
| @override |
| final ProgressToken? workDoneToken; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['color'] = color.toJson(); |
| if (partialResultToken != null) { |
| result['partialResultToken'] = partialResultToken; |
| } |
| result['range'] = range.toJson(); |
| result['textDocument'] = textDocument.toJson(); |
| if (workDoneToken != null) { |
| result['workDoneToken'] = workDoneToken; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseColor(obj, reporter, 'color', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseIntString(obj, reporter, 'partialResultToken', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseRange(obj, reporter, 'range', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseTextDocumentIdentifier(obj, reporter, 'textDocument', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseIntString(obj, reporter, 'workDoneToken', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type ColorPresentationParams'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is ColorPresentationParams && |
| other.runtimeType == ColorPresentationParams && |
| color == other.color && |
| partialResultToken == other.partialResultToken && |
| range == other.range && |
| textDocument == other.textDocument && |
| workDoneToken == other.workDoneToken; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| color, |
| partialResultToken, |
| range, |
| textDocument, |
| workDoneToken, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Represents a reference to a command. Provides a title which will be used to |
| /// represent a command in the UI and, optionally, |
| /// an array of arguments which will be passed to the command handler function |
| /// when invoked. |
| class Command implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| Command.canParse, |
| Command.fromJson, |
| ); |
| |
| Command({ |
| this.arguments, |
| required this.command, |
| required this.title, |
| }); |
| static Command fromJson(Map<String, Object?> json) { |
| final argumentsJson = json['arguments']; |
| final arguments = |
| (argumentsJson as List<Object?>?)?.map((item) => item).toList(); |
| final commandJson = json['command']; |
| final command = commandJson as String; |
| final titleJson = json['title']; |
| final title = titleJson as String; |
| return Command( |
| arguments: arguments, |
| command: command, |
| title: title, |
| ); |
| } |
| |
| /// Arguments that the command handler should be invoked with. |
| final List<LSPAny>? arguments; |
| |
| /// The identifier of the actual command handler. |
| final String command; |
| |
| /// Title of the command, like `save`. |
| final String title; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (arguments != null) { |
| result['arguments'] = arguments; |
| } |
| result['command'] = command; |
| result['title'] = title; |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseListObjectNullable(obj, reporter, 'arguments', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseString(obj, reporter, 'command', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseString(obj, reporter, 'title', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type Command'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is Command && |
| other.runtimeType == Command && |
| listEqual(arguments, other.arguments, (LSPAny a, LSPAny b) => a == b) && |
| command == other.command && |
| title == other.title; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| lspHashCode(arguments), |
| command, |
| title, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Completion client capabilities |
| class CompletionClientCapabilities implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CompletionClientCapabilities.canParse, |
| CompletionClientCapabilities.fromJson, |
| ); |
| |
| CompletionClientCapabilities({ |
| this.completionItem, |
| this.completionItemKind, |
| this.completionList, |
| this.contextSupport, |
| this.dynamicRegistration, |
| this.insertTextMode, |
| }); |
| static CompletionClientCapabilities fromJson(Map<String, Object?> json) { |
| final completionItemJson = json['completionItem']; |
| final completionItem = completionItemJson != null |
| ? CompletionClientCapabilitiesCompletionItem.fromJson( |
| completionItemJson as Map<String, Object?>) |
| : null; |
| final completionItemKindJson = json['completionItemKind']; |
| final completionItemKind = completionItemKindJson != null |
| ? CompletionClientCapabilitiesCompletionItemKind.fromJson( |
| completionItemKindJson as Map<String, Object?>) |
| : null; |
| final completionListJson = json['completionList']; |
| final completionList = completionListJson != null |
| ? CompletionClientCapabilitiesCompletionList.fromJson( |
| completionListJson as Map<String, Object?>) |
| : null; |
| final contextSupportJson = json['contextSupport']; |
| final contextSupport = contextSupportJson as bool?; |
| final dynamicRegistrationJson = json['dynamicRegistration']; |
| final dynamicRegistration = dynamicRegistrationJson as bool?; |
| final insertTextModeJson = json['insertTextMode']; |
| final insertTextMode = insertTextModeJson != null |
| ? InsertTextMode.fromJson(insertTextModeJson as int) |
| : null; |
| return CompletionClientCapabilities( |
| completionItem: completionItem, |
| completionItemKind: completionItemKind, |
| completionList: completionList, |
| contextSupport: contextSupport, |
| dynamicRegistration: dynamicRegistration, |
| insertTextMode: insertTextMode, |
| ); |
| } |
| |
| /// The client supports the following `CompletionItem` specific capabilities. |
| final CompletionClientCapabilitiesCompletionItem? completionItem; |
| final CompletionClientCapabilitiesCompletionItemKind? completionItemKind; |
| |
| /// The client supports the following `CompletionList` specific capabilities. |
| /// |
| /// @since 3.17.0 |
| final CompletionClientCapabilitiesCompletionList? completionList; |
| |
| /// The client supports to send additional context information for a |
| /// `textDocument/completion` request. |
| final bool? contextSupport; |
| |
| /// Whether completion supports dynamic registration. |
| final bool? dynamicRegistration; |
| |
| /// Defines how the client handles whitespace and indentation when accepting a |
| /// completion item that uses multi line text in either `insertText` or |
| /// `textEdit`. |
| /// |
| /// @since 3.17.0 |
| final InsertTextMode? insertTextMode; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (completionItem != null) { |
| result['completionItem'] = completionItem?.toJson(); |
| } |
| if (completionItemKind != null) { |
| result['completionItemKind'] = completionItemKind?.toJson(); |
| } |
| if (completionList != null) { |
| result['completionList'] = completionList?.toJson(); |
| } |
| if (contextSupport != null) { |
| result['contextSupport'] = contextSupport; |
| } |
| if (dynamicRegistration != null) { |
| result['dynamicRegistration'] = dynamicRegistration; |
| } |
| if (insertTextMode != null) { |
| result['insertTextMode'] = insertTextMode?.toJson(); |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseCompletionClientCapabilitiesCompletionItem( |
| obj, reporter, 'completionItem', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseCompletionClientCapabilitiesCompletionItemKind( |
| obj, reporter, 'completionItemKind', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseCompletionClientCapabilitiesCompletionList( |
| obj, reporter, 'completionList', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'contextSupport', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'dynamicRegistration', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseInsertTextMode(obj, reporter, 'insertTextMode', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CompletionClientCapabilities'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CompletionClientCapabilities && |
| other.runtimeType == CompletionClientCapabilities && |
| completionItem == other.completionItem && |
| completionItemKind == other.completionItemKind && |
| completionList == other.completionList && |
| contextSupport == other.contextSupport && |
| dynamicRegistration == other.dynamicRegistration && |
| insertTextMode == other.insertTextMode; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| completionItem, |
| completionItemKind, |
| completionList, |
| contextSupport, |
| dynamicRegistration, |
| insertTextMode, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class CompletionClientCapabilitiesCompletionItem implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CompletionClientCapabilitiesCompletionItem.canParse, |
| CompletionClientCapabilitiesCompletionItem.fromJson, |
| ); |
| |
| CompletionClientCapabilitiesCompletionItem({ |
| this.commitCharactersSupport, |
| this.deprecatedSupport, |
| this.documentationFormat, |
| this.insertReplaceSupport, |
| this.insertTextModeSupport, |
| this.labelDetailsSupport, |
| this.preselectSupport, |
| this.resolveSupport, |
| this.snippetSupport, |
| this.tagSupport, |
| }); |
| static CompletionClientCapabilitiesCompletionItem fromJson( |
| Map<String, Object?> json) { |
| final commitCharactersSupportJson = json['commitCharactersSupport']; |
| final commitCharactersSupport = commitCharactersSupportJson as bool?; |
| final deprecatedSupportJson = json['deprecatedSupport']; |
| final deprecatedSupport = deprecatedSupportJson as bool?; |
| final documentationFormatJson = json['documentationFormat']; |
| final documentationFormat = (documentationFormatJson as List<Object?>?) |
| ?.map((item) => MarkupKind.fromJson(item as String)) |
| .toList(); |
| final insertReplaceSupportJson = json['insertReplaceSupport']; |
| final insertReplaceSupport = insertReplaceSupportJson as bool?; |
| final insertTextModeSupportJson = json['insertTextModeSupport']; |
| final insertTextModeSupport = insertTextModeSupportJson != null |
| ? CompletionItemInsertTextModeSupport.fromJson( |
| insertTextModeSupportJson as Map<String, Object?>) |
| : null; |
| final labelDetailsSupportJson = json['labelDetailsSupport']; |
| final labelDetailsSupport = labelDetailsSupportJson as bool?; |
| final preselectSupportJson = json['preselectSupport']; |
| final preselectSupport = preselectSupportJson as bool?; |
| final resolveSupportJson = json['resolveSupport']; |
| final resolveSupport = resolveSupportJson != null |
| ? CompletionItemResolveSupport.fromJson( |
| resolveSupportJson as Map<String, Object?>) |
| : null; |
| final snippetSupportJson = json['snippetSupport']; |
| final snippetSupport = snippetSupportJson as bool?; |
| final tagSupportJson = json['tagSupport']; |
| final tagSupport = tagSupportJson != null |
| ? CompletionItemTagSupport.fromJson( |
| tagSupportJson as Map<String, Object?>) |
| : null; |
| return CompletionClientCapabilitiesCompletionItem( |
| commitCharactersSupport: commitCharactersSupport, |
| deprecatedSupport: deprecatedSupport, |
| documentationFormat: documentationFormat, |
| insertReplaceSupport: insertReplaceSupport, |
| insertTextModeSupport: insertTextModeSupport, |
| labelDetailsSupport: labelDetailsSupport, |
| preselectSupport: preselectSupport, |
| resolveSupport: resolveSupport, |
| snippetSupport: snippetSupport, |
| tagSupport: tagSupport, |
| ); |
| } |
| |
| /// Client supports commit characters on a completion item. |
| final bool? commitCharactersSupport; |
| |
| /// Client supports the deprecated property on a completion item. |
| final bool? deprecatedSupport; |
| |
| /// Client supports the following content formats for the documentation |
| /// property. The order describes the preferred format of the client. |
| final List<MarkupKind>? documentationFormat; |
| |
| /// Client support insert replace edit to control different behavior if a |
| /// completion item is inserted in the text or should replace text. |
| /// |
| /// @since 3.16.0 |
| final bool? insertReplaceSupport; |
| |
| /// The client supports the `insertTextMode` property on a completion item to |
| /// override the whitespace handling mode as defined by the client (see |
| /// `insertTextMode`). |
| /// |
| /// @since 3.16.0 |
| final CompletionItemInsertTextModeSupport? insertTextModeSupport; |
| |
| /// The client has support for completion item label details (see also |
| /// `CompletionItemLabelDetails`). |
| /// |
| /// @since 3.17.0 |
| final bool? labelDetailsSupport; |
| |
| /// Client supports the preselect property on a completion item. |
| final bool? preselectSupport; |
| |
| /// Indicates which properties a client can resolve lazily on a completion |
| /// item. Before version 3.16.0 only the predefined properties `documentation` |
| /// and `details` could be resolved lazily. |
| /// |
| /// @since 3.16.0 |
| final CompletionItemResolveSupport? resolveSupport; |
| |
| /// Client supports snippets as insert text. |
| /// |
| /// A snippet can define tab stops and placeholders with `$1`, `$2` and |
| /// `${3:foo}`. `$0` defines the final tab stop, it defaults to the end of the |
| /// snippet. Placeholders with equal identifiers are linked, |
| /// that is typing in one will update others too. |
| final bool? snippetSupport; |
| |
| /// Client supports the tag property on a completion item. Clients supporting |
| /// tags have to handle unknown tags gracefully. Clients especially need to |
| /// preserve unknown tags when sending a completion item back to the server in |
| /// a resolve call. |
| /// |
| /// @since 3.15.0 |
| final CompletionItemTagSupport? tagSupport; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (commitCharactersSupport != null) { |
| result['commitCharactersSupport'] = commitCharactersSupport; |
| } |
| if (deprecatedSupport != null) { |
| result['deprecatedSupport'] = deprecatedSupport; |
| } |
| if (documentationFormat != null) { |
| result['documentationFormat'] = |
| documentationFormat?.map((item) => item.toJson()).toList(); |
| } |
| if (insertReplaceSupport != null) { |
| result['insertReplaceSupport'] = insertReplaceSupport; |
| } |
| if (insertTextModeSupport != null) { |
| result['insertTextModeSupport'] = insertTextModeSupport?.toJson(); |
| } |
| if (labelDetailsSupport != null) { |
| result['labelDetailsSupport'] = labelDetailsSupport; |
| } |
| if (preselectSupport != null) { |
| result['preselectSupport'] = preselectSupport; |
| } |
| if (resolveSupport != null) { |
| result['resolveSupport'] = resolveSupport?.toJson(); |
| } |
| if (snippetSupport != null) { |
| result['snippetSupport'] = snippetSupport; |
| } |
| if (tagSupport != null) { |
| result['tagSupport'] = tagSupport?.toJson(); |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseBool(obj, reporter, 'commitCharactersSupport', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'deprecatedSupport', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseListMarkupKind(obj, reporter, 'documentationFormat', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'insertReplaceSupport', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseCompletionItemInsertTextModeSupport( |
| obj, reporter, 'insertTextModeSupport', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'labelDetailsSupport', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'preselectSupport', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseCompletionItemResolveSupport( |
| obj, reporter, 'resolveSupport', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'snippetSupport', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseCompletionItemTagSupport(obj, reporter, 'tagSupport', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError( |
| 'must be of type CompletionClientCapabilitiesCompletionItem'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CompletionClientCapabilitiesCompletionItem && |
| other.runtimeType == CompletionClientCapabilitiesCompletionItem && |
| commitCharactersSupport == other.commitCharactersSupport && |
| deprecatedSupport == other.deprecatedSupport && |
| listEqual(documentationFormat, other.documentationFormat, |
| (MarkupKind a, MarkupKind b) => a == b) && |
| insertReplaceSupport == other.insertReplaceSupport && |
| insertTextModeSupport == other.insertTextModeSupport && |
| labelDetailsSupport == other.labelDetailsSupport && |
| preselectSupport == other.preselectSupport && |
| resolveSupport == other.resolveSupport && |
| snippetSupport == other.snippetSupport && |
| tagSupport == other.tagSupport; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| commitCharactersSupport, |
| deprecatedSupport, |
| lspHashCode(documentationFormat), |
| insertReplaceSupport, |
| insertTextModeSupport, |
| labelDetailsSupport, |
| preselectSupport, |
| resolveSupport, |
| snippetSupport, |
| tagSupport, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class CompletionClientCapabilitiesCompletionItemKind implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CompletionClientCapabilitiesCompletionItemKind.canParse, |
| CompletionClientCapabilitiesCompletionItemKind.fromJson, |
| ); |
| |
| CompletionClientCapabilitiesCompletionItemKind({ |
| this.valueSet, |
| }); |
| static CompletionClientCapabilitiesCompletionItemKind fromJson( |
| Map<String, Object?> json) { |
| final valueSetJson = json['valueSet']; |
| final valueSet = (valueSetJson as List<Object?>?) |
| ?.map((item) => CompletionItemKind.fromJson(item as int)) |
| .toList(); |
| return CompletionClientCapabilitiesCompletionItemKind( |
| valueSet: valueSet, |
| ); |
| } |
| |
| /// The completion item kind values the client supports. When this property |
| /// exists the client also guarantees that it will handle values outside its |
| /// set gracefully and falls back to a default value when unknown. |
| /// |
| /// If this property is not present the client only supports the completion |
| /// items kinds from `Text` to `Reference` as defined in the initial version |
| /// of the protocol. |
| final List<CompletionItemKind>? valueSet; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (valueSet != null) { |
| result['valueSet'] = valueSet?.map((item) => item.toJson()).toList(); |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseListCompletionItemKind(obj, reporter, 'valueSet', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError( |
| 'must be of type CompletionClientCapabilitiesCompletionItemKind'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CompletionClientCapabilitiesCompletionItemKind && |
| other.runtimeType == CompletionClientCapabilitiesCompletionItemKind && |
| listEqual(valueSet, other.valueSet, |
| (CompletionItemKind a, CompletionItemKind b) => a == b); |
| } |
| |
| @override |
| int get hashCode => lspHashCode(valueSet); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class CompletionClientCapabilitiesCompletionList implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CompletionClientCapabilitiesCompletionList.canParse, |
| CompletionClientCapabilitiesCompletionList.fromJson, |
| ); |
| |
| CompletionClientCapabilitiesCompletionList({ |
| this.itemDefaults, |
| }); |
| static CompletionClientCapabilitiesCompletionList fromJson( |
| Map<String, Object?> json) { |
| final itemDefaultsJson = json['itemDefaults']; |
| final itemDefaults = (itemDefaultsJson as List<Object?>?) |
| ?.map((item) => item as String) |
| .toList(); |
| return CompletionClientCapabilitiesCompletionList( |
| itemDefaults: itemDefaults, |
| ); |
| } |
| |
| /// The client supports the following itemDefaults on a completion list. |
| /// |
| /// The value lists the supported property names of the |
| /// `CompletionList.itemDefaults` object. If omitted no properties are |
| /// supported. |
| /// |
| /// @since 3.17.0 |
| final List<String>? itemDefaults; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (itemDefaults != null) { |
| result['itemDefaults'] = itemDefaults; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseListString(obj, reporter, 'itemDefaults', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError( |
| 'must be of type CompletionClientCapabilitiesCompletionList'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CompletionClientCapabilitiesCompletionList && |
| other.runtimeType == CompletionClientCapabilitiesCompletionList && |
| listEqual( |
| itemDefaults, other.itemDefaults, (String a, String b) => a == b); |
| } |
| |
| @override |
| int get hashCode => lspHashCode(itemDefaults); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Contains additional information about the context in which a completion |
| /// request is triggered. |
| class CompletionContext implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CompletionContext.canParse, |
| CompletionContext.fromJson, |
| ); |
| |
| CompletionContext({ |
| this.triggerCharacter, |
| required this.triggerKind, |
| }); |
| static CompletionContext fromJson(Map<String, Object?> json) { |
| final triggerCharacterJson = json['triggerCharacter']; |
| final triggerCharacter = triggerCharacterJson as String?; |
| final triggerKindJson = json['triggerKind']; |
| final triggerKind = CompletionTriggerKind.fromJson(triggerKindJson as int); |
| return CompletionContext( |
| triggerCharacter: triggerCharacter, |
| triggerKind: triggerKind, |
| ); |
| } |
| |
| /// The trigger character (a single character) that has trigger code complete. |
| /// Is undefined if `triggerKind !== CompletionTriggerKind.TriggerCharacter` |
| final String? triggerCharacter; |
| |
| /// How the completion was triggered. |
| final CompletionTriggerKind triggerKind; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (triggerCharacter != null) { |
| result['triggerCharacter'] = triggerCharacter; |
| } |
| result['triggerKind'] = triggerKind.toJson(); |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseString(obj, reporter, 'triggerCharacter', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseCompletionTriggerKind(obj, reporter, 'triggerKind', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CompletionContext'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CompletionContext && |
| other.runtimeType == CompletionContext && |
| triggerCharacter == other.triggerCharacter && |
| triggerKind == other.triggerKind; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| triggerCharacter, |
| triggerKind, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// A completion item represents a text snippet that is proposed to complete |
| /// text that is being typed. |
| class CompletionItem implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CompletionItem.canParse, |
| CompletionItem.fromJson, |
| ); |
| |
| CompletionItem({ |
| this.additionalTextEdits, |
| this.command, |
| this.commitCharacters, |
| this.data, |
| this.deprecated, |
| this.detail, |
| this.documentation, |
| this.filterText, |
| this.insertText, |
| this.insertTextFormat, |
| this.insertTextMode, |
| this.kind, |
| required this.label, |
| this.labelDetails, |
| this.preselect, |
| this.sortText, |
| this.tags, |
| this.textEdit, |
| this.textEditText, |
| }); |
| static CompletionItem fromJson(Map<String, Object?> json) { |
| final additionalTextEditsJson = json['additionalTextEdits']; |
| final additionalTextEdits = (additionalTextEditsJson as List<Object?>?) |
| ?.map((item) => TextEdit.fromJson(item as Map<String, Object?>)) |
| .toList(); |
| final commandJson = json['command']; |
| final command = commandJson != null |
| ? Command.fromJson(commandJson as Map<String, Object?>) |
| : null; |
| final commitCharactersJson = json['commitCharacters']; |
| final commitCharacters = (commitCharactersJson as List<Object?>?) |
| ?.map((item) => item as String) |
| .toList(); |
| final dataJson = json['data']; |
| final data = dataJson != null |
| ? CompletionItemResolutionInfo.fromJson( |
| dataJson as Map<String, Object?>) |
| : null; |
| final deprecatedJson = json['deprecated']; |
| final deprecated = deprecatedJson as bool?; |
| final detailJson = json['detail']; |
| final detail = detailJson as String?; |
| final documentationJson = json['documentation']; |
| final documentation = documentationJson == null |
| ? null |
| : _eitherMarkupContentString(documentationJson); |
| final filterTextJson = json['filterText']; |
| final filterText = filterTextJson as String?; |
| final insertTextJson = json['insertText']; |
| final insertText = insertTextJson as String?; |
| final insertTextFormatJson = json['insertTextFormat']; |
| final insertTextFormat = insertTextFormatJson != null |
| ? InsertTextFormat.fromJson(insertTextFormatJson as int) |
| : null; |
| final insertTextModeJson = json['insertTextMode']; |
| final insertTextMode = insertTextModeJson != null |
| ? InsertTextMode.fromJson(insertTextModeJson as int) |
| : null; |
| final kindJson = json['kind']; |
| final kind = |
| kindJson != null ? CompletionItemKind.fromJson(kindJson as int) : null; |
| final labelJson = json['label']; |
| final label = labelJson as String; |
| final labelDetailsJson = json['labelDetails']; |
| final labelDetails = labelDetailsJson != null |
| ? CompletionItemLabelDetails.fromJson( |
| labelDetailsJson as Map<String, Object?>) |
| : null; |
| final preselectJson = json['preselect']; |
| final preselect = preselectJson as bool?; |
| final sortTextJson = json['sortText']; |
| final sortText = sortTextJson as String?; |
| final tagsJson = json['tags']; |
| final tags = (tagsJson as List<Object?>?) |
| ?.map((item) => CompletionItemTag.fromJson(item as int)) |
| .toList(); |
| final textEditJson = json['textEdit']; |
| final textEdit = textEditJson == null |
| ? null |
| : _eitherInsertReplaceEditTextEdit(textEditJson); |
| final textEditTextJson = json['textEditText']; |
| final textEditText = textEditTextJson as String?; |
| return CompletionItem( |
| additionalTextEdits: additionalTextEdits, |
| command: command, |
| commitCharacters: commitCharacters, |
| data: data, |
| deprecated: deprecated, |
| detail: detail, |
| documentation: documentation, |
| filterText: filterText, |
| insertText: insertText, |
| insertTextFormat: insertTextFormat, |
| insertTextMode: insertTextMode, |
| kind: kind, |
| label: label, |
| labelDetails: labelDetails, |
| preselect: preselect, |
| sortText: sortText, |
| tags: tags, |
| textEdit: textEdit, |
| textEditText: textEditText, |
| ); |
| } |
| |
| /// An optional array of additional text edits that are applied when selecting |
| /// this completion. Edits must not overlap (including the same insert |
| /// position) with the main edit nor with themselves. |
| /// |
| /// Additional text edits should be used to change text unrelated to the |
| /// current cursor position (for example adding an import statement at the top |
| /// of the file if the completion item will insert an unqualified type). |
| final List<TextEdit>? additionalTextEdits; |
| |
| /// An optional command that is executed *after* inserting this completion. |
| /// *Note* that additional modifications to the current document should be |
| /// described with the additionalTextEdits-property. |
| final Command? command; |
| |
| /// An optional set of characters that when pressed while this completion is |
| /// active will accept it first and then type that character. *Note* that all |
| /// commit characters should have `length=1` and that superfluous characters |
| /// will be ignored. |
| final List<String>? commitCharacters; |
| |
| /// A data entry field that is preserved on a completion item between a |
| /// CompletionRequest and a CompletionResolveRequest. |
| final CompletionItemResolutionInfo? data; |
| |
| /// Indicates if this item is deprecated. |
| /// @deprecated Use `tags` instead. |
| final bool? deprecated; |
| |
| /// A human-readable string with additional information about this item, like |
| /// type or symbol information. |
| final String? detail; |
| |
| /// A human-readable string that represents a doc-comment. |
| final Either2<MarkupContent, String>? documentation; |
| |
| /// A string that should be used when filtering a set of completion items. |
| /// When `falsy` the label is used. |
| 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`. If omitted |
| /// defaults to `InsertTextFormat.PlainText`. |
| /// |
| /// Please note that the insertTextFormat doesn't apply to |
| /// `additionalTextEdits`. |
| final InsertTextFormat? insertTextFormat; |
| |
| /// How whitespace and indentation is handled during completion item |
| /// insertion. If not provided the clients default value depends on the |
| /// `textDocument.completion.insertTextMode` client capability. |
| /// |
| /// @since 3.16.0 |
| final InsertTextMode? insertTextMode; |
| |
| /// The kind of this completion item. Based of the kind an icon is chosen by |
| /// the editor. |
| final CompletionItemKind? kind; |
| |
| /// The label of this completion item. |
| /// |
| /// The label property is also by default the text that is inserted when |
| /// selecting this completion. |
| /// |
| /// If label details are provided the label itself should be an unqualified |
| /// name of the completion item. |
| final String label; |
| |
| /// Additional details for the label |
| /// |
| /// @since 3.17.0 |
| final CompletionItemLabelDetails? labelDetails; |
| |
| /// Select this item when showing. |
| /// |
| /// *Note* that only one completion item can be selected and that the tool / |
| /// client decides which item that is. The rule is that the *first* |
| /// item of those that match best is selected. |
| final bool? preselect; |
| |
| /// A string that should be used when comparing this item with other items. |
| /// When `falsy` the label is used. |
| final String? sortText; |
| |
| /// Tags for this completion item. |
| /// |
| /// @since 3.15.0 |
| final List<CompletionItemTag>? tags; |
| |
| /// An edit which is applied to a document when selecting this completion. |
| /// When an edit is provided the value of insertText is ignored. |
| /// |
| /// Most editors support two different operations when accepting a completion |
| /// item. One is to insert a completion text and the other is to replace an |
| /// existing text with a completion text. Since this can usually not be |
| /// predetermined by a server it can report both ranges. Clients need to |
| /// signal support for `InsertReplaceEdits` via the |
| /// `textDocument.completion.insertReplaceSupport` client capability property. |
| /// |
| /// *Note 1:* The text edit's range as well as both ranges from an insert |
| /// replace edit must be a [single line] and they must contain the position at |
| /// which completion has been requested. |
| /// *Note 2:* If an `InsertReplaceEdit` is returned the edit's insert range |
| /// must be a prefix of the edit's replace range, that means it must be |
| /// contained and starting at the same position. |
| /// |
| /// @since 3.16.0 additional type `InsertReplaceEdit` |
| final Either2<InsertReplaceEdit, TextEdit>? textEdit; |
| |
| /// The edit text used if the completion item is part of a CompletionList and |
| /// CompletionList defines an item default for the text edit range. |
| /// |
| /// Clients will only honor this property if they opt into completion list |
| /// item defaults using the capability `completionList.itemDefaults`. |
| /// |
| /// If not provided and a list's default range is provided the label property |
| /// is used as a text. |
| /// |
| /// @since 3.17.0 |
| final String? textEditText; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (additionalTextEdits != null) { |
| result['additionalTextEdits'] = |
| additionalTextEdits?.map((item) => item.toJson()).toList(); |
| } |
| if (command != null) { |
| result['command'] = command?.toJson(); |
| } |
| if (commitCharacters != null) { |
| result['commitCharacters'] = commitCharacters; |
| } |
| if (data != null) { |
| result['data'] = data?.toJson(); |
| } |
| if (deprecated != null) { |
| result['deprecated'] = deprecated; |
| } |
| if (detail != null) { |
| result['detail'] = detail; |
| } |
| if (documentation != null) { |
| result['documentation'] = documentation; |
| } |
| if (filterText != null) { |
| result['filterText'] = filterText; |
| } |
| if (insertText != null) { |
| result['insertText'] = insertText; |
| } |
| if (insertTextFormat != null) { |
| result['insertTextFormat'] = insertTextFormat?.toJson(); |
| } |
| if (insertTextMode != null) { |
| result['insertTextMode'] = insertTextMode?.toJson(); |
| } |
| if (kind != null) { |
| result['kind'] = kind?.toJson(); |
| } |
| result['label'] = label; |
| if (labelDetails != null) { |
| result['labelDetails'] = labelDetails?.toJson(); |
| } |
| if (preselect != null) { |
| result['preselect'] = preselect; |
| } |
| if (sortText != null) { |
| result['sortText'] = sortText; |
| } |
| if (tags != null) { |
| result['tags'] = tags?.map((item) => item.toJson()).toList(); |
| } |
| if (textEdit != null) { |
| result['textEdit'] = textEdit; |
| } |
| if (textEditText != null) { |
| result['textEditText'] = textEditText; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseListTextEdit(obj, reporter, 'additionalTextEdits', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseCommand(obj, reporter, 'command', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseListString(obj, reporter, 'commitCharacters', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseCompletionItemResolutionInfo(obj, reporter, 'data', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'deprecated', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseString(obj, reporter, 'detail', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseMarkupContentString(obj, reporter, 'documentation', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseString(obj, reporter, 'filterText', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseString(obj, reporter, 'insertText', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseInsertTextFormat(obj, reporter, 'insertTextFormat', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseInsertTextMode(obj, reporter, 'insertTextMode', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseCompletionItemKind(obj, reporter, 'kind', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseString(obj, reporter, 'label', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseCompletionItemLabelDetails(obj, reporter, 'labelDetails', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'preselect', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseString(obj, reporter, 'sortText', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseListCompletionItemTag(obj, reporter, 'tags', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseInsertReplaceEditTextEdit(obj, reporter, 'textEdit', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseString(obj, reporter, 'textEditText', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CompletionItem'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CompletionItem && |
| other.runtimeType == CompletionItem && |
| listEqual(additionalTextEdits, other.additionalTextEdits, |
| (TextEdit a, TextEdit b) => a == b) && |
| command == other.command && |
| listEqual(commitCharacters, other.commitCharacters, |
| (String a, String b) => a == b) && |
| data == other.data && |
| deprecated == other.deprecated && |
| detail == other.detail && |
| documentation == other.documentation && |
| filterText == other.filterText && |
| insertText == other.insertText && |
| insertTextFormat == other.insertTextFormat && |
| insertTextMode == other.insertTextMode && |
| kind == other.kind && |
| label == other.label && |
| labelDetails == other.labelDetails && |
| preselect == other.preselect && |
| sortText == other.sortText && |
| listEqual(tags, other.tags, |
| (CompletionItemTag a, CompletionItemTag b) => a == b) && |
| textEdit == other.textEdit && |
| textEditText == other.textEditText; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| lspHashCode(additionalTextEdits), |
| command, |
| lspHashCode(commitCharacters), |
| data, |
| deprecated, |
| detail, |
| documentation, |
| filterText, |
| insertText, |
| insertTextFormat, |
| insertTextMode, |
| kind, |
| label, |
| labelDetails, |
| preselect, |
| sortText, |
| lspHashCode(tags), |
| textEdit, |
| textEditText, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class CompletionItemEditRange implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CompletionItemEditRange.canParse, |
| CompletionItemEditRange.fromJson, |
| ); |
| |
| CompletionItemEditRange({ |
| required this.insert, |
| required this.replace, |
| }); |
| static CompletionItemEditRange fromJson(Map<String, Object?> json) { |
| final insertJson = json['insert']; |
| final insert = Range.fromJson(insertJson as Map<String, Object?>); |
| final replaceJson = json['replace']; |
| final replace = Range.fromJson(replaceJson as Map<String, Object?>); |
| return CompletionItemEditRange( |
| insert: insert, |
| replace: replace, |
| ); |
| } |
| |
| final Range insert; |
| final Range replace; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['insert'] = insert.toJson(); |
| result['replace'] = replace.toJson(); |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseRange(obj, reporter, 'insert', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseRange(obj, reporter, 'replace', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CompletionItemEditRange'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CompletionItemEditRange && |
| other.runtimeType == CompletionItemEditRange && |
| insert == other.insert && |
| replace == other.replace; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| insert, |
| replace, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class CompletionItemInsertTextModeSupport implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CompletionItemInsertTextModeSupport.canParse, |
| CompletionItemInsertTextModeSupport.fromJson, |
| ); |
| |
| CompletionItemInsertTextModeSupport({ |
| required this.valueSet, |
| }); |
| static CompletionItemInsertTextModeSupport fromJson( |
| Map<String, Object?> json) { |
| final valueSetJson = json['valueSet']; |
| final valueSet = (valueSetJson as List<Object?>) |
| .map((item) => InsertTextMode.fromJson(item as int)) |
| .toList(); |
| return CompletionItemInsertTextModeSupport( |
| valueSet: valueSet, |
| ); |
| } |
| |
| final List<InsertTextMode> valueSet; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['valueSet'] = valueSet.map((item) => item.toJson()).toList(); |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseListInsertTextMode(obj, reporter, 'valueSet', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter |
| .reportError('must be of type CompletionItemInsertTextModeSupport'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CompletionItemInsertTextModeSupport && |
| other.runtimeType == CompletionItemInsertTextModeSupport && |
| listEqual(valueSet, other.valueSet, |
| (InsertTextMode a, InsertTextMode b) => a == b); |
| } |
| |
| @override |
| int get hashCode => lspHashCode(valueSet); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The kind of a completion entry. |
| class CompletionItemKind implements ToJsonable { |
| const CompletionItemKind(this._value); |
| const CompletionItemKind.fromJson(this._value); |
| |
| final int _value; |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) => obj is int; |
| static const Class = CompletionItemKind(7); |
| static const Color = CompletionItemKind(16); |
| static const Constant = CompletionItemKind(21); |
| static const Constructor = CompletionItemKind(4); |
| static const Enum = CompletionItemKind(13); |
| static const EnumMember = CompletionItemKind(20); |
| static const Event = CompletionItemKind(23); |
| static const Field = CompletionItemKind(5); |
| static const File = CompletionItemKind(17); |
| static const Folder = CompletionItemKind(19); |
| static const Function = CompletionItemKind(3); |
| static const Interface = CompletionItemKind(8); |
| static const Keyword = CompletionItemKind(14); |
| static const Method = CompletionItemKind(2); |
| static const Module = CompletionItemKind(9); |
| static const Operator = CompletionItemKind(24); |
| static const Property = CompletionItemKind(10); |
| static const Reference = CompletionItemKind(18); |
| static const Snippet = CompletionItemKind(15); |
| static const Struct = CompletionItemKind(22); |
| static const Text = CompletionItemKind(1); |
| static const TypeParameter = CompletionItemKind(25); |
| static const Unit = CompletionItemKind(11); |
| static const Value = CompletionItemKind(12); |
| static const Variable = CompletionItemKind(6); |
| |
| @override |
| Object toJson() => _value; |
| |
| @override |
| String toString() => _value.toString(); |
| |
| @override |
| int get hashCode => _value.hashCode; |
| |
| @override |
| bool operator ==(Object other) => |
| other is CompletionItemKind && other._value == _value; |
| } |
| |
| /// Additional details for a completion item label. |
| /// |
| /// @since 3.17.0 |
| class CompletionItemLabelDetails implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CompletionItemLabelDetails.canParse, |
| CompletionItemLabelDetails.fromJson, |
| ); |
| |
| CompletionItemLabelDetails({ |
| this.description, |
| this.detail, |
| }); |
| static CompletionItemLabelDetails fromJson(Map<String, Object?> json) { |
| final descriptionJson = json['description']; |
| final description = descriptionJson as String?; |
| final detailJson = json['detail']; |
| final detail = detailJson as String?; |
| return CompletionItemLabelDetails( |
| description: description, |
| detail: detail, |
| ); |
| } |
| |
| /// An optional string which is rendered less prominently after {@link |
| /// CompletionItem.detail}. Should be used for fully qualified names and file |
| /// paths. |
| final String? description; |
| |
| /// An optional string which is rendered less prominently directly after |
| /// {@link CompletionItem.label label}, |
| /// without any spacing. Should be used for function signatures and type |
| /// annotations. |
| final String? detail; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (description != null) { |
| result['description'] = description; |
| } |
| if (detail != null) { |
| result['detail'] = detail; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseString(obj, reporter, 'description', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseString(obj, reporter, 'detail', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CompletionItemLabelDetails'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CompletionItemLabelDetails && |
| other.runtimeType == CompletionItemLabelDetails && |
| description == other.description && |
| detail == other.detail; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| description, |
| detail, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class CompletionItemResolveSupport implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CompletionItemResolveSupport.canParse, |
| CompletionItemResolveSupport.fromJson, |
| ); |
| |
| CompletionItemResolveSupport({ |
| required this.properties, |
| }); |
| static CompletionItemResolveSupport fromJson(Map<String, Object?> json) { |
| final propertiesJson = json['properties']; |
| final properties = (propertiesJson as List<Object?>) |
| .map((item) => item as String) |
| .toList(); |
| return CompletionItemResolveSupport( |
| properties: properties, |
| ); |
| } |
| |
| /// The properties that a client can resolve lazily. |
| final List<String> properties; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['properties'] = properties; |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseListString(obj, reporter, 'properties', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CompletionItemResolveSupport'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CompletionItemResolveSupport && |
| other.runtimeType == CompletionItemResolveSupport && |
| listEqual(properties, other.properties, (String a, String b) => a == b); |
| } |
| |
| @override |
| int get hashCode => lspHashCode(properties); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Completion item tags are extra annotations that tweak the rendering of a |
| /// completion item. |
| /// |
| /// @since 3.15.0 |
| class CompletionItemTag implements ToJsonable { |
| const CompletionItemTag(this._value); |
| const CompletionItemTag.fromJson(this._value); |
| |
| final int _value; |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) => obj is int; |
| |
| /// Render a completion as obsolete, usually using a strike-out. |
| static const Deprecated = CompletionItemTag(1); |
| |
| @override |
| Object toJson() => _value; |
| |
| @override |
| String toString() => _value.toString(); |
| |
| @override |
| int get hashCode => _value.hashCode; |
| |
| @override |
| bool operator ==(Object other) => |
| other is CompletionItemTag && other._value == _value; |
| } |
| |
| class CompletionItemTagSupport implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CompletionItemTagSupport.canParse, |
| CompletionItemTagSupport.fromJson, |
| ); |
| |
| CompletionItemTagSupport({ |
| required this.valueSet, |
| }); |
| static CompletionItemTagSupport fromJson(Map<String, Object?> json) { |
| final valueSetJson = json['valueSet']; |
| final valueSet = (valueSetJson as List<Object?>) |
| .map((item) => CompletionItemTag.fromJson(item as int)) |
| .toList(); |
| return CompletionItemTagSupport( |
| valueSet: valueSet, |
| ); |
| } |
| |
| /// The tags supported by the client. |
| final List<CompletionItemTag> valueSet; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['valueSet'] = valueSet.map((item) => item.toJson()).toList(); |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseListCompletionItemTag(obj, reporter, 'valueSet', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CompletionItemTagSupport'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CompletionItemTagSupport && |
| other.runtimeType == CompletionItemTagSupport && |
| listEqual(valueSet, other.valueSet, |
| (CompletionItemTag a, CompletionItemTag b) => a == b); |
| } |
| |
| @override |
| int get hashCode => lspHashCode(valueSet); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Represents a collection of completion items to be presented in the editor. |
| class CompletionList implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CompletionList.canParse, |
| CompletionList.fromJson, |
| ); |
| |
| CompletionList({ |
| required this.isIncomplete, |
| this.itemDefaults, |
| required this.items, |
| }); |
| static CompletionList fromJson(Map<String, Object?> json) { |
| final isIncompleteJson = json['isIncomplete']; |
| final isIncomplete = isIncompleteJson as bool; |
| final itemDefaultsJson = json['itemDefaults']; |
| final itemDefaults = itemDefaultsJson != null |
| ? CompletionListItemDefaults.fromJson( |
| itemDefaultsJson as Map<String, Object?>) |
| : null; |
| final itemsJson = json['items']; |
| final items = (itemsJson as List<Object?>) |
| .map((item) => CompletionItem.fromJson(item as Map<String, Object?>)) |
| .toList(); |
| return CompletionList( |
| isIncomplete: isIncomplete, |
| itemDefaults: itemDefaults, |
| items: items, |
| ); |
| } |
| |
| /// This list it not complete. Further typing results in recomputing this |
| /// list. |
| /// |
| /// Recomputed lists have all their items replaced (not appended) in the |
| /// incomplete completion sessions. |
| final bool isIncomplete; |
| |
| /// In many cases the items of an actual completion result share the same |
| /// value for properties like `commitCharacters` or the range of a text edit. |
| /// A completion list can therefore define item defaults which will be used if |
| /// a completion item itself doesn't specify the value. |
| /// |
| /// If a completion list specifies a default value and a completion item also |
| /// specifies a corresponding value the one from the item is used. |
| /// |
| /// Servers are only allowed to return default values if the client signals |
| /// support for this via the `completionList.itemDefaults` capability. |
| /// |
| /// @since 3.17.0 |
| final CompletionListItemDefaults? itemDefaults; |
| |
| /// The completion items. |
| final List<CompletionItem> items; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['isIncomplete'] = isIncomplete; |
| if (itemDefaults != null) { |
| result['itemDefaults'] = itemDefaults?.toJson(); |
| } |
| result['items'] = items.map((item) => item.toJson()).toList(); |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseBool(obj, reporter, 'isIncomplete', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseCompletionListItemDefaults(obj, reporter, 'itemDefaults', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseListCompletionItem(obj, reporter, 'items', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CompletionList'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CompletionList && |
| other.runtimeType == CompletionList && |
| isIncomplete == other.isIncomplete && |
| itemDefaults == other.itemDefaults && |
| listEqual( |
| items, other.items, (CompletionItem a, CompletionItem b) => a == b); |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| isIncomplete, |
| itemDefaults, |
| lspHashCode(items), |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class CompletionListItemDefaults implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CompletionListItemDefaults.canParse, |
| CompletionListItemDefaults.fromJson, |
| ); |
| |
| CompletionListItemDefaults({ |
| this.commitCharacters, |
| this.data, |
| this.editRange, |
| this.insertTextFormat, |
| this.insertTextMode, |
| }); |
| static CompletionListItemDefaults fromJson(Map<String, Object?> json) { |
| final commitCharactersJson = json['commitCharacters']; |
| final commitCharacters = (commitCharactersJson as List<Object?>?) |
| ?.map((item) => item as String) |
| .toList(); |
| final dataJson = json['data']; |
| final data = dataJson; |
| final editRangeJson = json['editRange']; |
| final editRange = editRangeJson == null |
| ? null |
| : _eitherCompletionItemEditRangeRange(editRangeJson); |
| final insertTextFormatJson = json['insertTextFormat']; |
| final insertTextFormat = insertTextFormatJson != null |
| ? InsertTextFormat.fromJson(insertTextFormatJson as int) |
| : null; |
| final insertTextModeJson = json['insertTextMode']; |
| final insertTextMode = insertTextModeJson != null |
| ? InsertTextMode.fromJson(insertTextModeJson as int) |
| : null; |
| return CompletionListItemDefaults( |
| commitCharacters: commitCharacters, |
| data: data, |
| editRange: editRange, |
| insertTextFormat: insertTextFormat, |
| insertTextMode: insertTextMode, |
| ); |
| } |
| |
| /// A default commit character set. |
| /// |
| /// @since 3.17.0 |
| final List<String>? commitCharacters; |
| |
| /// A default data value. |
| /// |
| /// @since 3.17.0 |
| final LSPAny data; |
| |
| /// A default edit range. |
| /// |
| /// @since 3.17.0 |
| final Either2<CompletionItemEditRange, Range>? editRange; |
| |
| /// A default insert text format. |
| /// |
| /// @since 3.17.0 |
| final InsertTextFormat? insertTextFormat; |
| |
| /// A default insert text mode. |
| /// |
| /// @since 3.17.0 |
| final InsertTextMode? insertTextMode; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (commitCharacters != null) { |
| result['commitCharacters'] = commitCharacters; |
| } |
| if (data != null) { |
| result['data'] = data; |
| } |
| if (editRange != null) { |
| result['editRange'] = editRange; |
| } |
| if (insertTextFormat != null) { |
| result['insertTextFormat'] = insertTextFormat?.toJson(); |
| } |
| if (insertTextMode != null) { |
| result['insertTextMode'] = insertTextMode?.toJson(); |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseListString(obj, reporter, 'commitCharacters', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseCompletionItemEditRangeRange(obj, reporter, 'editRange', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseInsertTextFormat(obj, reporter, 'insertTextFormat', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseInsertTextMode(obj, reporter, 'insertTextMode', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CompletionListItemDefaults'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CompletionListItemDefaults && |
| other.runtimeType == CompletionListItemDefaults && |
| listEqual(commitCharacters, other.commitCharacters, |
| (String a, String b) => a == b) && |
| data == other.data && |
| editRange == other.editRange && |
| insertTextFormat == other.insertTextFormat && |
| insertTextMode == other.insertTextMode; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| lspHashCode(commitCharacters), |
| data, |
| editRange, |
| insertTextFormat, |
| insertTextMode, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Completion options. |
| class CompletionOptions implements WorkDoneProgressOptions, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CompletionOptions.canParse, |
| CompletionOptions.fromJson, |
| ); |
| |
| CompletionOptions({ |
| this.allCommitCharacters, |
| this.completionItem, |
| this.resolveProvider, |
| this.triggerCharacters, |
| this.workDoneProgress, |
| }); |
| static CompletionOptions fromJson(Map<String, Object?> json) { |
| if (CompletionRegistrationOptions.canParse(json, nullLspJsonReporter)) { |
| return CompletionRegistrationOptions.fromJson(json); |
| } |
| final allCommitCharactersJson = json['allCommitCharacters']; |
| final allCommitCharacters = (allCommitCharactersJson as List<Object?>?) |
| ?.map((item) => item as String) |
| .toList(); |
| final completionItemJson = json['completionItem']; |
| final completionItem = completionItemJson != null |
| ? CompletionOptionsCompletionItem.fromJson( |
| completionItemJson as Map<String, Object?>) |
| : null; |
| final resolveProviderJson = json['resolveProvider']; |
| final resolveProvider = resolveProviderJson as bool?; |
| final triggerCharactersJson = json['triggerCharacters']; |
| final triggerCharacters = (triggerCharactersJson as List<Object?>?) |
| ?.map((item) => item as String) |
| .toList(); |
| final workDoneProgressJson = json['workDoneProgress']; |
| final workDoneProgress = workDoneProgressJson as bool?; |
| return CompletionOptions( |
| allCommitCharacters: allCommitCharacters, |
| completionItem: completionItem, |
| resolveProvider: resolveProvider, |
| triggerCharacters: triggerCharacters, |
| workDoneProgress: workDoneProgress, |
| ); |
| } |
| |
| /// The list of all possible characters that commit a completion. This field |
| /// can be used if clients don't support individual commit characters per |
| /// completion item. See |
| /// `ClientCapabilities.textDocument.completion.completionItem.commitCharactersSupport` |
| /// |
| /// If a server provides both `allCommitCharacters` and commit characters on |
| /// an individual completion item the ones on the completion item win. |
| /// |
| /// @since 3.2.0 |
| final List<String>? allCommitCharacters; |
| |
| /// The server supports the following `CompletionItem` specific capabilities. |
| /// |
| /// @since 3.17.0 |
| final CompletionOptionsCompletionItem? completionItem; |
| |
| /// The server provides support to resolve additional information for a |
| /// completion item. |
| final bool? resolveProvider; |
| |
| /// Most tools trigger completion request automatically without explicitly |
| /// requesting it using a keyboard shortcut (e.g. Ctrl+Space). Typically they |
| /// do so when the user starts to type an identifier. For example if the user |
| /// types `c` in a JavaScript file code complete will automatically pop up |
| /// present `console` besides others as a completion item. Characters that |
| /// make up identifiers don't need to be listed here. |
| /// |
| /// If code complete should automatically be trigger on characters not being |
| /// valid inside an identifier (for example `.` in JavaScript) list them in |
| /// `triggerCharacters`. |
| final List<String>? triggerCharacters; |
| @override |
| final bool? workDoneProgress; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (allCommitCharacters != null) { |
| result['allCommitCharacters'] = allCommitCharacters; |
| } |
| if (completionItem != null) { |
| result['completionItem'] = completionItem?.toJson(); |
| } |
| if (resolveProvider != null) { |
| result['resolveProvider'] = resolveProvider; |
| } |
| if (triggerCharacters != null) { |
| result['triggerCharacters'] = triggerCharacters; |
| } |
| if (workDoneProgress != null) { |
| result['workDoneProgress'] = workDoneProgress; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseListString(obj, reporter, 'allCommitCharacters', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseCompletionOptionsCompletionItem( |
| obj, reporter, 'completionItem', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'resolveProvider', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseListString(obj, reporter, 'triggerCharacters', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseBool(obj, reporter, 'workDoneProgress', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CompletionOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CompletionOptions && |
| other.runtimeType == CompletionOptions && |
| listEqual(allCommitCharacters, other.allCommitCharacters, |
| (String a, String b) => a == b) && |
| completionItem == other.completionItem && |
| resolveProvider == other.resolveProvider && |
| listEqual(triggerCharacters, other.triggerCharacters, |
| (String a, String b) => a == b) && |
| workDoneProgress == other.workDoneProgress; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| lspHashCode(allCommitCharacters), |
| completionItem, |
| resolveProvider, |
| lspHashCode(triggerCharacters), |
| workDoneProgress, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class CompletionOptionsCompletionItem implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CompletionOptionsCompletionItem.canParse, |
| CompletionOptionsCompletionItem.fromJson, |
| ); |
| |
| CompletionOptionsCompletionItem({ |
| this.labelDetailsSupport, |
| }); |
| static CompletionOptionsCompletionItem fromJson(Map<String, Object?> json) { |
| final labelDetailsSupportJson = json['labelDetailsSupport']; |
| final labelDetailsSupport = labelDetailsSupportJson as bool?; |
| return CompletionOptionsCompletionItem( |
| labelDetailsSupport: labelDetailsSupport, |
| ); |
| } |
| |
| /// The server has support for completion item label details (see also |
| /// `CompletionItemLabelDetails`) when receiving a completion item in a |
| /// resolve call. |
| /// |
| /// @since 3.17.0 |
| final bool? labelDetailsSupport; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (labelDetailsSupport != null) { |
| result['labelDetailsSupport'] = labelDetailsSupport; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseBool(obj, reporter, 'labelDetailsSupport', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CompletionOptionsCompletionItem'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CompletionOptionsCompletionItem && |
| other.runtimeType == CompletionOptionsCompletionItem && |
| labelDetailsSupport == other.labelDetailsSupport; |
| } |
| |
| @override |
| int get hashCode => labelDetailsSupport.hashCode; |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Completion parameters |
| class CompletionParams |
| implements |
| PartialResultParams, |
| TextDocumentPositionParams, |
| WorkDoneProgressParams, |
| ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CompletionParams.canParse, |
| CompletionParams.fromJson, |
| ); |
| |
| CompletionParams({ |
| this.context, |
| this.partialResultToken, |
| required this.position, |
| required this.textDocument, |
| this.workDoneToken, |
| }); |
| static CompletionParams fromJson(Map<String, Object?> json) { |
| final contextJson = json['context']; |
| final context = contextJson != null |
| ? CompletionContext.fromJson(contextJson as Map<String, Object?>) |
| : null; |
| final partialResultTokenJson = json['partialResultToken']; |
| final partialResultToken = partialResultTokenJson == null |
| ? null |
| : _eitherIntString(partialResultTokenJson); |
| final positionJson = json['position']; |
| final position = Position.fromJson(positionJson as Map<String, Object?>); |
| final textDocumentJson = json['textDocument']; |
| final textDocument = TextDocumentIdentifier.fromJson( |
| textDocumentJson as Map<String, Object?>); |
| final workDoneTokenJson = json['workDoneToken']; |
| final workDoneToken = |
| workDoneTokenJson == null ? null : _eitherIntString(workDoneTokenJson); |
| return CompletionParams( |
| context: context, |
| partialResultToken: partialResultToken, |
| position: position, |
| textDocument: textDocument, |
| workDoneToken: workDoneToken, |
| ); |
| } |
| |
| /// The completion context. This is only available it the client specifies to |
| /// send this using the client capability |
| /// `textDocument.completion.contextSupport === true` |
| final CompletionContext? context; |
| |
| /// An optional token that a server can use to report partial results (e.g. |
| /// streaming) to the client. |
| @override |
| final ProgressToken? partialResultToken; |
| |
| /// The position inside the text document. |
| @override |
| final Position position; |
| |
| /// The text document. |
| @override |
| final TextDocumentIdentifier textDocument; |
| |
| /// An optional token that a server can use to report work done progress. |
| @override |
| final ProgressToken? workDoneToken; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (context != null) { |
| result['context'] = context?.toJson(); |
| } |
| if (partialResultToken != null) { |
| result['partialResultToken'] = partialResultToken; |
| } |
| result['position'] = position.toJson(); |
| result['textDocument'] = textDocument.toJson(); |
| if (workDoneToken != null) { |
| result['workDoneToken'] = workDoneToken; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseCompletionContext(obj, reporter, 'context', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseIntString(obj, reporter, 'partialResultToken', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParsePosition(obj, reporter, 'position', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseTextDocumentIdentifier(obj, reporter, 'textDocument', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseIntString(obj, reporter, 'workDoneToken', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CompletionParams'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CompletionParams && |
| other.runtimeType == CompletionParams && |
| context == other.context && |
| partialResultToken == other.partialResultToken && |
| position == other.position && |
| textDocument == other.textDocument && |
| workDoneToken == other.workDoneToken; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| context, |
| partialResultToken, |
| position, |
| textDocument, |
| workDoneToken, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Registration options for a CompletionRequest. |
| class CompletionRegistrationOptions |
| implements CompletionOptions, TextDocumentRegistrationOptions, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CompletionRegistrationOptions.canParse, |
| CompletionRegistrationOptions.fromJson, |
| ); |
| |
| CompletionRegistrationOptions({ |
| this.allCommitCharacters, |
| this.completionItem, |
| this.documentSelector, |
| this.resolveProvider, |
| this.triggerCharacters, |
| this.workDoneProgress, |
| }); |
| static CompletionRegistrationOptions fromJson(Map<String, Object?> json) { |
| final allCommitCharactersJson = json['allCommitCharacters']; |
| final allCommitCharacters = (allCommitCharactersJson as List<Object?>?) |
| ?.map((item) => item as String) |
| .toList(); |
| final completionItemJson = json['completionItem']; |
| final completionItem = completionItemJson != null |
| ? CompletionOptionsCompletionItem.fromJson( |
| completionItemJson as Map<String, Object?>) |
| : null; |
| final documentSelectorJson = json['documentSelector']; |
| final documentSelector = (documentSelectorJson as List<Object?>?) |
| ?.map((item) => |
| TextDocumentFilterWithScheme.fromJson(item as Map<String, Object?>)) |
| .toList(); |
| final resolveProviderJson = json['resolveProvider']; |
| final resolveProvider = resolveProviderJson as bool?; |
| final triggerCharactersJson = json['triggerCharacters']; |
| final triggerCharacters = (triggerCharactersJson as List<Object?>?) |
| ?.map((item) => item as String) |
| .toList(); |
| final workDoneProgressJson = json['workDoneProgress']; |
| final workDoneProgress = workDoneProgressJson as bool?; |
| return CompletionRegistrationOptions( |
| allCommitCharacters: allCommitCharacters, |
| completionItem: completionItem, |
| documentSelector: documentSelector, |
| resolveProvider: resolveProvider, |
| triggerCharacters: triggerCharacters, |
| workDoneProgress: workDoneProgress, |
| ); |
| } |
| |
| /// The list of all possible characters that commit a completion. This field |
| /// can be used if clients don't support individual commit characters per |
| /// completion item. See |
| /// `ClientCapabilities.textDocument.completion.completionItem.commitCharactersSupport` |
| /// |
| /// If a server provides both `allCommitCharacters` and commit characters on |
| /// an individual completion item the ones on the completion item win. |
| /// |
| /// @since 3.2.0 |
| @override |
| final List<String>? allCommitCharacters; |
| |
| /// The server supports the following `CompletionItem` specific capabilities. |
| /// |
| /// @since 3.17.0 |
| @override |
| final CompletionOptionsCompletionItem? completionItem; |
| |
| /// A document selector to identify the scope of the registration. If set to |
| /// null the document selector provided on the client side will be used. |
| @override |
| final List<TextDocumentFilterWithScheme>? documentSelector; |
| |
| /// The server provides support to resolve additional information for a |
| /// completion item. |
| @override |
| final bool? resolveProvider; |
| |
| /// Most tools trigger completion request automatically without explicitly |
| /// requesting it using a keyboard shortcut (e.g. Ctrl+Space). Typically they |
| /// do so when the user starts to type an identifier. For example if the user |
| /// types `c` in a JavaScript file code complete will automatically pop up |
| /// present `console` besides others as a completion item. Characters that |
| /// make up identifiers don't need to be listed here. |
| /// |
| /// If code complete should automatically be trigger on characters not being |
| /// valid inside an identifier (for example `.` in JavaScript) list them in |
| /// `triggerCharacters`. |
| @override |
| final List<String>? triggerCharacters; |
| @override |
| final bool? workDoneProgress; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (allCommitCharacters != null) { |
| result['allCommitCharacters'] = allCommitCharacters; |
| } |
| if (completionItem != null) { |
| result['completionItem'] = completionItem?.toJson(); |
| } |
| result['documentSelector'] = documentSelector; |
| if (resolveProvider != null) { |
| result['resolveProvider'] = resolveProvider; |
| } |
| if (triggerCharacters != null) { |
| result['triggerCharacters'] = triggerCharacters; |
| } |
| if (workDoneProgress != null) { |
| result['workDoneProgress'] = workDoneProgress; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseListString(obj, reporter, 'allCommitCharacters', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseCompletionOptionsCompletionItem( |
| obj, reporter, 'completionItem', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseListTextDocumentFilterWithScheme( |
| obj, reporter, 'documentSelector', |
| allowsUndefined: false, allowsNull: true)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'resolveProvider', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseListString(obj, reporter, 'triggerCharacters', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseBool(obj, reporter, 'workDoneProgress', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CompletionRegistrationOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CompletionRegistrationOptions && |
| other.runtimeType == CompletionRegistrationOptions && |
| listEqual(allCommitCharacters, other.allCommitCharacters, |
| (String a, String b) => a == b) && |
| completionItem == other.completionItem && |
| listEqual( |
| documentSelector, |
| other.documentSelector, |
| (TextDocumentFilterWithScheme a, TextDocumentFilterWithScheme b) => |
| a == b) && |
| resolveProvider == other.resolveProvider && |
| listEqual(triggerCharacters, other.triggerCharacters, |
| (String a, String b) => a == b) && |
| workDoneProgress == other.workDoneProgress; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| lspHashCode(allCommitCharacters), |
| completionItem, |
| lspHashCode(documentSelector), |
| resolveProvider, |
| lspHashCode(triggerCharacters), |
| workDoneProgress, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// How a completion was triggered |
| class CompletionTriggerKind implements ToJsonable { |
| const CompletionTriggerKind._(this._value); |
| const CompletionTriggerKind.fromJson(this._value); |
| |
| final int _value; |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| switch (obj) { |
| case 1: |
| case 2: |
| case 3: |
| return true; |
| } |
| return false; |
| } |
| |
| /// Completion was triggered by typing an identifier (24x7 code complete), |
| /// manual invocation (e.g Ctrl+Space) or via API. |
| static const Invoked = CompletionTriggerKind._(1); |
| |
| /// Completion was triggered by a trigger character specified by the |
| /// `triggerCharacters` properties of the `CompletionRegistrationOptions`. |
| static const TriggerCharacter = CompletionTriggerKind._(2); |
| |
| /// Completion was re-triggered as current completion list is incomplete |
| static const TriggerForIncompleteCompletions = CompletionTriggerKind._(3); |
| |
| @override |
| Object toJson() => _value; |
| |
| @override |
| String toString() => _value.toString(); |
| |
| @override |
| int get hashCode => _value.hashCode; |
| |
| @override |
| bool operator ==(Object other) => |
| other is CompletionTriggerKind && other._value == _value; |
| } |
| |
| class ConfigurationItem implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| ConfigurationItem.canParse, |
| ConfigurationItem.fromJson, |
| ); |
| |
| ConfigurationItem({ |
| this.scopeUri, |
| this.section, |
| }); |
| static ConfigurationItem fromJson(Map<String, Object?> json) { |
| final scopeUriJson = json['scopeUri']; |
| final scopeUri = scopeUriJson as String?; |
| final sectionJson = json['section']; |
| final section = sectionJson as String?; |
| return ConfigurationItem( |
| scopeUri: scopeUri, |
| section: section, |
| ); |
| } |
| |
| /// The scope to get the configuration section for. |
| final String? scopeUri; |
| |
| /// The configuration section asked for. |
| final String? section; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (scopeUri != null) { |
| result['scopeUri'] = scopeUri; |
| } |
| if (section != null) { |
| result['section'] = section; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseString(obj, reporter, 'scopeUri', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseString(obj, reporter, 'section', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type ConfigurationItem'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is ConfigurationItem && |
| other.runtimeType == ConfigurationItem && |
| scopeUri == other.scopeUri && |
| section == other.section; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| scopeUri, |
| section, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The parameters of a configuration request. |
| class ConfigurationParams implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| ConfigurationParams.canParse, |
| ConfigurationParams.fromJson, |
| ); |
| |
| ConfigurationParams({ |
| required this.items, |
| }); |
| static ConfigurationParams fromJson(Map<String, Object?> json) { |
| final itemsJson = json['items']; |
| final items = (itemsJson as List<Object?>) |
| .map((item) => ConfigurationItem.fromJson(item as Map<String, Object?>)) |
| .toList(); |
| return ConfigurationParams( |
| items: items, |
| ); |
| } |
| |
| final List<ConfigurationItem> items; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['items'] = items.map((item) => item.toJson()).toList(); |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseListConfigurationItem(obj, reporter, 'items', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type ConfigurationParams'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is ConfigurationParams && |
| other.runtimeType == ConfigurationParams && |
| listEqual(items, other.items, |
| (ConfigurationItem a, ConfigurationItem b) => a == b); |
| } |
| |
| @override |
| int get hashCode => lspHashCode(items); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Create file operation. |
| class CreateFile implements ResourceOperation, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CreateFile.canParse, |
| CreateFile.fromJson, |
| ); |
| |
| CreateFile({ |
| this.annotationId, |
| this.kind = 'create', |
| this.options, |
| required this.uri, |
| }) { |
| if (kind != 'create') { |
| throw 'kind may only be the literal \'create\''; |
| } |
| } |
| static CreateFile fromJson(Map<String, Object?> json) { |
| final annotationIdJson = json['annotationId']; |
| final annotationId = annotationIdJson as String?; |
| final kindJson = json['kind']; |
| final kind = kindJson as String; |
| final optionsJson = json['options']; |
| final options = optionsJson != null |
| ? CreateFileOptions.fromJson(optionsJson as Map<String, Object?>) |
| : null; |
| final uriJson = json['uri']; |
| final uri = uriJson as String; |
| return CreateFile( |
| annotationId: annotationId, |
| kind: kind, |
| options: options, |
| uri: uri, |
| ); |
| } |
| |
| /// An optional annotation identifier describing the operation. |
| /// |
| /// @since 3.16.0 |
| @override |
| final ChangeAnnotationIdentifier? annotationId; |
| |
| /// A create |
| @override |
| final String kind; |
| |
| /// Additional options |
| final CreateFileOptions? options; |
| |
| /// The resource to create. |
| final DocumentUri uri; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (annotationId != null) { |
| result['annotationId'] = annotationId; |
| } |
| result['kind'] = kind; |
| if (options != null) { |
| result['options'] = options?.toJson(); |
| } |
| result['uri'] = uri; |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseString(obj, reporter, 'annotationId', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseLiteral(obj, reporter, 'kind', |
| allowsUndefined: false, allowsNull: false, literal: 'create')) { |
| return false; |
| } |
| if (!_canParseCreateFileOptions(obj, reporter, 'options', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseString(obj, reporter, 'uri', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CreateFile'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CreateFile && |
| other.runtimeType == CreateFile && |
| annotationId == other.annotationId && |
| kind == other.kind && |
| options == other.options && |
| uri == other.uri; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| annotationId, |
| kind, |
| options, |
| uri, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Options to create a file. |
| class CreateFileOptions implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CreateFileOptions.canParse, |
| CreateFileOptions.fromJson, |
| ); |
| |
| CreateFileOptions({ |
| this.ignoreIfExists, |
| this.overwrite, |
| }); |
| static CreateFileOptions fromJson(Map<String, Object?> json) { |
| final ignoreIfExistsJson = json['ignoreIfExists']; |
| final ignoreIfExists = ignoreIfExistsJson as bool?; |
| final overwriteJson = json['overwrite']; |
| final overwrite = overwriteJson as bool?; |
| return CreateFileOptions( |
| ignoreIfExists: ignoreIfExists, |
| overwrite: overwrite, |
| ); |
| } |
| |
| /// Ignore if exists. |
| final bool? ignoreIfExists; |
| |
| /// Overwrite existing file. Overwrite wins over `ignoreIfExists` |
| final bool? overwrite; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (ignoreIfExists != null) { |
| result['ignoreIfExists'] = ignoreIfExists; |
| } |
| if (overwrite != null) { |
| result['overwrite'] = overwrite; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseBool(obj, reporter, 'ignoreIfExists', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseBool(obj, reporter, 'overwrite', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CreateFileOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CreateFileOptions && |
| other.runtimeType == CreateFileOptions && |
| ignoreIfExists == other.ignoreIfExists && |
| overwrite == other.overwrite; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| ignoreIfExists, |
| overwrite, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The parameters sent in notifications/requests for user-initiated creation of |
| /// files. |
| /// |
| /// @since 3.16.0 |
| class CreateFilesParams implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| CreateFilesParams.canParse, |
| CreateFilesParams.fromJson, |
| ); |
| |
| CreateFilesParams({ |
| required this.files, |
| }); |
| static CreateFilesParams fromJson(Map<String, Object?> json) { |
| final filesJson = json['files']; |
| final files = (filesJson as List<Object?>) |
| .map((item) => FileCreate.fromJson(item as Map<String, Object?>)) |
| .toList(); |
| return CreateFilesParams( |
| files: files, |
| ); |
| } |
| |
| /// An array of all files/folders created in this operation. |
| final List<FileCreate> files; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['files'] = files.map((item) => item.toJson()).toList(); |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseListFileCreate(obj, reporter, 'files', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type CreateFilesParams'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is CreateFilesParams && |
| other.runtimeType == CreateFilesParams && |
| listEqual(files, other.files, (FileCreate a, FileCreate b) => a == b); |
| } |
| |
| @override |
| int get hashCode => lspHashCode(files); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// @since 3.14.0 |
| class DeclarationClientCapabilities implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DeclarationClientCapabilities.canParse, |
| DeclarationClientCapabilities.fromJson, |
| ); |
| |
| DeclarationClientCapabilities({ |
| this.dynamicRegistration, |
| this.linkSupport, |
| }); |
| static DeclarationClientCapabilities fromJson(Map<String, Object?> json) { |
| final dynamicRegistrationJson = json['dynamicRegistration']; |
| final dynamicRegistration = dynamicRegistrationJson as bool?; |
| final linkSupportJson = json['linkSupport']; |
| final linkSupport = linkSupportJson as bool?; |
| return DeclarationClientCapabilities( |
| dynamicRegistration: dynamicRegistration, |
| linkSupport: linkSupport, |
| ); |
| } |
| |
| /// Whether declaration supports dynamic registration. If this is set to |
| /// `true` the client supports the new `DeclarationRegistrationOptions` return |
| /// value for the corresponding server capability as well. |
| final bool? dynamicRegistration; |
| |
| /// The client supports additional metadata in the form of declaration links. |
| final bool? linkSupport; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (dynamicRegistration != null) { |
| result['dynamicRegistration'] = dynamicRegistration; |
| } |
| if (linkSupport != null) { |
| result['linkSupport'] = linkSupport; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseBool(obj, reporter, 'dynamicRegistration', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseBool(obj, reporter, 'linkSupport', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DeclarationClientCapabilities'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DeclarationClientCapabilities && |
| other.runtimeType == DeclarationClientCapabilities && |
| dynamicRegistration == other.dynamicRegistration && |
| linkSupport == other.linkSupport; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| dynamicRegistration, |
| linkSupport, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class DeclarationOptions implements WorkDoneProgressOptions, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DeclarationOptions.canParse, |
| DeclarationOptions.fromJson, |
| ); |
| |
| DeclarationOptions({ |
| this.workDoneProgress, |
| }); |
| static DeclarationOptions fromJson(Map<String, Object?> json) { |
| if (DeclarationRegistrationOptions.canParse(json, nullLspJsonReporter)) { |
| return DeclarationRegistrationOptions.fromJson(json); |
| } |
| final workDoneProgressJson = json['workDoneProgress']; |
| final workDoneProgress = workDoneProgressJson as bool?; |
| return DeclarationOptions( |
| workDoneProgress: workDoneProgress, |
| ); |
| } |
| |
| @override |
| final bool? workDoneProgress; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (workDoneProgress != null) { |
| result['workDoneProgress'] = workDoneProgress; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseBool(obj, reporter, 'workDoneProgress', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DeclarationOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DeclarationOptions && |
| other.runtimeType == DeclarationOptions && |
| workDoneProgress == other.workDoneProgress; |
| } |
| |
| @override |
| int get hashCode => workDoneProgress.hashCode; |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class DeclarationParams |
| implements |
| PartialResultParams, |
| TextDocumentPositionParams, |
| WorkDoneProgressParams, |
| ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DeclarationParams.canParse, |
| DeclarationParams.fromJson, |
| ); |
| |
| DeclarationParams({ |
| this.partialResultToken, |
| required this.position, |
| required this.textDocument, |
| this.workDoneToken, |
| }); |
| static DeclarationParams fromJson(Map<String, Object?> json) { |
| final partialResultTokenJson = json['partialResultToken']; |
| final partialResultToken = partialResultTokenJson == null |
| ? null |
| : _eitherIntString(partialResultTokenJson); |
| final positionJson = json['position']; |
| final position = Position.fromJson(positionJson as Map<String, Object?>); |
| final textDocumentJson = json['textDocument']; |
| final textDocument = TextDocumentIdentifier.fromJson( |
| textDocumentJson as Map<String, Object?>); |
| final workDoneTokenJson = json['workDoneToken']; |
| final workDoneToken = |
| workDoneTokenJson == null ? null : _eitherIntString(workDoneTokenJson); |
| return DeclarationParams( |
| partialResultToken: partialResultToken, |
| position: position, |
| textDocument: textDocument, |
| workDoneToken: workDoneToken, |
| ); |
| } |
| |
| /// An optional token that a server can use to report partial results (e.g. |
| /// streaming) to the client. |
| @override |
| final ProgressToken? partialResultToken; |
| |
| /// The position inside the text document. |
| @override |
| final Position position; |
| |
| /// The text document. |
| @override |
| final TextDocumentIdentifier textDocument; |
| |
| /// An optional token that a server can use to report work done progress. |
| @override |
| final ProgressToken? workDoneToken; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (partialResultToken != null) { |
| result['partialResultToken'] = partialResultToken; |
| } |
| result['position'] = position.toJson(); |
| result['textDocument'] = textDocument.toJson(); |
| if (workDoneToken != null) { |
| result['workDoneToken'] = workDoneToken; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseIntString(obj, reporter, 'partialResultToken', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParsePosition(obj, reporter, 'position', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseTextDocumentIdentifier(obj, reporter, 'textDocument', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseIntString(obj, reporter, 'workDoneToken', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DeclarationParams'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DeclarationParams && |
| other.runtimeType == DeclarationParams && |
| partialResultToken == other.partialResultToken && |
| position == other.position && |
| textDocument == other.textDocument && |
| workDoneToken == other.workDoneToken; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| partialResultToken, |
| position, |
| textDocument, |
| workDoneToken, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class DeclarationRegistrationOptions |
| implements |
| DeclarationOptions, |
| StaticRegistrationOptions, |
| TextDocumentRegistrationOptions, |
| ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DeclarationRegistrationOptions.canParse, |
| DeclarationRegistrationOptions.fromJson, |
| ); |
| |
| DeclarationRegistrationOptions({ |
| this.documentSelector, |
| this.id, |
| this.workDoneProgress, |
| }); |
| static DeclarationRegistrationOptions fromJson(Map<String, Object?> json) { |
| final documentSelectorJson = json['documentSelector']; |
| final documentSelector = (documentSelectorJson as List<Object?>?) |
| ?.map((item) => |
| TextDocumentFilterWithScheme.fromJson(item as Map<String, Object?>)) |
| .toList(); |
| final idJson = json['id']; |
| final id = idJson as String?; |
| final workDoneProgressJson = json['workDoneProgress']; |
| final workDoneProgress = workDoneProgressJson as bool?; |
| return DeclarationRegistrationOptions( |
| documentSelector: documentSelector, |
| id: id, |
| workDoneProgress: workDoneProgress, |
| ); |
| } |
| |
| /// A document selector to identify the scope of the registration. If set to |
| /// null the document selector provided on the client side will be used. |
| @override |
| final List<TextDocumentFilterWithScheme>? documentSelector; |
| |
| /// The id used to register the request. The id can be used to deregister the |
| /// request again. See also Registration#id. |
| @override |
| final String? id; |
| @override |
| final bool? workDoneProgress; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['documentSelector'] = documentSelector; |
| if (id != null) { |
| result['id'] = id; |
| } |
| if (workDoneProgress != null) { |
| result['workDoneProgress'] = workDoneProgress; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseListTextDocumentFilterWithScheme( |
| obj, reporter, 'documentSelector', |
| allowsUndefined: false, allowsNull: true)) { |
| return false; |
| } |
| if (!_canParseString(obj, reporter, 'id', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseBool(obj, reporter, 'workDoneProgress', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DeclarationRegistrationOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DeclarationRegistrationOptions && |
| other.runtimeType == DeclarationRegistrationOptions && |
| listEqual( |
| documentSelector, |
| other.documentSelector, |
| (TextDocumentFilterWithScheme a, TextDocumentFilterWithScheme b) => |
| a == b) && |
| id == other.id && |
| workDoneProgress == other.workDoneProgress; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| lspHashCode(documentSelector), |
| id, |
| workDoneProgress, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Client Capabilities for a DefinitionRequest. |
| class DefinitionClientCapabilities implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DefinitionClientCapabilities.canParse, |
| DefinitionClientCapabilities.fromJson, |
| ); |
| |
| DefinitionClientCapabilities({ |
| this.dynamicRegistration, |
| this.linkSupport, |
| }); |
| static DefinitionClientCapabilities fromJson(Map<String, Object?> json) { |
| final dynamicRegistrationJson = json['dynamicRegistration']; |
| final dynamicRegistration = dynamicRegistrationJson as bool?; |
| final linkSupportJson = json['linkSupport']; |
| final linkSupport = linkSupportJson as bool?; |
| return DefinitionClientCapabilities( |
| dynamicRegistration: dynamicRegistration, |
| linkSupport: linkSupport, |
| ); |
| } |
| |
| /// Whether definition supports dynamic registration. |
| final bool? dynamicRegistration; |
| |
| /// The client supports additional metadata in the form of definition links. |
| /// |
| /// @since 3.14.0 |
| final bool? linkSupport; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (dynamicRegistration != null) { |
| result['dynamicRegistration'] = dynamicRegistration; |
| } |
| if (linkSupport != null) { |
| result['linkSupport'] = linkSupport; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseBool(obj, reporter, 'dynamicRegistration', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseBool(obj, reporter, 'linkSupport', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DefinitionClientCapabilities'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DefinitionClientCapabilities && |
| other.runtimeType == DefinitionClientCapabilities && |
| dynamicRegistration == other.dynamicRegistration && |
| linkSupport == other.linkSupport; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| dynamicRegistration, |
| linkSupport, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Server Capabilities for a DefinitionRequest. |
| class DefinitionOptions implements WorkDoneProgressOptions, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DefinitionOptions.canParse, |
| DefinitionOptions.fromJson, |
| ); |
| |
| DefinitionOptions({ |
| this.workDoneProgress, |
| }); |
| static DefinitionOptions fromJson(Map<String, Object?> json) { |
| if (DefinitionRegistrationOptions.canParse(json, nullLspJsonReporter)) { |
| return DefinitionRegistrationOptions.fromJson(json); |
| } |
| final workDoneProgressJson = json['workDoneProgress']; |
| final workDoneProgress = workDoneProgressJson as bool?; |
| return DefinitionOptions( |
| workDoneProgress: workDoneProgress, |
| ); |
| } |
| |
| @override |
| final bool? workDoneProgress; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (workDoneProgress != null) { |
| result['workDoneProgress'] = workDoneProgress; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseBool(obj, reporter, 'workDoneProgress', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DefinitionOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DefinitionOptions && |
| other.runtimeType == DefinitionOptions && |
| workDoneProgress == other.workDoneProgress; |
| } |
| |
| @override |
| int get hashCode => workDoneProgress.hashCode; |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Parameters for a DefinitionRequest. |
| class DefinitionParams |
| implements |
| PartialResultParams, |
| TextDocumentPositionParams, |
| WorkDoneProgressParams, |
| ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DefinitionParams.canParse, |
| DefinitionParams.fromJson, |
| ); |
| |
| DefinitionParams({ |
| this.partialResultToken, |
| required this.position, |
| required this.textDocument, |
| this.workDoneToken, |
| }); |
| static DefinitionParams fromJson(Map<String, Object?> json) { |
| final partialResultTokenJson = json['partialResultToken']; |
| final partialResultToken = partialResultTokenJson == null |
| ? null |
| : _eitherIntString(partialResultTokenJson); |
| final positionJson = json['position']; |
| final position = Position.fromJson(positionJson as Map<String, Object?>); |
| final textDocumentJson = json['textDocument']; |
| final textDocument = TextDocumentIdentifier.fromJson( |
| textDocumentJson as Map<String, Object?>); |
| final workDoneTokenJson = json['workDoneToken']; |
| final workDoneToken = |
| workDoneTokenJson == null ? null : _eitherIntString(workDoneTokenJson); |
| return DefinitionParams( |
| partialResultToken: partialResultToken, |
| position: position, |
| textDocument: textDocument, |
| workDoneToken: workDoneToken, |
| ); |
| } |
| |
| /// An optional token that a server can use to report partial results (e.g. |
| /// streaming) to the client. |
| @override |
| final ProgressToken? partialResultToken; |
| |
| /// The position inside the text document. |
| @override |
| final Position position; |
| |
| /// The text document. |
| @override |
| final TextDocumentIdentifier textDocument; |
| |
| /// An optional token that a server can use to report work done progress. |
| @override |
| final ProgressToken? workDoneToken; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (partialResultToken != null) { |
| result['partialResultToken'] = partialResultToken; |
| } |
| result['position'] = position.toJson(); |
| result['textDocument'] = textDocument.toJson(); |
| if (workDoneToken != null) { |
| result['workDoneToken'] = workDoneToken; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseIntString(obj, reporter, 'partialResultToken', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParsePosition(obj, reporter, 'position', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseTextDocumentIdentifier(obj, reporter, 'textDocument', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseIntString(obj, reporter, 'workDoneToken', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DefinitionParams'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DefinitionParams && |
| other.runtimeType == DefinitionParams && |
| partialResultToken == other.partialResultToken && |
| position == other.position && |
| textDocument == other.textDocument && |
| workDoneToken == other.workDoneToken; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| partialResultToken, |
| position, |
| textDocument, |
| workDoneToken, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Registration options for a DefinitionRequest. |
| class DefinitionRegistrationOptions |
| implements DefinitionOptions, TextDocumentRegistrationOptions, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DefinitionRegistrationOptions.canParse, |
| DefinitionRegistrationOptions.fromJson, |
| ); |
| |
| DefinitionRegistrationOptions({ |
| this.documentSelector, |
| this.workDoneProgress, |
| }); |
| static DefinitionRegistrationOptions fromJson(Map<String, Object?> json) { |
| final documentSelectorJson = json['documentSelector']; |
| final documentSelector = (documentSelectorJson as List<Object?>?) |
| ?.map((item) => |
| TextDocumentFilterWithScheme.fromJson(item as Map<String, Object?>)) |
| .toList(); |
| final workDoneProgressJson = json['workDoneProgress']; |
| final workDoneProgress = workDoneProgressJson as bool?; |
| return DefinitionRegistrationOptions( |
| documentSelector: documentSelector, |
| workDoneProgress: workDoneProgress, |
| ); |
| } |
| |
| /// A document selector to identify the scope of the registration. If set to |
| /// null the document selector provided on the client side will be used. |
| @override |
| final List<TextDocumentFilterWithScheme>? documentSelector; |
| @override |
| final bool? workDoneProgress; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['documentSelector'] = documentSelector; |
| if (workDoneProgress != null) { |
| result['workDoneProgress'] = workDoneProgress; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseListTextDocumentFilterWithScheme( |
| obj, reporter, 'documentSelector', |
| allowsUndefined: false, allowsNull: true)) { |
| return false; |
| } |
| return _canParseBool(obj, reporter, 'workDoneProgress', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DefinitionRegistrationOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DefinitionRegistrationOptions && |
| other.runtimeType == DefinitionRegistrationOptions && |
| listEqual( |
| documentSelector, |
| other.documentSelector, |
| (TextDocumentFilterWithScheme a, TextDocumentFilterWithScheme b) => |
| a == b) && |
| workDoneProgress == other.workDoneProgress; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| lspHashCode(documentSelector), |
| workDoneProgress, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Delete file operation |
| class DeleteFile implements ResourceOperation, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DeleteFile.canParse, |
| DeleteFile.fromJson, |
| ); |
| |
| DeleteFile({ |
| this.annotationId, |
| this.kind = 'delete', |
| this.options, |
| required this.uri, |
| }) { |
| if (kind != 'delete') { |
| throw 'kind may only be the literal \'delete\''; |
| } |
| } |
| static DeleteFile fromJson(Map<String, Object?> json) { |
| final annotationIdJson = json['annotationId']; |
| final annotationId = annotationIdJson as String?; |
| final kindJson = json['kind']; |
| final kind = kindJson as String; |
| final optionsJson = json['options']; |
| final options = optionsJson != null |
| ? DeleteFileOptions.fromJson(optionsJson as Map<String, Object?>) |
| : null; |
| final uriJson = json['uri']; |
| final uri = uriJson as String; |
| return DeleteFile( |
| annotationId: annotationId, |
| kind: kind, |
| options: options, |
| uri: uri, |
| ); |
| } |
| |
| /// An optional annotation identifier describing the operation. |
| /// |
| /// @since 3.16.0 |
| @override |
| final ChangeAnnotationIdentifier? annotationId; |
| |
| /// A delete |
| @override |
| final String kind; |
| |
| /// Delete options. |
| final DeleteFileOptions? options; |
| |
| /// The file to delete. |
| final DocumentUri uri; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (annotationId != null) { |
| result['annotationId'] = annotationId; |
| } |
| result['kind'] = kind; |
| if (options != null) { |
| result['options'] = options?.toJson(); |
| } |
| result['uri'] = uri; |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseString(obj, reporter, 'annotationId', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseLiteral(obj, reporter, 'kind', |
| allowsUndefined: false, allowsNull: false, literal: 'delete')) { |
| return false; |
| } |
| if (!_canParseDeleteFileOptions(obj, reporter, 'options', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseString(obj, reporter, 'uri', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DeleteFile'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DeleteFile && |
| other.runtimeType == DeleteFile && |
| annotationId == other.annotationId && |
| kind == other.kind && |
| options == other.options && |
| uri == other.uri; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| annotationId, |
| kind, |
| options, |
| uri, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Delete file options |
| class DeleteFileOptions implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DeleteFileOptions.canParse, |
| DeleteFileOptions.fromJson, |
| ); |
| |
| DeleteFileOptions({ |
| this.ignoreIfNotExists, |
| this.recursive, |
| }); |
| static DeleteFileOptions fromJson(Map<String, Object?> json) { |
| final ignoreIfNotExistsJson = json['ignoreIfNotExists']; |
| final ignoreIfNotExists = ignoreIfNotExistsJson as bool?; |
| final recursiveJson = json['recursive']; |
| final recursive = recursiveJson as bool?; |
| return DeleteFileOptions( |
| ignoreIfNotExists: ignoreIfNotExists, |
| recursive: recursive, |
| ); |
| } |
| |
| /// Ignore the operation if the file doesn't exist. |
| final bool? ignoreIfNotExists; |
| |
| /// Delete the content recursively if a folder is denoted. |
| final bool? recursive; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (ignoreIfNotExists != null) { |
| result['ignoreIfNotExists'] = ignoreIfNotExists; |
| } |
| if (recursive != null) { |
| result['recursive'] = recursive; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseBool(obj, reporter, 'ignoreIfNotExists', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseBool(obj, reporter, 'recursive', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DeleteFileOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DeleteFileOptions && |
| other.runtimeType == DeleteFileOptions && |
| ignoreIfNotExists == other.ignoreIfNotExists && |
| recursive == other.recursive; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| ignoreIfNotExists, |
| recursive, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The parameters sent in notifications/requests for user-initiated deletes of |
| /// files. |
| /// |
| /// @since 3.16.0 |
| class DeleteFilesParams implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DeleteFilesParams.canParse, |
| DeleteFilesParams.fromJson, |
| ); |
| |
| DeleteFilesParams({ |
| required this.files, |
| }); |
| static DeleteFilesParams fromJson(Map<String, Object?> json) { |
| final filesJson = json['files']; |
| final files = (filesJson as List<Object?>) |
| .map((item) => FileDelete.fromJson(item as Map<String, Object?>)) |
| .toList(); |
| return DeleteFilesParams( |
| files: files, |
| ); |
| } |
| |
| /// An array of all files/folders deleted in this operation. |
| final List<FileDelete> files; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['files'] = files.map((item) => item.toJson()).toList(); |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseListFileDelete(obj, reporter, 'files', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DeleteFilesParams'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DeleteFilesParams && |
| other.runtimeType == DeleteFilesParams && |
| listEqual(files, other.files, (FileDelete a, FileDelete b) => a == b); |
| } |
| |
| @override |
| int get hashCode => lspHashCode(files); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Represents a diagnostic, such as a compiler error or warning. Diagnostic |
| /// objects are only valid in the scope of a resource. |
| class Diagnostic implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| Diagnostic.canParse, |
| Diagnostic.fromJson, |
| ); |
| |
| Diagnostic({ |
| this.code, |
| this.codeDescription, |
| this.data, |
| required this.message, |
| required this.range, |
| this.relatedInformation, |
| this.severity, |
| this.source, |
| this.tags, |
| }); |
| static Diagnostic fromJson(Map<String, Object?> json) { |
| final codeJson = json['code']; |
| final code = codeJson as String?; |
| final codeDescriptionJson = json['codeDescription']; |
| final codeDescription = codeDescriptionJson != null |
| ? CodeDescription.fromJson(codeDescriptionJson as Map<String, Object?>) |
| : null; |
| final dataJson = json['data']; |
| final data = dataJson; |
| final messageJson = json['message']; |
| final message = messageJson as String; |
| final rangeJson = json['range']; |
| final range = Range.fromJson(rangeJson as Map<String, Object?>); |
| final relatedInformationJson = json['relatedInformation']; |
| final relatedInformation = (relatedInformationJson as List<Object?>?) |
| ?.map((item) => |
| DiagnosticRelatedInformation.fromJson(item as Map<String, Object?>)) |
| .toList(); |
| final severityJson = json['severity']; |
| final severity = severityJson != null |
| ? DiagnosticSeverity.fromJson(severityJson as int) |
| : null; |
| final sourceJson = json['source']; |
| final source = sourceJson as String?; |
| final tagsJson = json['tags']; |
| final tags = (tagsJson as List<Object?>?) |
| ?.map((item) => DiagnosticTag.fromJson(item as int)) |
| .toList(); |
| return Diagnostic( |
| code: code, |
| codeDescription: codeDescription, |
| data: data, |
| message: message, |
| range: range, |
| relatedInformation: relatedInformation, |
| severity: severity, |
| source: source, |
| tags: tags, |
| ); |
| } |
| |
| /// The diagnostic's code, which usually appear in the user interface. |
| final String? code; |
| |
| /// An optional property to describe the error code. Requires the code field |
| /// (above) to be present/not null. |
| /// |
| /// @since 3.16.0 |
| final CodeDescription? codeDescription; |
| |
| /// A data entry field that is preserved between a |
| /// `textDocument/publishDiagnostics` notification and |
| /// `textDocument/codeAction` request. |
| /// |
| /// @since 3.16.0 |
| final LSPAny data; |
| |
| /// The diagnostic's message. It usually appears in the user interface |
| final String message; |
| |
| /// The range at which the message applies |
| final Range range; |
| |
| /// An array of related diagnostic information, e.g. when symbol-names within |
| /// a scope collide all definitions can be marked via this property. |
| final List<DiagnosticRelatedInformation>? relatedInformation; |
| |
| /// The diagnostic's severity. Can be omitted. If omitted it is up to the |
| /// client to interpret diagnostics as error, warning, info or hint. |
| final DiagnosticSeverity? severity; |
| |
| /// A human-readable string describing the source of this diagnostic, e.g. |
| /// 'typescript' or 'super lint'. It usually appears in the user interface. |
| final String? source; |
| |
| /// Additional metadata about the diagnostic. |
| /// |
| /// @since 3.15.0 |
| final List<DiagnosticTag>? tags; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (code != null) { |
| result['code'] = code; |
| } |
| if (codeDescription != null) { |
| result['codeDescription'] = codeDescription?.toJson(); |
| } |
| if (data != null) { |
| result['data'] = data; |
| } |
| result['message'] = message; |
| result['range'] = range.toJson(); |
| if (relatedInformation != null) { |
| result['relatedInformation'] = |
| relatedInformation?.map((item) => item.toJson()).toList(); |
| } |
| if (severity != null) { |
| result['severity'] = severity?.toJson(); |
| } |
| if (source != null) { |
| result['source'] = source; |
| } |
| if (tags != null) { |
| result['tags'] = tags?.map((item) => item.toJson()).toList(); |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseString(obj, reporter, 'code', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseCodeDescription(obj, reporter, 'codeDescription', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseString(obj, reporter, 'message', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseRange(obj, reporter, 'range', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseListDiagnosticRelatedInformation( |
| obj, reporter, 'relatedInformation', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseDiagnosticSeverity(obj, reporter, 'severity', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseString(obj, reporter, 'source', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseListDiagnosticTag(obj, reporter, 'tags', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type Diagnostic'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is Diagnostic && |
| other.runtimeType == Diagnostic && |
| code == other.code && |
| codeDescription == other.codeDescription && |
| data == other.data && |
| message == other.message && |
| range == other.range && |
| listEqual( |
| relatedInformation, |
| other.relatedInformation, |
| (DiagnosticRelatedInformation a, DiagnosticRelatedInformation b) => |
| a == b) && |
| severity == other.severity && |
| source == other.source && |
| listEqual( |
| tags, other.tags, (DiagnosticTag a, DiagnosticTag b) => a == b); |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| code, |
| codeDescription, |
| data, |
| message, |
| range, |
| lspHashCode(relatedInformation), |
| severity, |
| source, |
| lspHashCode(tags), |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Client capabilities specific to diagnostic pull requests. |
| /// |
| /// @since 3.17.0 |
| class DiagnosticClientCapabilities implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DiagnosticClientCapabilities.canParse, |
| DiagnosticClientCapabilities.fromJson, |
| ); |
| |
| DiagnosticClientCapabilities({ |
| this.dynamicRegistration, |
| this.relatedDocumentSupport, |
| }); |
| static DiagnosticClientCapabilities fromJson(Map<String, Object?> json) { |
| final dynamicRegistrationJson = json['dynamicRegistration']; |
| final dynamicRegistration = dynamicRegistrationJson as bool?; |
| final relatedDocumentSupportJson = json['relatedDocumentSupport']; |
| final relatedDocumentSupport = relatedDocumentSupportJson as bool?; |
| return DiagnosticClientCapabilities( |
| dynamicRegistration: dynamicRegistration, |
| relatedDocumentSupport: relatedDocumentSupport, |
| ); |
| } |
| |
| /// Whether implementation supports dynamic registration. If this is set to |
| /// `true` the client supports the new `(TextDocumentRegistrationOptions & |
| /// StaticRegistrationOptions)` return value for the corresponding server |
| /// capability as well. |
| final bool? dynamicRegistration; |
| |
| /// Whether the clients supports related documents for document diagnostic |
| /// pulls. |
| final bool? relatedDocumentSupport; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (dynamicRegistration != null) { |
| result['dynamicRegistration'] = dynamicRegistration; |
| } |
| if (relatedDocumentSupport != null) { |
| result['relatedDocumentSupport'] = relatedDocumentSupport; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseBool(obj, reporter, 'dynamicRegistration', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseBool(obj, reporter, 'relatedDocumentSupport', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DiagnosticClientCapabilities'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DiagnosticClientCapabilities && |
| other.runtimeType == DiagnosticClientCapabilities && |
| dynamicRegistration == other.dynamicRegistration && |
| relatedDocumentSupport == other.relatedDocumentSupport; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| dynamicRegistration, |
| relatedDocumentSupport, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Diagnostic options. |
| /// |
| /// @since 3.17.0 |
| class DiagnosticOptions implements WorkDoneProgressOptions, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DiagnosticOptions.canParse, |
| DiagnosticOptions.fromJson, |
| ); |
| |
| DiagnosticOptions({ |
| this.identifier, |
| required this.interFileDependencies, |
| this.workDoneProgress, |
| required this.workspaceDiagnostics, |
| }); |
| static DiagnosticOptions fromJson(Map<String, Object?> json) { |
| if (DiagnosticRegistrationOptions.canParse(json, nullLspJsonReporter)) { |
| return DiagnosticRegistrationOptions.fromJson(json); |
| } |
| final identifierJson = json['identifier']; |
| final identifier = identifierJson as String?; |
| final interFileDependenciesJson = json['interFileDependencies']; |
| final interFileDependencies = interFileDependenciesJson as bool; |
| final workDoneProgressJson = json['workDoneProgress']; |
| final workDoneProgress = workDoneProgressJson as bool?; |
| final workspaceDiagnosticsJson = json['workspaceDiagnostics']; |
| final workspaceDiagnostics = workspaceDiagnosticsJson as bool; |
| return DiagnosticOptions( |
| identifier: identifier, |
| interFileDependencies: interFileDependencies, |
| workDoneProgress: workDoneProgress, |
| workspaceDiagnostics: workspaceDiagnostics, |
| ); |
| } |
| |
| /// An optional identifier under which the diagnostics are managed by the |
| /// client. |
| final String? identifier; |
| |
| /// Whether the language has inter file dependencies meaning that editing code |
| /// in one file can result in a different diagnostic set in another file. |
| /// Inter file dependencies are common for most programming languages and |
| /// typically uncommon for linters. |
| final bool interFileDependencies; |
| @override |
| final bool? workDoneProgress; |
| |
| /// The server provides support for workspace diagnostics as well. |
| final bool workspaceDiagnostics; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (identifier != null) { |
| result['identifier'] = identifier; |
| } |
| result['interFileDependencies'] = interFileDependencies; |
| if (workDoneProgress != null) { |
| result['workDoneProgress'] = workDoneProgress; |
| } |
| result['workspaceDiagnostics'] = workspaceDiagnostics; |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseString(obj, reporter, 'identifier', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'interFileDependencies', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'workDoneProgress', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseBool(obj, reporter, 'workspaceDiagnostics', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DiagnosticOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DiagnosticOptions && |
| other.runtimeType == DiagnosticOptions && |
| identifier == other.identifier && |
| interFileDependencies == other.interFileDependencies && |
| workDoneProgress == other.workDoneProgress && |
| workspaceDiagnostics == other.workspaceDiagnostics; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| identifier, |
| interFileDependencies, |
| workDoneProgress, |
| workspaceDiagnostics, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Diagnostic registration options. |
| /// |
| /// @since 3.17.0 |
| class DiagnosticRegistrationOptions |
| implements |
| DiagnosticOptions, |
| StaticRegistrationOptions, |
| TextDocumentRegistrationOptions, |
| ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DiagnosticRegistrationOptions.canParse, |
| DiagnosticRegistrationOptions.fromJson, |
| ); |
| |
| DiagnosticRegistrationOptions({ |
| this.documentSelector, |
| this.id, |
| this.identifier, |
| required this.interFileDependencies, |
| this.workDoneProgress, |
| required this.workspaceDiagnostics, |
| }); |
| static DiagnosticRegistrationOptions fromJson(Map<String, Object?> json) { |
| final documentSelectorJson = json['documentSelector']; |
| final documentSelector = (documentSelectorJson as List<Object?>?) |
| ?.map((item) => |
| TextDocumentFilterWithScheme.fromJson(item as Map<String, Object?>)) |
| .toList(); |
| final idJson = json['id']; |
| final id = idJson as String?; |
| final identifierJson = json['identifier']; |
| final identifier = identifierJson as String?; |
| final interFileDependenciesJson = json['interFileDependencies']; |
| final interFileDependencies = interFileDependenciesJson as bool; |
| final workDoneProgressJson = json['workDoneProgress']; |
| final workDoneProgress = workDoneProgressJson as bool?; |
| final workspaceDiagnosticsJson = json['workspaceDiagnostics']; |
| final workspaceDiagnostics = workspaceDiagnosticsJson as bool; |
| return DiagnosticRegistrationOptions( |
| documentSelector: documentSelector, |
| id: id, |
| identifier: identifier, |
| interFileDependencies: interFileDependencies, |
| workDoneProgress: workDoneProgress, |
| workspaceDiagnostics: workspaceDiagnostics, |
| ); |
| } |
| |
| /// A document selector to identify the scope of the registration. If set to |
| /// null the document selector provided on the client side will be used. |
| @override |
| final List<TextDocumentFilterWithScheme>? documentSelector; |
| |
| /// The id used to register the request. The id can be used to deregister the |
| /// request again. See also Registration#id. |
| @override |
| final String? id; |
| |
| /// An optional identifier under which the diagnostics are managed by the |
| /// client. |
| @override |
| final String? identifier; |
| |
| /// Whether the language has inter file dependencies meaning that editing code |
| /// in one file can result in a different diagnostic set in another file. |
| /// Inter file dependencies are common for most programming languages and |
| /// typically uncommon for linters. |
| @override |
| final bool interFileDependencies; |
| @override |
| final bool? workDoneProgress; |
| |
| /// The server provides support for workspace diagnostics as well. |
| @override |
| final bool workspaceDiagnostics; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['documentSelector'] = documentSelector; |
| if (id != null) { |
| result['id'] = id; |
| } |
| if (identifier != null) { |
| result['identifier'] = identifier; |
| } |
| result['interFileDependencies'] = interFileDependencies; |
| if (workDoneProgress != null) { |
| result['workDoneProgress'] = workDoneProgress; |
| } |
| result['workspaceDiagnostics'] = workspaceDiagnostics; |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseListTextDocumentFilterWithScheme( |
| obj, reporter, 'documentSelector', |
| allowsUndefined: false, allowsNull: true)) { |
| return false; |
| } |
| if (!_canParseString(obj, reporter, 'id', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseString(obj, reporter, 'identifier', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'interFileDependencies', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'workDoneProgress', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseBool(obj, reporter, 'workspaceDiagnostics', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DiagnosticRegistrationOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DiagnosticRegistrationOptions && |
| other.runtimeType == DiagnosticRegistrationOptions && |
| listEqual( |
| documentSelector, |
| other.documentSelector, |
| (TextDocumentFilterWithScheme a, TextDocumentFilterWithScheme b) => |
| a == b) && |
| id == other.id && |
| identifier == other.identifier && |
| interFileDependencies == other.interFileDependencies && |
| workDoneProgress == other.workDoneProgress && |
| workspaceDiagnostics == other.workspaceDiagnostics; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| lspHashCode(documentSelector), |
| id, |
| identifier, |
| interFileDependencies, |
| workDoneProgress, |
| workspaceDiagnostics, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Represents a related message and source code location for a diagnostic. This |
| /// should be used to point to code locations that cause or related to a |
| /// diagnostics, e.g when duplicating a symbol in a scope. |
| class DiagnosticRelatedInformation implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DiagnosticRelatedInformation.canParse, |
| DiagnosticRelatedInformation.fromJson, |
| ); |
| |
| DiagnosticRelatedInformation({ |
| required this.location, |
| required this.message, |
| }); |
| static DiagnosticRelatedInformation fromJson(Map<String, Object?> json) { |
| final locationJson = json['location']; |
| final location = Location.fromJson(locationJson as Map<String, Object?>); |
| final messageJson = json['message']; |
| final message = messageJson as String; |
| return DiagnosticRelatedInformation( |
| location: location, |
| message: message, |
| ); |
| } |
| |
| /// The location of this related diagnostic information. |
| final Location location; |
| |
| /// The message of this related diagnostic information. |
| final String message; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['location'] = location.toJson(); |
| result['message'] = message; |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseLocation(obj, reporter, 'location', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseString(obj, reporter, 'message', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DiagnosticRelatedInformation'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DiagnosticRelatedInformation && |
| other.runtimeType == DiagnosticRelatedInformation && |
| location == other.location && |
| message == other.message; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| location, |
| message, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Cancellation data returned from a diagnostic request. |
| /// |
| /// @since 3.17.0 |
| class DiagnosticServerCancellationData implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DiagnosticServerCancellationData.canParse, |
| DiagnosticServerCancellationData.fromJson, |
| ); |
| |
| DiagnosticServerCancellationData({ |
| required this.retriggerRequest, |
| }); |
| static DiagnosticServerCancellationData fromJson(Map<String, Object?> json) { |
| final retriggerRequestJson = json['retriggerRequest']; |
| final retriggerRequest = retriggerRequestJson as bool; |
| return DiagnosticServerCancellationData( |
| retriggerRequest: retriggerRequest, |
| ); |
| } |
| |
| final bool retriggerRequest; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['retriggerRequest'] = retriggerRequest; |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseBool(obj, reporter, 'retriggerRequest', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DiagnosticServerCancellationData'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DiagnosticServerCancellationData && |
| other.runtimeType == DiagnosticServerCancellationData && |
| retriggerRequest == other.retriggerRequest; |
| } |
| |
| @override |
| int get hashCode => retriggerRequest.hashCode; |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The diagnostic's severity. |
| class DiagnosticSeverity implements ToJsonable { |
| const DiagnosticSeverity(this._value); |
| const DiagnosticSeverity.fromJson(this._value); |
| |
| final int _value; |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) => obj is int; |
| |
| /// Reports an error. |
| static const Error = DiagnosticSeverity(1); |
| |
| /// Reports a hint. |
| static const Hint = DiagnosticSeverity(4); |
| |
| /// Reports an information. |
| static const Information = DiagnosticSeverity(3); |
| |
| /// Reports a warning. |
| static const Warning = DiagnosticSeverity(2); |
| |
| @override |
| Object toJson() => _value; |
| |
| @override |
| String toString() => _value.toString(); |
| |
| @override |
| int get hashCode => _value.hashCode; |
| |
| @override |
| bool operator ==(Object other) => |
| other is DiagnosticSeverity && other._value == _value; |
| } |
| |
| /// The diagnostic tags. |
| /// |
| /// @since 3.15.0 |
| class DiagnosticTag implements ToJsonable { |
| const DiagnosticTag(this._value); |
| const DiagnosticTag.fromJson(this._value); |
| |
| final int _value; |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) => obj is int; |
| |
| /// Deprecated or obsolete code. |
| /// |
| /// Clients are allowed to rendered diagnostics with this tag strike through. |
| static const Deprecated = DiagnosticTag(2); |
| |
| /// Unused or unnecessary code. |
| /// |
| /// Clients are allowed to render diagnostics with this tag faded out instead |
| /// of having an error squiggle. |
| static const Unnecessary = DiagnosticTag(1); |
| |
| @override |
| Object toJson() => _value; |
| |
| @override |
| String toString() => _value.toString(); |
| |
| @override |
| int get hashCode => _value.hashCode; |
| |
| @override |
| bool operator ==(Object other) => |
| other is DiagnosticTag && other._value == _value; |
| } |
| |
| /// Workspace client capabilities specific to diagnostic pull requests. |
| /// |
| /// @since 3.17.0 |
| class DiagnosticWorkspaceClientCapabilities implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DiagnosticWorkspaceClientCapabilities.canParse, |
| DiagnosticWorkspaceClientCapabilities.fromJson, |
| ); |
| |
| DiagnosticWorkspaceClientCapabilities({ |
| this.refreshSupport, |
| }); |
| static DiagnosticWorkspaceClientCapabilities fromJson( |
| Map<String, Object?> json) { |
| final refreshSupportJson = json['refreshSupport']; |
| final refreshSupport = refreshSupportJson as bool?; |
| return DiagnosticWorkspaceClientCapabilities( |
| refreshSupport: refreshSupport, |
| ); |
| } |
| |
| /// Whether the client implementation supports a refresh request sent from the |
| /// server to the client. |
| /// |
| /// Note that this event is global and will force the client to refresh all |
| /// pulled diagnostics currently shown. It should be used with absolute care |
| /// and is useful for situation where a server for example detects a project |
| /// wide change that requires such a calculation. |
| final bool? refreshSupport; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (refreshSupport != null) { |
| result['refreshSupport'] = refreshSupport; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseBool(obj, reporter, 'refreshSupport', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter |
| .reportError('must be of type DiagnosticWorkspaceClientCapabilities'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DiagnosticWorkspaceClientCapabilities && |
| other.runtimeType == DiagnosticWorkspaceClientCapabilities && |
| refreshSupport == other.refreshSupport; |
| } |
| |
| @override |
| int get hashCode => refreshSupport.hashCode; |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class DidChangeConfigurationClientCapabilities implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DidChangeConfigurationClientCapabilities.canParse, |
| DidChangeConfigurationClientCapabilities.fromJson, |
| ); |
| |
| DidChangeConfigurationClientCapabilities({ |
| this.dynamicRegistration, |
| }); |
| static DidChangeConfigurationClientCapabilities fromJson( |
| Map<String, Object?> json) { |
| final dynamicRegistrationJson = json['dynamicRegistration']; |
| final dynamicRegistration = dynamicRegistrationJson as bool?; |
| return DidChangeConfigurationClientCapabilities( |
| dynamicRegistration: dynamicRegistration, |
| ); |
| } |
| |
| /// Did change configuration notification supports dynamic registration. |
| final bool? dynamicRegistration; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (dynamicRegistration != null) { |
| result['dynamicRegistration'] = dynamicRegistration; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseBool(obj, reporter, 'dynamicRegistration', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError( |
| 'must be of type DidChangeConfigurationClientCapabilities'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DidChangeConfigurationClientCapabilities && |
| other.runtimeType == DidChangeConfigurationClientCapabilities && |
| dynamicRegistration == other.dynamicRegistration; |
| } |
| |
| @override |
| int get hashCode => dynamicRegistration.hashCode; |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The parameters of a change configuration notification. |
| class DidChangeConfigurationParams implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DidChangeConfigurationParams.canParse, |
| DidChangeConfigurationParams.fromJson, |
| ); |
| |
| DidChangeConfigurationParams({ |
| this.settings, |
| }); |
| static DidChangeConfigurationParams fromJson(Map<String, Object?> json) { |
| final settingsJson = json['settings']; |
| final settings = settingsJson; |
| return DidChangeConfigurationParams( |
| settings: settings, |
| ); |
| } |
| |
| /// The actual changed settings |
| final LSPAny settings; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['settings'] = settings; |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return true; |
| } else { |
| reporter.reportError('must be of type DidChangeConfigurationParams'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DidChangeConfigurationParams && |
| other.runtimeType == DidChangeConfigurationParams && |
| settings == other.settings; |
| } |
| |
| @override |
| int get hashCode => settings.hashCode; |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The params sent in a change notebook document notification. |
| /// |
| /// @since 3.17.0 |
| class DidChangeNotebookDocumentParams implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DidChangeNotebookDocumentParams.canParse, |
| DidChangeNotebookDocumentParams.fromJson, |
| ); |
| |
| DidChangeNotebookDocumentParams({ |
| required this.change, |
| required this.notebookDocument, |
| }); |
| static DidChangeNotebookDocumentParams fromJson(Map<String, Object?> json) { |
| final changeJson = json['change']; |
| final change = NotebookDocumentChangeEvent.fromJson( |
| changeJson as Map<String, Object?>); |
| final notebookDocumentJson = json['notebookDocument']; |
| final notebookDocument = VersionedNotebookDocumentIdentifier.fromJson( |
| notebookDocumentJson as Map<String, Object?>); |
| return DidChangeNotebookDocumentParams( |
| change: change, |
| notebookDocument: notebookDocument, |
| ); |
| } |
| |
| /// The actual changes to the notebook document. |
| /// |
| /// The changes describe single state changes to the notebook document. So if |
| /// there are two changes c1 (at array index 0) and c2 (at array index 1) for |
| /// a notebook in state S then c1 moves the notebook from S to S' and c2 from |
| /// S' to S''. So c1 is computed on the state S and c2 is computed on the |
| /// state S'. |
| /// |
| /// To mirror the content of a notebook using change events use the following |
| /// approach: |
| /// - start with the same initial content |
| /// - apply the 'notebookDocument/didChange' notifications in the order you |
| /// receive them. |
| /// - apply the `NotebookChangeEvent`s in a single notification in the order |
| /// you receive them. |
| final NotebookDocumentChangeEvent change; |
| |
| /// The notebook document that did change. The version number points to the |
| /// version after all provided changes have been applied. If only the text |
| /// document content of a cell changes the notebook version doesn't |
| /// necessarily have to change. |
| final VersionedNotebookDocumentIdentifier notebookDocument; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['change'] = change.toJson(); |
| result['notebookDocument'] = notebookDocument.toJson(); |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseNotebookDocumentChangeEvent(obj, reporter, 'change', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseVersionedNotebookDocumentIdentifier( |
| obj, reporter, 'notebookDocument', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DidChangeNotebookDocumentParams'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DidChangeNotebookDocumentParams && |
| other.runtimeType == DidChangeNotebookDocumentParams && |
| change == other.change && |
| notebookDocument == other.notebookDocument; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| change, |
| notebookDocument, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The change text document notification's parameters. |
| class DidChangeTextDocumentParams implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DidChangeTextDocumentParams.canParse, |
| DidChangeTextDocumentParams.fromJson, |
| ); |
| |
| DidChangeTextDocumentParams({ |
| required this.contentChanges, |
| required this.textDocument, |
| }); |
| static DidChangeTextDocumentParams fromJson(Map<String, Object?> json) { |
| final contentChangesJson = json['contentChanges']; |
| final contentChanges = (contentChangesJson as List<Object?>) |
| .map((item) => |
| _eitherTextDocumentContentChangeEvent1TextDocumentContentChangeEvent2( |
| item)) |
| .toList(); |
| final textDocumentJson = json['textDocument']; |
| final textDocument = VersionedTextDocumentIdentifier.fromJson( |
| textDocumentJson as Map<String, Object?>); |
| return DidChangeTextDocumentParams( |
| contentChanges: contentChanges, |
| textDocument: textDocument, |
| ); |
| } |
| |
| /// The actual content changes. The content changes describe single state |
| /// changes to the document. So if there are two content changes c1 (at array |
| /// index 0) and c2 (at array index 1) for a document in state S then c1 moves |
| /// the document from S to S' and c2 from S' to S''. So c1 is computed on the |
| /// state S and c2 is computed on the state S'. |
| /// |
| /// To mirror the content of a document using change events use the following |
| /// approach: |
| /// - start with the same initial content |
| /// - apply the 'textDocument/didChange' notifications in the order you |
| /// receive them. |
| /// - apply the `TextDocumentContentChangeEvent`s in a single notification in |
| /// the order |
| /// you receive them. |
| final List<TextDocumentContentChangeEvent> contentChanges; |
| |
| /// The document that did change. The version number points to the version |
| /// after all provided content changes have been applied. |
| final VersionedTextDocumentIdentifier textDocument; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['contentChanges'] = contentChanges; |
| result['textDocument'] = textDocument.toJson(); |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseListTextDocumentContentChangeEvent1TextDocumentContentChangeEvent2( |
| obj, reporter, 'contentChanges', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseVersionedTextDocumentIdentifier( |
| obj, reporter, 'textDocument', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DidChangeTextDocumentParams'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DidChangeTextDocumentParams && |
| other.runtimeType == DidChangeTextDocumentParams && |
| listEqual( |
| contentChanges, |
| other.contentChanges, |
| (TextDocumentContentChangeEvent a, |
| TextDocumentContentChangeEvent b) => |
| a == b) && |
| textDocument == other.textDocument; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| lspHashCode(contentChanges), |
| textDocument, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class DidChangeWatchedFilesClientCapabilities implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DidChangeWatchedFilesClientCapabilities.canParse, |
| DidChangeWatchedFilesClientCapabilities.fromJson, |
| ); |
| |
| DidChangeWatchedFilesClientCapabilities({ |
| this.dynamicRegistration, |
| this.relativePatternSupport, |
| }); |
| static DidChangeWatchedFilesClientCapabilities fromJson( |
| Map<String, Object?> json) { |
| final dynamicRegistrationJson = json['dynamicRegistration']; |
| final dynamicRegistration = dynamicRegistrationJson as bool?; |
| final relativePatternSupportJson = json['relativePatternSupport']; |
| final relativePatternSupport = relativePatternSupportJson as bool?; |
| return DidChangeWatchedFilesClientCapabilities( |
| dynamicRegistration: dynamicRegistration, |
| relativePatternSupport: relativePatternSupport, |
| ); |
| } |
| |
| /// Did change watched files notification supports dynamic registration. |
| /// Please note that the current protocol doesn't support static configuration |
| /// for file changes from the server side. |
| final bool? dynamicRegistration; |
| |
| /// Whether the client has support for {@link RelativePattern relative |
| /// pattern} |
| /// or not. |
| /// |
| /// @since 3.17.0 |
| final bool? relativePatternSupport; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (dynamicRegistration != null) { |
| result['dynamicRegistration'] = dynamicRegistration; |
| } |
| if (relativePatternSupport != null) { |
| result['relativePatternSupport'] = relativePatternSupport; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseBool(obj, reporter, 'dynamicRegistration', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseBool(obj, reporter, 'relativePatternSupport', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError( |
| 'must be of type DidChangeWatchedFilesClientCapabilities'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DidChangeWatchedFilesClientCapabilities && |
| other.runtimeType == DidChangeWatchedFilesClientCapabilities && |
| dynamicRegistration == other.dynamicRegistration && |
| relativePatternSupport == other.relativePatternSupport; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| dynamicRegistration, |
| relativePatternSupport, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The watched files change notification's parameters. |
| class DidChangeWatchedFilesParams implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DidChangeWatchedFilesParams.canParse, |
| DidChangeWatchedFilesParams.fromJson, |
| ); |
| |
| DidChangeWatchedFilesParams({ |
| required this.changes, |
| }); |
| static DidChangeWatchedFilesParams fromJson(Map<String, Object?> json) { |
| final changesJson = json['changes']; |
| final changes = (changesJson as List<Object?>) |
| .map((item) => FileEvent.fromJson(item as Map<String, Object?>)) |
| .toList(); |
| return DidChangeWatchedFilesParams( |
| changes: changes, |
| ); |
| } |
| |
| /// The actual file events. |
| final List<FileEvent> changes; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['changes'] = changes.map((item) => item.toJson()).toList(); |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseListFileEvent(obj, reporter, 'changes', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DidChangeWatchedFilesParams'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DidChangeWatchedFilesParams && |
| other.runtimeType == DidChangeWatchedFilesParams && |
| listEqual(changes, other.changes, (FileEvent a, FileEvent b) => a == b); |
| } |
| |
| @override |
| int get hashCode => lspHashCode(changes); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Describe options to be used when registered for text document change events. |
| class DidChangeWatchedFilesRegistrationOptions implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DidChangeWatchedFilesRegistrationOptions.canParse, |
| DidChangeWatchedFilesRegistrationOptions.fromJson, |
| ); |
| |
| DidChangeWatchedFilesRegistrationOptions({ |
| required this.watchers, |
| }); |
| static DidChangeWatchedFilesRegistrationOptions fromJson( |
| Map<String, Object?> json) { |
| final watchersJson = json['watchers']; |
| final watchers = (watchersJson as List<Object?>) |
| .map((item) => FileSystemWatcher.fromJson(item as Map<String, Object?>)) |
| .toList(); |
| return DidChangeWatchedFilesRegistrationOptions( |
| watchers: watchers, |
| ); |
| } |
| |
| /// The watchers to register. |
| final List<FileSystemWatcher> watchers; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['watchers'] = watchers.map((item) => item.toJson()).toList(); |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseListFileSystemWatcher(obj, reporter, 'watchers', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError( |
| 'must be of type DidChangeWatchedFilesRegistrationOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DidChangeWatchedFilesRegistrationOptions && |
| other.runtimeType == DidChangeWatchedFilesRegistrationOptions && |
| listEqual(watchers, other.watchers, |
| (FileSystemWatcher a, FileSystemWatcher b) => a == b); |
| } |
| |
| @override |
| int get hashCode => lspHashCode(watchers); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The parameters of a `workspace/didChangeWorkspaceFolders` notification. |
| class DidChangeWorkspaceFoldersParams implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DidChangeWorkspaceFoldersParams.canParse, |
| DidChangeWorkspaceFoldersParams.fromJson, |
| ); |
| |
| DidChangeWorkspaceFoldersParams({ |
| required this.event, |
| }); |
| static DidChangeWorkspaceFoldersParams fromJson(Map<String, Object?> json) { |
| final eventJson = json['event']; |
| final event = |
| WorkspaceFoldersChangeEvent.fromJson(eventJson as Map<String, Object?>); |
| return DidChangeWorkspaceFoldersParams( |
| event: event, |
| ); |
| } |
| |
| /// The actual workspace folder change event. |
| final WorkspaceFoldersChangeEvent event; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['event'] = event.toJson(); |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseWorkspaceFoldersChangeEvent(obj, reporter, 'event', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DidChangeWorkspaceFoldersParams'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DidChangeWorkspaceFoldersParams && |
| other.runtimeType == DidChangeWorkspaceFoldersParams && |
| event == other.event; |
| } |
| |
| @override |
| int get hashCode => event.hashCode; |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The params sent in a close notebook document notification. |
| /// |
| /// @since 3.17.0 |
| class DidCloseNotebookDocumentParams implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DidCloseNotebookDocumentParams.canParse, |
| DidCloseNotebookDocumentParams.fromJson, |
| ); |
| |
| DidCloseNotebookDocumentParams({ |
| required this.cellTextDocuments, |
| required this.notebookDocument, |
| }); |
| static DidCloseNotebookDocumentParams fromJson(Map<String, Object?> json) { |
| final cellTextDocumentsJson = json['cellTextDocuments']; |
| final cellTextDocuments = (cellTextDocumentsJson as List<Object?>) |
| .map((item) => |
| TextDocumentIdentifier.fromJson(item as Map<String, Object?>)) |
| .toList(); |
| final notebookDocumentJson = json['notebookDocument']; |
| final notebookDocument = NotebookDocumentIdentifier.fromJson( |
| notebookDocumentJson as Map<String, Object?>); |
| return DidCloseNotebookDocumentParams( |
| cellTextDocuments: cellTextDocuments, |
| notebookDocument: notebookDocument, |
| ); |
| } |
| |
| /// The text documents that represent the content of a notebook cell that got |
| /// closed. |
| final List<TextDocumentIdentifier> cellTextDocuments; |
| |
| /// The notebook document that got closed. |
| final NotebookDocumentIdentifier notebookDocument; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['cellTextDocuments'] = |
| cellTextDocuments.map((item) => item.toJson()).toList(); |
| result['notebookDocument'] = notebookDocument.toJson(); |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseListTextDocumentIdentifier( |
| obj, reporter, 'cellTextDocuments', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseNotebookDocumentIdentifier( |
| obj, reporter, 'notebookDocument', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DidCloseNotebookDocumentParams'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DidCloseNotebookDocumentParams && |
| other.runtimeType == DidCloseNotebookDocumentParams && |
| listEqual(cellTextDocuments, other.cellTextDocuments, |
| (TextDocumentIdentifier a, TextDocumentIdentifier b) => a == b) && |
| notebookDocument == other.notebookDocument; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| lspHashCode(cellTextDocuments), |
| notebookDocument, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The parameters sent in a close text document notification |
| class DidCloseTextDocumentParams implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DidCloseTextDocumentParams.canParse, |
| DidCloseTextDocumentParams.fromJson, |
| ); |
| |
| DidCloseTextDocumentParams({ |
| required this.textDocument, |
| }); |
| static DidCloseTextDocumentParams fromJson(Map<String, Object?> json) { |
| final textDocumentJson = json['textDocument']; |
| final textDocument = TextDocumentIdentifier.fromJson( |
| textDocumentJson as Map<String, Object?>); |
| return DidCloseTextDocumentParams( |
| textDocument: textDocument, |
| ); |
| } |
| |
| /// The document that was closed. |
| final TextDocumentIdentifier textDocument; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['textDocument'] = textDocument.toJson(); |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseTextDocumentIdentifier(obj, reporter, 'textDocument', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DidCloseTextDocumentParams'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DidCloseTextDocumentParams && |
| other.runtimeType == DidCloseTextDocumentParams && |
| textDocument == other.textDocument; |
| } |
| |
| @override |
| int get hashCode => textDocument.hashCode; |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The params sent in an open notebook document notification. |
| /// |
| /// @since 3.17.0 |
| class DidOpenNotebookDocumentParams implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DidOpenNotebookDocumentParams.canParse, |
| DidOpenNotebookDocumentParams.fromJson, |
| ); |
| |
| DidOpenNotebookDocumentParams({ |
| required this.cellTextDocuments, |
| required this.notebookDocument, |
| }); |
| static DidOpenNotebookDocumentParams fromJson(Map<String, Object?> json) { |
| final cellTextDocumentsJson = json['cellTextDocuments']; |
| final cellTextDocuments = (cellTextDocumentsJson as List<Object?>) |
| .map((item) => TextDocumentItem.fromJson(item as Map<String, Object?>)) |
| .toList(); |
| final notebookDocumentJson = json['notebookDocument']; |
| final notebookDocument = |
| NotebookDocument.fromJson(notebookDocumentJson as Map<String, Object?>); |
| return DidOpenNotebookDocumentParams( |
| cellTextDocuments: cellTextDocuments, |
| notebookDocument: notebookDocument, |
| ); |
| } |
| |
| /// The text documents that represent the content of a notebook cell. |
| final List<TextDocumentItem> cellTextDocuments; |
| |
| /// The notebook document that got opened. |
| final NotebookDocument notebookDocument; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['cellTextDocuments'] = |
| cellTextDocuments.map((item) => item.toJson()).toList(); |
| result['notebookDocument'] = notebookDocument.toJson(); |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseListTextDocumentItem(obj, reporter, 'cellTextDocuments', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseNotebookDocument(obj, reporter, 'notebookDocument', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DidOpenNotebookDocumentParams'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DidOpenNotebookDocumentParams && |
| other.runtimeType == DidOpenNotebookDocumentParams && |
| listEqual(cellTextDocuments, other.cellTextDocuments, |
| (TextDocumentItem a, TextDocumentItem b) => a == b) && |
| notebookDocument == other.notebookDocument; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| lspHashCode(cellTextDocuments), |
| notebookDocument, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The parameters sent in an open text document notification |
| class DidOpenTextDocumentParams implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DidOpenTextDocumentParams.canParse, |
| DidOpenTextDocumentParams.fromJson, |
| ); |
| |
| DidOpenTextDocumentParams({ |
| required this.textDocument, |
| }); |
| static DidOpenTextDocumentParams fromJson(Map<String, Object?> json) { |
| final textDocumentJson = json['textDocument']; |
| final textDocument = |
| TextDocumentItem.fromJson(textDocumentJson as Map<String, Object?>); |
| return DidOpenTextDocumentParams( |
| textDocument: textDocument, |
| ); |
| } |
| |
| /// The document that was opened. |
| final TextDocumentItem textDocument; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['textDocument'] = textDocument.toJson(); |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseTextDocumentItem(obj, reporter, 'textDocument', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DidOpenTextDocumentParams'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DidOpenTextDocumentParams && |
| other.runtimeType == DidOpenTextDocumentParams && |
| textDocument == other.textDocument; |
| } |
| |
| @override |
| int get hashCode => textDocument.hashCode; |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The params sent in a save notebook document notification. |
| /// |
| /// @since 3.17.0 |
| class DidSaveNotebookDocumentParams implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DidSaveNotebookDocumentParams.canParse, |
| DidSaveNotebookDocumentParams.fromJson, |
| ); |
| |
| DidSaveNotebookDocumentParams({ |
| required this.notebookDocument, |
| }); |
| static DidSaveNotebookDocumentParams fromJson(Map<String, Object?> json) { |
| final notebookDocumentJson = json['notebookDocument']; |
| final notebookDocument = NotebookDocumentIdentifier.fromJson( |
| notebookDocumentJson as Map<String, Object?>); |
| return DidSaveNotebookDocumentParams( |
| notebookDocument: notebookDocument, |
| ); |
| } |
| |
| /// The notebook document that got saved. |
| final NotebookDocumentIdentifier notebookDocument; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['notebookDocument'] = notebookDocument.toJson(); |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseNotebookDocumentIdentifier( |
| obj, reporter, 'notebookDocument', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DidSaveNotebookDocumentParams'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DidSaveNotebookDocumentParams && |
| other.runtimeType == DidSaveNotebookDocumentParams && |
| notebookDocument == other.notebookDocument; |
| } |
| |
| @override |
| int get hashCode => notebookDocument.hashCode; |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The parameters sent in a save text document notification |
| class DidSaveTextDocumentParams implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DidSaveTextDocumentParams.canParse, |
| DidSaveTextDocumentParams.fromJson, |
| ); |
| |
| DidSaveTextDocumentParams({ |
| this.text, |
| required this.textDocument, |
| }); |
| static DidSaveTextDocumentParams fromJson(Map<String, Object?> json) { |
| final textJson = json['text']; |
| final text = textJson as String?; |
| final textDocumentJson = json['textDocument']; |
| final textDocument = TextDocumentIdentifier.fromJson( |
| textDocumentJson as Map<String, Object?>); |
| return DidSaveTextDocumentParams( |
| text: text, |
| textDocument: textDocument, |
| ); |
| } |
| |
| /// Optional the content when saved. Depends on the includeText value when the |
| /// save notification was requested. |
| final String? text; |
| |
| /// The document that was saved. |
| final TextDocumentIdentifier textDocument; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (text != null) { |
| result['text'] = text; |
| } |
| result['textDocument'] = textDocument.toJson(); |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseString(obj, reporter, 'text', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseTextDocumentIdentifier(obj, reporter, 'textDocument', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DidSaveTextDocumentParams'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DidSaveTextDocumentParams && |
| other.runtimeType == DidSaveTextDocumentParams && |
| text == other.text && |
| textDocument == other.textDocument; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| text, |
| textDocument, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class DocumentColorClientCapabilities implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DocumentColorClientCapabilities.canParse, |
| DocumentColorClientCapabilities.fromJson, |
| ); |
| |
| DocumentColorClientCapabilities({ |
| this.dynamicRegistration, |
| }); |
| static DocumentColorClientCapabilities fromJson(Map<String, Object?> json) { |
| final dynamicRegistrationJson = json['dynamicRegistration']; |
| final dynamicRegistration = dynamicRegistrationJson as bool?; |
| return DocumentColorClientCapabilities( |
| dynamicRegistration: dynamicRegistration, |
| ); |
| } |
| |
| /// Whether implementation supports dynamic registration. If this is set to |
| /// `true` the client supports the new `DocumentColorRegistrationOptions` |
| /// return value for the corresponding server capability as well. |
| final bool? dynamicRegistration; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (dynamicRegistration != null) { |
| result['dynamicRegistration'] = dynamicRegistration; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseBool(obj, reporter, 'dynamicRegistration', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DocumentColorClientCapabilities'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DocumentColorClientCapabilities && |
| other.runtimeType == DocumentColorClientCapabilities && |
| dynamicRegistration == other.dynamicRegistration; |
| } |
| |
| @override |
| int get hashCode => dynamicRegistration.hashCode; |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class DocumentColorOptions implements WorkDoneProgressOptions, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DocumentColorOptions.canParse, |
| DocumentColorOptions.fromJson, |
| ); |
| |
| DocumentColorOptions({ |
| this.workDoneProgress, |
| }); |
| static DocumentColorOptions fromJson(Map<String, Object?> json) { |
| if (DocumentColorRegistrationOptions.canParse(json, nullLspJsonReporter)) { |
| return DocumentColorRegistrationOptions.fromJson(json); |
| } |
| final workDoneProgressJson = json['workDoneProgress']; |
| final workDoneProgress = workDoneProgressJson as bool?; |
| return DocumentColorOptions( |
| workDoneProgress: workDoneProgress, |
| ); |
| } |
| |
| @override |
| final bool? workDoneProgress; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (workDoneProgress != null) { |
| result['workDoneProgress'] = workDoneProgress; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseBool(obj, reporter, 'workDoneProgress', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DocumentColorOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DocumentColorOptions && |
| other.runtimeType == DocumentColorOptions && |
| workDoneProgress == other.workDoneProgress; |
| } |
| |
| @override |
| int get hashCode => workDoneProgress.hashCode; |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Parameters for a DocumentColorRequest. |
| class DocumentColorParams |
| implements PartialResultParams, WorkDoneProgressParams, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DocumentColorParams.canParse, |
| DocumentColorParams.fromJson, |
| ); |
| |
| DocumentColorParams({ |
| this.partialResultToken, |
| required this.textDocument, |
| this.workDoneToken, |
| }); |
| static DocumentColorParams fromJson(Map<String, Object?> json) { |
| final partialResultTokenJson = json['partialResultToken']; |
| final partialResultToken = partialResultTokenJson == null |
| ? null |
| : _eitherIntString(partialResultTokenJson); |
| final textDocumentJson = json['textDocument']; |
| final textDocument = TextDocumentIdentifier.fromJson( |
| textDocumentJson as Map<String, Object?>); |
| final workDoneTokenJson = json['workDoneToken']; |
| final workDoneToken = |
| workDoneTokenJson == null ? null : _eitherIntString(workDoneTokenJson); |
| return DocumentColorParams( |
| partialResultToken: partialResultToken, |
| textDocument: textDocument, |
| workDoneToken: workDoneToken, |
| ); |
| } |
| |
| /// An optional token that a server can use to report partial results (e.g. |
| /// streaming) to the client. |
| @override |
| final ProgressToken? partialResultToken; |
| |
| /// The text document. |
| final TextDocumentIdentifier textDocument; |
| |
| /// An optional token that a server can use to report work done progress. |
| @override |
| final ProgressToken? workDoneToken; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (partialResultToken != null) { |
| result['partialResultToken'] = partialResultToken; |
| } |
| result['textDocument'] = textDocument.toJson(); |
| if (workDoneToken != null) { |
| result['workDoneToken'] = workDoneToken; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseIntString(obj, reporter, 'partialResultToken', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseTextDocumentIdentifier(obj, reporter, 'textDocument', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseIntString(obj, reporter, 'workDoneToken', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DocumentColorParams'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DocumentColorParams && |
| other.runtimeType == DocumentColorParams && |
| partialResultToken == other.partialResultToken && |
| textDocument == other.textDocument && |
| workDoneToken == other.workDoneToken; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| partialResultToken, |
| textDocument, |
| workDoneToken, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class DocumentColorRegistrationOptions |
| implements |
| DocumentColorOptions, |
| StaticRegistrationOptions, |
| TextDocumentRegistrationOptions, |
| ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DocumentColorRegistrationOptions.canParse, |
| DocumentColorRegistrationOptions.fromJson, |
| ); |
| |
| DocumentColorRegistrationOptions({ |
| this.documentSelector, |
| this.id, |
| this.workDoneProgress, |
| }); |
| static DocumentColorRegistrationOptions fromJson(Map<String, Object?> json) { |
| final documentSelectorJson = json['documentSelector']; |
| final documentSelector = (documentSelectorJson as List<Object?>?) |
| ?.map((item) => |
| TextDocumentFilterWithScheme.fromJson(item as Map<String, Object?>)) |
| .toList(); |
| final idJson = json['id']; |
| final id = idJson as String?; |
| final workDoneProgressJson = json['workDoneProgress']; |
| final workDoneProgress = workDoneProgressJson as bool?; |
| return DocumentColorRegistrationOptions( |
| documentSelector: documentSelector, |
| id: id, |
| workDoneProgress: workDoneProgress, |
| ); |
| } |
| |
| /// A document selector to identify the scope of the registration. If set to |
| /// null the document selector provided on the client side will be used. |
| @override |
| final List<TextDocumentFilterWithScheme>? documentSelector; |
| |
| /// The id used to register the request. The id can be used to deregister the |
| /// request again. See also Registration#id. |
| @override |
| final String? id; |
| @override |
| final bool? workDoneProgress; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['documentSelector'] = documentSelector; |
| if (id != null) { |
| result['id'] = id; |
| } |
| if (workDoneProgress != null) { |
| result['workDoneProgress'] = workDoneProgress; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseListTextDocumentFilterWithScheme( |
| obj, reporter, 'documentSelector', |
| allowsUndefined: false, allowsNull: true)) { |
| return false; |
| } |
| if (!_canParseString(obj, reporter, 'id', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseBool(obj, reporter, 'workDoneProgress', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DocumentColorRegistrationOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DocumentColorRegistrationOptions && |
| other.runtimeType == DocumentColorRegistrationOptions && |
| listEqual( |
| documentSelector, |
| other.documentSelector, |
| (TextDocumentFilterWithScheme a, TextDocumentFilterWithScheme b) => |
| a == b) && |
| id == other.id && |
| workDoneProgress == other.workDoneProgress; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| lspHashCode(documentSelector), |
| id, |
| workDoneProgress, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Parameters of the document diagnostic request. |
| /// |
| /// @since 3.17.0 |
| class DocumentDiagnosticParams |
| implements PartialResultParams, WorkDoneProgressParams, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DocumentDiagnosticParams.canParse, |
| DocumentDiagnosticParams.fromJson, |
| ); |
| |
| DocumentDiagnosticParams({ |
| this.identifier, |
| this.partialResultToken, |
| this.previousResultId, |
| required this.textDocument, |
| this.workDoneToken, |
| }); |
| static DocumentDiagnosticParams fromJson(Map<String, Object?> json) { |
| final identifierJson = json['identifier']; |
| final identifier = identifierJson as String?; |
| final partialResultTokenJson = json['partialResultToken']; |
| final partialResultToken = partialResultTokenJson == null |
| ? null |
| : _eitherIntString(partialResultTokenJson); |
| final previousResultIdJson = json['previousResultId']; |
| final previousResultId = previousResultIdJson as String?; |
| final textDocumentJson = json['textDocument']; |
| final textDocument = TextDocumentIdentifier.fromJson( |
| textDocumentJson as Map<String, Object?>); |
| final workDoneTokenJson = json['workDoneToken']; |
| final workDoneToken = |
| workDoneTokenJson == null ? null : _eitherIntString(workDoneTokenJson); |
| return DocumentDiagnosticParams( |
| identifier: identifier, |
| partialResultToken: partialResultToken, |
| previousResultId: previousResultId, |
| textDocument: textDocument, |
| workDoneToken: workDoneToken, |
| ); |
| } |
| |
| /// The additional identifier provided during registration. |
| final String? identifier; |
| |
| /// An optional token that a server can use to report partial results (e.g. |
| /// streaming) to the client. |
| @override |
| final ProgressToken? partialResultToken; |
| |
| /// The result id of a previous response if provided. |
| final String? previousResultId; |
| |
| /// The text document. |
| final TextDocumentIdentifier textDocument; |
| |
| /// An optional token that a server can use to report work done progress. |
| @override |
| final ProgressToken? workDoneToken; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (identifier != null) { |
| result['identifier'] = identifier; |
| } |
| if (partialResultToken != null) { |
| result['partialResultToken'] = partialResultToken; |
| } |
| if (previousResultId != null) { |
| result['previousResultId'] = previousResultId; |
| } |
| result['textDocument'] = textDocument.toJson(); |
| if (workDoneToken != null) { |
| result['workDoneToken'] = workDoneToken; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseString(obj, reporter, 'identifier', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseIntString(obj, reporter, 'partialResultToken', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseString(obj, reporter, 'previousResultId', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseTextDocumentIdentifier(obj, reporter, 'textDocument', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseIntString(obj, reporter, 'workDoneToken', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DocumentDiagnosticParams'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DocumentDiagnosticParams && |
| other.runtimeType == DocumentDiagnosticParams && |
| identifier == other.identifier && |
| partialResultToken == other.partialResultToken && |
| previousResultId == other.previousResultId && |
| textDocument == other.textDocument && |
| workDoneToken == other.workDoneToken; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| identifier, |
| partialResultToken, |
| previousResultId, |
| textDocument, |
| workDoneToken, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// A partial result for a document diagnostic report. |
| /// |
| /// @since 3.17.0 |
| class DocumentDiagnosticReportPartialResult implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DocumentDiagnosticReportPartialResult.canParse, |
| DocumentDiagnosticReportPartialResult.fromJson, |
| ); |
| |
| DocumentDiagnosticReportPartialResult({ |
| required this.relatedDocuments, |
| }); |
| static DocumentDiagnosticReportPartialResult fromJson( |
| Map<String, Object?> json) { |
| final relatedDocumentsJson = json['relatedDocuments']; |
| final relatedDocuments = (relatedDocumentsJson as Map<Object, Object?>).map( |
| (key, value) => MapEntry( |
| key as String, |
| _eitherFullDocumentDiagnosticReportUnchangedDocumentDiagnosticReport( |
| value))); |
| return DocumentDiagnosticReportPartialResult( |
| relatedDocuments: relatedDocuments, |
| ); |
| } |
| |
| final Map< |
| DocumentUri, |
| Either2<FullDocumentDiagnosticReport, |
| UnchangedDocumentDiagnosticReport>> relatedDocuments; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['relatedDocuments'] = relatedDocuments; |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseMapStringFullDocumentDiagnosticReportUnchangedDocumentDiagnosticReport( |
| obj, reporter, 'relatedDocuments', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter |
| .reportError('must be of type DocumentDiagnosticReportPartialResult'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DocumentDiagnosticReportPartialResult && |
| other.runtimeType == DocumentDiagnosticReportPartialResult && |
| mapEqual( |
| relatedDocuments, |
| other.relatedDocuments, |
| (Either2<FullDocumentDiagnosticReport, |
| UnchangedDocumentDiagnosticReport> |
| a, |
| Either2<FullDocumentDiagnosticReport, |
| UnchangedDocumentDiagnosticReport> |
| b) => |
| a == b); |
| } |
| |
| @override |
| int get hashCode => lspHashCode(relatedDocuments); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Client capabilities of a DocumentFormattingRequest. |
| class DocumentFormattingClientCapabilities implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DocumentFormattingClientCapabilities.canParse, |
| DocumentFormattingClientCapabilities.fromJson, |
| ); |
| |
| DocumentFormattingClientCapabilities({ |
| this.dynamicRegistration, |
| }); |
| static DocumentFormattingClientCapabilities fromJson( |
| Map<String, Object?> json) { |
| final dynamicRegistrationJson = json['dynamicRegistration']; |
| final dynamicRegistration = dynamicRegistrationJson as bool?; |
| return DocumentFormattingClientCapabilities( |
| dynamicRegistration: dynamicRegistration, |
| ); |
| } |
| |
| /// Whether formatting supports dynamic registration. |
| final bool? dynamicRegistration; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (dynamicRegistration != null) { |
| result['dynamicRegistration'] = dynamicRegistration; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseBool(obj, reporter, 'dynamicRegistration', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter |
| .reportError('must be of type DocumentFormattingClientCapabilities'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DocumentFormattingClientCapabilities && |
| other.runtimeType == DocumentFormattingClientCapabilities && |
| dynamicRegistration == other.dynamicRegistration; |
| } |
| |
| @override |
| int get hashCode => dynamicRegistration.hashCode; |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Provider options for a DocumentFormattingRequest. |
| class DocumentFormattingOptions implements WorkDoneProgressOptions, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DocumentFormattingOptions.canParse, |
| DocumentFormattingOptions.fromJson, |
| ); |
| |
| DocumentFormattingOptions({ |
| this.workDoneProgress, |
| }); |
| static DocumentFormattingOptions fromJson(Map<String, Object?> json) { |
| if (DocumentFormattingRegistrationOptions.canParse( |
| json, nullLspJsonReporter)) { |
| return DocumentFormattingRegistrationOptions.fromJson(json); |
| } |
| final workDoneProgressJson = json['workDoneProgress']; |
| final workDoneProgress = workDoneProgressJson as bool?; |
| return DocumentFormattingOptions( |
| workDoneProgress: workDoneProgress, |
| ); |
| } |
| |
| @override |
| final bool? workDoneProgress; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (workDoneProgress != null) { |
| result['workDoneProgress'] = workDoneProgress; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseBool(obj, reporter, 'workDoneProgress', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DocumentFormattingOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DocumentFormattingOptions && |
| other.runtimeType == DocumentFormattingOptions && |
| workDoneProgress == other.workDoneProgress; |
| } |
| |
| @override |
| int get hashCode => workDoneProgress.hashCode; |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The parameters of a DocumentFormattingRequest. |
| class DocumentFormattingParams implements WorkDoneProgressParams, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DocumentFormattingParams.canParse, |
| DocumentFormattingParams.fromJson, |
| ); |
| |
| DocumentFormattingParams({ |
| required this.options, |
| required this.textDocument, |
| this.workDoneToken, |
| }); |
| static DocumentFormattingParams fromJson(Map<String, Object?> json) { |
| final optionsJson = json['options']; |
| final options = |
| FormattingOptions.fromJson(optionsJson as Map<String, Object?>); |
| final textDocumentJson = json['textDocument']; |
| final textDocument = TextDocumentIdentifier.fromJson( |
| textDocumentJson as Map<String, Object?>); |
| final workDoneTokenJson = json['workDoneToken']; |
| final workDoneToken = |
| workDoneTokenJson == null ? null : _eitherIntString(workDoneTokenJson); |
| return DocumentFormattingParams( |
| options: options, |
| textDocument: textDocument, |
| workDoneToken: workDoneToken, |
| ); |
| } |
| |
| /// The format options. |
| final FormattingOptions options; |
| |
| /// The document to format. |
| final TextDocumentIdentifier textDocument; |
| |
| /// An optional token that a server can use to report work done progress. |
| @override |
| final ProgressToken? workDoneToken; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['options'] = options.toJson(); |
| result['textDocument'] = textDocument.toJson(); |
| if (workDoneToken != null) { |
| result['workDoneToken'] = workDoneToken; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseFormattingOptions(obj, reporter, 'options', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseTextDocumentIdentifier(obj, reporter, 'textDocument', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseIntString(obj, reporter, 'workDoneToken', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DocumentFormattingParams'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DocumentFormattingParams && |
| other.runtimeType == DocumentFormattingParams && |
| options == other.options && |
| textDocument == other.textDocument && |
| workDoneToken == other.workDoneToken; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| options, |
| textDocument, |
| workDoneToken, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Registration options for a DocumentFormattingRequest. |
| class DocumentFormattingRegistrationOptions |
| implements |
| DocumentFormattingOptions, |
| TextDocumentRegistrationOptions, |
| ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DocumentFormattingRegistrationOptions.canParse, |
| DocumentFormattingRegistrationOptions.fromJson, |
| ); |
| |
| DocumentFormattingRegistrationOptions({ |
| this.documentSelector, |
| this.workDoneProgress, |
| }); |
| static DocumentFormattingRegistrationOptions fromJson( |
| Map<String, Object?> json) { |
| final documentSelectorJson = json['documentSelector']; |
| final documentSelector = (documentSelectorJson as List<Object?>?) |
| ?.map((item) => |
| TextDocumentFilterWithScheme.fromJson(item as Map<String, Object?>)) |
| .toList(); |
| final workDoneProgressJson = json['workDoneProgress']; |
| final workDoneProgress = workDoneProgressJson as bool?; |
| return DocumentFormattingRegistrationOptions( |
| documentSelector: documentSelector, |
| workDoneProgress: workDoneProgress, |
| ); |
| } |
| |
| /// A document selector to identify the scope of the registration. If set to |
| /// null the document selector provided on the client side will be used. |
| @override |
| final List<TextDocumentFilterWithScheme>? documentSelector; |
| @override |
| final bool? workDoneProgress; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['documentSelector'] = documentSelector; |
| if (workDoneProgress != null) { |
| result['workDoneProgress'] = workDoneProgress; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseListTextDocumentFilterWithScheme( |
| obj, reporter, 'documentSelector', |
| allowsUndefined: false, allowsNull: true)) { |
| return false; |
| } |
| return _canParseBool(obj, reporter, 'workDoneProgress', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter |
| .reportError('must be of type DocumentFormattingRegistrationOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DocumentFormattingRegistrationOptions && |
| other.runtimeType == DocumentFormattingRegistrationOptions && |
| listEqual( |
| documentSelector, |
| other.documentSelector, |
| (TextDocumentFilterWithScheme a, TextDocumentFilterWithScheme b) => |
| a == b) && |
| workDoneProgress == other.workDoneProgress; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| lspHashCode(documentSelector), |
| workDoneProgress, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// A document highlight is a range inside a text document which deserves |
| /// special attention. Usually a document highlight is visualized by changing |
| /// the background color of its range. |
| class DocumentHighlight implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DocumentHighlight.canParse, |
| DocumentHighlight.fromJson, |
| ); |
| |
| DocumentHighlight({ |
| this.kind, |
| required this.range, |
| }); |
| static DocumentHighlight fromJson(Map<String, Object?> json) { |
| final kindJson = json['kind']; |
| final kind = kindJson != null |
| ? DocumentHighlightKind.fromJson(kindJson as int) |
| : null; |
| final rangeJson = json['range']; |
| final range = Range.fromJson(rangeJson as Map<String, Object?>); |
| return DocumentHighlight( |
| kind: kind, |
| range: range, |
| ); |
| } |
| |
| /// The highlight kind, default is text. |
| final DocumentHighlightKind? kind; |
| |
| /// The range this highlight applies to. |
| final Range range; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (kind != null) { |
| result['kind'] = kind?.toJson(); |
| } |
| result['range'] = range.toJson(); |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseDocumentHighlightKind(obj, reporter, 'kind', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseRange(obj, reporter, 'range', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DocumentHighlight'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DocumentHighlight && |
| other.runtimeType == DocumentHighlight && |
| kind == other.kind && |
| range == other.range; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| kind, |
| range, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Client Capabilities for a DocumentHighlightRequest. |
| class DocumentHighlightClientCapabilities implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DocumentHighlightClientCapabilities.canParse, |
| DocumentHighlightClientCapabilities.fromJson, |
| ); |
| |
| DocumentHighlightClientCapabilities({ |
| this.dynamicRegistration, |
| }); |
| static DocumentHighlightClientCapabilities fromJson( |
| Map<String, Object?> json) { |
| final dynamicRegistrationJson = json['dynamicRegistration']; |
| final dynamicRegistration = dynamicRegistrationJson as bool?; |
| return DocumentHighlightClientCapabilities( |
| dynamicRegistration: dynamicRegistration, |
| ); |
| } |
| |
| /// Whether document highlight supports dynamic registration. |
| final bool? dynamicRegistration; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (dynamicRegistration != null) { |
| result['dynamicRegistration'] = dynamicRegistration; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseBool(obj, reporter, 'dynamicRegistration', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter |
| .reportError('must be of type DocumentHighlightClientCapabilities'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DocumentHighlightClientCapabilities && |
| other.runtimeType == DocumentHighlightClientCapabilities && |
| dynamicRegistration == other.dynamicRegistration; |
| } |
| |
| @override |
| int get hashCode => dynamicRegistration.hashCode; |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// A document highlight kind. |
| class DocumentHighlightKind implements ToJsonable { |
| const DocumentHighlightKind(this._value); |
| const DocumentHighlightKind.fromJson(this._value); |
| |
| final int _value; |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) => obj is int; |
| |
| /// Read-access of a symbol, like reading a variable. |
| static const Read = DocumentHighlightKind(2); |
| |
| /// A textual occurrence. |
| static const Text = DocumentHighlightKind(1); |
| |
| /// Write-access of a symbol, like writing to a variable. |
| static const Write = DocumentHighlightKind(3); |
| |
| @override |
| Object toJson() => _value; |
| |
| @override |
| String toString() => _value.toString(); |
| |
| @override |
| int get hashCode => _value.hashCode; |
| |
| @override |
| bool operator ==(Object other) => |
| other is DocumentHighlightKind && other._value == _value; |
| } |
| |
| /// Provider options for a DocumentHighlightRequest. |
| class DocumentHighlightOptions implements WorkDoneProgressOptions, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DocumentHighlightOptions.canParse, |
| DocumentHighlightOptions.fromJson, |
| ); |
| |
| DocumentHighlightOptions({ |
| this.workDoneProgress, |
| }); |
| static DocumentHighlightOptions fromJson(Map<String, Object?> json) { |
| if (DocumentHighlightRegistrationOptions.canParse( |
| json, nullLspJsonReporter)) { |
| return DocumentHighlightRegistrationOptions.fromJson(json); |
| } |
| final workDoneProgressJson = json['workDoneProgress']; |
| final workDoneProgress = workDoneProgressJson as bool?; |
| return DocumentHighlightOptions( |
| workDoneProgress: workDoneProgress, |
| ); |
| } |
| |
| @override |
| final bool? workDoneProgress; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (workDoneProgress != null) { |
| result['workDoneProgress'] = workDoneProgress; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseBool(obj, reporter, 'workDoneProgress', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DocumentHighlightOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DocumentHighlightOptions && |
| other.runtimeType == DocumentHighlightOptions && |
| workDoneProgress == other.workDoneProgress; |
| } |
| |
| @override |
| int get hashCode => workDoneProgress.hashCode; |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Parameters for a DocumentHighlightRequest. |
| class DocumentHighlightParams |
| implements |
| PartialResultParams, |
| TextDocumentPositionParams, |
| WorkDoneProgressParams, |
| ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DocumentHighlightParams.canParse, |
| DocumentHighlightParams.fromJson, |
| ); |
| |
| DocumentHighlightParams({ |
| this.partialResultToken, |
| required this.position, |
| required this.textDocument, |
| this.workDoneToken, |
| }); |
| static DocumentHighlightParams fromJson(Map<String, Object?> json) { |
| final partialResultTokenJson = json['partialResultToken']; |
| final partialResultToken = partialResultTokenJson == null |
| ? null |
| : _eitherIntString(partialResultTokenJson); |
| final positionJson = json['position']; |
| final position = Position.fromJson(positionJson as Map<String, Object?>); |
| final textDocumentJson = json['textDocument']; |
| final textDocument = TextDocumentIdentifier.fromJson( |
| textDocumentJson as Map<String, Object?>); |
| final workDoneTokenJson = json['workDoneToken']; |
| final workDoneToken = |
| workDoneTokenJson == null ? null : _eitherIntString(workDoneTokenJson); |
| return DocumentHighlightParams( |
| partialResultToken: partialResultToken, |
| position: position, |
| textDocument: textDocument, |
| workDoneToken: workDoneToken, |
| ); |
| } |
| |
| /// An optional token that a server can use to report partial results (e.g. |
| /// streaming) to the client. |
| @override |
| final ProgressToken? partialResultToken; |
| |
| /// The position inside the text document. |
| @override |
| final Position position; |
| |
| /// The text document. |
| @override |
| final TextDocumentIdentifier textDocument; |
| |
| /// An optional token that a server can use to report work done progress. |
| @override |
| final ProgressToken? workDoneToken; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (partialResultToken != null) { |
| result['partialResultToken'] = partialResultToken; |
| } |
| result['position'] = position.toJson(); |
| result['textDocument'] = textDocument.toJson(); |
| if (workDoneToken != null) { |
| result['workDoneToken'] = workDoneToken; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseIntString(obj, reporter, 'partialResultToken', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParsePosition(obj, reporter, 'position', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseTextDocumentIdentifier(obj, reporter, 'textDocument', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseIntString(obj, reporter, 'workDoneToken', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DocumentHighlightParams'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DocumentHighlightParams && |
| other.runtimeType == DocumentHighlightParams && |
| partialResultToken == other.partialResultToken && |
| position == other.position && |
| textDocument == other.textDocument && |
| workDoneToken == other.workDoneToken; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| partialResultToken, |
| position, |
| textDocument, |
| workDoneToken, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Registration options for a DocumentHighlightRequest. |
| class DocumentHighlightRegistrationOptions |
| implements |
| DocumentHighlightOptions, |
| TextDocumentRegistrationOptions, |
| ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DocumentHighlightRegistrationOptions.canParse, |
| DocumentHighlightRegistrationOptions.fromJson, |
| ); |
| |
| DocumentHighlightRegistrationOptions({ |
| this.documentSelector, |
| this.workDoneProgress, |
| }); |
| static DocumentHighlightRegistrationOptions fromJson( |
| Map<String, Object?> json) { |
| final documentSelectorJson = json['documentSelector']; |
| final documentSelector = (documentSelectorJson as List<Object?>?) |
| ?.map((item) => |
| TextDocumentFilterWithScheme.fromJson(item as Map<String, Object?>)) |
| .toList(); |
| final workDoneProgressJson = json['workDoneProgress']; |
| final workDoneProgress = workDoneProgressJson as bool?; |
| return DocumentHighlightRegistrationOptions( |
| documentSelector: documentSelector, |
| workDoneProgress: workDoneProgress, |
| ); |
| } |
| |
| /// A document selector to identify the scope of the registration. If set to |
| /// null the document selector provided on the client side will be used. |
| @override |
| final List<TextDocumentFilterWithScheme>? documentSelector; |
| @override |
| final bool? workDoneProgress; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['documentSelector'] = documentSelector; |
| if (workDoneProgress != null) { |
| result['workDoneProgress'] = workDoneProgress; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseListTextDocumentFilterWithScheme( |
| obj, reporter, 'documentSelector', |
| allowsUndefined: false, allowsNull: true)) { |
| return false; |
| } |
| return _canParseBool(obj, reporter, 'workDoneProgress', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter |
| .reportError('must be of type DocumentHighlightRegistrationOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DocumentHighlightRegistrationOptions && |
| other.runtimeType == DocumentHighlightRegistrationOptions && |
| listEqual( |
| documentSelector, |
| other.documentSelector, |
| (TextDocumentFilterWithScheme a, TextDocumentFilterWithScheme b) => |
| a == b) && |
| workDoneProgress == other.workDoneProgress; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| lspHashCode(documentSelector), |
| workDoneProgress, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// A document link is a range in a text document that links to an internal or |
| /// external resource, like another text document or a web site. |
| class DocumentLink implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DocumentLink.canParse, |
| DocumentLink.fromJson, |
| ); |
| |
| DocumentLink({ |
| this.data, |
| required this.range, |
| this.target, |
| this.tooltip, |
| }); |
| static DocumentLink fromJson(Map<String, Object?> json) { |
| final dataJson = json['data']; |
| final data = dataJson; |
| final rangeJson = json['range']; |
| final range = Range.fromJson(rangeJson as Map<String, Object?>); |
| final targetJson = json['target']; |
| final target = targetJson as String?; |
| final tooltipJson = json['tooltip']; |
| final tooltip = tooltipJson as String?; |
| return DocumentLink( |
| data: data, |
| range: range, |
| target: target, |
| tooltip: tooltip, |
| ); |
| } |
| |
| /// A data entry field that is preserved on a document link between a |
| /// DocumentLinkRequest and a DocumentLinkResolveRequest. |
| final LSPAny data; |
| |
| /// The range this link applies to. |
| final Range range; |
| |
| /// The uri this link points to. If missing a resolve request is sent later. |
| final String? target; |
| |
| /// The tooltip text when you hover over this link. |
| /// |
| /// If a tooltip is provided, is will be displayed in a string that includes |
| /// instructions on how to trigger the link, such as `{0} (ctrl + click)`. The |
| /// specific instructions vary depending on OS, |
| /// user settings, and localization. |
| /// |
| /// @since 3.15.0 |
| final String? tooltip; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (data != null) { |
| result['data'] = data; |
| } |
| result['range'] = range.toJson(); |
| if (target != null) { |
| result['target'] = target; |
| } |
| if (tooltip != null) { |
| result['tooltip'] = tooltip; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseRange(obj, reporter, 'range', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseString(obj, reporter, 'target', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseString(obj, reporter, 'tooltip', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DocumentLink'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DocumentLink && |
| other.runtimeType == DocumentLink && |
| data == other.data && |
| range == other.range && |
| target == other.target && |
| tooltip == other.tooltip; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| data, |
| range, |
| target, |
| tooltip, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The client capabilities of a DocumentLinkRequest. |
| class DocumentLinkClientCapabilities implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DocumentLinkClientCapabilities.canParse, |
| DocumentLinkClientCapabilities.fromJson, |
| ); |
| |
| DocumentLinkClientCapabilities({ |
| this.dynamicRegistration, |
| this.tooltipSupport, |
| }); |
| static DocumentLinkClientCapabilities fromJson(Map<String, Object?> json) { |
| final dynamicRegistrationJson = json['dynamicRegistration']; |
| final dynamicRegistration = dynamicRegistrationJson as bool?; |
| final tooltipSupportJson = json['tooltipSupport']; |
| final tooltipSupport = tooltipSupportJson as bool?; |
| return DocumentLinkClientCapabilities( |
| dynamicRegistration: dynamicRegistration, |
| tooltipSupport: tooltipSupport, |
| ); |
| } |
| |
| /// Whether document link supports dynamic registration. |
| final bool? dynamicRegistration; |
| |
| /// Whether the client supports the `tooltip` property on `DocumentLink`. |
| /// |
| /// @since 3.15.0 |
| final bool? tooltipSupport; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (dynamicRegistration != null) { |
| result['dynamicRegistration'] = dynamicRegistration; |
| } |
| if (tooltipSupport != null) { |
| result['tooltipSupport'] = tooltipSupport; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseBool(obj, reporter, 'dynamicRegistration', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseBool(obj, reporter, 'tooltipSupport', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DocumentLinkClientCapabilities'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DocumentLinkClientCapabilities && |
| other.runtimeType == DocumentLinkClientCapabilities && |
| dynamicRegistration == other.dynamicRegistration && |
| tooltipSupport == other.tooltipSupport; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| dynamicRegistration, |
| tooltipSupport, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Provider options for a DocumentLinkRequest. |
| class DocumentLinkOptions implements WorkDoneProgressOptions, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DocumentLinkOptions.canParse, |
| DocumentLinkOptions.fromJson, |
| ); |
| |
| DocumentLinkOptions({ |
| this.resolveProvider, |
| this.workDoneProgress, |
| }); |
| static DocumentLinkOptions fromJson(Map<String, Object?> json) { |
| if (DocumentLinkRegistrationOptions.canParse(json, nullLspJsonReporter)) { |
| return DocumentLinkRegistrationOptions.fromJson(json); |
| } |
| final resolveProviderJson = json['resolveProvider']; |
| final resolveProvider = resolveProviderJson as bool?; |
| final workDoneProgressJson = json['workDoneProgress']; |
| final workDoneProgress = workDoneProgressJson as bool?; |
| return DocumentLinkOptions( |
| resolveProvider: resolveProvider, |
| workDoneProgress: workDoneProgress, |
| ); |
| } |
| |
| /// Document links have a resolve provider as well. |
| final bool? resolveProvider; |
| @override |
| final bool? workDoneProgress; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (resolveProvider != null) { |
| result['resolveProvider'] = resolveProvider; |
| } |
| if (workDoneProgress != null) { |
| result['workDoneProgress'] = workDoneProgress; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseBool(obj, reporter, 'resolveProvider', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseBool(obj, reporter, 'workDoneProgress', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DocumentLinkOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DocumentLinkOptions && |
| other.runtimeType == DocumentLinkOptions && |
| resolveProvider == other.resolveProvider && |
| workDoneProgress == other.workDoneProgress; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| resolveProvider, |
| workDoneProgress, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The parameters of a DocumentLinkRequest. |
| class DocumentLinkParams |
| implements PartialResultParams, WorkDoneProgressParams, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DocumentLinkParams.canParse, |
| DocumentLinkParams.fromJson, |
| ); |
| |
| DocumentLinkParams({ |
| this.partialResultToken, |
| required this.textDocument, |
| this.workDoneToken, |
| }); |
| static DocumentLinkParams fromJson(Map<String, Object?> json) { |
| final partialResultTokenJson = json['partialResultToken']; |
| final partialResultToken = partialResultTokenJson == null |
| ? null |
| : _eitherIntString(partialResultTokenJson); |
| final textDocumentJson = json['textDocument']; |
| final textDocument = TextDocumentIdentifier.fromJson( |
| textDocumentJson as Map<String, Object?>); |
| final workDoneTokenJson = json['workDoneToken']; |
| final workDoneToken = |
| workDoneTokenJson == null ? null : _eitherIntString(workDoneTokenJson); |
| return DocumentLinkParams( |
| partialResultToken: partialResultToken, |
| textDocument: textDocument, |
| workDoneToken: workDoneToken, |
| ); |
| } |
| |
| /// An optional token that a server can use to report partial results (e.g. |
| /// streaming) to the client. |
| @override |
| final ProgressToken? partialResultToken; |
| |
| /// The document to provide document links for. |
| final TextDocumentIdentifier textDocument; |
| |
| /// An optional token that a server can use to report work done progress. |
| @override |
| final ProgressToken? workDoneToken; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (partialResultToken != null) { |
| result['partialResultToken'] = partialResultToken; |
| } |
| result['textDocument'] = textDocument.toJson(); |
| if (workDoneToken != null) { |
| result['workDoneToken'] = workDoneToken; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseIntString(obj, reporter, 'partialResultToken', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseTextDocumentIdentifier(obj, reporter, 'textDocument', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseIntString(obj, reporter, 'workDoneToken', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DocumentLinkParams'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DocumentLinkParams && |
| other.runtimeType == DocumentLinkParams && |
| partialResultToken == other.partialResultToken && |
| textDocument == other.textDocument && |
| workDoneToken == other.workDoneToken; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| partialResultToken, |
| textDocument, |
| workDoneToken, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Registration options for a DocumentLinkRequest. |
| class DocumentLinkRegistrationOptions |
| implements |
| DocumentLinkOptions, |
| TextDocumentRegistrationOptions, |
| ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DocumentLinkRegistrationOptions.canParse, |
| DocumentLinkRegistrationOptions.fromJson, |
| ); |
| |
| DocumentLinkRegistrationOptions({ |
| this.documentSelector, |
| this.resolveProvider, |
| this.workDoneProgress, |
| }); |
| static DocumentLinkRegistrationOptions fromJson(Map<String, Object?> json) { |
| final documentSelectorJson = json['documentSelector']; |
| final documentSelector = (documentSelectorJson as List<Object?>?) |
| ?.map((item) => |
| TextDocumentFilterWithScheme.fromJson(item as Map<String, Object?>)) |
| .toList(); |
| final resolveProviderJson = json['resolveProvider']; |
| final resolveProvider = resolveProviderJson as bool?; |
| final workDoneProgressJson = json['workDoneProgress']; |
| final workDoneProgress = workDoneProgressJson as bool?; |
| return DocumentLinkRegistrationOptions( |
| 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. |
| @override |
| final List<TextDocumentFilterWithScheme>? documentSelector; |
| |
| /// Document links have a resolve provider as well. |
| @override |
| final bool? resolveProvider; |
| @override |
| final bool? workDoneProgress; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['documentSelector'] = documentSelector; |
| if (resolveProvider != null) { |
| result['resolveProvider'] = resolveProvider; |
| } |
| if (workDoneProgress != null) { |
| result['workDoneProgress'] = workDoneProgress; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseListTextDocumentFilterWithScheme( |
| obj, reporter, 'documentSelector', |
| allowsUndefined: false, allowsNull: true)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'resolveProvider', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseBool(obj, reporter, 'workDoneProgress', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DocumentLinkRegistrationOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DocumentLinkRegistrationOptions && |
| other.runtimeType == DocumentLinkRegistrationOptions && |
| listEqual( |
| documentSelector, |
| other.documentSelector, |
| (TextDocumentFilterWithScheme a, TextDocumentFilterWithScheme b) => |
| a == b) && |
| resolveProvider == other.resolveProvider && |
| workDoneProgress == other.workDoneProgress; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| lspHashCode(documentSelector), |
| resolveProvider, |
| workDoneProgress, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Client capabilities of a DocumentOnTypeFormattingRequest. |
| class DocumentOnTypeFormattingClientCapabilities implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DocumentOnTypeFormattingClientCapabilities.canParse, |
| DocumentOnTypeFormattingClientCapabilities.fromJson, |
| ); |
| |
| DocumentOnTypeFormattingClientCapabilities({ |
| this.dynamicRegistration, |
| }); |
| static DocumentOnTypeFormattingClientCapabilities fromJson( |
| Map<String, Object?> json) { |
| final dynamicRegistrationJson = json['dynamicRegistration']; |
| final dynamicRegistration = dynamicRegistrationJson as bool?; |
| return DocumentOnTypeFormattingClientCapabilities( |
| dynamicRegistration: dynamicRegistration, |
| ); |
| } |
| |
| /// Whether on type formatting supports dynamic registration. |
| final bool? dynamicRegistration; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (dynamicRegistration != null) { |
| result['dynamicRegistration'] = dynamicRegistration; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseBool(obj, reporter, 'dynamicRegistration', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError( |
| 'must be of type DocumentOnTypeFormattingClientCapabilities'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DocumentOnTypeFormattingClientCapabilities && |
| other.runtimeType == DocumentOnTypeFormattingClientCapabilities && |
| dynamicRegistration == other.dynamicRegistration; |
| } |
| |
| @override |
| int get hashCode => dynamicRegistration.hashCode; |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Provider options for a DocumentOnTypeFormattingRequest. |
| class DocumentOnTypeFormattingOptions implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DocumentOnTypeFormattingOptions.canParse, |
| DocumentOnTypeFormattingOptions.fromJson, |
| ); |
| |
| DocumentOnTypeFormattingOptions({ |
| required this.firstTriggerCharacter, |
| this.moreTriggerCharacter, |
| }); |
| static DocumentOnTypeFormattingOptions fromJson(Map<String, Object?> json) { |
| if (DocumentOnTypeFormattingRegistrationOptions.canParse( |
| json, nullLspJsonReporter)) { |
| return DocumentOnTypeFormattingRegistrationOptions.fromJson(json); |
| } |
| final firstTriggerCharacterJson = json['firstTriggerCharacter']; |
| final firstTriggerCharacter = firstTriggerCharacterJson as String; |
| final moreTriggerCharacterJson = json['moreTriggerCharacter']; |
| final moreTriggerCharacter = (moreTriggerCharacterJson as List<Object?>?) |
| ?.map((item) => item as String) |
| .toList(); |
| return DocumentOnTypeFormattingOptions( |
| firstTriggerCharacter: firstTriggerCharacter, |
| moreTriggerCharacter: moreTriggerCharacter, |
| ); |
| } |
| |
| /// A character on which formatting should be triggered, like `{`. |
| final String firstTriggerCharacter; |
| |
| /// More trigger characters. |
| final List<String>? moreTriggerCharacter; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['firstTriggerCharacter'] = firstTriggerCharacter; |
| if (moreTriggerCharacter != null) { |
| result['moreTriggerCharacter'] = moreTriggerCharacter; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseString(obj, reporter, 'firstTriggerCharacter', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseListString(obj, reporter, 'moreTriggerCharacter', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DocumentOnTypeFormattingOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DocumentOnTypeFormattingOptions && |
| other.runtimeType == DocumentOnTypeFormattingOptions && |
| firstTriggerCharacter == other.firstTriggerCharacter && |
| listEqual(moreTriggerCharacter, other.moreTriggerCharacter, |
| (String a, String b) => a == b); |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| firstTriggerCharacter, |
| lspHashCode(moreTriggerCharacter), |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The parameters of a DocumentOnTypeFormattingRequest. |
| class DocumentOnTypeFormattingParams implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DocumentOnTypeFormattingParams.canParse, |
| DocumentOnTypeFormattingParams.fromJson, |
| ); |
| |
| DocumentOnTypeFormattingParams({ |
| required this.ch, |
| required this.options, |
| required this.position, |
| required this.textDocument, |
| }); |
| static DocumentOnTypeFormattingParams fromJson(Map<String, Object?> json) { |
| final chJson = json['ch']; |
| final ch = chJson as String; |
| final optionsJson = json['options']; |
| final options = |
| FormattingOptions.fromJson(optionsJson as Map<String, Object?>); |
| final positionJson = json['position']; |
| final position = Position.fromJson(positionJson as Map<String, Object?>); |
| final textDocumentJson = json['textDocument']; |
| final textDocument = TextDocumentIdentifier.fromJson( |
| textDocumentJson as Map<String, Object?>); |
| return DocumentOnTypeFormattingParams( |
| ch: ch, |
| options: options, |
| position: position, |
| textDocument: textDocument, |
| ); |
| } |
| |
| /// The character that has been typed that triggered the formatting on type |
| /// request. That is not necessarily the last character that got inserted into |
| /// the document since the client could auto insert characters as well (e.g. |
| /// like automatic brace completion). |
| final String ch; |
| |
| /// The formatting options. |
| final FormattingOptions options; |
| |
| /// The position around which the on type formatting should happen. This is |
| /// not necessarily the exact position where the character denoted by the |
| /// property `ch` got typed. |
| final Position position; |
| |
| /// The document to format. |
| final TextDocumentIdentifier textDocument; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['ch'] = ch; |
| result['options'] = options.toJson(); |
| result['position'] = position.toJson(); |
| result['textDocument'] = textDocument.toJson(); |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseString(obj, reporter, 'ch', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseFormattingOptions(obj, reporter, 'options', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParsePosition(obj, reporter, 'position', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseTextDocumentIdentifier(obj, reporter, 'textDocument', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DocumentOnTypeFormattingParams'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DocumentOnTypeFormattingParams && |
| other.runtimeType == DocumentOnTypeFormattingParams && |
| ch == other.ch && |
| options == other.options && |
| position == other.position && |
| textDocument == other.textDocument; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| ch, |
| options, |
| position, |
| textDocument, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Registration options for a DocumentOnTypeFormattingRequest. |
| class DocumentOnTypeFormattingRegistrationOptions |
| implements |
| DocumentOnTypeFormattingOptions, |
| TextDocumentRegistrationOptions, |
| ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DocumentOnTypeFormattingRegistrationOptions.canParse, |
| DocumentOnTypeFormattingRegistrationOptions.fromJson, |
| ); |
| |
| DocumentOnTypeFormattingRegistrationOptions({ |
| this.documentSelector, |
| required this.firstTriggerCharacter, |
| this.moreTriggerCharacter, |
| }); |
| static DocumentOnTypeFormattingRegistrationOptions fromJson( |
| Map<String, Object?> json) { |
| final documentSelectorJson = json['documentSelector']; |
| final documentSelector = (documentSelectorJson as List<Object?>?) |
| ?.map((item) => |
| TextDocumentFilterWithScheme.fromJson(item as Map<String, Object?>)) |
| .toList(); |
| final firstTriggerCharacterJson = json['firstTriggerCharacter']; |
| final firstTriggerCharacter = firstTriggerCharacterJson as String; |
| final moreTriggerCharacterJson = json['moreTriggerCharacter']; |
| final moreTriggerCharacter = (moreTriggerCharacterJson as List<Object?>?) |
| ?.map((item) => item as String) |
| .toList(); |
| return DocumentOnTypeFormattingRegistrationOptions( |
| documentSelector: documentSelector, |
| firstTriggerCharacter: firstTriggerCharacter, |
| moreTriggerCharacter: moreTriggerCharacter, |
| ); |
| } |
| |
| /// 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. |
| @override |
| final List<TextDocumentFilterWithScheme>? documentSelector; |
| |
| /// A character on which formatting should be triggered, like `{`. |
| @override |
| final String firstTriggerCharacter; |
| |
| /// More trigger characters. |
| @override |
| final List<String>? moreTriggerCharacter; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['documentSelector'] = documentSelector; |
| result['firstTriggerCharacter'] = firstTriggerCharacter; |
| if (moreTriggerCharacter != null) { |
| result['moreTriggerCharacter'] = moreTriggerCharacter; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseListTextDocumentFilterWithScheme( |
| obj, reporter, 'documentSelector', |
| allowsUndefined: false, allowsNull: true)) { |
| return false; |
| } |
| if (!_canParseString(obj, reporter, 'firstTriggerCharacter', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseListString(obj, reporter, 'moreTriggerCharacter', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError( |
| 'must be of type DocumentOnTypeFormattingRegistrationOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DocumentOnTypeFormattingRegistrationOptions && |
| other.runtimeType == DocumentOnTypeFormattingRegistrationOptions && |
| listEqual( |
| documentSelector, |
| other.documentSelector, |
| (TextDocumentFilterWithScheme a, TextDocumentFilterWithScheme b) => |
| a == b) && |
| firstTriggerCharacter == other.firstTriggerCharacter && |
| listEqual(moreTriggerCharacter, other.moreTriggerCharacter, |
| (String a, String b) => a == b); |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| lspHashCode(documentSelector), |
| firstTriggerCharacter, |
| lspHashCode(moreTriggerCharacter), |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Client capabilities of a DocumentRangeFormattingRequest. |
| class DocumentRangeFormattingClientCapabilities implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DocumentRangeFormattingClientCapabilities.canParse, |
| DocumentRangeFormattingClientCapabilities.fromJson, |
| ); |
| |
| DocumentRangeFormattingClientCapabilities({ |
| this.dynamicRegistration, |
| }); |
| static DocumentRangeFormattingClientCapabilities fromJson( |
| Map<String, Object?> json) { |
| final dynamicRegistrationJson = json['dynamicRegistration']; |
| final dynamicRegistration = dynamicRegistrationJson as bool?; |
| return DocumentRangeFormattingClientCapabilities( |
| dynamicRegistration: dynamicRegistration, |
| ); |
| } |
| |
| /// Whether range formatting supports dynamic registration. |
| final bool? dynamicRegistration; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (dynamicRegistration != null) { |
| result['dynamicRegistration'] = dynamicRegistration; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseBool(obj, reporter, 'dynamicRegistration', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError( |
| 'must be of type DocumentRangeFormattingClientCapabilities'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DocumentRangeFormattingClientCapabilities && |
| other.runtimeType == DocumentRangeFormattingClientCapabilities && |
| dynamicRegistration == other.dynamicRegistration; |
| } |
| |
| @override |
| int get hashCode => dynamicRegistration.hashCode; |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Provider options for a DocumentRangeFormattingRequest. |
| class DocumentRangeFormattingOptions |
| implements WorkDoneProgressOptions, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DocumentRangeFormattingOptions.canParse, |
| DocumentRangeFormattingOptions.fromJson, |
| ); |
| |
| DocumentRangeFormattingOptions({ |
| this.workDoneProgress, |
| }); |
| static DocumentRangeFormattingOptions fromJson(Map<String, Object?> json) { |
| if (DocumentRangeFormattingRegistrationOptions.canParse( |
| json, nullLspJsonReporter)) { |
| return DocumentRangeFormattingRegistrationOptions.fromJson(json); |
| } |
| final workDoneProgressJson = json['workDoneProgress']; |
| final workDoneProgress = workDoneProgressJson as bool?; |
| return DocumentRangeFormattingOptions( |
| workDoneProgress: workDoneProgress, |
| ); |
| } |
| |
| @override |
| final bool? workDoneProgress; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (workDoneProgress != null) { |
| result['workDoneProgress'] = workDoneProgress; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseBool(obj, reporter, 'workDoneProgress', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DocumentRangeFormattingOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DocumentRangeFormattingOptions && |
| other.runtimeType == DocumentRangeFormattingOptions && |
| workDoneProgress == other.workDoneProgress; |
| } |
| |
| @override |
| int get hashCode => workDoneProgress.hashCode; |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The parameters of a DocumentRangeFormattingRequest. |
| class DocumentRangeFormattingParams |
| implements WorkDoneProgressParams, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DocumentRangeFormattingParams.canParse, |
| DocumentRangeFormattingParams.fromJson, |
| ); |
| |
| DocumentRangeFormattingParams({ |
| required this.options, |
| required this.range, |
| required this.textDocument, |
| this.workDoneToken, |
| }); |
| static DocumentRangeFormattingParams fromJson(Map<String, Object?> json) { |
| final optionsJson = json['options']; |
| final options = |
| FormattingOptions.fromJson(optionsJson as Map<String, Object?>); |
| final rangeJson = json['range']; |
| final range = Range.fromJson(rangeJson as Map<String, Object?>); |
| final textDocumentJson = json['textDocument']; |
| final textDocument = TextDocumentIdentifier.fromJson( |
| textDocumentJson as Map<String, Object?>); |
| final workDoneTokenJson = json['workDoneToken']; |
| final workDoneToken = |
| workDoneTokenJson == null ? null : _eitherIntString(workDoneTokenJson); |
| return DocumentRangeFormattingParams( |
| options: options, |
| range: range, |
| textDocument: textDocument, |
| workDoneToken: workDoneToken, |
| ); |
| } |
| |
| /// The format options |
| final FormattingOptions options; |
| |
| /// The range to format |
| final Range range; |
| |
| /// The document to format. |
| final TextDocumentIdentifier textDocument; |
| |
| /// An optional token that a server can use to report work done progress. |
| @override |
| final ProgressToken? workDoneToken; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['options'] = options.toJson(); |
| result['range'] = range.toJson(); |
| result['textDocument'] = textDocument.toJson(); |
| if (workDoneToken != null) { |
| result['workDoneToken'] = workDoneToken; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseFormattingOptions(obj, reporter, 'options', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseRange(obj, reporter, 'range', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseTextDocumentIdentifier(obj, reporter, 'textDocument', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseIntString(obj, reporter, 'workDoneToken', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DocumentRangeFormattingParams'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DocumentRangeFormattingParams && |
| other.runtimeType == DocumentRangeFormattingParams && |
| options == other.options && |
| range == other.range && |
| textDocument == other.textDocument && |
| workDoneToken == other.workDoneToken; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| options, |
| range, |
| textDocument, |
| workDoneToken, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Registration options for a DocumentRangeFormattingRequest. |
| class DocumentRangeFormattingRegistrationOptions |
| implements |
| DocumentRangeFormattingOptions, |
| TextDocumentRegistrationOptions, |
| ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DocumentRangeFormattingRegistrationOptions.canParse, |
| DocumentRangeFormattingRegistrationOptions.fromJson, |
| ); |
| |
| DocumentRangeFormattingRegistrationOptions({ |
| this.documentSelector, |
| this.workDoneProgress, |
| }); |
| static DocumentRangeFormattingRegistrationOptions fromJson( |
| Map<String, Object?> json) { |
| final documentSelectorJson = json['documentSelector']; |
| final documentSelector = (documentSelectorJson as List<Object?>?) |
| ?.map((item) => |
| TextDocumentFilterWithScheme.fromJson(item as Map<String, Object?>)) |
| .toList(); |
| final workDoneProgressJson = json['workDoneProgress']; |
| final workDoneProgress = workDoneProgressJson as bool?; |
| return DocumentRangeFormattingRegistrationOptions( |
| documentSelector: documentSelector, |
| workDoneProgress: workDoneProgress, |
| ); |
| } |
| |
| /// A document selector to identify the scope of the registration. If set to |
| /// null the document selector provided on the client side will be used. |
| @override |
| final List<TextDocumentFilterWithScheme>? documentSelector; |
| @override |
| final bool? workDoneProgress; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['documentSelector'] = documentSelector; |
| if (workDoneProgress != null) { |
| result['workDoneProgress'] = workDoneProgress; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseListTextDocumentFilterWithScheme( |
| obj, reporter, 'documentSelector', |
| allowsUndefined: false, allowsNull: true)) { |
| return false; |
| } |
| return _canParseBool(obj, reporter, 'workDoneProgress', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError( |
| 'must be of type DocumentRangeFormattingRegistrationOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DocumentRangeFormattingRegistrationOptions && |
| other.runtimeType == DocumentRangeFormattingRegistrationOptions && |
| listEqual( |
| documentSelector, |
| other.documentSelector, |
| (TextDocumentFilterWithScheme a, TextDocumentFilterWithScheme b) => |
| a == b) && |
| workDoneProgress == other.workDoneProgress; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| lspHashCode(documentSelector), |
| workDoneProgress, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Represents programming constructs like variables, classes, interfaces etc. |
| /// that appear in a document. Document symbols can be hierarchical and they |
| /// have two ranges: one that encloses its definition and one that points to its |
| /// most interesting range, e.g. the range of an identifier. |
| class DocumentSymbol implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DocumentSymbol.canParse, |
| DocumentSymbol.fromJson, |
| ); |
| |
| DocumentSymbol({ |
| this.children, |
| this.deprecated, |
| this.detail, |
| required this.kind, |
| required this.name, |
| required this.range, |
| required this.selectionRange, |
| this.tags, |
| }); |
| static DocumentSymbol fromJson(Map<String, Object?> json) { |
| final childrenJson = json['children']; |
| final children = (childrenJson as List<Object?>?) |
| ?.map((item) => DocumentSymbol.fromJson(item as Map<String, Object?>)) |
| .toList(); |
| final deprecatedJson = json['deprecated']; |
| final deprecated = deprecatedJson as bool?; |
| final detailJson = json['detail']; |
| final detail = detailJson as String?; |
| final kindJson = json['kind']; |
| final kind = SymbolKind.fromJson(kindJson as int); |
| final nameJson = json['name']; |
| final name = nameJson as String; |
| final rangeJson = json['range']; |
| final range = Range.fromJson(rangeJson as Map<String, Object?>); |
| final selectionRangeJson = json['selectionRange']; |
| final selectionRange = |
| Range.fromJson(selectionRangeJson as Map<String, Object?>); |
| final tagsJson = json['tags']; |
| final tags = (tagsJson as List<Object?>?) |
| ?.map((item) => SymbolTag.fromJson(item as int)) |
| .toList(); |
| return DocumentSymbol( |
| children: children, |
| deprecated: deprecated, |
| detail: detail, |
| kind: kind, |
| name: name, |
| range: range, |
| selectionRange: selectionRange, |
| tags: tags, |
| ); |
| } |
| |
| /// Children of this symbol, e.g. properties of a class. |
| final List<DocumentSymbol>? children; |
| |
| /// Indicates if this symbol is deprecated. |
| /// |
| /// @deprecated Use tags instead |
| final bool? deprecated; |
| |
| /// More detail for this symbol, e.g the signature of a function. |
| final String? detail; |
| |
| /// The kind of this symbol. |
| final SymbolKind kind; |
| |
| /// The name of this symbol. Will be displayed in the user interface and |
| /// therefore must not be an empty string or a string only consisting of white |
| /// spaces. |
| final String name; |
| |
| /// The range enclosing this symbol not including leading/trailing whitespace |
| /// but everything else like comments. This information is typically used to |
| /// determine if the clients cursor is inside the symbol to reveal in the |
| /// symbol in the UI. |
| final Range range; |
| |
| /// The range that should be selected and revealed when this symbol is being |
| /// picked, e.g the name of a function. Must be contained by the `range`. |
| final Range selectionRange; |
| |
| /// Tags for this document symbol. |
| /// |
| /// @since 3.16.0 |
| final List<SymbolTag>? tags; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (children != null) { |
| result['children'] = children?.map((item) => item.toJson()).toList(); |
| } |
| if (deprecated != null) { |
| result['deprecated'] = deprecated; |
| } |
| if (detail != null) { |
| result['detail'] = detail; |
| } |
| result['kind'] = kind.toJson(); |
| result['name'] = name; |
| result['range'] = range.toJson(); |
| result['selectionRange'] = selectionRange.toJson(); |
| if (tags != null) { |
| result['tags'] = tags?.map((item) => item.toJson()).toList(); |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseListDocumentSymbol(obj, reporter, 'children', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'deprecated', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseString(obj, reporter, 'detail', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseSymbolKind(obj, reporter, 'kind', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseString(obj, reporter, 'name', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseRange(obj, reporter, 'range', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseRange(obj, reporter, 'selectionRange', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseListSymbolTag(obj, reporter, 'tags', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DocumentSymbol'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DocumentSymbol && |
| other.runtimeType == DocumentSymbol && |
| listEqual(children, other.children, |
| (DocumentSymbol a, DocumentSymbol b) => a == b) && |
| deprecated == other.deprecated && |
| detail == other.detail && |
| kind == other.kind && |
| name == other.name && |
| range == other.range && |
| selectionRange == other.selectionRange && |
| listEqual(tags, other.tags, (SymbolTag a, SymbolTag b) => a == b); |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| lspHashCode(children), |
| deprecated, |
| detail, |
| kind, |
| name, |
| range, |
| selectionRange, |
| lspHashCode(tags), |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Client Capabilities for a DocumentSymbolRequest. |
| class DocumentSymbolClientCapabilities implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DocumentSymbolClientCapabilities.canParse, |
| DocumentSymbolClientCapabilities.fromJson, |
| ); |
| |
| DocumentSymbolClientCapabilities({ |
| this.dynamicRegistration, |
| this.hierarchicalDocumentSymbolSupport, |
| this.labelSupport, |
| this.symbolKind, |
| this.tagSupport, |
| }); |
| static DocumentSymbolClientCapabilities fromJson(Map<String, Object?> json) { |
| final dynamicRegistrationJson = json['dynamicRegistration']; |
| final dynamicRegistration = dynamicRegistrationJson as bool?; |
| final hierarchicalDocumentSymbolSupportJson = |
| json['hierarchicalDocumentSymbolSupport']; |
| final hierarchicalDocumentSymbolSupport = |
| hierarchicalDocumentSymbolSupportJson as bool?; |
| final labelSupportJson = json['labelSupport']; |
| final labelSupport = labelSupportJson as bool?; |
| final symbolKindJson = json['symbolKind']; |
| final symbolKind = symbolKindJson != null |
| ? DocumentSymbolClientCapabilitiesSymbolKind.fromJson( |
| symbolKindJson as Map<String, Object?>) |
| : null; |
| final tagSupportJson = json['tagSupport']; |
| final tagSupport = tagSupportJson != null |
| ? DocumentSymbolClientCapabilitiesTagSupport.fromJson( |
| tagSupportJson as Map<String, Object?>) |
| : null; |
| return DocumentSymbolClientCapabilities( |
| dynamicRegistration: dynamicRegistration, |
| hierarchicalDocumentSymbolSupport: hierarchicalDocumentSymbolSupport, |
| labelSupport: labelSupport, |
| symbolKind: symbolKind, |
| tagSupport: tagSupport, |
| ); |
| } |
| |
| /// Whether document symbol supports dynamic registration. |
| final bool? dynamicRegistration; |
| |
| /// The client supports hierarchical document symbols. |
| final bool? hierarchicalDocumentSymbolSupport; |
| |
| /// The client supports an additional label presented in the UI when |
| /// registering a document symbol provider. |
| /// |
| /// @since 3.16.0 |
| final bool? labelSupport; |
| |
| /// Specific capabilities for the `SymbolKind` in the |
| /// `textDocument/documentSymbol` request. |
| final DocumentSymbolClientCapabilitiesSymbolKind? symbolKind; |
| |
| /// The client supports tags on `SymbolInformation`. Tags are supported on |
| /// `DocumentSymbol` if `hierarchicalDocumentSymbolSupport` is set to true. |
| /// Clients supporting tags have to handle unknown tags gracefully. |
| /// |
| /// @since 3.16.0 |
| final DocumentSymbolClientCapabilitiesTagSupport? tagSupport; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (dynamicRegistration != null) { |
| result['dynamicRegistration'] = dynamicRegistration; |
| } |
| if (hierarchicalDocumentSymbolSupport != null) { |
| result['hierarchicalDocumentSymbolSupport'] = |
| hierarchicalDocumentSymbolSupport; |
| } |
| if (labelSupport != null) { |
| result['labelSupport'] = labelSupport; |
| } |
| if (symbolKind != null) { |
| result['symbolKind'] = symbolKind?.toJson(); |
| } |
| if (tagSupport != null) { |
| result['tagSupport'] = tagSupport?.toJson(); |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseBool(obj, reporter, 'dynamicRegistration', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'hierarchicalDocumentSymbolSupport', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'labelSupport', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseDocumentSymbolClientCapabilitiesSymbolKind( |
| obj, reporter, 'symbolKind', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseDocumentSymbolClientCapabilitiesTagSupport( |
| obj, reporter, 'tagSupport', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DocumentSymbolClientCapabilities'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DocumentSymbolClientCapabilities && |
| other.runtimeType == DocumentSymbolClientCapabilities && |
| dynamicRegistration == other.dynamicRegistration && |
| hierarchicalDocumentSymbolSupport == |
| other.hierarchicalDocumentSymbolSupport && |
| labelSupport == other.labelSupport && |
| symbolKind == other.symbolKind && |
| tagSupport == other.tagSupport; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| dynamicRegistration, |
| hierarchicalDocumentSymbolSupport, |
| labelSupport, |
| symbolKind, |
| tagSupport, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class DocumentSymbolClientCapabilitiesSymbolKind implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DocumentSymbolClientCapabilitiesSymbolKind.canParse, |
| DocumentSymbolClientCapabilitiesSymbolKind.fromJson, |
| ); |
| |
| DocumentSymbolClientCapabilitiesSymbolKind({ |
| this.valueSet, |
| }); |
| static DocumentSymbolClientCapabilitiesSymbolKind fromJson( |
| Map<String, Object?> json) { |
| final valueSetJson = json['valueSet']; |
| final valueSet = (valueSetJson as List<Object?>?) |
| ?.map((item) => SymbolKind.fromJson(item as int)) |
| .toList(); |
| return DocumentSymbolClientCapabilitiesSymbolKind( |
| valueSet: valueSet, |
| ); |
| } |
| |
| /// The symbol kind values the client supports. When this property exists the |
| /// client also guarantees that it will handle values outside its set |
| /// gracefully and falls back to a default value when unknown. |
| /// |
| /// If this property is not present the client only supports the symbol kinds |
| /// from `File` to `Array` as defined in the initial version of the protocol. |
| final List<SymbolKind>? valueSet; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (valueSet != null) { |
| result['valueSet'] = valueSet?.map((item) => item.toJson()).toList(); |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseListSymbolKind(obj, reporter, 'valueSet', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError( |
| 'must be of type DocumentSymbolClientCapabilitiesSymbolKind'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DocumentSymbolClientCapabilitiesSymbolKind && |
| other.runtimeType == DocumentSymbolClientCapabilitiesSymbolKind && |
| listEqual( |
| valueSet, other.valueSet, (SymbolKind a, SymbolKind b) => a == b); |
| } |
| |
| @override |
| int get hashCode => lspHashCode(valueSet); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class DocumentSymbolClientCapabilitiesTagSupport implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DocumentSymbolClientCapabilitiesTagSupport.canParse, |
| DocumentSymbolClientCapabilitiesTagSupport.fromJson, |
| ); |
| |
| DocumentSymbolClientCapabilitiesTagSupport({ |
| required this.valueSet, |
| }); |
| static DocumentSymbolClientCapabilitiesTagSupport fromJson( |
| Map<String, Object?> json) { |
| final valueSetJson = json['valueSet']; |
| final valueSet = (valueSetJson as List<Object?>) |
| .map((item) => SymbolTag.fromJson(item as int)) |
| .toList(); |
| return DocumentSymbolClientCapabilitiesTagSupport( |
| valueSet: valueSet, |
| ); |
| } |
| |
| /// The tags supported by the client. |
| final List<SymbolTag> valueSet; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['valueSet'] = valueSet.map((item) => item.toJson()).toList(); |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseListSymbolTag(obj, reporter, 'valueSet', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError( |
| 'must be of type DocumentSymbolClientCapabilitiesTagSupport'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DocumentSymbolClientCapabilitiesTagSupport && |
| other.runtimeType == DocumentSymbolClientCapabilitiesTagSupport && |
| listEqual( |
| valueSet, other.valueSet, (SymbolTag a, SymbolTag b) => a == b); |
| } |
| |
| @override |
| int get hashCode => lspHashCode(valueSet); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Provider options for a DocumentSymbolRequest. |
| class DocumentSymbolOptions implements WorkDoneProgressOptions, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DocumentSymbolOptions.canParse, |
| DocumentSymbolOptions.fromJson, |
| ); |
| |
| DocumentSymbolOptions({ |
| this.label, |
| this.workDoneProgress, |
| }); |
| static DocumentSymbolOptions fromJson(Map<String, Object?> json) { |
| if (DocumentSymbolRegistrationOptions.canParse(json, nullLspJsonReporter)) { |
| return DocumentSymbolRegistrationOptions.fromJson(json); |
| } |
| final labelJson = json['label']; |
| final label = labelJson as String?; |
| final workDoneProgressJson = json['workDoneProgress']; |
| final workDoneProgress = workDoneProgressJson as bool?; |
| return DocumentSymbolOptions( |
| label: label, |
| workDoneProgress: workDoneProgress, |
| ); |
| } |
| |
| /// A human-readable string that is shown when multiple outlines trees are |
| /// shown for the same document. |
| /// |
| /// @since 3.16.0 |
| final String? label; |
| @override |
| final bool? workDoneProgress; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (label != null) { |
| result['label'] = label; |
| } |
| if (workDoneProgress != null) { |
| result['workDoneProgress'] = workDoneProgress; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseString(obj, reporter, 'label', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseBool(obj, reporter, 'workDoneProgress', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DocumentSymbolOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DocumentSymbolOptions && |
| other.runtimeType == DocumentSymbolOptions && |
| label == other.label && |
| workDoneProgress == other.workDoneProgress; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| label, |
| workDoneProgress, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Parameters for a DocumentSymbolRequest. |
| class DocumentSymbolParams |
| implements PartialResultParams, WorkDoneProgressParams, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DocumentSymbolParams.canParse, |
| DocumentSymbolParams.fromJson, |
| ); |
| |
| DocumentSymbolParams({ |
| this.partialResultToken, |
| required this.textDocument, |
| this.workDoneToken, |
| }); |
| static DocumentSymbolParams fromJson(Map<String, Object?> json) { |
| final partialResultTokenJson = json['partialResultToken']; |
| final partialResultToken = partialResultTokenJson == null |
| ? null |
| : _eitherIntString(partialResultTokenJson); |
| final textDocumentJson = json['textDocument']; |
| final textDocument = TextDocumentIdentifier.fromJson( |
| textDocumentJson as Map<String, Object?>); |
| final workDoneTokenJson = json['workDoneToken']; |
| final workDoneToken = |
| workDoneTokenJson == null ? null : _eitherIntString(workDoneTokenJson); |
| return DocumentSymbolParams( |
| partialResultToken: partialResultToken, |
| textDocument: textDocument, |
| workDoneToken: workDoneToken, |
| ); |
| } |
| |
| /// An optional token that a server can use to report partial results (e.g. |
| /// streaming) to the client. |
| @override |
| final ProgressToken? partialResultToken; |
| |
| /// The text document. |
| final TextDocumentIdentifier textDocument; |
| |
| /// An optional token that a server can use to report work done progress. |
| @override |
| final ProgressToken? workDoneToken; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (partialResultToken != null) { |
| result['partialResultToken'] = partialResultToken; |
| } |
| result['textDocument'] = textDocument.toJson(); |
| if (workDoneToken != null) { |
| result['workDoneToken'] = workDoneToken; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseIntString(obj, reporter, 'partialResultToken', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseTextDocumentIdentifier(obj, reporter, 'textDocument', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseIntString(obj, reporter, 'workDoneToken', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DocumentSymbolParams'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DocumentSymbolParams && |
| other.runtimeType == DocumentSymbolParams && |
| partialResultToken == other.partialResultToken && |
| textDocument == other.textDocument && |
| workDoneToken == other.workDoneToken; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| partialResultToken, |
| textDocument, |
| workDoneToken, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Registration options for a DocumentSymbolRequest. |
| class DocumentSymbolRegistrationOptions |
| implements |
| DocumentSymbolOptions, |
| TextDocumentRegistrationOptions, |
| ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| DocumentSymbolRegistrationOptions.canParse, |
| DocumentSymbolRegistrationOptions.fromJson, |
| ); |
| |
| DocumentSymbolRegistrationOptions({ |
| this.documentSelector, |
| this.label, |
| this.workDoneProgress, |
| }); |
| static DocumentSymbolRegistrationOptions fromJson(Map<String, Object?> json) { |
| final documentSelectorJson = json['documentSelector']; |
| final documentSelector = (documentSelectorJson as List<Object?>?) |
| ?.map((item) => |
| TextDocumentFilterWithScheme.fromJson(item as Map<String, Object?>)) |
| .toList(); |
| final labelJson = json['label']; |
| final label = labelJson as String?; |
| final workDoneProgressJson = json['workDoneProgress']; |
| final workDoneProgress = workDoneProgressJson as bool?; |
| return DocumentSymbolRegistrationOptions( |
| documentSelector: documentSelector, |
| label: label, |
| 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. |
| @override |
| final List<TextDocumentFilterWithScheme>? documentSelector; |
| |
| /// A human-readable string that is shown when multiple outlines trees are |
| /// shown for the same document. |
| /// |
| /// @since 3.16.0 |
| @override |
| final String? label; |
| @override |
| final bool? workDoneProgress; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['documentSelector'] = documentSelector; |
| if (label != null) { |
| result['label'] = label; |
| } |
| if (workDoneProgress != null) { |
| result['workDoneProgress'] = workDoneProgress; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseListTextDocumentFilterWithScheme( |
| obj, reporter, 'documentSelector', |
| allowsUndefined: false, allowsNull: true)) { |
| return false; |
| } |
| if (!_canParseString(obj, reporter, 'label', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseBool(obj, reporter, 'workDoneProgress', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type DocumentSymbolRegistrationOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is DocumentSymbolRegistrationOptions && |
| other.runtimeType == DocumentSymbolRegistrationOptions && |
| listEqual( |
| documentSelector, |
| other.documentSelector, |
| (TextDocumentFilterWithScheme a, TextDocumentFilterWithScheme b) => |
| a == b) && |
| label == other.label && |
| workDoneProgress == other.workDoneProgress; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| lspHashCode(documentSelector), |
| label, |
| workDoneProgress, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Predefined error codes. |
| class ErrorCodes implements ToJsonable { |
| const ErrorCodes(this._value); |
| const ErrorCodes.fromJson(this._value); |
| |
| final int _value; |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) => obj is int; |
| |
| /// The server detected that the content of a document got modified outside |
| /// normal conditions. A server should NOT send this error code if it detects |
| /// a content change in it unprocessed messages. The result even computed on |
| /// an older state might still be useful for the client. |
| /// |
| /// If a client decides that a result is not of any use anymore the client |
| /// should cancel the request. |
| static const ContentModified = ErrorCodes(-32801); |
| static const InternalError = ErrorCodes(-32603); |
| static const InvalidParams = ErrorCodes(-32602); |
| static const InvalidRequest = ErrorCodes(-32600); |
| |
| /// This is the end range of JSON RPC reserved error codes. It doesn't denote |
| /// a real error code. |
| /// |
| /// @since 3.16.0 |
| static const jsonrpcReservedErrorRangeEnd = ErrorCodes(-32000); |
| |
| /// This is the start range of JSON RPC reserved error codes. It doesn't |
| /// denote a real error code. No application error codes should be defined |
| /// between the start and end range. For backwards compatibility the |
| /// `ServerNotInitialized` and the `UnknownErrorCode` are left in the range. |
| /// |
| /// @since 3.16.0 |
| static const jsonrpcReservedErrorRangeStart = ErrorCodes(-32099); |
| |
| /// This is the end range of LSP reserved error codes. It doesn't denote a |
| /// real error code. |
| /// |
| /// @since 3.16.0 |
| static const lspReservedErrorRangeEnd = ErrorCodes(-32800); |
| |
| /// This is the start range of LSP reserved error codes. It doesn't denote a |
| /// real error code. |
| /// |
| /// @since 3.16.0 |
| static const lspReservedErrorRangeStart = ErrorCodes(-32899); |
| static const MethodNotFound = ErrorCodes(-32601); |
| static const ParseError = ErrorCodes(-32700); |
| |
| /// The client has canceled a request and a server as detected the cancel. |
| static const RequestCancelled = ErrorCodes(-32800); |
| |
| /// A request failed but it was syntactically correct, e.g the method name was |
| /// known and the parameters were valid. The error message should contain |
| /// human readable information about why the request failed. |
| /// |
| /// @since 3.17.0 |
| static const RequestFailed = ErrorCodes(-32803); |
| |
| /// The server cancelled the request. This error code should only be used for |
| /// requests that explicitly support being server cancellable. |
| /// |
| /// @since 3.17.0 |
| static const ServerCancelled = ErrorCodes(-32802); |
| |
| /// Error code indicating that a server received a notification or request |
| /// before the server has received the `initialize` request. |
| static const ServerNotInitialized = ErrorCodes(-32002); |
| static const UnknownErrorCode = ErrorCodes(-32001); |
| |
| @override |
| Object toJson() => _value; |
| |
| @override |
| String toString() => _value.toString(); |
| |
| @override |
| int get hashCode => _value.hashCode; |
| |
| @override |
| bool operator ==(Object other) => |
| other is ErrorCodes && other._value == _value; |
| } |
| |
| /// The client capabilities of a ExecuteCommandRequest. |
| class ExecuteCommandClientCapabilities implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| ExecuteCommandClientCapabilities.canParse, |
| ExecuteCommandClientCapabilities.fromJson, |
| ); |
| |
| ExecuteCommandClientCapabilities({ |
| this.dynamicRegistration, |
| }); |
| static ExecuteCommandClientCapabilities fromJson(Map<String, Object?> json) { |
| final dynamicRegistrationJson = json['dynamicRegistration']; |
| final dynamicRegistration = dynamicRegistrationJson as bool?; |
| return ExecuteCommandClientCapabilities( |
| dynamicRegistration: dynamicRegistration, |
| ); |
| } |
| |
| /// Execute command supports dynamic registration. |
| final bool? dynamicRegistration; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (dynamicRegistration != null) { |
| result['dynamicRegistration'] = dynamicRegistration; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseBool(obj, reporter, 'dynamicRegistration', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type ExecuteCommandClientCapabilities'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is ExecuteCommandClientCapabilities && |
| other.runtimeType == ExecuteCommandClientCapabilities && |
| dynamicRegistration == other.dynamicRegistration; |
| } |
| |
| @override |
| int get hashCode => dynamicRegistration.hashCode; |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The server capabilities of a ExecuteCommandRequest. |
| class ExecuteCommandOptions implements WorkDoneProgressOptions, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| ExecuteCommandOptions.canParse, |
| ExecuteCommandOptions.fromJson, |
| ); |
| |
| ExecuteCommandOptions({ |
| required this.commands, |
| this.workDoneProgress, |
| }); |
| static ExecuteCommandOptions fromJson(Map<String, Object?> json) { |
| if (ExecuteCommandRegistrationOptions.canParse(json, nullLspJsonReporter)) { |
| return ExecuteCommandRegistrationOptions.fromJson(json); |
| } |
| final commandsJson = json['commands']; |
| final commands = |
| (commandsJson as List<Object?>).map((item) => item as String).toList(); |
| final workDoneProgressJson = json['workDoneProgress']; |
| final workDoneProgress = workDoneProgressJson as bool?; |
| return ExecuteCommandOptions( |
| commands: commands, |
| workDoneProgress: workDoneProgress, |
| ); |
| } |
| |
| /// The commands to be executed on the server |
| final List<String> commands; |
| @override |
| final bool? workDoneProgress; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['commands'] = commands; |
| if (workDoneProgress != null) { |
| result['workDoneProgress'] = workDoneProgress; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseListString(obj, reporter, 'commands', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseBool(obj, reporter, 'workDoneProgress', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type ExecuteCommandOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is ExecuteCommandOptions && |
| other.runtimeType == ExecuteCommandOptions && |
| listEqual(commands, other.commands, (String a, String b) => a == b) && |
| workDoneProgress == other.workDoneProgress; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| lspHashCode(commands), |
| workDoneProgress, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The parameters of a ExecuteCommandRequest. |
| class ExecuteCommandParams implements WorkDoneProgressParams, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| ExecuteCommandParams.canParse, |
| ExecuteCommandParams.fromJson, |
| ); |
| |
| ExecuteCommandParams({ |
| this.arguments, |
| required this.command, |
| this.workDoneToken, |
| }); |
| static ExecuteCommandParams fromJson(Map<String, Object?> json) { |
| final argumentsJson = json['arguments']; |
| final arguments = |
| (argumentsJson as List<Object?>?)?.map((item) => item).toList(); |
| final commandJson = json['command']; |
| final command = commandJson as String; |
| final workDoneTokenJson = json['workDoneToken']; |
| final workDoneToken = |
| workDoneTokenJson == null ? null : _eitherIntString(workDoneTokenJson); |
| return ExecuteCommandParams( |
| arguments: arguments, |
| command: command, |
| workDoneToken: workDoneToken, |
| ); |
| } |
| |
| /// Arguments that the command should be invoked with. |
| final List<LSPAny>? arguments; |
| |
| /// The identifier of the actual command handler. |
| final String command; |
| |
| /// An optional token that a server can use to report work done progress. |
| @override |
| final ProgressToken? workDoneToken; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (arguments != null) { |
| result['arguments'] = arguments; |
| } |
| result['command'] = command; |
| if (workDoneToken != null) { |
| result['workDoneToken'] = workDoneToken; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseListObjectNullable(obj, reporter, 'arguments', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseString(obj, reporter, 'command', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseIntString(obj, reporter, 'workDoneToken', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type ExecuteCommandParams'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is ExecuteCommandParams && |
| other.runtimeType == ExecuteCommandParams && |
| listEqual(arguments, other.arguments, (LSPAny a, LSPAny b) => a == b) && |
| command == other.command && |
| workDoneToken == other.workDoneToken; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| lspHashCode(arguments), |
| command, |
| workDoneToken, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Registration options for a ExecuteCommandRequest. |
| class ExecuteCommandRegistrationOptions |
| implements ExecuteCommandOptions, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| ExecuteCommandRegistrationOptions.canParse, |
| ExecuteCommandRegistrationOptions.fromJson, |
| ); |
| |
| ExecuteCommandRegistrationOptions({ |
| required this.commands, |
| this.workDoneProgress, |
| }); |
| static ExecuteCommandRegistrationOptions fromJson(Map<String, Object?> json) { |
| final commandsJson = json['commands']; |
| final commands = |
| (commandsJson as List<Object?>).map((item) => item as String).toList(); |
| final workDoneProgressJson = json['workDoneProgress']; |
| final workDoneProgress = workDoneProgressJson as bool?; |
| return ExecuteCommandRegistrationOptions( |
| commands: commands, |
| workDoneProgress: workDoneProgress, |
| ); |
| } |
| |
| /// The commands to be executed on the server |
| @override |
| final List<String> commands; |
| @override |
| final bool? workDoneProgress; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['commands'] = commands; |
| if (workDoneProgress != null) { |
| result['workDoneProgress'] = workDoneProgress; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseListString(obj, reporter, 'commands', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseBool(obj, reporter, 'workDoneProgress', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type ExecuteCommandRegistrationOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is ExecuteCommandRegistrationOptions && |
| other.runtimeType == ExecuteCommandRegistrationOptions && |
| listEqual(commands, other.commands, (String a, String b) => a == b) && |
| workDoneProgress == other.workDoneProgress; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| lspHashCode(commands), |
| workDoneProgress, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class ExecutionSummary implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| ExecutionSummary.canParse, |
| ExecutionSummary.fromJson, |
| ); |
| |
| ExecutionSummary({ |
| required this.executionOrder, |
| this.success, |
| }); |
| static ExecutionSummary fromJson(Map<String, Object?> json) { |
| final executionOrderJson = json['executionOrder']; |
| final executionOrder = executionOrderJson as int; |
| final successJson = json['success']; |
| final success = successJson as bool?; |
| return ExecutionSummary( |
| executionOrder: executionOrder, |
| success: success, |
| ); |
| } |
| |
| /// A strict monotonically increasing value indicating the execution order of |
| /// a cell inside a notebook. |
| final int executionOrder; |
| |
| /// Whether the execution was successful or not if known by the client. |
| final bool? success; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['executionOrder'] = executionOrder; |
| if (success != null) { |
| result['success'] = success; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseInt(obj, reporter, 'executionOrder', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseBool(obj, reporter, 'success', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type ExecutionSummary'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is ExecutionSummary && |
| other.runtimeType == ExecutionSummary && |
| executionOrder == other.executionOrder && |
| success == other.success; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| executionOrder, |
| success, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class FailureHandlingKind implements ToJsonable { |
| const FailureHandlingKind._(this._value); |
| const FailureHandlingKind.fromJson(this._value); |
| |
| final String _value; |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| switch (obj) { |
| case 'abort': |
| case 'textOnlyTransactional': |
| case 'transactional': |
| case 'undo': |
| return true; |
| } |
| return false; |
| } |
| |
| /// Applying the workspace change is simply aborted if one of the changes |
| /// provided fails. All operations executed before the failing operation stay |
| /// executed. |
| static const Abort = FailureHandlingKind._('abort'); |
| |
| /// If the workspace edit contains only textual file changes they are executed |
| /// transactional. If resource changes (create, rename or delete file) are |
| /// part of the change the failure handling strategy is abort. |
| static const TextOnlyTransactional = |
| FailureHandlingKind._('textOnlyTransactional'); |
| |
| /// All operations are executed transactional. That means they either all |
| /// succeed or no changes at all are applied to the workspace. |
| static const Transactional = FailureHandlingKind._('transactional'); |
| |
| /// The client tries to undo the operations already executed. But there is no |
| /// guarantee that this is succeeding. |
| static const Undo = FailureHandlingKind._('undo'); |
| |
| @override |
| Object toJson() => _value; |
| |
| @override |
| String toString() => _value.toString(); |
| |
| @override |
| int get hashCode => _value.hashCode; |
| |
| @override |
| bool operator ==(Object other) => |
| other is FailureHandlingKind && other._value == _value; |
| } |
| |
| /// The file event type |
| class FileChangeType implements ToJsonable { |
| const FileChangeType(this._value); |
| const FileChangeType.fromJson(this._value); |
| |
| final int _value; |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) => obj is int; |
| |
| /// The file got changed. |
| static const Changed = FileChangeType(2); |
| |
| /// The file got created. |
| static const Created = FileChangeType(1); |
| |
| /// The file got deleted. |
| static const Deleted = FileChangeType(3); |
| |
| @override |
| Object toJson() => _value; |
| |
| @override |
| String toString() => _value.toString(); |
| |
| @override |
| int get hashCode => _value.hashCode; |
| |
| @override |
| bool operator ==(Object other) => |
| other is FileChangeType && other._value == _value; |
| } |
| |
| /// Represents information on a file/folder create. |
| /// |
| /// @since 3.16.0 |
| class FileCreate implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| FileCreate.canParse, |
| FileCreate.fromJson, |
| ); |
| |
| FileCreate({ |
| required this.uri, |
| }); |
| static FileCreate fromJson(Map<String, Object?> json) { |
| final uriJson = json['uri']; |
| final uri = uriJson as String; |
| return FileCreate( |
| uri: uri, |
| ); |
| } |
| |
| /// A file:// URI for the location of the file/folder being created. |
| final String uri; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['uri'] = uri; |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseString(obj, reporter, 'uri', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type FileCreate'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is FileCreate && |
| other.runtimeType == FileCreate && |
| uri == other.uri; |
| } |
| |
| @override |
| int get hashCode => uri.hashCode; |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Represents information on a file/folder delete. |
| /// |
| /// @since 3.16.0 |
| class FileDelete implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| FileDelete.canParse, |
| FileDelete.fromJson, |
| ); |
| |
| FileDelete({ |
| required this.uri, |
| }); |
| static FileDelete fromJson(Map<String, Object?> json) { |
| final uriJson = json['uri']; |
| final uri = uriJson as String; |
| return FileDelete( |
| uri: uri, |
| ); |
| } |
| |
| /// A file:// URI for the location of the file/folder being deleted. |
| final String uri; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['uri'] = uri; |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseString(obj, reporter, 'uri', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type FileDelete'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is FileDelete && |
| other.runtimeType == FileDelete && |
| uri == other.uri; |
| } |
| |
| @override |
| int get hashCode => uri.hashCode; |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// An event describing a file change. |
| class FileEvent implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| FileEvent.canParse, |
| FileEvent.fromJson, |
| ); |
| |
| FileEvent({ |
| required this.type, |
| required this.uri, |
| }); |
| static FileEvent fromJson(Map<String, Object?> json) { |
| final typeJson = json['type']; |
| final type = FileChangeType.fromJson(typeJson as int); |
| final uriJson = json['uri']; |
| final uri = uriJson as String; |
| return FileEvent( |
| type: type, |
| uri: uri, |
| ); |
| } |
| |
| /// The change type. |
| final FileChangeType type; |
| |
| /// The file's uri. |
| final DocumentUri uri; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['type'] = type.toJson(); |
| result['uri'] = uri; |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseFileChangeType(obj, reporter, 'type', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseString(obj, reporter, 'uri', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type FileEvent'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is FileEvent && |
| other.runtimeType == FileEvent && |
| type == other.type && |
| uri == other.uri; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| type, |
| uri, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Capabilities relating to events from file operations by the user in the |
| /// client. |
| /// |
| /// These events do not come from the file system, they come from user |
| /// operations like renaming a file in the UI. |
| /// |
| /// @since 3.16.0 |
| class FileOperationClientCapabilities implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| FileOperationClientCapabilities.canParse, |
| FileOperationClientCapabilities.fromJson, |
| ); |
| |
| FileOperationClientCapabilities({ |
| this.didCreate, |
| this.didDelete, |
| this.didRename, |
| this.dynamicRegistration, |
| this.willCreate, |
| this.willDelete, |
| this.willRename, |
| }); |
| static FileOperationClientCapabilities fromJson(Map<String, Object?> json) { |
| final didCreateJson = json['didCreate']; |
| final didCreate = didCreateJson as bool?; |
| final didDeleteJson = json['didDelete']; |
| final didDelete = didDeleteJson as bool?; |
| final didRenameJson = json['didRename']; |
| final didRename = didRenameJson as bool?; |
| final dynamicRegistrationJson = json['dynamicRegistration']; |
| final dynamicRegistration = dynamicRegistrationJson as bool?; |
| final willCreateJson = json['willCreate']; |
| final willCreate = willCreateJson as bool?; |
| final willDeleteJson = json['willDelete']; |
| final willDelete = willDeleteJson as bool?; |
| final willRenameJson = json['willRename']; |
| final willRename = willRenameJson as bool?; |
| return FileOperationClientCapabilities( |
| didCreate: didCreate, |
| didDelete: didDelete, |
| didRename: didRename, |
| dynamicRegistration: dynamicRegistration, |
| willCreate: willCreate, |
| willDelete: willDelete, |
| willRename: willRename, |
| ); |
| } |
| |
| /// The client has support for sending didCreateFiles notifications. |
| final bool? didCreate; |
| |
| /// The client has support for sending didDeleteFiles notifications. |
| final bool? didDelete; |
| |
| /// The client has support for sending didRenameFiles notifications. |
| final bool? didRename; |
| |
| /// Whether the client supports dynamic registration for file |
| /// requests/notifications. |
| final bool? dynamicRegistration; |
| |
| /// The client has support for sending willCreateFiles requests. |
| final bool? willCreate; |
| |
| /// The client has support for sending willDeleteFiles requests. |
| final bool? willDelete; |
| |
| /// The client has support for sending willRenameFiles requests. |
| final bool? willRename; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (didCreate != null) { |
| result['didCreate'] = didCreate; |
| } |
| if (didDelete != null) { |
| result['didDelete'] = didDelete; |
| } |
| if (didRename != null) { |
| result['didRename'] = didRename; |
| } |
| if (dynamicRegistration != null) { |
| result['dynamicRegistration'] = dynamicRegistration; |
| } |
| if (willCreate != null) { |
| result['willCreate'] = willCreate; |
| } |
| if (willDelete != null) { |
| result['willDelete'] = willDelete; |
| } |
| if (willRename != null) { |
| result['willRename'] = willRename; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseBool(obj, reporter, 'didCreate', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'didDelete', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'didRename', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'dynamicRegistration', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'willCreate', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'willDelete', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseBool(obj, reporter, 'willRename', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type FileOperationClientCapabilities'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is FileOperationClientCapabilities && |
| other.runtimeType == FileOperationClientCapabilities && |
| didCreate == other.didCreate && |
| didDelete == other.didDelete && |
| didRename == other.didRename && |
| dynamicRegistration == other.dynamicRegistration && |
| willCreate == other.willCreate && |
| willDelete == other.willDelete && |
| willRename == other.willRename; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| didCreate, |
| didDelete, |
| didRename, |
| dynamicRegistration, |
| willCreate, |
| willDelete, |
| willRename, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// A filter to describe in which file operation requests or notifications the |
| /// server is interested in receiving. |
| /// |
| /// @since 3.16.0 |
| class FileOperationFilter implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| FileOperationFilter.canParse, |
| FileOperationFilter.fromJson, |
| ); |
| |
| FileOperationFilter({ |
| required this.pattern, |
| this.scheme, |
| }); |
| static FileOperationFilter fromJson(Map<String, Object?> json) { |
| final patternJson = json['pattern']; |
| final pattern = |
| FileOperationPattern.fromJson(patternJson as Map<String, Object?>); |
| final schemeJson = json['scheme']; |
| final scheme = schemeJson as String?; |
| return FileOperationFilter( |
| pattern: pattern, |
| scheme: scheme, |
| ); |
| } |
| |
| /// The actual file operation pattern. |
| final FileOperationPattern pattern; |
| |
| /// A Uri scheme like `file` or `untitled`. |
| final String? scheme; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['pattern'] = pattern.toJson(); |
| if (scheme != null) { |
| result['scheme'] = scheme; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseFileOperationPattern(obj, reporter, 'pattern', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseString(obj, reporter, 'scheme', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type FileOperationFilter'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is FileOperationFilter && |
| other.runtimeType == FileOperationFilter && |
| pattern == other.pattern && |
| scheme == other.scheme; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| pattern, |
| scheme, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Options for notifications/requests for user operations on files. |
| /// |
| /// @since 3.16.0 |
| class FileOperationOptions implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| FileOperationOptions.canParse, |
| FileOperationOptions.fromJson, |
| ); |
| |
| FileOperationOptions({ |
| this.didCreate, |
| this.didDelete, |
| this.didRename, |
| this.willCreate, |
| this.willDelete, |
| this.willRename, |
| }); |
| static FileOperationOptions fromJson(Map<String, Object?> json) { |
| final didCreateJson = json['didCreate']; |
| final didCreate = didCreateJson != null |
| ? FileOperationRegistrationOptions.fromJson( |
| didCreateJson as Map<String, Object?>) |
| : null; |
| final didDeleteJson = json['didDelete']; |
| final didDelete = didDeleteJson != null |
| ? FileOperationRegistrationOptions.fromJson( |
| didDeleteJson as Map<String, Object?>) |
| : null; |
| final didRenameJson = json['didRename']; |
| final didRename = didRenameJson != null |
| ? FileOperationRegistrationOptions.fromJson( |
| didRenameJson as Map<String, Object?>) |
| : null; |
| final willCreateJson = json['willCreate']; |
| final willCreate = willCreateJson != null |
| ? FileOperationRegistrationOptions.fromJson( |
| willCreateJson as Map<String, Object?>) |
| : null; |
| final willDeleteJson = json['willDelete']; |
| final willDelete = willDeleteJson != null |
| ? FileOperationRegistrationOptions.fromJson( |
| willDeleteJson as Map<String, Object?>) |
| : null; |
| final willRenameJson = json['willRename']; |
| final willRename = willRenameJson != null |
| ? FileOperationRegistrationOptions.fromJson( |
| willRenameJson as Map<String, Object?>) |
| : null; |
| return FileOperationOptions( |
| didCreate: didCreate, |
| didDelete: didDelete, |
| didRename: didRename, |
| willCreate: willCreate, |
| willDelete: willDelete, |
| willRename: willRename, |
| ); |
| } |
| |
| /// The server is interested in receiving didCreateFiles notifications. |
| final FileOperationRegistrationOptions? didCreate; |
| |
| /// The server is interested in receiving didDeleteFiles file notifications. |
| final FileOperationRegistrationOptions? didDelete; |
| |
| /// The server is interested in receiving didRenameFiles notifications. |
| final FileOperationRegistrationOptions? didRename; |
| |
| /// The server is interested in receiving willCreateFiles requests. |
| final FileOperationRegistrationOptions? willCreate; |
| |
| /// The server is interested in receiving willDeleteFiles file requests. |
| final FileOperationRegistrationOptions? willDelete; |
| |
| /// The server is interested in receiving willRenameFiles requests. |
| final FileOperationRegistrationOptions? willRename; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (didCreate != null) { |
| result['didCreate'] = didCreate?.toJson(); |
| } |
| if (didDelete != null) { |
| result['didDelete'] = didDelete?.toJson(); |
| } |
| if (didRename != null) { |
| result['didRename'] = didRename?.toJson(); |
| } |
| if (willCreate != null) { |
| result['willCreate'] = willCreate?.toJson(); |
| } |
| if (willDelete != null) { |
| result['willDelete'] = willDelete?.toJson(); |
| } |
| if (willRename != null) { |
| result['willRename'] = willRename?.toJson(); |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseFileOperationRegistrationOptions(obj, reporter, 'didCreate', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseFileOperationRegistrationOptions(obj, reporter, 'didDelete', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseFileOperationRegistrationOptions(obj, reporter, 'didRename', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseFileOperationRegistrationOptions( |
| obj, reporter, 'willCreate', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseFileOperationRegistrationOptions( |
| obj, reporter, 'willDelete', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseFileOperationRegistrationOptions( |
| obj, reporter, 'willRename', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type FileOperationOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is FileOperationOptions && |
| other.runtimeType == FileOperationOptions && |
| didCreate == other.didCreate && |
| didDelete == other.didDelete && |
| didRename == other.didRename && |
| willCreate == other.willCreate && |
| willDelete == other.willDelete && |
| willRename == other.willRename; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| didCreate, |
| didDelete, |
| didRename, |
| willCreate, |
| willDelete, |
| willRename, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// A pattern to describe in which file operation requests or notifications the |
| /// server is interested in receiving. |
| /// |
| /// @since 3.16.0 |
| class FileOperationPattern implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| FileOperationPattern.canParse, |
| FileOperationPattern.fromJson, |
| ); |
| |
| FileOperationPattern({ |
| required this.glob, |
| this.matches, |
| this.options, |
| }); |
| static FileOperationPattern fromJson(Map<String, Object?> json) { |
| final globJson = json['glob']; |
| final glob = globJson as String; |
| final matchesJson = json['matches']; |
| final matches = matchesJson != null |
| ? FileOperationPatternKind.fromJson(matchesJson as String) |
| : null; |
| final optionsJson = json['options']; |
| final options = optionsJson != null |
| ? FileOperationPatternOptions.fromJson( |
| optionsJson as Map<String, Object?>) |
| : null; |
| return FileOperationPattern( |
| glob: glob, |
| matches: matches, |
| options: options, |
| ); |
| } |
| |
| /// The glob pattern to match. Glob patterns can have the following syntax: |
| /// - `*` to match one or more characters in a path segment |
| /// - `?` to match on one character in a path segment |
| /// - `**` to match any number of path segments, including none |
| /// - `{}` to group sub patterns into an OR expression. (e.g. `**/*.{ts,js}` |
| /// matches all TypeScript and JavaScript files) |
| /// - `[]` to declare a range of characters to match in a path segment (e.g., |
| /// `example.[0-9]` to match on `example.0`, `example.1`, …) |
| /// - `[!...]` to negate a range of characters to match in a path segment |
| /// (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not |
| /// `example.0`) |
| final String glob; |
| |
| /// Whether to match files or folders with this pattern. |
| /// |
| /// Matches both if undefined. |
| final FileOperationPatternKind? matches; |
| |
| /// Additional options used during matching. |
| final FileOperationPatternOptions? options; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['glob'] = glob; |
| if (matches != null) { |
| result['matches'] = matches?.toJson(); |
| } |
| if (options != null) { |
| result['options'] = options?.toJson(); |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseString(obj, reporter, 'glob', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseFileOperationPatternKind(obj, reporter, 'matches', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseFileOperationPatternOptions(obj, reporter, 'options', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type FileOperationPattern'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is FileOperationPattern && |
| other.runtimeType == FileOperationPattern && |
| glob == other.glob && |
| matches == other.matches && |
| options == other.options; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| glob, |
| matches, |
| options, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// A pattern kind describing if a glob pattern matches a file a folder or both. |
| /// |
| /// @since 3.16.0 |
| class FileOperationPatternKind implements ToJsonable { |
| const FileOperationPatternKind(this._value); |
| const FileOperationPatternKind.fromJson(this._value); |
| |
| final String _value; |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) => obj is String; |
| |
| /// The pattern matches a file only. |
| static const file = FileOperationPatternKind('file'); |
| |
| /// The pattern matches a folder only. |
| static const folder = FileOperationPatternKind('folder'); |
| |
| @override |
| Object toJson() => _value; |
| |
| @override |
| String toString() => _value.toString(); |
| |
| @override |
| int get hashCode => _value.hashCode; |
| |
| @override |
| bool operator ==(Object other) => |
| other is FileOperationPatternKind && other._value == _value; |
| } |
| |
| /// Matching options for the file operation pattern. |
| /// |
| /// @since 3.16.0 |
| class FileOperationPatternOptions implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| FileOperationPatternOptions.canParse, |
| FileOperationPatternOptions.fromJson, |
| ); |
| |
| FileOperationPatternOptions({ |
| this.ignoreCase, |
| }); |
| static FileOperationPatternOptions fromJson(Map<String, Object?> json) { |
| final ignoreCaseJson = json['ignoreCase']; |
| final ignoreCase = ignoreCaseJson as bool?; |
| return FileOperationPatternOptions( |
| ignoreCase: ignoreCase, |
| ); |
| } |
| |
| /// The pattern should be matched ignoring casing. |
| final bool? ignoreCase; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (ignoreCase != null) { |
| result['ignoreCase'] = ignoreCase; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseBool(obj, reporter, 'ignoreCase', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type FileOperationPatternOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is FileOperationPatternOptions && |
| other.runtimeType == FileOperationPatternOptions && |
| ignoreCase == other.ignoreCase; |
| } |
| |
| @override |
| int get hashCode => ignoreCase.hashCode; |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The options to register for file operations. |
| /// |
| /// @since 3.16.0 |
| class FileOperationRegistrationOptions implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| FileOperationRegistrationOptions.canParse, |
| FileOperationRegistrationOptions.fromJson, |
| ); |
| |
| FileOperationRegistrationOptions({ |
| required this.filters, |
| }); |
| static FileOperationRegistrationOptions fromJson(Map<String, Object?> json) { |
| final filtersJson = json['filters']; |
| final filters = (filtersJson as List<Object?>) |
| .map((item) => |
| FileOperationFilter.fromJson(item as Map<String, Object?>)) |
| .toList(); |
| return FileOperationRegistrationOptions( |
| filters: filters, |
| ); |
| } |
| |
| /// The actual filters. |
| final List<FileOperationFilter> filters; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['filters'] = filters.map((item) => item.toJson()).toList(); |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseListFileOperationFilter(obj, reporter, 'filters', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type FileOperationRegistrationOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is FileOperationRegistrationOptions && |
| other.runtimeType == FileOperationRegistrationOptions && |
| listEqual(filters, other.filters, |
| (FileOperationFilter a, FileOperationFilter b) => a == b); |
| } |
| |
| @override |
| int get hashCode => lspHashCode(filters); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Represents information on a file/folder rename. |
| /// |
| /// @since 3.16.0 |
| class FileRename implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| FileRename.canParse, |
| FileRename.fromJson, |
| ); |
| |
| FileRename({ |
| required this.newUri, |
| required this.oldUri, |
| }); |
| static FileRename fromJson(Map<String, Object?> json) { |
| final newUriJson = json['newUri']; |
| final newUri = newUriJson as String; |
| final oldUriJson = json['oldUri']; |
| final oldUri = oldUriJson as String; |
| return FileRename( |
| newUri: newUri, |
| oldUri: oldUri, |
| ); |
| } |
| |
| /// A file:// URI for the new location of the file/folder being renamed. |
| final String newUri; |
| |
| /// A file:// URI for the original location of the file/folder being renamed. |
| final String oldUri; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['newUri'] = newUri; |
| result['oldUri'] = oldUri; |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseString(obj, reporter, 'newUri', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseString(obj, reporter, 'oldUri', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type FileRename'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is FileRename && |
| other.runtimeType == FileRename && |
| newUri == other.newUri && |
| oldUri == other.oldUri; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| newUri, |
| oldUri, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class FileSystemWatcher implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| FileSystemWatcher.canParse, |
| FileSystemWatcher.fromJson, |
| ); |
| |
| FileSystemWatcher({ |
| required this.globPattern, |
| this.kind, |
| }); |
| static FileSystemWatcher fromJson(Map<String, Object?> json) { |
| final globPatternJson = json['globPattern']; |
| final globPattern = _eitherStringRelativePattern(globPatternJson); |
| final kindJson = json['kind']; |
| final kind = kindJson != null ? WatchKind.fromJson(kindJson as int) : null; |
| return FileSystemWatcher( |
| globPattern: globPattern, |
| kind: kind, |
| ); |
| } |
| |
| /// The glob pattern to watch. See {@link GlobPattern glob pattern} for more |
| /// detail. |
| /// |
| /// @since 3.17.0 support for relative patterns. |
| final GlobPattern globPattern; |
| |
| /// The kind of events of interest. If omitted it defaults to WatchKind.Create |
| /// | WatchKind.Change | WatchKind.Delete which is 7. |
| final WatchKind? kind; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['globPattern'] = globPattern; |
| if (kind != null) { |
| result['kind'] = kind?.toJson(); |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseStringRelativePattern(obj, reporter, 'globPattern', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseWatchKind(obj, reporter, 'kind', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type FileSystemWatcher'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is FileSystemWatcher && |
| other.runtimeType == FileSystemWatcher && |
| globPattern == other.globPattern && |
| kind == other.kind; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| globPattern, |
| kind, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Represents a folding range. To be valid, start and end line must be bigger |
| /// than zero and smaller than the number of lines in the document. Clients are |
| /// free to ignore invalid ranges. |
| class FoldingRange implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| FoldingRange.canParse, |
| FoldingRange.fromJson, |
| ); |
| |
| FoldingRange({ |
| this.collapsedText, |
| this.endCharacter, |
| required this.endLine, |
| this.kind, |
| this.startCharacter, |
| required this.startLine, |
| }); |
| static FoldingRange fromJson(Map<String, Object?> json) { |
| final collapsedTextJson = json['collapsedText']; |
| final collapsedText = collapsedTextJson as String?; |
| final endCharacterJson = json['endCharacter']; |
| final endCharacter = endCharacterJson as int?; |
| final endLineJson = json['endLine']; |
| final endLine = endLineJson as int; |
| final kindJson = json['kind']; |
| final kind = |
| kindJson != null ? FoldingRangeKind.fromJson(kindJson as String) : null; |
| final startCharacterJson = json['startCharacter']; |
| final startCharacter = startCharacterJson as int?; |
| final startLineJson = json['startLine']; |
| final startLine = startLineJson as int; |
| return FoldingRange( |
| collapsedText: collapsedText, |
| endCharacter: endCharacter, |
| endLine: endLine, |
| kind: kind, |
| startCharacter: startCharacter, |
| startLine: startLine, |
| ); |
| } |
| |
| /// The text that the client should show when the specified range is |
| /// collapsed. If not defined or not supported by the client, a default will |
| /// be chosen by the client. |
| /// |
| /// @since 3.17.0 |
| final String? collapsedText; |
| |
| /// The zero-based character offset before the folded range ends. If not |
| /// defined, defaults to the length of the end line. |
| final int? endCharacter; |
| |
| /// The zero-based end line of the range to fold. The folded area ends with |
| /// the line's last character. To be valid, the end must be zero or larger and |
| /// smaller than the number of lines in the document. |
| final int endLine; |
| |
| /// Describes the kind of the folding range such as `comment' or 'region'. The |
| /// kind is used to categorize folding ranges and used by commands like 'Fold |
| /// all comments'. See FoldingRangeKind for an enumeration of standardized |
| /// kinds. |
| final FoldingRangeKind? kind; |
| |
| /// The zero-based character offset from where the folded range starts. If not |
| /// defined, defaults to the length of the start line. |
| final int? startCharacter; |
| |
| /// The zero-based start line of the range to fold. The folded area starts |
| /// after the line's last character. To be valid, the end must be zero or |
| /// larger and smaller than the number of lines in the document. |
| final int startLine; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (collapsedText != null) { |
| result['collapsedText'] = collapsedText; |
| } |
| if (endCharacter != null) { |
| result['endCharacter'] = endCharacter; |
| } |
| result['endLine'] = endLine; |
| if (kind != null) { |
| result['kind'] = kind?.toJson(); |
| } |
| if (startCharacter != null) { |
| result['startCharacter'] = startCharacter; |
| } |
| result['startLine'] = startLine; |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseString(obj, reporter, 'collapsedText', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseInt(obj, reporter, 'endCharacter', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseInt(obj, reporter, 'endLine', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseFoldingRangeKind(obj, reporter, 'kind', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseInt(obj, reporter, 'startCharacter', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseInt(obj, reporter, 'startLine', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type FoldingRange'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is FoldingRange && |
| other.runtimeType == FoldingRange && |
| collapsedText == other.collapsedText && |
| endCharacter == other.endCharacter && |
| endLine == other.endLine && |
| kind == other.kind && |
| startCharacter == other.startCharacter && |
| startLine == other.startLine; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| collapsedText, |
| endCharacter, |
| endLine, |
| kind, |
| startCharacter, |
| startLine, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class FoldingRangeClientCapabilities implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| FoldingRangeClientCapabilities.canParse, |
| FoldingRangeClientCapabilities.fromJson, |
| ); |
| |
| FoldingRangeClientCapabilities({ |
| this.dynamicRegistration, |
| this.foldingRange, |
| this.foldingRangeKind, |
| this.lineFoldingOnly, |
| this.rangeLimit, |
| }); |
| static FoldingRangeClientCapabilities fromJson(Map<String, Object?> json) { |
| final dynamicRegistrationJson = json['dynamicRegistration']; |
| final dynamicRegistration = dynamicRegistrationJson as bool?; |
| final foldingRangeJson = json['foldingRange']; |
| final foldingRange = foldingRangeJson != null |
| ? FoldingRangeClientCapabilitiesFoldingRange.fromJson( |
| foldingRangeJson as Map<String, Object?>) |
| : null; |
| final foldingRangeKindJson = json['foldingRangeKind']; |
| final foldingRangeKind = foldingRangeKindJson != null |
| ? FoldingRangeClientCapabilitiesFoldingRangeKind.fromJson( |
| foldingRangeKindJson as Map<String, Object?>) |
| : null; |
| final lineFoldingOnlyJson = json['lineFoldingOnly']; |
| final lineFoldingOnly = lineFoldingOnlyJson as bool?; |
| final rangeLimitJson = json['rangeLimit']; |
| final rangeLimit = rangeLimitJson as int?; |
| return FoldingRangeClientCapabilities( |
| dynamicRegistration: dynamicRegistration, |
| foldingRange: foldingRange, |
| foldingRangeKind: foldingRangeKind, |
| lineFoldingOnly: lineFoldingOnly, |
| rangeLimit: rangeLimit, |
| ); |
| } |
| |
| /// Whether implementation supports dynamic registration for folding range |
| /// providers. If this is set to `true` the client supports the new |
| /// `FoldingRangeRegistrationOptions` return value for the corresponding |
| /// server capability as well. |
| final bool? dynamicRegistration; |
| |
| /// Specific options for the folding range. |
| /// |
| /// @since 3.17.0 |
| final FoldingRangeClientCapabilitiesFoldingRange? foldingRange; |
| |
| /// Specific options for the folding range kind. |
| /// |
| /// @since 3.17.0 |
| final FoldingRangeClientCapabilitiesFoldingRangeKind? foldingRangeKind; |
| |
| /// If set, the client signals that it only supports folding complete lines. |
| /// If set, client will ignore specified `startCharacter` and `endCharacter` |
| /// properties in a FoldingRange. |
| final bool? lineFoldingOnly; |
| |
| /// The maximum number of folding ranges that the client prefers to receive |
| /// per document. The value serves as a hint, servers are free to follow the |
| /// limit. |
| final int? rangeLimit; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (dynamicRegistration != null) { |
| result['dynamicRegistration'] = dynamicRegistration; |
| } |
| if (foldingRange != null) { |
| result['foldingRange'] = foldingRange?.toJson(); |
| } |
| if (foldingRangeKind != null) { |
| result['foldingRangeKind'] = foldingRangeKind?.toJson(); |
| } |
| if (lineFoldingOnly != null) { |
| result['lineFoldingOnly'] = lineFoldingOnly; |
| } |
| if (rangeLimit != null) { |
| result['rangeLimit'] = rangeLimit; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseBool(obj, reporter, 'dynamicRegistration', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseFoldingRangeClientCapabilitiesFoldingRange( |
| obj, reporter, 'foldingRange', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseFoldingRangeClientCapabilitiesFoldingRangeKind( |
| obj, reporter, 'foldingRangeKind', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'lineFoldingOnly', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseInt(obj, reporter, 'rangeLimit', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type FoldingRangeClientCapabilities'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is FoldingRangeClientCapabilities && |
| other.runtimeType == FoldingRangeClientCapabilities && |
| dynamicRegistration == other.dynamicRegistration && |
| foldingRange == other.foldingRange && |
| foldingRangeKind == other.foldingRangeKind && |
| lineFoldingOnly == other.lineFoldingOnly && |
| rangeLimit == other.rangeLimit; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| dynamicRegistration, |
| foldingRange, |
| foldingRangeKind, |
| lineFoldingOnly, |
| rangeLimit, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class FoldingRangeClientCapabilitiesFoldingRange implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| FoldingRangeClientCapabilitiesFoldingRange.canParse, |
| FoldingRangeClientCapabilitiesFoldingRange.fromJson, |
| ); |
| |
| FoldingRangeClientCapabilitiesFoldingRange({ |
| this.collapsedText, |
| }); |
| static FoldingRangeClientCapabilitiesFoldingRange fromJson( |
| Map<String, Object?> json) { |
| final collapsedTextJson = json['collapsedText']; |
| final collapsedText = collapsedTextJson as bool?; |
| return FoldingRangeClientCapabilitiesFoldingRange( |
| collapsedText: collapsedText, |
| ); |
| } |
| |
| /// If set, the client signals that it supports setting collapsedText on |
| /// folding ranges to display custom labels instead of the default text. |
| /// |
| /// @since 3.17.0 |
| final bool? collapsedText; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (collapsedText != null) { |
| result['collapsedText'] = collapsedText; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseBool(obj, reporter, 'collapsedText', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError( |
| 'must be of type FoldingRangeClientCapabilitiesFoldingRange'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is FoldingRangeClientCapabilitiesFoldingRange && |
| other.runtimeType == FoldingRangeClientCapabilitiesFoldingRange && |
| collapsedText == other.collapsedText; |
| } |
| |
| @override |
| int get hashCode => collapsedText.hashCode; |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class FoldingRangeClientCapabilitiesFoldingRangeKind implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| FoldingRangeClientCapabilitiesFoldingRangeKind.canParse, |
| FoldingRangeClientCapabilitiesFoldingRangeKind.fromJson, |
| ); |
| |
| FoldingRangeClientCapabilitiesFoldingRangeKind({ |
| this.valueSet, |
| }); |
| static FoldingRangeClientCapabilitiesFoldingRangeKind fromJson( |
| Map<String, Object?> json) { |
| final valueSetJson = json['valueSet']; |
| final valueSet = (valueSetJson as List<Object?>?) |
| ?.map((item) => FoldingRangeKind.fromJson(item as String)) |
| .toList(); |
| return FoldingRangeClientCapabilitiesFoldingRangeKind( |
| valueSet: valueSet, |
| ); |
| } |
| |
| /// The folding range 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<FoldingRangeKind>? valueSet; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (valueSet != null) { |
| result['valueSet'] = valueSet?.map((item) => item.toJson()).toList(); |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseListFoldingRangeKind(obj, reporter, 'valueSet', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError( |
| 'must be of type FoldingRangeClientCapabilitiesFoldingRangeKind'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is FoldingRangeClientCapabilitiesFoldingRangeKind && |
| other.runtimeType == FoldingRangeClientCapabilitiesFoldingRangeKind && |
| listEqual(valueSet, other.valueSet, |
| (FoldingRangeKind a, FoldingRangeKind b) => a == b); |
| } |
| |
| @override |
| int get hashCode => lspHashCode(valueSet); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// A set of predefined range kinds. |
| class FoldingRangeKind implements ToJsonable { |
| const FoldingRangeKind(this._value); |
| const FoldingRangeKind.fromJson(this._value); |
| |
| final String _value; |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) => obj is String; |
| |
| /// Folding range for a comment |
| static const Comment = FoldingRangeKind('comment'); |
| |
| /// Folding range for an import or include |
| static const Imports = FoldingRangeKind('imports'); |
| |
| /// Folding range for a region (e.g. `#region`) |
| static const Region = FoldingRangeKind('region'); |
| |
| @override |
| Object toJson() => _value; |
| |
| @override |
| String toString() => _value.toString(); |
| |
| @override |
| int get hashCode => _value.hashCode; |
| |
| @override |
| bool operator ==(Object other) => |
| other is FoldingRangeKind && other._value == _value; |
| } |
| |
| class FoldingRangeOptions implements WorkDoneProgressOptions, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| FoldingRangeOptions.canParse, |
| FoldingRangeOptions.fromJson, |
| ); |
| |
| FoldingRangeOptions({ |
| this.workDoneProgress, |
| }); |
| static FoldingRangeOptions fromJson(Map<String, Object?> json) { |
| if (FoldingRangeRegistrationOptions.canParse(json, nullLspJsonReporter)) { |
| return FoldingRangeRegistrationOptions.fromJson(json); |
| } |
| final workDoneProgressJson = json['workDoneProgress']; |
| final workDoneProgress = workDoneProgressJson as bool?; |
| return FoldingRangeOptions( |
| workDoneProgress: workDoneProgress, |
| ); |
| } |
| |
| @override |
| final bool? workDoneProgress; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (workDoneProgress != null) { |
| result['workDoneProgress'] = workDoneProgress; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseBool(obj, reporter, 'workDoneProgress', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type FoldingRangeOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is FoldingRangeOptions && |
| other.runtimeType == FoldingRangeOptions && |
| workDoneProgress == other.workDoneProgress; |
| } |
| |
| @override |
| int get hashCode => workDoneProgress.hashCode; |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Parameters for a FoldingRangeRequest. |
| class FoldingRangeParams |
| implements PartialResultParams, WorkDoneProgressParams, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| FoldingRangeParams.canParse, |
| FoldingRangeParams.fromJson, |
| ); |
| |
| FoldingRangeParams({ |
| this.partialResultToken, |
| required this.textDocument, |
| this.workDoneToken, |
| }); |
| static FoldingRangeParams fromJson(Map<String, Object?> json) { |
| final partialResultTokenJson = json['partialResultToken']; |
| final partialResultToken = partialResultTokenJson == null |
| ? null |
| : _eitherIntString(partialResultTokenJson); |
| final textDocumentJson = json['textDocument']; |
| final textDocument = TextDocumentIdentifier.fromJson( |
| textDocumentJson as Map<String, Object?>); |
| final workDoneTokenJson = json['workDoneToken']; |
| final workDoneToken = |
| workDoneTokenJson == null ? null : _eitherIntString(workDoneTokenJson); |
| return FoldingRangeParams( |
| partialResultToken: partialResultToken, |
| textDocument: textDocument, |
| workDoneToken: workDoneToken, |
| ); |
| } |
| |
| /// An optional token that a server can use to report partial results (e.g. |
| /// streaming) to the client. |
| @override |
| final ProgressToken? partialResultToken; |
| |
| /// The text document. |
| final TextDocumentIdentifier textDocument; |
| |
| /// An optional token that a server can use to report work done progress. |
| @override |
| final ProgressToken? workDoneToken; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (partialResultToken != null) { |
| result['partialResultToken'] = partialResultToken; |
| } |
| result['textDocument'] = textDocument.toJson(); |
| if (workDoneToken != null) { |
| result['workDoneToken'] = workDoneToken; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseIntString(obj, reporter, 'partialResultToken', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseTextDocumentIdentifier(obj, reporter, 'textDocument', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseIntString(obj, reporter, 'workDoneToken', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type FoldingRangeParams'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is FoldingRangeParams && |
| other.runtimeType == FoldingRangeParams && |
| partialResultToken == other.partialResultToken && |
| textDocument == other.textDocument && |
| workDoneToken == other.workDoneToken; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| partialResultToken, |
| textDocument, |
| workDoneToken, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class FoldingRangeRegistrationOptions |
| implements |
| FoldingRangeOptions, |
| StaticRegistrationOptions, |
| TextDocumentRegistrationOptions, |
| ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| FoldingRangeRegistrationOptions.canParse, |
| FoldingRangeRegistrationOptions.fromJson, |
| ); |
| |
| FoldingRangeRegistrationOptions({ |
| this.documentSelector, |
| this.id, |
| this.workDoneProgress, |
| }); |
| static FoldingRangeRegistrationOptions fromJson(Map<String, Object?> json) { |
| final documentSelectorJson = json['documentSelector']; |
| final documentSelector = (documentSelectorJson as List<Object?>?) |
| ?.map((item) => |
| TextDocumentFilterWithScheme.fromJson(item as Map<String, Object?>)) |
| .toList(); |
| final idJson = json['id']; |
| final id = idJson as String?; |
| final workDoneProgressJson = json['workDoneProgress']; |
| final workDoneProgress = workDoneProgressJson as bool?; |
| return FoldingRangeRegistrationOptions( |
| documentSelector: documentSelector, |
| id: id, |
| workDoneProgress: workDoneProgress, |
| ); |
| } |
| |
| /// A document selector to identify the scope of the registration. If set to |
| /// null the document selector provided on the client side will be used. |
| @override |
| final List<TextDocumentFilterWithScheme>? documentSelector; |
| |
| /// The id used to register the request. The id can be used to deregister the |
| /// request again. See also Registration#id. |
| @override |
| final String? id; |
| @override |
| final bool? workDoneProgress; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['documentSelector'] = documentSelector; |
| if (id != null) { |
| result['id'] = id; |
| } |
| if (workDoneProgress != null) { |
| result['workDoneProgress'] = workDoneProgress; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseListTextDocumentFilterWithScheme( |
| obj, reporter, 'documentSelector', |
| allowsUndefined: false, allowsNull: true)) { |
| return false; |
| } |
| if (!_canParseString(obj, reporter, 'id', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseBool(obj, reporter, 'workDoneProgress', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type FoldingRangeRegistrationOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is FoldingRangeRegistrationOptions && |
| other.runtimeType == FoldingRangeRegistrationOptions && |
| listEqual( |
| documentSelector, |
| other.documentSelector, |
| (TextDocumentFilterWithScheme a, TextDocumentFilterWithScheme b) => |
| a == b) && |
| id == other.id && |
| workDoneProgress == other.workDoneProgress; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| lspHashCode(documentSelector), |
| id, |
| workDoneProgress, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Value-object describing what options formatting should use. |
| class FormattingOptions implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| FormattingOptions.canParse, |
| FormattingOptions.fromJson, |
| ); |
| |
| FormattingOptions({ |
| this.insertFinalNewline, |
| required this.insertSpaces, |
| required this.tabSize, |
| this.trimFinalNewlines, |
| this.trimTrailingWhitespace, |
| }); |
| static FormattingOptions fromJson(Map<String, Object?> json) { |
| final insertFinalNewlineJson = json['insertFinalNewline']; |
| final insertFinalNewline = insertFinalNewlineJson as bool?; |
| final insertSpacesJson = json['insertSpaces']; |
| final insertSpaces = insertSpacesJson as bool; |
| final tabSizeJson = json['tabSize']; |
| final tabSize = tabSizeJson as int; |
| final trimFinalNewlinesJson = json['trimFinalNewlines']; |
| final trimFinalNewlines = trimFinalNewlinesJson as bool?; |
| final trimTrailingWhitespaceJson = json['trimTrailingWhitespace']; |
| final trimTrailingWhitespace = trimTrailingWhitespaceJson as bool?; |
| return FormattingOptions( |
| insertFinalNewline: insertFinalNewline, |
| insertSpaces: insertSpaces, |
| tabSize: tabSize, |
| trimFinalNewlines: trimFinalNewlines, |
| trimTrailingWhitespace: trimTrailingWhitespace, |
| ); |
| } |
| |
| /// Insert a newline character at the end of the file if one does not exist. |
| /// |
| /// @since 3.15.0 |
| final bool? insertFinalNewline; |
| |
| /// Prefer spaces over tabs. |
| final bool insertSpaces; |
| |
| /// Size of a tab in spaces. |
| final int tabSize; |
| |
| /// Trim all newlines after the final newline at the end of the file. |
| /// |
| /// @since 3.15.0 |
| final bool? trimFinalNewlines; |
| |
| /// Trim trailing whitespace on a line. |
| /// |
| /// @since 3.15.0 |
| final bool? trimTrailingWhitespace; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (insertFinalNewline != null) { |
| result['insertFinalNewline'] = insertFinalNewline; |
| } |
| result['insertSpaces'] = insertSpaces; |
| result['tabSize'] = tabSize; |
| if (trimFinalNewlines != null) { |
| result['trimFinalNewlines'] = trimFinalNewlines; |
| } |
| if (trimTrailingWhitespace != null) { |
| result['trimTrailingWhitespace'] = trimTrailingWhitespace; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseBool(obj, reporter, 'insertFinalNewline', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'insertSpaces', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseInt(obj, reporter, 'tabSize', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseBool(obj, reporter, 'trimFinalNewlines', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseBool(obj, reporter, 'trimTrailingWhitespace', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type FormattingOptions'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is FormattingOptions && |
| other.runtimeType == FormattingOptions && |
| insertFinalNewline == other.insertFinalNewline && |
| insertSpaces == other.insertSpaces && |
| tabSize == other.tabSize && |
| trimFinalNewlines == other.trimFinalNewlines && |
| trimTrailingWhitespace == other.trimTrailingWhitespace; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| insertFinalNewline, |
| insertSpaces, |
| tabSize, |
| trimFinalNewlines, |
| trimTrailingWhitespace, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// A diagnostic report with a full set of problems. |
| /// |
| /// @since 3.17.0 |
| class FullDocumentDiagnosticReport implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| FullDocumentDiagnosticReport.canParse, |
| FullDocumentDiagnosticReport.fromJson, |
| ); |
| |
| FullDocumentDiagnosticReport({ |
| required this.items, |
| this.kind = 'full', |
| this.resultId, |
| }) { |
| if (kind != 'full') { |
| throw 'kind may only be the literal \'full\''; |
| } |
| } |
| static FullDocumentDiagnosticReport fromJson(Map<String, Object?> json) { |
| if (WorkspaceFullDocumentDiagnosticReport.canParse( |
| json, nullLspJsonReporter)) { |
| return WorkspaceFullDocumentDiagnosticReport.fromJson(json); |
| } |
| if (RelatedFullDocumentDiagnosticReport.canParse( |
| json, nullLspJsonReporter)) { |
| return RelatedFullDocumentDiagnosticReport.fromJson(json); |
| } |
| final itemsJson = json['items']; |
| final items = (itemsJson as List<Object?>) |
| .map((item) => Diagnostic.fromJson(item as Map<String, Object?>)) |
| .toList(); |
| final kindJson = json['kind']; |
| final kind = kindJson as String; |
| final resultIdJson = json['resultId']; |
| final resultId = resultIdJson as String?; |
| return FullDocumentDiagnosticReport( |
| items: items, |
| kind: kind, |
| resultId: resultId, |
| ); |
| } |
| |
| /// The actual items. |
| final List<Diagnostic> items; |
| |
| /// A full document diagnostic report. |
| final String kind; |
| |
| /// An optional result id. If provided it will be sent on the next diagnostic |
| /// request for the same document. |
| final String? resultId; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['items'] = items.map((item) => item.toJson()).toList(); |
| result['kind'] = kind; |
| if (resultId != null) { |
| result['resultId'] = resultId; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseListDiagnostic(obj, reporter, 'items', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseLiteral(obj, reporter, 'kind', |
| allowsUndefined: false, allowsNull: false, literal: 'full')) { |
| return false; |
| } |
| return _canParseString(obj, reporter, 'resultId', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type FullDocumentDiagnosticReport'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is FullDocumentDiagnosticReport && |
| other.runtimeType == FullDocumentDiagnosticReport && |
| listEqual(items, other.items, (Diagnostic a, Diagnostic b) => a == b) && |
| kind == other.kind && |
| resultId == other.resultId; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| lspHashCode(items), |
| kind, |
| resultId, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// General client capabilities. |
| /// |
| /// @since 3.16.0 |
| class GeneralClientCapabilities implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| GeneralClientCapabilities.canParse, |
| GeneralClientCapabilities.fromJson, |
| ); |
| |
| GeneralClientCapabilities({ |
| this.markdown, |
| this.positionEncodings, |
| this.regularExpressions, |
| this.staleRequestSupport, |
| }); |
| static GeneralClientCapabilities fromJson(Map<String, Object?> json) { |
| final markdownJson = json['markdown']; |
| final markdown = markdownJson != null |
| ? MarkdownClientCapabilities.fromJson( |
| markdownJson as Map<String, Object?>) |
| : null; |
| final positionEncodingsJson = json['positionEncodings']; |
| final positionEncodings = (positionEncodingsJson as List<Object?>?) |
| ?.map((item) => PositionEncodingKind.fromJson(item as String)) |
| .toList(); |
| final regularExpressionsJson = json['regularExpressions']; |
| final regularExpressions = regularExpressionsJson != null |
| ? RegularExpressionsClientCapabilities.fromJson( |
| regularExpressionsJson as Map<String, Object?>) |
| : null; |
| final staleRequestSupportJson = json['staleRequestSupport']; |
| final staleRequestSupport = staleRequestSupportJson != null |
| ? GeneralClientCapabilitiesStaleRequestSupport.fromJson( |
| staleRequestSupportJson as Map<String, Object?>) |
| : null; |
| return GeneralClientCapabilities( |
| markdown: markdown, |
| positionEncodings: positionEncodings, |
| regularExpressions: regularExpressions, |
| staleRequestSupport: staleRequestSupport, |
| ); |
| } |
| |
| /// Client capabilities specific to the client's markdown parser. |
| /// |
| /// @since 3.16.0 |
| final MarkdownClientCapabilities? markdown; |
| |
| /// The position encodings supported by the client. Client and server have to |
| /// agree on the same position encoding to ensure that offsets (e.g. character |
| /// position in a line) are interpreted the same on both sides. |
| /// |
| /// To keep the protocol backwards compatible the following applies: if the |
| /// value 'utf-16' is missing from the array of position encodings servers can |
| /// assume that the client supports UTF-16. UTF-16 is therefore a mandatory |
| /// encoding. |
| /// |
| /// If omitted it defaults to ['utf-16']. |
| /// |
| /// Implementation considerations: since the conversion from one encoding into |
| /// another requires the content of the file / line the conversion is best |
| /// done where the file is read which is usually on the server side. |
| /// |
| /// @since 3.17.0 |
| final List<PositionEncodingKind>? positionEncodings; |
| |
| /// Client capabilities specific to regular expressions. |
| /// |
| /// @since 3.16.0 |
| final RegularExpressionsClientCapabilities? regularExpressions; |
| |
| /// Client capability that signals how the client handles stale requests (e.g. |
| /// a request for which the client will not process the response anymore since |
| /// the information is outdated). |
| /// |
| /// @since 3.17.0 |
| final GeneralClientCapabilitiesStaleRequestSupport? staleRequestSupport; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (markdown != null) { |
| result['markdown'] = markdown?.toJson(); |
| } |
| if (positionEncodings != null) { |
| result['positionEncodings'] = |
| positionEncodings?.map((item) => item.toJson()).toList(); |
| } |
| if (regularExpressions != null) { |
| result['regularExpressions'] = regularExpressions?.toJson(); |
| } |
| if (staleRequestSupport != null) { |
| result['staleRequestSupport'] = staleRequestSupport?.toJson(); |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseMarkdownClientCapabilities(obj, reporter, 'markdown', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseListPositionEncodingKind(obj, reporter, 'positionEncodings', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| if (!_canParseRegularExpressionsClientCapabilities( |
| obj, reporter, 'regularExpressions', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseGeneralClientCapabilitiesStaleRequestSupport( |
| obj, reporter, 'staleRequestSupport', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type GeneralClientCapabilities'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is GeneralClientCapabilities && |
| other.runtimeType == GeneralClientCapabilities && |
| markdown == other.markdown && |
| listEqual(positionEncodings, other.positionEncodings, |
| (PositionEncodingKind a, PositionEncodingKind b) => a == b) && |
| regularExpressions == other.regularExpressions && |
| staleRequestSupport == other.staleRequestSupport; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| markdown, |
| lspHashCode(positionEncodings), |
| regularExpressions, |
| staleRequestSupport, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class GeneralClientCapabilitiesStaleRequestSupport implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| GeneralClientCapabilitiesStaleRequestSupport.canParse, |
| GeneralClientCapabilitiesStaleRequestSupport.fromJson, |
| ); |
| |
| GeneralClientCapabilitiesStaleRequestSupport({ |
| required this.cancel, |
| required this.retryOnContentModified, |
| }); |
| static GeneralClientCapabilitiesStaleRequestSupport fromJson( |
| Map<String, Object?> json) { |
| final cancelJson = json['cancel']; |
| final cancel = cancelJson as bool; |
| final retryOnContentModifiedJson = json['retryOnContentModified']; |
| final retryOnContentModified = (retryOnContentModifiedJson as List<Object?>) |
| .map((item) => item as String) |
| .toList(); |
| return GeneralClientCapabilitiesStaleRequestSupport( |
| cancel: cancel, |
| retryOnContentModified: retryOnContentModified, |
| ); |
| } |
| |
| /// The client will actively cancel the request. |
| final bool cancel; |
| |
| /// The list of requests for which the client will retry the request if it |
| /// receives a response with error code `ContentModified` |
| final List<String> retryOnContentModified; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['cancel'] = cancel; |
| result['retryOnContentModified'] = retryOnContentModified; |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseBool(obj, reporter, 'cancel', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseListString(obj, reporter, 'retryOnContentModified', |
| allowsUndefined: false, allowsNull: false); |
| } else { |
| reporter.reportError( |
| 'must be of type GeneralClientCapabilitiesStaleRequestSupport'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is GeneralClientCapabilitiesStaleRequestSupport && |
| other.runtimeType == GeneralClientCapabilitiesStaleRequestSupport && |
| cancel == other.cancel && |
| listEqual(retryOnContentModified, other.retryOnContentModified, |
| (String a, String b) => a == b); |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| cancel, |
| lspHashCode(retryOnContentModified), |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// The result of a hover request. |
| class Hover implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| Hover.canParse, |
| Hover.fromJson, |
| ); |
| |
| Hover({ |
| required this.contents, |
| this.range, |
| }); |
| static Hover fromJson(Map<String, Object?> json) { |
| final contentsJson = json['contents']; |
| final contents = _eitherMarkupContentString(contentsJson); |
| final rangeJson = json['range']; |
| final range = rangeJson != null |
| ? Range.fromJson(rangeJson as Map<String, Object?>) |
| : null; |
| return Hover( |
| contents: contents, |
| range: range, |
| ); |
| } |
| |
| /// The hover's content |
| final Either2<MarkupContent, String> contents; |
| |
| /// An optional range inside the text document that is used to visualize the |
| /// hover, e.g. by changing the background color. |
| final Range? range; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| result['contents'] = contents; |
| if (range != null) { |
| result['range'] = range?.toJson(); |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseMarkupContentString(obj, reporter, 'contents', |
| allowsUndefined: false, allowsNull: false)) { |
| return false; |
| } |
| return _canParseRange(obj, reporter, 'range', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type Hover'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is Hover && |
| other.runtimeType == Hover && |
| contents == other.contents && |
| range == other.range; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| contents, |
| range, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| class HoverClientCapabilities implements ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| HoverClientCapabilities.canParse, |
| HoverClientCapabilities.fromJson, |
| ); |
| |
| HoverClientCapabilities({ |
| this.contentFormat, |
| this.dynamicRegistration, |
| }); |
| static HoverClientCapabilities fromJson(Map<String, Object?> json) { |
| final contentFormatJson = json['contentFormat']; |
| final contentFormat = (contentFormatJson as List<Object?>?) |
| ?.map((item) => MarkupKind.fromJson(item as String)) |
| .toList(); |
| final dynamicRegistrationJson = json['dynamicRegistration']; |
| final dynamicRegistration = dynamicRegistrationJson as bool?; |
| return HoverClientCapabilities( |
| contentFormat: contentFormat, |
| dynamicRegistration: dynamicRegistration, |
| ); |
| } |
| |
| /// Client supports the following content formats for the content property. |
| /// The order describes the preferred format of the client. |
| final List<MarkupKind>? contentFormat; |
| |
| /// Whether hover supports dynamic registration. |
| final bool? dynamicRegistration; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (contentFormat != null) { |
| result['contentFormat'] = |
| contentFormat?.map((item) => item.toJson()).toList(); |
| } |
| if (dynamicRegistration != null) { |
| result['dynamicRegistration'] = dynamicRegistration; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| if (!_canParseListMarkupKind(obj, reporter, 'contentFormat', |
| allowsUndefined: true, allowsNull: false)) { |
| return false; |
| } |
| return _canParseBool(obj, reporter, 'dynamicRegistration', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.reportError('must be of type HoverClientCapabilities'); |
| return false; |
| } |
| } |
| |
| @override |
| bool operator ==(Object other) { |
| return other is HoverClientCapabilities && |
| other.runtimeType == HoverClientCapabilities && |
| listEqual(contentFormat, other.contentFormat, |
| (MarkupKind a, MarkupKind b) => a == b) && |
| dynamicRegistration == other.dynamicRegistration; |
| } |
| |
| @override |
| int get hashCode => Object.hash( |
| lspHashCode(contentFormat), |
| dynamicRegistration, |
| ); |
| |
| @override |
| String toString() => jsonEncoder.convert(toJson()); |
| } |
| |
| /// Hover options. |
| class HoverOptions implements WorkDoneProgressOptions, ToJsonable { |
| static const jsonHandler = LspJsonHandler( |
| HoverOptions.canParse, |
| HoverOptions.fromJson, |
| ); |
| |
| HoverOptions({ |
| this.workDoneProgress, |
| }); |
| static HoverOptions fromJson(Map<String, Object?> json) { |
| if (HoverRegistrationOptions.canParse(json, nullLspJsonReporter)) { |
| return HoverRegistrationOptions.fromJson(json); |
| } |
| final workDoneProgressJson = json['workDoneProgress']; |
| final workDoneProgress = workDoneProgressJson as bool?; |
| return HoverOptions( |
| workDoneProgress: workDoneProgress, |
| ); |
| } |
| |
| @override |
| final bool? workDoneProgress; |
| |
| @override |
| Map<String, Object?> toJson() { |
| var result = <String, Object?>{}; |
| if (workDoneProgress != null) { |
| result['workDoneProgress'] = workDoneProgress; |
| } |
| return result; |
| } |
| |
| static bool canParse(Object? obj, LspJsonReporter reporter) { |
| if (obj is Map<String, Object?>) { |
| return _canParseBool(obj, reporter, 'workDoneProgress', |
| allowsUndefined: true, allowsNull: false); |
| } else { |
| reporter.
|