gen-lsp-types-0.8.0/.cargo/config.toml000064400000000000000000000000421046102023000156470ustar 00000000000000[alias] xtask = "run -p xtask --" gen-lsp-types-0.8.0/.cargo_vcs_info.json0000644000000001361046102023000135720ustar { "git": { "sha1": "6d3a438628389bc9ee352376fc72d751426c591d" }, "path_in_vcs": "" }gen-lsp-types-0.8.0/.gitignore000064400000000000000000000000101046102023000143170ustar 00000000000000/target gen-lsp-types-0.8.0/Cargo.lock0000644000000244171046102023000115550ustar # This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 4 [[package]] name = "borrow-or-share" version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc0b364ead1874514c8c2855ab558056ebfeb775653e7ae45ff72f28f8f3166c" [[package]] name = "displaydoc" version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "fluent-uri" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc74ac4d8359ae70623506d512209619e5cf8f347124910440dbc221714b328e" dependencies = [ "borrow-or-share", "ref-cast", "serde", ] [[package]] name = "form_urlencoded" version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" dependencies = [ "percent-encoding", ] [[package]] name = "gen-lsp-types" version = "0.8.0" dependencies = [ "fluent-uri", "serde", "serde_json", "url", ] [[package]] name = "icu_collections" version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2984d1cd16c883d7935b9e07e44071dca8d917fd52ecc02c04d5fa0b5a3f191c" dependencies = [ "displaydoc", "potential_utf", "utf8_iter", "yoke", "zerofrom", "zerovec", ] [[package]] name = "icu_locale_core" version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92219b62b3e2b4d88ac5119f8904c10f8f61bf7e95b640d25ba3075e6cac2c29" dependencies = [ "displaydoc", "litemap", "tinystr", "writeable", "zerovec", ] [[package]] name = "icu_normalizer" version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c56e5ee99d6e3d33bd91c5d85458b6005a22140021cc324cea84dd0e72cff3b4" dependencies = [ "icu_collections", "icu_normalizer_data", "icu_properties", "icu_provider", "smallvec", "zerovec", ] [[package]] name = "icu_normalizer_data" version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da3be0ae77ea334f4da67c12f149704f19f81d1adf7c51cf482943e84a2bad38" [[package]] name = "icu_properties" version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bee3b67d0ea5c2cca5003417989af8996f8604e34fb9ddf96208a033901e70de" dependencies = [ "icu_collections", "icu_locale_core", "icu_properties_data", "icu_provider", "zerotrie", "zerovec", ] [[package]] name = "icu_properties_data" version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e2bbb201e0c04f7b4b3e14382af113e17ba4f63e2c9d2ee626b720cbce54a14" [[package]] name = "icu_provider" version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "139c4cf31c8b5f33d7e199446eff9c1e02decfc2f0eec2c8d71f65befa45b421" dependencies = [ "displaydoc", "icu_locale_core", "writeable", "yoke", "zerofrom", "zerotrie", "zerovec", ] [[package]] name = "idna" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" dependencies = [ "idna_adapter", "smallvec", "utf8_iter", ] [[package]] name = "idna_adapter" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" dependencies = [ "icu_normalizer", "icu_properties", ] [[package]] name = "itoa" version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" [[package]] name = "litemap" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92daf443525c4cce67b150400bc2316076100ce0b3686209eb8cf3c31612e6f0" [[package]] name = "memchr" version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" [[package]] name = "percent-encoding" version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" [[package]] name = "potential_utf" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0103b1cef7ec0cf76490e969665504990193874ea05c85ff9bab8b911d0a0564" dependencies = [ "zerovec", ] [[package]] name = "proc-macro2" version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" dependencies = [ "unicode-ident", ] [[package]] name = "quote" version = "1.0.45" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" dependencies = [ "proc-macro2", ] [[package]] name = "ref-cast" version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f354300ae66f76f1c85c5f84693f0ce81d747e2c3f21a45fef496d89c960bf7d" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "serde" version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" dependencies = [ "serde_core", "serde_derive", ] [[package]] name = "serde_core" version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "serde_json" version = "1.0.150" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8014e44b4736ed0538adeecded0fce2a272f22dc9578a7eb6b2d9993c74cfb9" dependencies = [ "itoa", "memchr", "serde", "serde_core", "zmij", ] [[package]] name = "smallvec" version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" [[package]] name = "stable_deref_trait" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" [[package]] name = "syn" version = "2.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] [[package]] name = "synstructure" version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "tinystr" version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8323304221c2a851516f22236c5722a72eaa19749016521d6dff0824447d96d" dependencies = [ "displaydoc", "zerovec", ] [[package]] name = "unicode-ident" version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" [[package]] name = "url" version = "2.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" dependencies = [ "form_urlencoded", "idna", "percent-encoding", "serde", "serde_derive", ] [[package]] name = "utf8_iter" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" [[package]] name = "writeable" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ffae5123b2d3fc086436f8834ae3ab053a283cfac8fe0a0b8eaae044768a4c4" [[package]] name = "yoke" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "abe8c5fda708d9ca3df187cae8bfb9ceda00dd96231bed36e445a1a48e66f9ca" dependencies = [ "stable_deref_trait", "yoke-derive", "zerofrom", ] [[package]] name = "yoke-derive" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de844c262c8848816172cef550288e7dc6c7b7814b4ee56b3e1553f275f1858e" dependencies = [ "proc-macro2", "quote", "syn", "synstructure", ] [[package]] name = "zerofrom" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69faa1f2a1ea75661980b013019ed6687ed0e83d069bc1114e2cc74c6c04c4df" dependencies = [ "zerofrom-derive", ] [[package]] name = "zerofrom-derive" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11532158c46691caf0f2593ea8358fed6bbf68a0315e80aae9bd41fbade684a1" dependencies = [ "proc-macro2", "quote", "syn", "synstructure", ] [[package]] name = "zerotrie" version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f9152d31db0792fa83f70fb2f83148effb5c1f5b8c7686c3459e361d9bc20bf" dependencies = [ "displaydoc", "yoke", "zerofrom", ] [[package]] name = "zerovec" version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90f911cbc359ab6af17377d242225f4d75119aec87ea711a880987b18cd7b239" dependencies = [ "yoke", "zerofrom", "zerovec-derive", ] [[package]] name = "zerovec-derive" version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "625dc425cab0dca6dc3c3319506e6593dcb08a9f387ea3b284dbd52a92c40555" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "zmij" version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" gen-lsp-types-0.8.0/Cargo.toml0000644000000034311046102023000115710ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2024" name = "gen-lsp-types" version = "0.8.0" authors = ["Riley Bruins "] build = false exclude = ["/.github/"] autolib = false autobins = false autoexamples = false autotests = false autobenches = false description = "Library of Rust LSP types generated from the official metamodel" readme = "README.md" keywords = [ "lsp", "codegen", ] categories = ["development-tools"] license = "MIT" repository = "https://github.com/ribru17/gen-lsp-types" [features] fluent-uri = ["dep:fluent-uri"] url = ["dep:url"] [lib] name = "gen_lsp_types" path = "src/lib.rs" [dependencies.fluent-uri] version = "0.4.1" features = ["serde"] optional = true [dependencies.serde] version = "1.0.228" features = ["derive"] [dependencies.serde_json] version = "1.0.150" [dependencies.url] version = "2.5.8" features = ["serde"] optional = true [lints.clippy] cargo_common_metadata = "allow" cast-possible-truncation = "allow" cast_lossless = "allow" cast_precision_loss = "allow" cast_sign_loss = "allow" cognitive_complexity = "allow" dbg_macro = "deny" items_after_statements = "allow" multiple_crate_versions = "allow" todo = "deny" too_many_lines = "allow" [lints.clippy.cargo] level = "deny" priority = -1 [lints.clippy.nursery] level = "warn" priority = -1 [lints.clippy.pedantic] level = "warn" priority = -1 gen-lsp-types-0.8.0/Cargo.toml.orig000064400000000000000000000024421046102023000152310ustar 00000000000000[package] name = "gen-lsp-types" version = "0.8.0" edition = "2024" authors = ["Riley Bruins "] description = "Library of Rust LSP types generated from the official metamodel" license = "MIT" repository = "https://github.com/ribru17/gen-lsp-types" keywords = ["lsp", "codegen"] readme = "README.md" categories = ["development-tools"] exclude = ["/.github/"] [lib] path = "src/lib.rs" [dependencies] fluent-uri = { version = "0.4.1", features = ["serde"], optional = true } serde = { workspace = true } serde_json = { workspace = true } url = { version = "2.5.8", features = ["serde"], optional = true } [lints] workspace = true [workspace.lints.clippy] dbg_macro = "deny" todo = "deny" pedantic = { level = "warn", priority = -1 } nursery = { level = "warn", priority = -1 } cargo = { level = "deny", priority = -1 } cargo_common_metadata = "allow" cast_precision_loss = "allow" cast-possible-truncation = "allow" cast_lossless = "allow" cast_sign_loss = "allow" cognitive_complexity = "allow" items_after_statements = "allow" multiple_crate_versions = "allow" too_many_lines = "allow" [features] url = ["dep:url"] fluent-uri = ["dep:fluent-uri"] [workspace] members = [".", "xtask"] [workspace.dependencies] serde = { version = "1.0.228", features = ["derive"] } serde_json = "1.0.150" gen-lsp-types-0.8.0/LICENSE000064400000000000000000000020551046102023000133470ustar 00000000000000MIT License Copyright (c) 2026 Riley Bruins Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. gen-lsp-types-0.8.0/README.md000064400000000000000000000151271046102023000136250ustar 00000000000000# gen-lsp-types Programmatically generated Rust type definitions for the [Language Server Protocol](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification/). ## Features ### 100% Accurate to the protocol* **All** types are generated by the LSP Metamodel, and will be up-to-date on the latest LSP changes. \* If you notice that this is not the case, please [file an issue](https://github.com/ribru17/gen-lsp-types/issues/new)! ### Comprehensive `derive` usage Every type implements `serde`'s `Serialize` and `Deserialize` traits adhering to the protocol, as well as `Debug`, `Clone`, and `PartialEq`. Additionally, the generator will derive all of the following traits on every `enum`/`struct` that supports them: - `Copy` - `Default` - `Eq` - `Hash` Special types `Position` and `Range` also derive `Ord` and `PartialOrd`, and string enumerations derive `From` and `Display`. All structures generate `::new()` constructors for convenience. For the same reason, string enumerations supporting custom values will also provide `::new()` constructors, taking a `&'static str`. All "or" types in the spec (e.g. `bar: string | integer | null`) are represented as untagged `enum`s, with intuitive naming based on the context that the "or" type is defined in. Every "or" type `enum` implements `From` so it can be seamlessly converted from its member types. E.g., for the above example, you can do: ```rust // This... let bar: Bar = 123.into(); // ...or this... let bar: Bar = String::from("baz").into(); // ...or this. let bar: Bar = ().into(); ``` ### Distinguishes between `null` and "not present" properties Unlike the original [`lsp-types`](https://github.com/gluon-lang/lsp-types) crate, this one is able to encode properties as `null` **or** `undefined` (not present). This is important because the spec **does differentiate the two from each other**. For example, for the following property which can be `null` **or** `undefined`: ```ts interface InitializeParams extends WorkDoneProgressParams { // ... /** * The workspace folders configured in the client when the server starts. * This property is only available if the client supports workspace folders. * It can be `null` if the client supports workspace folders but none are * configured. * * @since 3.6.0 */ workspaceFolders?: WorkspaceFolder[] | null; } ``` The generated Rust struct will be: ```rust pub struct InitializeParams { // ... /// The workspace folders configured in the client when the server starts. /// /// This property is only available if the client supports workspace folders. /// It can be `null` if the client supports workspace folders but none are /// configured. /// /// @since 3.6.0 #[serde(default, deserialize_with = "deserialize_some")] #[serde(skip_serializing_if = "Option::is_none")] pub workspace_folders: Option, } ``` ...where `WorkspaceFolders` is an `enum`: ```rust #[serde(untagged)] pub enum WorkspaceFolders { WorkspaceFolderList(Vec), Null, } ``` So `undefined` is represented as `workspace_folders = None`, and `null` is represented as `workspace_folders = Some(WorkspaceFolders::Null)`. > [!NOTE] > If a property can only be one of `undefined` or `null`, not both, `None` will > be used in both cases to denote those values, for convenience. ### Support for string literal properties Structures with string literal properties will have those properties omitted from their generated Rust types. E.g., for the following `DeleteFile` definition: ```ts /** * Delete file operation */ export interface DeleteFile { /** * This is a delete operation. */ kind: 'delete'; /** * The file to delete. */ uri: DocumentUri; /** * Delete options. */ options?: DeleteFileOptions; /** * An optional annotation identifier describing the operation. * * @since 3.16.0 */ annotationId?: ChangeAnnotationIdentifier; } ``` The generated Rust struct looks like the following: ```rust /// Delete file operation pub struct DeleteFile { /// The file to delete. pub uri: Uri, /// Delete options. #[serde(skip_serializing_if = "Option::is_none")] pub options: Option, /// An optional annotation identifier describing the operation. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub annotation_id: Option, } ``` Note the `kind` property is not present. However, when serializing, it will always be present with a value of `"delete"`. Deserializing only succeeds when the field is present and has a `"delete"` value. ### Stronger typing This library's `Request` and `Notification` traits define not only the associated `Params` and `Result` objects, but also their message directions (i.e. `ClientToServer`, `ServerToClient`, `Both`). It also defines the method string as an `enum`, rather than a `&'static str`. Additionally, the library defines a `RequestWithPartialResults` trait for requests which support streaming partial results. The trait exposes a `PartialResult` type for this use case. ## Notable changes from `lsp-types` [`lsp-types` controversially switched to `fluent-uri`](https://github.com/gluon-lang/lsp-types/issues/284) for better spec correctness, at the cost of decreased interoperability and poorer DX. Previously, the `url` crate was used, which is significantly more battle-tested, but isn't spec-compliant in all cases. This library deliberately puts the URI encoding decision in the hands of the downstream consumer. Developers migrating from the original `lsp-types` crate will notice that the URI type is just a newtype wrapper over a `String`, allowing them to internally represent URIs however they wish. This crate also uses feature flags to allow downstream consumers to tell it to prefer a specific URI representation. The `url` feature instructs the library to deserialize URIs as `url::Url` (matching `lsp-types <=0.95.0`), and the `fluent-uri` feature instructs it to deserialize them as `fluent_uri::Uri`. Note that the two features are mutually exclusive, and by default just the `String` wrapper will be used. ## Stability Changes that are backwards compatible from a protocol perspective (e.g. `foo: integer | string` -> `foo: integer | string | boolean`) are still breaking from the point of view of this library. In the above example, an extra `enum` variant would be added to the `Foo` type, which is a breaking change. Thus the library will be perpetually kept at [zerover](https://0ver.org/) versioning, like the original `lsp-types` crate. gen-lsp-types-0.8.0/src/generated/common.rs000064400000000000000000000733531046102023000167360ustar 00000000000000use serde::{de::DeserializeOwned, Deserialize, Serialize}; use std::{borrow::Cow, fmt}; /// Indicates in which direction a message is sent in the protocol. #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)] pub enum MessageDirection { ClientToServer, ServerToClient, Both, } pub trait Notification { type Params: DeserializeOwned + Serialize + Send + Sync + 'static; const METHOD: LspNotificationMethod<'static>; const MESSAGE_DIRECTION: MessageDirection; } pub trait Request { type Params: DeserializeOwned + Serialize + Send + Sync + 'static; type Result: DeserializeOwned + Serialize + Send + Sync + 'static; const METHOD: LspRequestMethod<'static>; const MESSAGE_DIRECTION: MessageDirection; } pub trait RequestWithPartialResults: Request { type PartialResult: DeserializeOwned + Serialize + Send + Sync + 'static; } #[cfg(all(not(feature = "url"), not(feature = "fluent-uri")))] /// URIs are transferred as strings. The URI's format is defined in https://tools.ietf.org/html/rfc3986. #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] pub struct Uri(pub String); #[cfg(all(not(feature = "url"), not(feature = "fluent-uri")))] impl From for Uri { fn from(s: String) -> Self { Self(s) } } #[cfg(all(not(feature = "url"), not(feature = "fluent-uri")))] impl From<&str> for Uri { fn from(s: &str) -> Self { Self(s.into()) } } #[cfg(all(not(feature = "url"), not(feature = "fluent-uri")))] impl From> for Uri { fn from(s: Box) -> Self { Self(s.into()) } } #[cfg(all(not(feature = "url"), not(feature = "fluent-uri")))] impl From> for Uri { fn from(s: Cow<'_, str>) -> Self { Self(s.into()) } } #[cfg(all(not(feature = "url"), not(feature = "fluent-uri")))] impl AsRef for Uri { fn as_ref(&self) -> &str { &self.0 } } #[cfg(all(not(feature = "url"), not(feature = "fluent-uri")))] impl fmt::Display for Uri { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.0) } } #[cfg(feature = "url")] pub type Uri = url::Url; #[cfg(all(feature = "fluent-uri", not(feature = "url")))] pub type Uri = fluent_uri::Uri; #[cfg(all(feature = "url", feature = "fluent-uri"))] compile_error!( "Features 'url' and 'fluent-uri' are mutually exclusive and cannot be enabled together." ); #[derive(PartialEq, Eq, Hash, Debug, Clone, Copy, Serialize, Deserialize)] #[serde(into = "String", from = "&'a str")] pub enum LspRequestMethod<'a> { TextDocumentImplementation, TextDocumentTypeDefinition, WorkspaceWorkspaceFolders, WorkspaceConfiguration, TextDocumentDocumentColor, TextDocumentColorPresentation, TextDocumentFoldingRange, WorkspaceFoldingRangeRefresh, TextDocumentDeclaration, TextDocumentSelectionRange, WindowWorkDoneProgressCreate, TextDocumentPrepareCallHierarchy, CallHierarchyIncomingCalls, CallHierarchyOutgoingCalls, TextDocumentSemanticTokensFull, TextDocumentSemanticTokensFullDelta, TextDocumentSemanticTokensRange, WorkspaceSemanticTokensRefresh, WindowShowDocument, TextDocumentLinkedEditingRange, WorkspaceWillCreateFiles, WorkspaceWillRenameFiles, WorkspaceWillDeleteFiles, TextDocumentMoniker, TextDocumentPrepareTypeHierarchy, TypeHierarchySupertypes, TypeHierarchySubtypes, TextDocumentInlineValue, WorkspaceInlineValueRefresh, TextDocumentInlayHint, InlayHintResolve, WorkspaceInlayHintRefresh, TextDocumentDiagnostic, WorkspaceDiagnostic, WorkspaceDiagnosticRefresh, TextDocumentInlineCompletion, WorkspaceTextDocumentContent, WorkspaceTextDocumentContentRefresh, ClientRegisterCapability, ClientUnregisterCapability, Initialize, Shutdown, WindowShowMessageRequest, TextDocumentWillSaveWaitUntil, TextDocumentCompletion, CompletionItemResolve, TextDocumentHover, TextDocumentSignatureHelp, TextDocumentDefinition, TextDocumentReferences, TextDocumentDocumentHighlight, TextDocumentDocumentSymbol, TextDocumentCodeAction, CodeActionResolve, WorkspaceSymbol, WorkspaceSymbolResolve, TextDocumentCodeLens, CodeLensResolve, WorkspaceCodeLensRefresh, TextDocumentDocumentLink, DocumentLinkResolve, TextDocumentFormatting, TextDocumentRangeFormatting, TextDocumentRangesFormatting, TextDocumentOnTypeFormatting, TextDocumentRename, TextDocumentPrepareRename, WorkspaceExecuteCommand, WorkspaceApplyEdit, Custom(&'a str), } impl<'a> LspRequestMethod<'a> { #[must_use] pub const fn as_str(&self) -> &'a str { match self { Self::TextDocumentImplementation => "textDocument/implementation", Self::TextDocumentTypeDefinition => "textDocument/typeDefinition", Self::WorkspaceWorkspaceFolders => "workspace/workspaceFolders", Self::WorkspaceConfiguration => "workspace/configuration", Self::TextDocumentDocumentColor => "textDocument/documentColor", Self::TextDocumentColorPresentation => "textDocument/colorPresentation", Self::TextDocumentFoldingRange => "textDocument/foldingRange", Self::WorkspaceFoldingRangeRefresh => "workspace/foldingRange/refresh", Self::TextDocumentDeclaration => "textDocument/declaration", Self::TextDocumentSelectionRange => "textDocument/selectionRange", Self::WindowWorkDoneProgressCreate => "window/workDoneProgress/create", Self::TextDocumentPrepareCallHierarchy => "textDocument/prepareCallHierarchy", Self::CallHierarchyIncomingCalls => "callHierarchy/incomingCalls", Self::CallHierarchyOutgoingCalls => "callHierarchy/outgoingCalls", Self::TextDocumentSemanticTokensFull => "textDocument/semanticTokens/full", Self::TextDocumentSemanticTokensFullDelta => { "textDocument/semanticTokens/full/delta" } Self::TextDocumentSemanticTokensRange => "textDocument/semanticTokens/range", Self::WorkspaceSemanticTokensRefresh => "workspace/semanticTokens/refresh", Self::WindowShowDocument => "window/showDocument", Self::TextDocumentLinkedEditingRange => "textDocument/linkedEditingRange", Self::WorkspaceWillCreateFiles => "workspace/willCreateFiles", Self::WorkspaceWillRenameFiles => "workspace/willRenameFiles", Self::WorkspaceWillDeleteFiles => "workspace/willDeleteFiles", Self::TextDocumentMoniker => "textDocument/moniker", Self::TextDocumentPrepareTypeHierarchy => "textDocument/prepareTypeHierarchy", Self::TypeHierarchySupertypes => "typeHierarchy/supertypes", Self::TypeHierarchySubtypes => "typeHierarchy/subtypes", Self::TextDocumentInlineValue => "textDocument/inlineValue", Self::WorkspaceInlineValueRefresh => "workspace/inlineValue/refresh", Self::TextDocumentInlayHint => "textDocument/inlayHint", Self::InlayHintResolve => "inlayHint/resolve", Self::WorkspaceInlayHintRefresh => "workspace/inlayHint/refresh", Self::TextDocumentDiagnostic => "textDocument/diagnostic", Self::WorkspaceDiagnostic => "workspace/diagnostic", Self::WorkspaceDiagnosticRefresh => "workspace/diagnostic/refresh", Self::TextDocumentInlineCompletion => "textDocument/inlineCompletion", Self::WorkspaceTextDocumentContent => "workspace/textDocumentContent", Self::WorkspaceTextDocumentContentRefresh => { "workspace/textDocumentContent/refresh" } Self::ClientRegisterCapability => "client/registerCapability", Self::ClientUnregisterCapability => "client/unregisterCapability", Self::Initialize => "initialize", Self::Shutdown => "shutdown", Self::WindowShowMessageRequest => "window/showMessageRequest", Self::TextDocumentWillSaveWaitUntil => "textDocument/willSaveWaitUntil", Self::TextDocumentCompletion => "textDocument/completion", Self::CompletionItemResolve => "completionItem/resolve", Self::TextDocumentHover => "textDocument/hover", Self::TextDocumentSignatureHelp => "textDocument/signatureHelp", Self::TextDocumentDefinition => "textDocument/definition", Self::TextDocumentReferences => "textDocument/references", Self::TextDocumentDocumentHighlight => "textDocument/documentHighlight", Self::TextDocumentDocumentSymbol => "textDocument/documentSymbol", Self::TextDocumentCodeAction => "textDocument/codeAction", Self::CodeActionResolve => "codeAction/resolve", Self::WorkspaceSymbol => "workspace/symbol", Self::WorkspaceSymbolResolve => "workspaceSymbol/resolve", Self::TextDocumentCodeLens => "textDocument/codeLens", Self::CodeLensResolve => "codeLens/resolve", Self::WorkspaceCodeLensRefresh => "workspace/codeLens/refresh", Self::TextDocumentDocumentLink => "textDocument/documentLink", Self::DocumentLinkResolve => "documentLink/resolve", Self::TextDocumentFormatting => "textDocument/formatting", Self::TextDocumentRangeFormatting => "textDocument/rangeFormatting", Self::TextDocumentRangesFormatting => "textDocument/rangesFormatting", Self::TextDocumentOnTypeFormatting => "textDocument/onTypeFormatting", Self::TextDocumentRename => "textDocument/rename", Self::TextDocumentPrepareRename => "textDocument/prepareRename", Self::WorkspaceExecuteCommand => "workspace/executeCommand", Self::WorkspaceApplyEdit => "workspace/applyEdit", Self::Custom(custom) => custom, } } /// Creates a new [LspRequestMethod]. The created variant will **always** be [LspRequestMethod::Custom]. #[must_use] pub const fn new(value: &'a str) -> Self { Self::Custom(value) } } impl<'a> From<&'a str> for LspRequestMethod<'a> { /// Creates a new [LspRequestMethod] from a `&str`. The created variant will be /// [LspRequestMethod::Custom] **if and only if** the `&str` does not match an /// existing [LspRequestMethod]. fn from(value: &'a str) -> Self { match value { "textDocument/implementation" => Self::TextDocumentImplementation, "textDocument/typeDefinition" => Self::TextDocumentTypeDefinition, "workspace/workspaceFolders" => Self::WorkspaceWorkspaceFolders, "workspace/configuration" => Self::WorkspaceConfiguration, "textDocument/documentColor" => Self::TextDocumentDocumentColor, "textDocument/colorPresentation" => Self::TextDocumentColorPresentation, "textDocument/foldingRange" => Self::TextDocumentFoldingRange, "workspace/foldingRange/refresh" => Self::WorkspaceFoldingRangeRefresh, "textDocument/declaration" => Self::TextDocumentDeclaration, "textDocument/selectionRange" => Self::TextDocumentSelectionRange, "window/workDoneProgress/create" => Self::WindowWorkDoneProgressCreate, "textDocument/prepareCallHierarchy" => Self::TextDocumentPrepareCallHierarchy, "callHierarchy/incomingCalls" => Self::CallHierarchyIncomingCalls, "callHierarchy/outgoingCalls" => Self::CallHierarchyOutgoingCalls, "textDocument/semanticTokens/full" => Self::TextDocumentSemanticTokensFull, "textDocument/semanticTokens/full/delta" => { Self::TextDocumentSemanticTokensFullDelta } "textDocument/semanticTokens/range" => Self::TextDocumentSemanticTokensRange, "workspace/semanticTokens/refresh" => Self::WorkspaceSemanticTokensRefresh, "window/showDocument" => Self::WindowShowDocument, "textDocument/linkedEditingRange" => Self::TextDocumentLinkedEditingRange, "workspace/willCreateFiles" => Self::WorkspaceWillCreateFiles, "workspace/willRenameFiles" => Self::WorkspaceWillRenameFiles, "workspace/willDeleteFiles" => Self::WorkspaceWillDeleteFiles, "textDocument/moniker" => Self::TextDocumentMoniker, "textDocument/prepareTypeHierarchy" => Self::TextDocumentPrepareTypeHierarchy, "typeHierarchy/supertypes" => Self::TypeHierarchySupertypes, "typeHierarchy/subtypes" => Self::TypeHierarchySubtypes, "textDocument/inlineValue" => Self::TextDocumentInlineValue, "workspace/inlineValue/refresh" => Self::WorkspaceInlineValueRefresh, "textDocument/inlayHint" => Self::TextDocumentInlayHint, "inlayHint/resolve" => Self::InlayHintResolve, "workspace/inlayHint/refresh" => Self::WorkspaceInlayHintRefresh, "textDocument/diagnostic" => Self::TextDocumentDiagnostic, "workspace/diagnostic" => Self::WorkspaceDiagnostic, "workspace/diagnostic/refresh" => Self::WorkspaceDiagnosticRefresh, "textDocument/inlineCompletion" => Self::TextDocumentInlineCompletion, "workspace/textDocumentContent" => Self::WorkspaceTextDocumentContent, "workspace/textDocumentContent/refresh" => { Self::WorkspaceTextDocumentContentRefresh } "client/registerCapability" => Self::ClientRegisterCapability, "client/unregisterCapability" => Self::ClientUnregisterCapability, "initialize" => Self::Initialize, "shutdown" => Self::Shutdown, "window/showMessageRequest" => Self::WindowShowMessageRequest, "textDocument/willSaveWaitUntil" => Self::TextDocumentWillSaveWaitUntil, "textDocument/completion" => Self::TextDocumentCompletion, "completionItem/resolve" => Self::CompletionItemResolve, "textDocument/hover" => Self::TextDocumentHover, "textDocument/signatureHelp" => Self::TextDocumentSignatureHelp, "textDocument/definition" => Self::TextDocumentDefinition, "textDocument/references" => Self::TextDocumentReferences, "textDocument/documentHighlight" => Self::TextDocumentDocumentHighlight, "textDocument/documentSymbol" => Self::TextDocumentDocumentSymbol, "textDocument/codeAction" => Self::TextDocumentCodeAction, "codeAction/resolve" => Self::CodeActionResolve, "workspace/symbol" => Self::WorkspaceSymbol, "workspaceSymbol/resolve" => Self::WorkspaceSymbolResolve, "textDocument/codeLens" => Self::TextDocumentCodeLens, "codeLens/resolve" => Self::CodeLensResolve, "workspace/codeLens/refresh" => Self::WorkspaceCodeLensRefresh, "textDocument/documentLink" => Self::TextDocumentDocumentLink, "documentLink/resolve" => Self::DocumentLinkResolve, "textDocument/formatting" => Self::TextDocumentFormatting, "textDocument/rangeFormatting" => Self::TextDocumentRangeFormatting, "textDocument/rangesFormatting" => Self::TextDocumentRangesFormatting, "textDocument/onTypeFormatting" => Self::TextDocumentOnTypeFormatting, "textDocument/rename" => Self::TextDocumentRename, "textDocument/prepareRename" => Self::TextDocumentPrepareRename, "workspace/executeCommand" => Self::WorkspaceExecuteCommand, "workspace/applyEdit" => Self::WorkspaceApplyEdit, _ => Self::Custom(value), } } } impl<'a> From> for String { fn from(value: LspRequestMethod<'a>) -> Self { value.as_str().to_owned() } } impl fmt::Display for LspRequestMethod<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let s = self.as_str(); write!(f, "{s}") } } #[derive(PartialEq, Eq, Hash, Debug, Clone, Copy, Serialize, Deserialize)] #[serde(into = "String", from = "&'a str")] pub enum LspNotificationMethod<'a> { WorkspaceDidChangeWorkspaceFolders, WindowWorkDoneProgressCancel, WorkspaceDidCreateFiles, WorkspaceDidRenameFiles, WorkspaceDidDeleteFiles, NotebookDocumentDidOpen, NotebookDocumentDidChange, NotebookDocumentDidSave, NotebookDocumentDidClose, Initialized, Exit, WorkspaceDidChangeConfiguration, WindowShowMessage, WindowLogMessage, TelemetryEvent, TextDocumentDidOpen, TextDocumentDidChange, TextDocumentDidClose, TextDocumentDidSave, TextDocumentWillSave, WorkspaceDidChangeWatchedFiles, TextDocumentPublishDiagnostics, SetTrace, LogTrace, CancelRequest, Progress, Custom(&'a str), } impl<'a> LspNotificationMethod<'a> { #[must_use] pub const fn as_str(&self) -> &'a str { match self { Self::WorkspaceDidChangeWorkspaceFolders => { "workspace/didChangeWorkspaceFolders" } Self::WindowWorkDoneProgressCancel => "window/workDoneProgress/cancel", Self::WorkspaceDidCreateFiles => "workspace/didCreateFiles", Self::WorkspaceDidRenameFiles => "workspace/didRenameFiles", Self::WorkspaceDidDeleteFiles => "workspace/didDeleteFiles", Self::NotebookDocumentDidOpen => "notebookDocument/didOpen", Self::NotebookDocumentDidChange => "notebookDocument/didChange", Self::NotebookDocumentDidSave => "notebookDocument/didSave", Self::NotebookDocumentDidClose => "notebookDocument/didClose", Self::Initialized => "initialized", Self::Exit => "exit", Self::WorkspaceDidChangeConfiguration => "workspace/didChangeConfiguration", Self::WindowShowMessage => "window/showMessage", Self::WindowLogMessage => "window/logMessage", Self::TelemetryEvent => "telemetry/event", Self::TextDocumentDidOpen => "textDocument/didOpen", Self::TextDocumentDidChange => "textDocument/didChange", Self::TextDocumentDidClose => "textDocument/didClose", Self::TextDocumentDidSave => "textDocument/didSave", Self::TextDocumentWillSave => "textDocument/willSave", Self::WorkspaceDidChangeWatchedFiles => "workspace/didChangeWatchedFiles", Self::TextDocumentPublishDiagnostics => "textDocument/publishDiagnostics", Self::SetTrace => "$/setTrace", Self::LogTrace => "$/logTrace", Self::CancelRequest => "$/cancelRequest", Self::Progress => "$/progress", Self::Custom(custom) => custom, } } /// Creates a new [LspNotificationMethod]. The created variant will **always** be [LspNotificationMethod::Custom]. #[must_use] pub const fn new(value: &'a str) -> Self { Self::Custom(value) } } impl<'a> From<&'a str> for LspNotificationMethod<'a> { /// Creates a new [LspNotificationMethod] from a `&str`. The created variant will be /// [LspNotificationMethod::Custom] **if and only if** the `&str` does not match an /// existing [LspNotificationMethod]. fn from(value: &'a str) -> Self { match value { "workspace/didChangeWorkspaceFolders" => { Self::WorkspaceDidChangeWorkspaceFolders } "window/workDoneProgress/cancel" => Self::WindowWorkDoneProgressCancel, "workspace/didCreateFiles" => Self::WorkspaceDidCreateFiles, "workspace/didRenameFiles" => Self::WorkspaceDidRenameFiles, "workspace/didDeleteFiles" => Self::WorkspaceDidDeleteFiles, "notebookDocument/didOpen" => Self::NotebookDocumentDidOpen, "notebookDocument/didChange" => Self::NotebookDocumentDidChange, "notebookDocument/didSave" => Self::NotebookDocumentDidSave, "notebookDocument/didClose" => Self::NotebookDocumentDidClose, "initialized" => Self::Initialized, "exit" => Self::Exit, "workspace/didChangeConfiguration" => Self::WorkspaceDidChangeConfiguration, "window/showMessage" => Self::WindowShowMessage, "window/logMessage" => Self::WindowLogMessage, "telemetry/event" => Self::TelemetryEvent, "textDocument/didOpen" => Self::TextDocumentDidOpen, "textDocument/didChange" => Self::TextDocumentDidChange, "textDocument/didClose" => Self::TextDocumentDidClose, "textDocument/didSave" => Self::TextDocumentDidSave, "textDocument/willSave" => Self::TextDocumentWillSave, "workspace/didChangeWatchedFiles" => Self::WorkspaceDidChangeWatchedFiles, "textDocument/publishDiagnostics" => Self::TextDocumentPublishDiagnostics, "$/setTrace" => Self::SetTrace, "$/logTrace" => Self::LogTrace, "$/cancelRequest" => Self::CancelRequest, "$/progress" => Self::Progress, _ => Self::Custom(value), } } } impl<'a> From> for String { fn from(value: LspNotificationMethod<'a>) -> Self { value.as_str().to_owned() } } impl fmt::Display for LspNotificationMethod<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let s = self.as_str(); write!(f, "{s}") } } /// Get the [`Request`] type for a request method. /// /// Example: /// /// ``` /// use gen_lsp_types::{Request, lsp_request}; /// let params: ::Params; /// ``` #[macro_export] macro_rules! lsp_request { ("textDocument/implementation") => { $crate::ImplementationRequest }; ("textDocument/typeDefinition") => { $crate::TypeDefinitionRequest }; ("workspace/workspaceFolders") => { $crate::WorkspaceFoldersRequest }; ("workspace/configuration") => { $crate::ConfigurationRequest }; ("textDocument/documentColor") => { $crate::DocumentColorRequest }; ("textDocument/colorPresentation") => { $crate::ColorPresentationRequest }; ("textDocument/foldingRange") => { $crate::FoldingRangeRequest }; ("workspace/foldingRange/refresh") => { $crate::FoldingRangeRefreshRequest }; ("textDocument/declaration") => { $crate::DeclarationRequest }; ("textDocument/selectionRange") => { $crate::SelectionRangeRequest }; ("window/workDoneProgress/create") => { $crate::WorkDoneProgressCreateRequest }; ("textDocument/prepareCallHierarchy") => { $crate::CallHierarchyPrepareRequest }; ("callHierarchy/incomingCalls") => { $crate::CallHierarchyIncomingCallsRequest }; ("callHierarchy/outgoingCalls") => { $crate::CallHierarchyOutgoingCallsRequest }; ("textDocument/semanticTokens/full") => { $crate::SemanticTokensRequest }; ("textDocument/semanticTokens/full/delta") => { $crate::SemanticTokensDeltaRequest }; ("textDocument/semanticTokens/range") => { $crate::SemanticTokensRangeRequest }; ("workspace/semanticTokens/refresh") => { $crate::SemanticTokensRefreshRequest }; ("window/showDocument") => { $crate::ShowDocumentRequest }; ("textDocument/linkedEditingRange") => { $crate::LinkedEditingRangeRequest }; ("workspace/willCreateFiles") => { $crate::WillCreateFilesRequest }; ("workspace/willRenameFiles") => { $crate::WillRenameFilesRequest }; ("workspace/willDeleteFiles") => { $crate::WillDeleteFilesRequest }; ("textDocument/moniker") => { $crate::MonikerRequest }; ("textDocument/prepareTypeHierarchy") => { $crate::TypeHierarchyPrepareRequest }; ("typeHierarchy/supertypes") => { $crate::TypeHierarchySupertypesRequest }; ("typeHierarchy/subtypes") => { $crate::TypeHierarchySubtypesRequest }; ("textDocument/inlineValue") => { $crate::InlineValueRequest }; ("workspace/inlineValue/refresh") => { $crate::InlineValueRefreshRequest }; ("textDocument/inlayHint") => { $crate::InlayHintRequest }; ("inlayHint/resolve") => { $crate::InlayHintResolveRequest }; ("workspace/inlayHint/refresh") => { $crate::InlayHintRefreshRequest }; ("textDocument/diagnostic") => { $crate::DocumentDiagnosticRequest }; ("workspace/diagnostic") => { $crate::WorkspaceDiagnosticRequest }; ("workspace/diagnostic/refresh") => { $crate::DiagnosticRefreshRequest }; ("textDocument/inlineCompletion") => { $crate::InlineCompletionRequest }; ("workspace/textDocumentContent") => { $crate::TextDocumentContentRequest }; ("workspace/textDocumentContent/refresh") => { $crate::TextDocumentContentRefreshRequest }; ("client/registerCapability") => { $crate::RegistrationRequest }; ("client/unregisterCapability") => { $crate::UnregistrationRequest }; ("initialize") => { $crate::InitializeRequest }; ("shutdown") => { $crate::ShutdownRequest }; ("window/showMessageRequest") => { $crate::ShowMessageRequest }; ("textDocument/willSaveWaitUntil") => { $crate::WillSaveTextDocumentWaitUntilRequest }; ("textDocument/completion") => { $crate::CompletionRequest }; ("completionItem/resolve") => { $crate::CompletionResolveRequest }; ("textDocument/hover") => { $crate::HoverRequest }; ("textDocument/signatureHelp") => { $crate::SignatureHelpRequest }; ("textDocument/definition") => { $crate::DefinitionRequest }; ("textDocument/references") => { $crate::ReferencesRequest }; ("textDocument/documentHighlight") => { $crate::DocumentHighlightRequest }; ("textDocument/documentSymbol") => { $crate::DocumentSymbolRequest }; ("textDocument/codeAction") => { $crate::CodeActionRequest }; ("codeAction/resolve") => { $crate::CodeActionResolveRequest }; ("workspace/symbol") => { $crate::WorkspaceSymbolRequest }; ("workspaceSymbol/resolve") => { $crate::WorkspaceSymbolResolveRequest }; ("textDocument/codeLens") => { $crate::CodeLensRequest }; ("codeLens/resolve") => { $crate::CodeLensResolveRequest }; ("workspace/codeLens/refresh") => { $crate::CodeLensRefreshRequest }; ("textDocument/documentLink") => { $crate::DocumentLinkRequest }; ("documentLink/resolve") => { $crate::DocumentLinkResolveRequest }; ("textDocument/formatting") => { $crate::DocumentFormattingRequest }; ("textDocument/rangeFormatting") => { $crate::DocumentRangeFormattingRequest }; ("textDocument/rangesFormatting") => { $crate::DocumentRangesFormattingRequest }; ("textDocument/onTypeFormatting") => { $crate::DocumentOnTypeFormattingRequest }; ("textDocument/rename") => { $crate::RenameRequest }; ("textDocument/prepareRename") => { $crate::PrepareRenameRequest }; ("workspace/executeCommand") => { $crate::ExecuteCommandRequest }; ("workspace/applyEdit") => { $crate::ApplyWorkspaceEditRequest }; } /// Get the [`Notification`] type for a notification method. /// /// Example: /// /// ``` /// use gen_lsp_types::{Notification, lsp_notification}; /// let params: ::Params; /// ``` #[macro_export] macro_rules! lsp_notification { ("workspace/didChangeWorkspaceFolders") => { $crate::DidChangeWorkspaceFoldersNotification }; ("window/workDoneProgress/cancel") => { $crate::WorkDoneProgressCancelNotification }; ("workspace/didCreateFiles") => { $crate::DidCreateFilesNotification }; ("workspace/didRenameFiles") => { $crate::DidRenameFilesNotification }; ("workspace/didDeleteFiles") => { $crate::DidDeleteFilesNotification }; ("notebookDocument/didOpen") => { $crate::DidOpenNotebookDocumentNotification }; ("notebookDocument/didChange") => { $crate::DidChangeNotebookDocumentNotification }; ("notebookDocument/didSave") => { $crate::DidSaveNotebookDocumentNotification }; ("notebookDocument/didClose") => { $crate::DidCloseNotebookDocumentNotification }; ("initialized") => { $crate::InitializedNotification }; ("exit") => { $crate::ExitNotification }; ("workspace/didChangeConfiguration") => { $crate::DidChangeConfigurationNotification }; ("window/showMessage") => { $crate::ShowMessageNotification }; ("window/logMessage") => { $crate::LogMessageNotification }; ("telemetry/event") => { $crate::TelemetryEventNotification }; ("textDocument/didOpen") => { $crate::DidOpenTextDocumentNotification }; ("textDocument/didChange") => { $crate::DidChangeTextDocumentNotification }; ("textDocument/didClose") => { $crate::DidCloseTextDocumentNotification }; ("textDocument/didSave") => { $crate::DidSaveTextDocumentNotification }; ("textDocument/willSave") => { $crate::WillSaveTextDocumentNotification }; ("workspace/didChangeWatchedFiles") => { $crate::DidChangeWatchedFilesNotification }; ("textDocument/publishDiagnostics") => { $crate::PublishDiagnosticsNotification }; ("$/setTrace") => { $crate::SetTraceNotification }; ("$/logTrace") => { $crate::LogTraceNotification }; ("$/cancelRequest") => { $crate::CancelNotification }; ("$/progress") => { $crate::ProgressNotification }; } gen-lsp-types-0.8.0/src/generated/enum_ors.rs000064400000000000000000001526621046102023000172760ustar 00000000000000use serde::{Deserialize, Serialize}; use std::borrow::Cow; #[allow(clippy::wildcard_imports)] use super::*; #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Copy)] #[serde(untagged)] pub enum ActiveParameter { Int(u32), Null, } impl From for ActiveParameter { fn from(v: u32) -> Self { Self::Int(v) } } impl From<()> for ActiveParameter { fn from((): ()) -> Self { Self::Null } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum BaseUri { WorkspaceFolder(WorkspaceFolder), Uri(Uri), } impl From for BaseUri { fn from(v: WorkspaceFolder) -> Self { Self::WorkspaceFolder(v) } } impl From for BaseUri { fn from(v: Uri) -> Self { Self::Uri(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum CallHierarchyProvider { Bool(bool), CallHierarchyOptions(CallHierarchyOptions), CallHierarchyRegistrationOptions(CallHierarchyRegistrationOptions), } impl From for CallHierarchyProvider { fn from(v: bool) -> Self { Self::Bool(v) } } impl From for CallHierarchyProvider { fn from(v: CallHierarchyOptions) -> Self { Self::CallHierarchyOptions(v) } } impl From for CallHierarchyProvider { fn from(v: CallHierarchyRegistrationOptions) -> Self { Self::CallHierarchyRegistrationOptions(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum ChangeNotifications { String(String), Bool(bool), } impl From for ChangeNotifications { fn from(v: String) -> Self { Self::String(v) } } impl From<&str> for ChangeNotifications { fn from(v: &str) -> Self { Self::String(v.into()) } } impl From for ChangeNotifications { fn from(v: char) -> Self { Self::String(v.into()) } } impl From> for ChangeNotifications { fn from(v: Box) -> Self { Self::String(v.into()) } } impl From> for ChangeNotifications { fn from(v: Cow<'_, str>) -> Self { Self::String(v.into()) } } impl From for ChangeNotifications { fn from(v: bool) -> Self { Self::Bool(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Copy)] #[serde(untagged)] pub enum ClientSemanticTokensRequestOptionsFull { Bool(bool), ClientSemanticTokensRequestFullDelta(ClientSemanticTokensRequestFullDelta), } impl From for ClientSemanticTokensRequestOptionsFull { fn from(v: bool) -> Self { Self::Bool(v) } } impl From for ClientSemanticTokensRequestOptionsFull { fn from(v: ClientSemanticTokensRequestFullDelta) -> Self { Self::ClientSemanticTokensRequestFullDelta(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum ClientSemanticTokensRequestOptionsRange { Bool(bool), Object(LspObject), } impl From for ClientSemanticTokensRequestOptionsRange { fn from(v: bool) -> Self { Self::Bool(v) } } impl From for ClientSemanticTokensRequestOptionsRange { fn from(v: LspObject) -> Self { Self::Object(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum Code { Int(i32), String(String), } impl From for Code { fn from(v: i32) -> Self { Self::Int(v) } } impl From for Code { fn from(v: String) -> Self { Self::String(v) } } impl From<&str> for Code { fn from(v: &str) -> Self { Self::String(v.into()) } } impl From for Code { fn from(v: char) -> Self { Self::String(v.into()) } } impl From> for Code { fn from(v: Box) -> Self { Self::String(v.into()) } } impl From> for Code { fn from(v: Cow<'_, str>) -> Self { Self::String(v.into()) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq)] #[serde(untagged)] pub enum CodeActionPartialResponse { Command(Command), CodeAction(CodeAction), } impl From for CodeActionPartialResponse { fn from(v: Command) -> Self { Self::Command(v) } } impl From for CodeActionPartialResponse { fn from(v: CodeAction) -> Self { Self::CodeAction(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum CodeActionProvider { Bool(bool), CodeActionOptions(CodeActionOptions), } impl From for CodeActionProvider { fn from(v: bool) -> Self { Self::Bool(v) } } impl From for CodeActionProvider { fn from(v: CodeActionOptions) -> Self { Self::CodeActionOptions(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq)] #[serde(untagged)] pub enum CodeActionResponse { Command(Command), CodeAction(CodeAction), } impl From for CodeActionResponse { fn from(v: Command) -> Self { Self::Command(v) } } impl From for CodeActionResponse { fn from(v: CodeAction) -> Self { Self::CodeAction(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum ColorProvider { Bool(bool), DocumentColorOptions(DocumentColorOptions), DocumentColorRegistrationOptions(DocumentColorRegistrationOptions), } impl From for ColorProvider { fn from(v: bool) -> Self { Self::Bool(v) } } impl From for ColorProvider { fn from(v: DocumentColorOptions) -> Self { Self::DocumentColorOptions(v) } } impl From for ColorProvider { fn from(v: DocumentColorRegistrationOptions) -> Self { Self::DocumentColorRegistrationOptions(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum CompletionItemTextEdit { TextEdit(TextEdit), InsertReplaceEdit(InsertReplaceEdit), } impl From for CompletionItemTextEdit { fn from(v: TextEdit) -> Self { Self::TextEdit(v) } } impl From for CompletionItemTextEdit { fn from(v: InsertReplaceEdit) -> Self { Self::InsertReplaceEdit(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum CompletionResponse { CompletionItemList(Vec), CompletionList(CompletionList), } impl From> for CompletionResponse { fn from(v: Vec) -> Self { Self::CompletionItemList(v) } } impl From for CompletionResponse { fn from(v: CompletionList) -> Self { Self::CompletionList(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum Contents { MarkupContent(MarkupContent), MarkedString(MarkedString), MarkedStringList(Vec), } impl From for Contents { fn from(v: MarkupContent) -> Self { Self::MarkupContent(v) } } impl From for Contents { fn from(v: MarkedString) -> Self { Self::MarkedString(v) } } impl From> for Contents { fn from(v: Vec) -> Self { Self::MarkedStringList(v) } } /// The declaration of a symbol representation as one or many [locations][Location]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum Declaration { Location(Location), LocationList(Vec), } impl From for Declaration { fn from(v: Location) -> Self { Self::Location(v) } } impl From> for Declaration { fn from(v: Vec) -> Self { Self::LocationList(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum DeclarationPartialResponse { LocationList(Vec), DeclarationLinkList(Vec), } impl From> for DeclarationPartialResponse { fn from(v: Vec) -> Self { Self::LocationList(v) } } impl From> for DeclarationPartialResponse { fn from(v: Vec) -> Self { Self::DeclarationLinkList(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum DeclarationProvider { Bool(bool), DeclarationOptions(DeclarationOptions), DeclarationRegistrationOptions(DeclarationRegistrationOptions), } impl From for DeclarationProvider { fn from(v: bool) -> Self { Self::Bool(v) } } impl From for DeclarationProvider { fn from(v: DeclarationOptions) -> Self { Self::DeclarationOptions(v) } } impl From for DeclarationProvider { fn from(v: DeclarationRegistrationOptions) -> Self { Self::DeclarationRegistrationOptions(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum DeclarationResponse { Declaration(Declaration), DeclarationLinkList(Vec), } impl From for DeclarationResponse { fn from(v: Declaration) -> Self { Self::Declaration(v) } } impl From> for DeclarationResponse { fn from(v: Vec) -> Self { Self::DeclarationLinkList(v) } } /// The definition of a symbol represented as one or many [locations][Location]. /// 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. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum Definition { Location(Location), LocationList(Vec), } impl From for Definition { fn from(v: Location) -> Self { Self::Location(v) } } impl From> for Definition { fn from(v: Vec) -> Self { Self::LocationList(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum DefinitionPartialResponse { LocationList(Vec), DefinitionLinkList(Vec), } impl From> for DefinitionPartialResponse { fn from(v: Vec) -> Self { Self::LocationList(v) } } impl From> for DefinitionPartialResponse { fn from(v: Vec) -> Self { Self::DefinitionLinkList(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Copy)] #[serde(untagged)] pub enum DefinitionProvider { Bool(bool), DefinitionOptions(DefinitionOptions), } impl From for DefinitionProvider { fn from(v: bool) -> Self { Self::Bool(v) } } impl From for DefinitionProvider { fn from(v: DefinitionOptions) -> Self { Self::DefinitionOptions(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum DefinitionResponse { Definition(Definition), DefinitionLinkList(Vec), } impl From for DefinitionResponse { fn from(v: Definition) -> Self { Self::Definition(v) } } impl From> for DefinitionResponse { fn from(v: Vec) -> Self { Self::DefinitionLinkList(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum DiagnosticProvider { DiagnosticOptions(DiagnosticOptions), DiagnosticRegistrationOptions(DiagnosticRegistrationOptions), } impl From for DiagnosticProvider { fn from(v: DiagnosticOptions) -> Self { Self::DiagnosticOptions(v) } } impl From for DiagnosticProvider { fn from(v: DiagnosticRegistrationOptions) -> Self { Self::DiagnosticRegistrationOptions(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum DocumentChange { TextDocumentEdit(TextDocumentEdit), CreateFile(CreateFile), RenameFile(RenameFile), DeleteFile(DeleteFile), } impl From for DocumentChange { fn from(v: TextDocumentEdit) -> Self { Self::TextDocumentEdit(v) } } impl From for DocumentChange { fn from(v: CreateFile) -> Self { Self::CreateFile(v) } } impl From for DocumentChange { fn from(v: RenameFile) -> Self { Self::RenameFile(v) } } impl From for DocumentChange { fn from(v: DeleteFile) -> Self { Self::DeleteFile(v) } } /// 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 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq)] #[serde(untagged)] pub enum DocumentDiagnosticReport { RelatedFullDocumentDiagnosticReport(RelatedFullDocumentDiagnosticReport), RelatedUnchangedDocumentDiagnosticReport(RelatedUnchangedDocumentDiagnosticReport), } impl From for DocumentDiagnosticReport { fn from(v: RelatedFullDocumentDiagnosticReport) -> Self { Self::RelatedFullDocumentDiagnosticReport(v) } } impl From for DocumentDiagnosticReport { fn from(v: RelatedUnchangedDocumentDiagnosticReport) -> Self { Self::RelatedUnchangedDocumentDiagnosticReport(v) } } /// A document filter describes a top level text document or /// a notebook cell document. /// /// @since 3.17.0 - support for NotebookCellTextDocumentFilter. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum DocumentFilter { TextDocumentFilter(TextDocumentFilter), NotebookCellTextDocumentFilter(NotebookCellTextDocumentFilter), } impl From for DocumentFilter { fn from(v: TextDocumentFilter) -> Self { Self::TextDocumentFilter(v) } } impl From for DocumentFilter { fn from(v: NotebookCellTextDocumentFilter) -> Self { Self::NotebookCellTextDocumentFilter(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Copy)] #[serde(untagged)] pub enum DocumentFormattingProvider { Bool(bool), DocumentFormattingOptions(DocumentFormattingOptions), } impl From for DocumentFormattingProvider { fn from(v: bool) -> Self { Self::Bool(v) } } impl From for DocumentFormattingProvider { fn from(v: DocumentFormattingOptions) -> Self { Self::DocumentFormattingOptions(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Copy)] #[serde(untagged)] pub enum DocumentHighlightProvider { Bool(bool), DocumentHighlightOptions(DocumentHighlightOptions), } impl From for DocumentHighlightProvider { fn from(v: bool) -> Self { Self::Bool(v) } } impl From for DocumentHighlightProvider { fn from(v: DocumentHighlightOptions) -> Self { Self::DocumentHighlightOptions(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Copy)] #[serde(untagged)] pub enum DocumentRangeFormattingProvider { Bool(bool), DocumentRangeFormattingOptions(DocumentRangeFormattingOptions), } impl From for DocumentRangeFormattingProvider { fn from(v: bool) -> Self { Self::Bool(v) } } impl From for DocumentRangeFormattingProvider { fn from(v: DocumentRangeFormattingOptions) -> Self { Self::DocumentRangeFormattingOptions(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum DocumentSymbolPartialResponse { SymbolInformationList(Vec), DocumentSymbolList(Vec), } impl From> for DocumentSymbolPartialResponse { fn from(v: Vec) -> Self { Self::SymbolInformationList(v) } } impl From> for DocumentSymbolPartialResponse { fn from(v: Vec) -> Self { Self::DocumentSymbolList(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum DocumentSymbolProvider { Bool(bool), DocumentSymbolOptions(DocumentSymbolOptions), } impl From for DocumentSymbolProvider { fn from(v: bool) -> Self { Self::Bool(v) } } impl From for DocumentSymbolProvider { fn from(v: DocumentSymbolOptions) -> Self { Self::DocumentSymbolOptions(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum DocumentSymbolResponse { SymbolInformationList(Vec), DocumentSymbolList(Vec), } impl From> for DocumentSymbolResponse { fn from(v: Vec) -> Self { Self::SymbolInformationList(v) } } impl From> for DocumentSymbolResponse { fn from(v: Vec) -> Self { Self::DocumentSymbolList(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum Documentation { String(String), MarkupContent(MarkupContent), } impl From for Documentation { fn from(v: String) -> Self { Self::String(v) } } impl From<&str> for Documentation { fn from(v: &str) -> Self { Self::String(v.into()) } } impl From for Documentation { fn from(v: char) -> Self { Self::String(v.into()) } } impl From> for Documentation { fn from(v: Box) -> Self { Self::String(v.into()) } } impl From> for Documentation { fn from(v: Cow<'_, str>) -> Self { Self::String(v.into()) } } impl From for Documentation { fn from(v: MarkupContent) -> Self { Self::MarkupContent(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum Edit { TextEdit(TextEdit), AnnotatedTextEdit(AnnotatedTextEdit), SnippetTextEdit(SnippetTextEdit), } impl From for Edit { fn from(v: TextEdit) -> Self { Self::TextEdit(v) } } impl From for Edit { fn from(v: AnnotatedTextEdit) -> Self { Self::AnnotatedTextEdit(v) } } impl From for Edit { fn from(v: SnippetTextEdit) -> Self { Self::SnippetTextEdit(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Copy)] #[serde(untagged)] pub enum EditRange { Range(Range), EditRangeWithInsertReplace(EditRangeWithInsertReplace), } impl From for EditRange { fn from(v: Range) -> Self { Self::Range(v) } } impl From for EditRange { fn from(v: EditRangeWithInsertReplace) -> Self { Self::EditRangeWithInsertReplace(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum FoldingRangeProvider { Bool(bool), FoldingRangeOptions(FoldingRangeOptions), FoldingRangeRegistrationOptions(FoldingRangeRegistrationOptions), } impl From for FoldingRangeProvider { fn from(v: bool) -> Self { Self::Bool(v) } } impl From for FoldingRangeProvider { fn from(v: FoldingRangeOptions) -> Self { Self::FoldingRangeOptions(v) } } impl From for FoldingRangeProvider { fn from(v: FoldingRangeRegistrationOptions) -> Self { Self::FoldingRangeRegistrationOptions(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Copy)] #[serde(untagged)] pub enum Full { Bool(bool), SemanticTokensFullDelta(SemanticTokensFullDelta), } impl From for Full { fn from(v: bool) -> Self { Self::Bool(v) } } impl From for Full { fn from(v: SemanticTokensFullDelta) -> Self { Self::SemanticTokensFullDelta(v) } } /// The glob pattern. Either a string pattern or a relative pattern. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum GlobPattern { Pattern(Pattern), RelativePattern(RelativePattern), } impl From for GlobPattern { fn from(v: Pattern) -> Self { Self::Pattern(v) } } impl From for GlobPattern { fn from(v: RelativePattern) -> Self { Self::RelativePattern(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Copy)] #[serde(untagged)] pub enum HoverProvider { Bool(bool), HoverOptions(HoverOptions), } impl From for HoverProvider { fn from(v: bool) -> Self { Self::Bool(v) } } impl From for HoverProvider { fn from(v: HoverOptions) -> Self { Self::HoverOptions(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum Id { Int(i32), String(String), } impl From for Id { fn from(v: i32) -> Self { Self::Int(v) } } impl From for Id { fn from(v: String) -> Self { Self::String(v) } } impl From<&str> for Id { fn from(v: &str) -> Self { Self::String(v.into()) } } impl From for Id { fn from(v: char) -> Self { Self::String(v.into()) } } impl From> for Id { fn from(v: Box) -> Self { Self::String(v.into()) } } impl From> for Id { fn from(v: Cow<'_, str>) -> Self { Self::String(v.into()) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum ImplementationPartialResponse { LocationList(Vec), DefinitionLinkList(Vec), } impl From> for ImplementationPartialResponse { fn from(v: Vec) -> Self { Self::LocationList(v) } } impl From> for ImplementationPartialResponse { fn from(v: Vec) -> Self { Self::DefinitionLinkList(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum ImplementationProvider { Bool(bool), ImplementationOptions(ImplementationOptions), ImplementationRegistrationOptions(ImplementationRegistrationOptions), } impl From for ImplementationProvider { fn from(v: bool) -> Self { Self::Bool(v) } } impl From for ImplementationProvider { fn from(v: ImplementationOptions) -> Self { Self::ImplementationOptions(v) } } impl From for ImplementationProvider { fn from(v: ImplementationRegistrationOptions) -> Self { Self::ImplementationRegistrationOptions(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum ImplementationResponse { Definition(Definition), DefinitionLinkList(Vec), } impl From for ImplementationResponse { fn from(v: Definition) -> Self { Self::Definition(v) } } impl From> for ImplementationResponse { fn from(v: Vec) -> Self { Self::DefinitionLinkList(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum InlayHintProvider { Bool(bool), InlayHintOptions(InlayHintOptions), InlayHintRegistrationOptions(InlayHintRegistrationOptions), } impl From for InlayHintProvider { fn from(v: bool) -> Self { Self::Bool(v) } } impl From for InlayHintProvider { fn from(v: InlayHintOptions) -> Self { Self::InlayHintOptions(v) } } impl From for InlayHintProvider { fn from(v: InlayHintRegistrationOptions) -> Self { Self::InlayHintRegistrationOptions(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Copy)] #[serde(untagged)] pub enum InlineCompletionProvider { Bool(bool), InlineCompletionOptions(InlineCompletionOptions), } impl From for InlineCompletionProvider { fn from(v: bool) -> Self { Self::Bool(v) } } impl From for InlineCompletionProvider { fn from(v: InlineCompletionOptions) -> Self { Self::InlineCompletionOptions(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum InlineCompletionResponse { InlineCompletionList(InlineCompletionList), InlineCompletionItemList(Vec), } impl From for InlineCompletionResponse { fn from(v: InlineCompletionList) -> Self { Self::InlineCompletionList(v) } } impl From> for InlineCompletionResponse { fn from(v: Vec) -> Self { Self::InlineCompletionItemList(v) } } /// 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 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum InlineValue { Text(InlineValueText), VariableLookup(InlineValueVariableLookup), EvaluatableExpression(InlineValueEvaluatableExpression), } impl From for InlineValue { fn from(v: InlineValueText) -> Self { Self::Text(v) } } impl From for InlineValue { fn from(v: InlineValueVariableLookup) -> Self { Self::VariableLookup(v) } } impl From for InlineValue { fn from(v: InlineValueEvaluatableExpression) -> Self { Self::EvaluatableExpression(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum InlineValueProvider { Bool(bool), InlineValueOptions(InlineValueOptions), InlineValueRegistrationOptions(InlineValueRegistrationOptions), } impl From for InlineValueProvider { fn from(v: bool) -> Self { Self::Bool(v) } } impl From for InlineValueProvider { fn from(v: InlineValueOptions) -> Self { Self::InlineValueOptions(v) } } impl From for InlineValueProvider { fn from(v: InlineValueRegistrationOptions) -> Self { Self::InlineValueRegistrationOptions(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum InsertText { String(String), StringValue(StringValue), } impl From for InsertText { fn from(v: String) -> Self { Self::String(v) } } impl From<&str> for InsertText { fn from(v: &str) -> Self { Self::String(v.into()) } } impl From for InsertText { fn from(v: char) -> Self { Self::String(v.into()) } } impl From> for InsertText { fn from(v: Box) -> Self { Self::String(v.into()) } } impl From> for InsertText { fn from(v: Cow<'_, str>) -> Self { Self::String(v.into()) } } impl From for InsertText { fn from(v: StringValue) -> Self { Self::StringValue(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum Label { String(String), InlayHintLabelPartList(Vec), } impl From for Label { fn from(v: String) -> Self { Self::String(v) } } impl From<&str> for Label { fn from(v: &str) -> Self { Self::String(v.into()) } } impl From for Label { fn from(v: char) -> Self { Self::String(v.into()) } } impl From> for Label { fn from(v: Box) -> Self { Self::String(v.into()) } } impl From> for Label { fn from(v: Cow<'_, str>) -> Self { Self::String(v.into()) } } impl From> for Label { fn from(v: Vec) -> Self { Self::InlayHintLabelPartList(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum LinkedEditingRangeProvider { Bool(bool), LinkedEditingRangeOptions(LinkedEditingRangeOptions), LinkedEditingRangeRegistrationOptions(LinkedEditingRangeRegistrationOptions), } impl From for LinkedEditingRangeProvider { fn from(v: bool) -> Self { Self::Bool(v) } } impl From for LinkedEditingRangeProvider { fn from(v: LinkedEditingRangeOptions) -> Self { Self::LinkedEditingRangeOptions(v) } } impl From for LinkedEditingRangeProvider { fn from(v: LinkedEditingRangeRegistrationOptions) -> Self { Self::LinkedEditingRangeRegistrationOptions(v) } } /// MarkedString can be used to render human readable text. It is either a markdown string /// or a code-block that provides a language and a code snippet. The language identifier /// is semantically equal to the optional language identifier in fenced code blocks in GitHub /// issues. See https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting /// /// The pair of a language and a value is an equivalent to markdown: /// ```${language} /// ${value} /// ``` /// /// Note that markdown strings will be sanitized - that means html will be escaped. /// @deprecated use MarkupContent instead. #[deprecated(note = "use MarkupContent instead.")] #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum MarkedString { String(String), MarkedStringWithLanguage(MarkedStringWithLanguage), } impl From for MarkedString { fn from(v: String) -> Self { Self::String(v) } } impl From<&str> for MarkedString { fn from(v: &str) -> Self { Self::String(v.into()) } } impl From for MarkedString { fn from(v: char) -> Self { Self::String(v.into()) } } impl From> for MarkedString { fn from(v: Box) -> Self { Self::String(v.into()) } } impl From> for MarkedString { fn from(v: Cow<'_, str>) -> Self { Self::String(v.into()) } } impl From for MarkedString { fn from(v: MarkedStringWithLanguage) -> Self { Self::MarkedStringWithLanguage(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum Message { String(String), MarkupContent(MarkupContent), } impl From for Message { fn from(v: String) -> Self { Self::String(v) } } impl From<&str> for Message { fn from(v: &str) -> Self { Self::String(v.into()) } } impl From for Message { fn from(v: char) -> Self { Self::String(v.into()) } } impl From> for Message { fn from(v: Box) -> Self { Self::String(v.into()) } } impl From> for Message { fn from(v: Cow<'_, str>) -> Self { Self::String(v.into()) } } impl From for Message { fn from(v: MarkupContent) -> Self { Self::MarkupContent(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum MonikerProvider { Bool(bool), MonikerOptions(MonikerOptions), MonikerRegistrationOptions(MonikerRegistrationOptions), } impl From for MonikerProvider { fn from(v: bool) -> Self { Self::Bool(v) } } impl From for MonikerProvider { fn from(v: MonikerOptions) -> Self { Self::MonikerOptions(v) } } impl From for MonikerProvider { fn from(v: MonikerRegistrationOptions) -> Self { Self::MonikerRegistrationOptions(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum Notebook { String(String), NotebookDocumentFilter(NotebookDocumentFilter), } impl From for Notebook { fn from(v: String) -> Self { Self::String(v) } } impl From<&str> for Notebook { fn from(v: &str) -> Self { Self::String(v.into()) } } impl From for Notebook { fn from(v: char) -> Self { Self::String(v.into()) } } impl From> for Notebook { fn from(v: Box) -> Self { Self::String(v.into()) } } impl From> for Notebook { fn from(v: Cow<'_, str>) -> Self { Self::String(v.into()) } } impl From for Notebook { fn from(v: NotebookDocumentFilter) -> Self { Self::NotebookDocumentFilter(v) } } /// 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 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum NotebookDocumentFilter { NotebookType(NotebookDocumentFilterNotebookType), Scheme(NotebookDocumentFilterScheme), Pattern(NotebookDocumentFilterPattern), } impl From for NotebookDocumentFilter { fn from(v: NotebookDocumentFilterNotebookType) -> Self { Self::NotebookType(v) } } impl From for NotebookDocumentFilter { fn from(v: NotebookDocumentFilterScheme) -> Self { Self::Scheme(v) } } impl From for NotebookDocumentFilter { fn from(v: NotebookDocumentFilterPattern) -> Self { Self::Pattern(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum NotebookDocumentSync { Options(NotebookDocumentSyncOptions), RegistrationOptions(NotebookDocumentSyncRegistrationOptions), } impl From for NotebookDocumentSync { fn from(v: NotebookDocumentSyncOptions) -> Self { Self::Options(v) } } impl From for NotebookDocumentSync { fn from(v: NotebookDocumentSyncRegistrationOptions) -> Self { Self::RegistrationOptions(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum NotebookSelector { NotebookDocumentFilterWithNotebook(NotebookDocumentFilterWithNotebook), NotebookDocumentFilterWithCells(NotebookDocumentFilterWithCells), } impl From for NotebookSelector { fn from(v: NotebookDocumentFilterWithNotebook) -> Self { Self::NotebookDocumentFilterWithNotebook(v) } } impl From for NotebookSelector { fn from(v: NotebookDocumentFilterWithCells) -> Self { Self::NotebookDocumentFilterWithCells(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum ParameterInformationLabel { String(String), Tuple((u32, u32)), } impl From for ParameterInformationLabel { fn from(v: String) -> Self { Self::String(v) } } impl From<&str> for ParameterInformationLabel { fn from(v: &str) -> Self { Self::String(v.into()) } } impl From for ParameterInformationLabel { fn from(v: char) -> Self { Self::String(v.into()) } } impl From> for ParameterInformationLabel { fn from(v: Box) -> Self { Self::String(v.into()) } } impl From> for ParameterInformationLabel { fn from(v: Cow<'_, str>) -> Self { Self::String(v.into()) } } impl From<(u32, u32)> for ParameterInformationLabel { fn from(v: (u32, u32)) -> Self { Self::Tuple(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum PrepareRenameResult { Range(Range), PrepareRenamePlaceholder(PrepareRenamePlaceholder), PrepareRenameDefaultBehavior(PrepareRenameDefaultBehavior), } impl From for PrepareRenameResult { fn from(v: Range) -> Self { Self::Range(v) } } impl From for PrepareRenameResult { fn from(v: PrepareRenamePlaceholder) -> Self { Self::PrepareRenamePlaceholder(v) } } impl From for PrepareRenameResult { fn from(v: PrepareRenameDefaultBehavior) -> Self { Self::PrepareRenameDefaultBehavior(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum ProgressToken { Int(i32), String(String), } impl From for ProgressToken { fn from(v: i32) -> Self { Self::Int(v) } } impl From for ProgressToken { fn from(v: String) -> Self { Self::String(v) } } impl From<&str> for ProgressToken { fn from(v: &str) -> Self { Self::String(v.into()) } } impl From for ProgressToken { fn from(v: char) -> Self { Self::String(v.into()) } } impl From> for ProgressToken { fn from(v: Box) -> Self { Self::String(v.into()) } } impl From> for ProgressToken { fn from(v: Cow<'_, str>) -> Self { Self::String(v.into()) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Copy)] #[serde(untagged)] pub enum ReferencesProvider { Bool(bool), ReferenceOptions(ReferenceOptions), } impl From for ReferencesProvider { fn from(v: bool) -> Self { Self::Bool(v) } } impl From for ReferencesProvider { fn from(v: ReferenceOptions) -> Self { Self::ReferenceOptions(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum RelatedDocument { FullDocumentDiagnosticReport(FullDocumentDiagnosticReport), UnchangedDocumentDiagnosticReport(UnchangedDocumentDiagnosticReport), } impl From for RelatedDocument { fn from(v: FullDocumentDiagnosticReport) -> Self { Self::FullDocumentDiagnosticReport(v) } } impl From for RelatedDocument { fn from(v: UnchangedDocumentDiagnosticReport) -> Self { Self::UnchangedDocumentDiagnosticReport(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Copy)] #[serde(untagged)] pub enum RenameProvider { Bool(bool), RenameOptions(RenameOptions), } impl From for RenameProvider { fn from(v: bool) -> Self { Self::Bool(v) } } impl From for RenameProvider { fn from(v: RenameOptions) -> Self { Self::RenameOptions(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum RootPath { String(String), Null, } impl From for RootPath { fn from(v: String) -> Self { Self::String(v) } } impl From<&str> for RootPath { fn from(v: &str) -> Self { Self::String(v.into()) } } impl From for RootPath { fn from(v: char) -> Self { Self::String(v.into()) } } impl From> for RootPath { fn from(v: Box) -> Self { Self::String(v.into()) } } impl From> for RootPath { fn from(v: Cow<'_, str>) -> Self { Self::String(v.into()) } } impl From<()> for RootPath { fn from((): ()) -> Self { Self::Null } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Copy)] #[serde(untagged)] pub enum Save { Bool(bool), SaveOptions(SaveOptions), } impl From for Save { fn from(v: bool) -> Self { Self::Bool(v) } } impl From for Save { fn from(v: SaveOptions) -> Self { Self::SaveOptions(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum Section { String(String), StringList(Vec), } impl From for Section { fn from(v: String) -> Self { Self::String(v) } } impl From<&str> for Section { fn from(v: &str) -> Self { Self::String(v.into()) } } impl From for Section { fn from(v: char) -> Self { Self::String(v.into()) } } impl From> for Section { fn from(v: Box) -> Self { Self::String(v.into()) } } impl From> for Section { fn from(v: Cow<'_, str>) -> Self { Self::String(v.into()) } } impl From> for Section { fn from(v: Vec) -> Self { Self::StringList(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum SelectionRangeProvider { Bool(bool), SelectionRangeOptions(SelectionRangeOptions), SelectionRangeRegistrationOptions(SelectionRangeRegistrationOptions), } impl From for SelectionRangeProvider { fn from(v: bool) -> Self { Self::Bool(v) } } impl From for SelectionRangeProvider { fn from(v: SelectionRangeOptions) -> Self { Self::SelectionRangeOptions(v) } } impl From for SelectionRangeProvider { fn from(v: SelectionRangeRegistrationOptions) -> Self { Self::SelectionRangeRegistrationOptions(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum SemanticTokensDeltaPartialResponse { SemanticTokensPartialResult(SemanticTokensPartialResult), SemanticTokensDeltaPartialResult(SemanticTokensDeltaPartialResult), } impl From for SemanticTokensDeltaPartialResponse { fn from(v: SemanticTokensPartialResult) -> Self { Self::SemanticTokensPartialResult(v) } } impl From for SemanticTokensDeltaPartialResponse { fn from(v: SemanticTokensDeltaPartialResult) -> Self { Self::SemanticTokensDeltaPartialResult(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum SemanticTokensDeltaResponse { SemanticTokens(SemanticTokens), SemanticTokensDelta(SemanticTokensDelta), } impl From for SemanticTokensDeltaResponse { fn from(v: SemanticTokens) -> Self { Self::SemanticTokens(v) } } impl From for SemanticTokensDeltaResponse { fn from(v: SemanticTokensDelta) -> Self { Self::SemanticTokensDelta(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum SemanticTokensOptionsRange { Bool(bool), Object(LspObject), } impl From for SemanticTokensOptionsRange { fn from(v: bool) -> Self { Self::Bool(v) } } impl From for SemanticTokensOptionsRange { fn from(v: LspObject) -> Self { Self::Object(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum SemanticTokensProvider { SemanticTokensOptions(SemanticTokensOptions), SemanticTokensRegistrationOptions(SemanticTokensRegistrationOptions), } impl From for SemanticTokensProvider { fn from(v: SemanticTokensOptions) -> Self { Self::SemanticTokensOptions(v) } } impl From for SemanticTokensProvider { fn from(v: SemanticTokensRegistrationOptions) -> Self { Self::SemanticTokensRegistrationOptions(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum TextDocumentContent { Options(TextDocumentContentOptions), RegistrationOptions(TextDocumentContentRegistrationOptions), } impl From for TextDocumentContent { fn from(v: TextDocumentContentOptions) -> Self { Self::Options(v) } } impl From for TextDocumentContent { fn from(v: TextDocumentContentRegistrationOptions) -> Self { Self::RegistrationOptions(v) } } /// 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. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum TextDocumentContentChangeEvent { TextDocumentContentChangePartial(TextDocumentContentChangePartial), TextDocumentContentChangeWholeDocument(TextDocumentContentChangeWholeDocument), } impl From for TextDocumentContentChangeEvent { fn from(v: TextDocumentContentChangePartial) -> Self { Self::TextDocumentContentChangePartial(v) } } impl From for TextDocumentContentChangeEvent { fn from(v: TextDocumentContentChangeWholeDocument) -> Self { Self::TextDocumentContentChangeWholeDocument(v) } } /// A document filter denotes a document by different properties like /// the [language][`TextDocument::languageId`], the [scheme][`Uri::scheme`] of /// its resource, or a glob-pattern that is applied to the [path][`TextDocument::fileName`]. /// /// Glob patterns can have the following syntax: /// - `*` to match zero 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 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum TextDocumentFilter { Language(TextDocumentFilterLanguage), Scheme(TextDocumentFilterScheme), Pattern(TextDocumentFilterPattern), } impl From for TextDocumentFilter { fn from(v: TextDocumentFilterLanguage) -> Self { Self::Language(v) } } impl From for TextDocumentFilter { fn from(v: TextDocumentFilterScheme) -> Self { Self::Scheme(v) } } impl From for TextDocumentFilter { fn from(v: TextDocumentFilterPattern) -> Self { Self::Pattern(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Copy)] #[serde(untagged)] pub enum TextDocumentSync { Options(TextDocumentSyncOptions), Kind(TextDocumentSyncKind), } impl From for TextDocumentSync { fn from(v: TextDocumentSyncOptions) -> Self { Self::Options(v) } } impl From for TextDocumentSync { fn from(v: TextDocumentSyncKind) -> Self { Self::Kind(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum Tooltip { String(String), MarkupContent(MarkupContent), } impl From for Tooltip { fn from(v: String) -> Self { Self::String(v) } } impl From<&str> for Tooltip { fn from(v: &str) -> Self { Self::String(v.into()) } } impl From for Tooltip { fn from(v: char) -> Self { Self::String(v.into()) } } impl From> for Tooltip { fn from(v: Box) -> Self { Self::String(v.into()) } } impl From> for Tooltip { fn from(v: Cow<'_, str>) -> Self { Self::String(v.into()) } } impl From for Tooltip { fn from(v: MarkupContent) -> Self { Self::MarkupContent(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum TypeDefinitionPartialResponse { LocationList(Vec), DefinitionLinkList(Vec), } impl From> for TypeDefinitionPartialResponse { fn from(v: Vec) -> Self { Self::LocationList(v) } } impl From> for TypeDefinitionPartialResponse { fn from(v: Vec) -> Self { Self::DefinitionLinkList(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum TypeDefinitionProvider { Bool(bool), TypeDefinitionOptions(TypeDefinitionOptions), TypeDefinitionRegistrationOptions(TypeDefinitionRegistrationOptions), } impl From for TypeDefinitionProvider { fn from(v: bool) -> Self { Self::Bool(v) } } impl From for TypeDefinitionProvider { fn from(v: TypeDefinitionOptions) -> Self { Self::TypeDefinitionOptions(v) } } impl From for TypeDefinitionProvider { fn from(v: TypeDefinitionRegistrationOptions) -> Self { Self::TypeDefinitionRegistrationOptions(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum TypeDefinitionResponse { Definition(Definition), DefinitionLinkList(Vec), } impl From for TypeDefinitionResponse { fn from(v: Definition) -> Self { Self::Definition(v) } } impl From> for TypeDefinitionResponse { fn from(v: Vec) -> Self { Self::DefinitionLinkList(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum TypeHierarchyProvider { Bool(bool), TypeHierarchyOptions(TypeHierarchyOptions), TypeHierarchyRegistrationOptions(TypeHierarchyRegistrationOptions), } impl From for TypeHierarchyProvider { fn from(v: bool) -> Self { Self::Bool(v) } } impl From for TypeHierarchyProvider { fn from(v: TypeHierarchyOptions) -> Self { Self::TypeHierarchyOptions(v) } } impl From for TypeHierarchyProvider { fn from(v: TypeHierarchyRegistrationOptions) -> Self { Self::TypeHierarchyRegistrationOptions(v) } } /// A workspace diagnostic document report. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum WorkspaceDocumentDiagnosticReport { WorkspaceFullDocumentDiagnosticReport(WorkspaceFullDocumentDiagnosticReport), WorkspaceUnchangedDocumentDiagnosticReport( WorkspaceUnchangedDocumentDiagnosticReport, ), } impl From for WorkspaceDocumentDiagnosticReport { fn from(v: WorkspaceFullDocumentDiagnosticReport) -> Self { Self::WorkspaceFullDocumentDiagnosticReport(v) } } impl From for WorkspaceDocumentDiagnosticReport { fn from(v: WorkspaceUnchangedDocumentDiagnosticReport) -> Self { Self::WorkspaceUnchangedDocumentDiagnosticReport(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum WorkspaceFolders { WorkspaceFolderList(Vec), Null, } impl From> for WorkspaceFolders { fn from(v: Vec) -> Self { Self::WorkspaceFolderList(v) } } impl From<()> for WorkspaceFolders { fn from((): ()) -> Self { Self::Null } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum WorkspaceSymbolLocation { Location(Location), LocationUriOnly(LocationUriOnly), } impl From for WorkspaceSymbolLocation { fn from(v: Location) -> Self { Self::Location(v) } } impl From for WorkspaceSymbolLocation { fn from(v: LocationUriOnly) -> Self { Self::LocationUriOnly(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum WorkspaceSymbolPartialResponse { SymbolInformationList(Vec), WorkspaceSymbolList(Vec), } impl From> for WorkspaceSymbolPartialResponse { fn from(v: Vec) -> Self { Self::SymbolInformationList(v) } } impl From> for WorkspaceSymbolPartialResponse { fn from(v: Vec) -> Self { Self::WorkspaceSymbolList(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Copy)] #[serde(untagged)] pub enum WorkspaceSymbolProvider { Bool(bool), WorkspaceSymbolOptions(WorkspaceSymbolOptions), } impl From for WorkspaceSymbolProvider { fn from(v: bool) -> Self { Self::Bool(v) } } impl From for WorkspaceSymbolProvider { fn from(v: WorkspaceSymbolOptions) -> Self { Self::WorkspaceSymbolOptions(v) } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(untagged)] pub enum WorkspaceSymbolResponse { SymbolInformationList(Vec), WorkspaceSymbolList(Vec), } impl From> for WorkspaceSymbolResponse { fn from(v: Vec) -> Self { Self::SymbolInformationList(v) } } impl From> for WorkspaceSymbolResponse { fn from(v: Vec) -> Self { Self::WorkspaceSymbolList(v) } } gen-lsp-types-0.8.0/src/generated/enumerations.rs000064400000000000000000002325271046102023000201570ustar 00000000000000use serde::{Deserialize, Serialize}; use std::{borrow::Cow, fmt}; /// A set of predefined token types. This set is not fixed /// an clients can specify additional token types via the /// corresponding client capabilities. /// /// @since 3.16.0 #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize)] #[serde(into = "String", from = "String")] pub enum SemanticTokenTypes { Namespace, /// Represents a generic type. Acts as a fallback for types which can't be mapped to /// a specific type like class or enum. Type, Class, Enum, Interface, Struct, TypeParameter, Parameter, Variable, Property, EnumMember, Event, Function, Method, Macro, Keyword, Modifier, Comment, String, Number, Regexp, Operator, /// @since 3.17.0 Decorator, /// @since 3.18.0 Label, /// A custom value. #[serde(untagged)] Custom(Cow<'static, str>), } impl From for String { fn from(e: SemanticTokenTypes) -> Self { match e { SemanticTokenTypes::Namespace => "namespace".to_string(), SemanticTokenTypes::Type => "type".to_string(), SemanticTokenTypes::Class => "class".to_string(), SemanticTokenTypes::Enum => "enum".to_string(), SemanticTokenTypes::Interface => "interface".to_string(), SemanticTokenTypes::Struct => "struct".to_string(), SemanticTokenTypes::TypeParameter => "typeParameter".to_string(), SemanticTokenTypes::Parameter => "parameter".to_string(), SemanticTokenTypes::Variable => "variable".to_string(), SemanticTokenTypes::Property => "property".to_string(), SemanticTokenTypes::EnumMember => "enumMember".to_string(), SemanticTokenTypes::Event => "event".to_string(), SemanticTokenTypes::Function => "function".to_string(), SemanticTokenTypes::Method => "method".to_string(), SemanticTokenTypes::Macro => "macro".to_string(), SemanticTokenTypes::Keyword => "keyword".to_string(), SemanticTokenTypes::Modifier => "modifier".to_string(), SemanticTokenTypes::Comment => "comment".to_string(), SemanticTokenTypes::String => "string".to_string(), SemanticTokenTypes::Number => "number".to_string(), SemanticTokenTypes::Regexp => "regexp".to_string(), SemanticTokenTypes::Operator => "operator".to_string(), SemanticTokenTypes::Decorator => "decorator".to_string(), SemanticTokenTypes::Label => "label".to_string(), SemanticTokenTypes::Custom(any) => any.into_owned(), } } } impl From for SemanticTokenTypes { fn from(v: String) -> Self { match v.as_str() { "namespace" => Self::Namespace, "type" => Self::Type, "class" => Self::Class, "enum" => Self::Enum, "interface" => Self::Interface, "struct" => Self::Struct, "typeParameter" => Self::TypeParameter, "parameter" => Self::Parameter, "variable" => Self::Variable, "property" => Self::Property, "enumMember" => Self::EnumMember, "event" => Self::Event, "function" => Self::Function, "method" => Self::Method, "macro" => Self::Macro, "keyword" => Self::Keyword, "modifier" => Self::Modifier, "comment" => Self::Comment, "string" => Self::String, "number" => Self::Number, "regexp" => Self::Regexp, "operator" => Self::Operator, "decorator" => Self::Decorator, "label" => Self::Label, _ => Self::Custom(Cow::Owned(v)), } } } impl SemanticTokenTypes { /// Create a custom `SemanticTokenTypes` from a string literal. #[must_use] pub const fn new(s: &'static str) -> Self { Self::Custom(Cow::Borrowed(s)) } } impl From<&'static str> for SemanticTokenTypes { fn from(s: &'static str) -> Self { match s { "namespace" => Self::Namespace, "type" => Self::Type, "class" => Self::Class, "enum" => Self::Enum, "interface" => Self::Interface, "struct" => Self::Struct, "typeParameter" => Self::TypeParameter, "parameter" => Self::Parameter, "variable" => Self::Variable, "property" => Self::Property, "enumMember" => Self::EnumMember, "event" => Self::Event, "function" => Self::Function, "method" => Self::Method, "macro" => Self::Macro, "keyword" => Self::Keyword, "modifier" => Self::Modifier, "comment" => Self::Comment, "string" => Self::String, "number" => Self::Number, "regexp" => Self::Regexp, "operator" => Self::Operator, "decorator" => Self::Decorator, "label" => Self::Label, _ => Self::Custom(Cow::Borrowed(s)), } } } impl fmt::Display for SemanticTokenTypes { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let s: String = self.clone().into(); write!(f, "{s}") } } impl SemanticTokenTypes { #[must_use] pub fn as_str(&self) -> &str { match self { Self::Namespace => "namespace", Self::Type => "type", Self::Class => "class", Self::Enum => "enum", Self::Interface => "interface", Self::Struct => "struct", Self::TypeParameter => "typeParameter", Self::Parameter => "parameter", Self::Variable => "variable", Self::Property => "property", Self::EnumMember => "enumMember", Self::Event => "event", Self::Function => "function", Self::Method => "method", Self::Macro => "macro", Self::Keyword => "keyword", Self::Modifier => "modifier", Self::Comment => "comment", Self::String => "string", Self::Number => "number", Self::Regexp => "regexp", Self::Operator => "operator", Self::Decorator => "decorator", Self::Label => "label", Self::Custom(any) => any, } } } /// A set of predefined token modifiers. This set is not fixed /// an clients can specify additional token types via the /// corresponding client capabilities. /// /// @since 3.16.0 #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize)] #[serde(into = "String", from = "String")] pub enum SemanticTokenModifiers { Declaration, Definition, Readonly, Static, Deprecated, Abstract, Async, Modification, Documentation, DefaultLibrary, /// A custom value. #[serde(untagged)] Custom(Cow<'static, str>), } impl From for String { fn from(e: SemanticTokenModifiers) -> Self { match e { SemanticTokenModifiers::Declaration => "declaration".to_string(), SemanticTokenModifiers::Definition => "definition".to_string(), SemanticTokenModifiers::Readonly => "readonly".to_string(), SemanticTokenModifiers::Static => "static".to_string(), SemanticTokenModifiers::Deprecated => "deprecated".to_string(), SemanticTokenModifiers::Abstract => "abstract".to_string(), SemanticTokenModifiers::Async => "async".to_string(), SemanticTokenModifiers::Modification => "modification".to_string(), SemanticTokenModifiers::Documentation => "documentation".to_string(), SemanticTokenModifiers::DefaultLibrary => "defaultLibrary".to_string(), SemanticTokenModifiers::Custom(any) => any.into_owned(), } } } impl From for SemanticTokenModifiers { fn from(v: String) -> Self { match v.as_str() { "declaration" => Self::Declaration, "definition" => Self::Definition, "readonly" => Self::Readonly, "static" => Self::Static, "deprecated" => Self::Deprecated, "abstract" => Self::Abstract, "async" => Self::Async, "modification" => Self::Modification, "documentation" => Self::Documentation, "defaultLibrary" => Self::DefaultLibrary, _ => Self::Custom(Cow::Owned(v)), } } } impl SemanticTokenModifiers { /// Create a custom `SemanticTokenModifiers` from a string literal. #[must_use] pub const fn new(s: &'static str) -> Self { Self::Custom(Cow::Borrowed(s)) } } impl From<&'static str> for SemanticTokenModifiers { fn from(s: &'static str) -> Self { match s { "declaration" => Self::Declaration, "definition" => Self::Definition, "readonly" => Self::Readonly, "static" => Self::Static, "deprecated" => Self::Deprecated, "abstract" => Self::Abstract, "async" => Self::Async, "modification" => Self::Modification, "documentation" => Self::Documentation, "defaultLibrary" => Self::DefaultLibrary, _ => Self::Custom(Cow::Borrowed(s)), } } } impl fmt::Display for SemanticTokenModifiers { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let s: String = self.clone().into(); write!(f, "{s}") } } impl SemanticTokenModifiers { #[must_use] pub fn as_str(&self) -> &str { match self { Self::Declaration => "declaration", Self::Definition => "definition", Self::Readonly => "readonly", Self::Static => "static", Self::Deprecated => "deprecated", Self::Abstract => "abstract", Self::Async => "async", Self::Modification => "modification", Self::Documentation => "documentation", Self::DefaultLibrary => "defaultLibrary", Self::Custom(any) => any, } } } /// The document diagnostic report kinds. /// /// @since 3.17.0 #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)] #[serde(into = "String", try_from = "String")] pub enum DocumentDiagnosticReportKind { /// A diagnostic report with a full /// set of problems. Full, /// A report indicating that the last /// returned report is still accurate. Unchanged, } impl From for String { fn from(e: DocumentDiagnosticReportKind) -> Self { match e { DocumentDiagnosticReportKind::Full => "full".to_string(), DocumentDiagnosticReportKind::Unchanged => "unchanged".to_string(), } } } impl TryFrom for DocumentDiagnosticReportKind { type Error = String; fn try_from(v: String) -> Result>::Error> { match v.as_str() { "full" => Ok(Self::Full), "unchanged" => Ok(Self::Unchanged), _ => Err(format!("Invalid DocumentDiagnosticReportKind: {v}")), } } } impl fmt::Display for DocumentDiagnosticReportKind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let s: String = (*self).into(); write!(f, "{s}") } } impl DocumentDiagnosticReportKind { #[must_use] pub fn as_str(&self) -> &str { match self { Self::Full => "full", Self::Unchanged => "unchanged", } } } /// Predefined error codes. #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)] #[serde(into = "i32", from = "i32")] pub enum ErrorCodes { ParseError, InvalidRequest, MethodNotFound, InvalidParams, InternalError, /// Error code indicating that a server received a notification or /// request before the server has received the `initialize` request. ServerNotInitialized, UnknownErrorCode, /// A custom value. #[serde(untagged)] Custom(i32), } impl From for i32 { fn from(e: ErrorCodes) -> Self { match e { ErrorCodes::ParseError => -32700i32, ErrorCodes::InvalidRequest => -32600i32, ErrorCodes::MethodNotFound => -32601i32, ErrorCodes::InvalidParams => -32602i32, ErrorCodes::InternalError => -32603i32, ErrorCodes::ServerNotInitialized => -32002i32, ErrorCodes::UnknownErrorCode => -32001i32, ErrorCodes::Custom(any) => any, } } } impl From for ErrorCodes { fn from(v: i32) -> Self { match v { -32700i32 => Self::ParseError, -32600i32 => Self::InvalidRequest, -32601i32 => Self::MethodNotFound, -32602i32 => Self::InvalidParams, -32603i32 => Self::InternalError, -32002i32 => Self::ServerNotInitialized, -32001i32 => Self::UnknownErrorCode, _ => Self::Custom(v), } } } #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)] #[serde(into = "i32", from = "i32")] pub enum LspErrorCodes { /// 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 RequestFailed, /// The server cancelled the request. This error code should /// only be used for requests that explicitly support being /// server cancellable. /// /// @since 3.17.0 ServerCancelled, /// 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. ContentModified, /// The client has canceled a request and a server has detected /// the cancel. RequestCancelled, /// A custom value. #[serde(untagged)] Custom(i32), } impl From for i32 { fn from(e: LspErrorCodes) -> Self { match e { LspErrorCodes::RequestFailed => -32803i32, LspErrorCodes::ServerCancelled => -32802i32, LspErrorCodes::ContentModified => -32801i32, LspErrorCodes::RequestCancelled => -32800i32, LspErrorCodes::Custom(any) => any, } } } impl From for LspErrorCodes { fn from(v: i32) -> Self { match v { -32803i32 => Self::RequestFailed, -32802i32 => Self::ServerCancelled, -32801i32 => Self::ContentModified, -32800i32 => Self::RequestCancelled, _ => Self::Custom(v), } } } /// A set of predefined range kinds. #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize)] #[serde(into = "String", from = "String")] pub enum FoldingRangeKind { /// Folding range for a comment Comment, /// Folding range for an import or include Imports, /// Folding range for a region (e.g. `#region`) Region, /// A custom value. #[serde(untagged)] Custom(Cow<'static, str>), } impl From for String { fn from(e: FoldingRangeKind) -> Self { match e { FoldingRangeKind::Comment => "comment".to_string(), FoldingRangeKind::Imports => "imports".to_string(), FoldingRangeKind::Region => "region".to_string(), FoldingRangeKind::Custom(any) => any.into_owned(), } } } impl From for FoldingRangeKind { fn from(v: String) -> Self { match v.as_str() { "comment" => Self::Comment, "imports" => Self::Imports, "region" => Self::Region, _ => Self::Custom(Cow::Owned(v)), } } } impl FoldingRangeKind { /// Create a custom `FoldingRangeKind` from a string literal. #[must_use] pub const fn new(s: &'static str) -> Self { Self::Custom(Cow::Borrowed(s)) } } impl From<&'static str> for FoldingRangeKind { fn from(s: &'static str) -> Self { match s { "comment" => Self::Comment, "imports" => Self::Imports, "region" => Self::Region, _ => Self::Custom(Cow::Borrowed(s)), } } } impl fmt::Display for FoldingRangeKind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let s: String = self.clone().into(); write!(f, "{s}") } } impl FoldingRangeKind { #[must_use] pub fn as_str(&self) -> &str { match self { Self::Comment => "comment", Self::Imports => "imports", Self::Region => "region", Self::Custom(any) => any, } } } /// A symbol kind. #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)] #[serde(into = "u32", try_from = "u32")] pub enum SymbolKind { File, Module, Namespace, Package, Class, Method, Property, Field, Constructor, Enum, Interface, Function, Variable, Constant, String, Number, Boolean, Array, Object, Key, Null, EnumMember, Struct, Event, Operator, TypeParameter, } impl From for u32 { fn from(e: SymbolKind) -> Self { match e { SymbolKind::File => 1u32, SymbolKind::Module => 2u32, SymbolKind::Namespace => 3u32, SymbolKind::Package => 4u32, SymbolKind::Class => 5u32, SymbolKind::Method => 6u32, SymbolKind::Property => 7u32, SymbolKind::Field => 8u32, SymbolKind::Constructor => 9u32, SymbolKind::Enum => 10u32, SymbolKind::Interface => 11u32, SymbolKind::Function => 12u32, SymbolKind::Variable => 13u32, SymbolKind::Constant => 14u32, SymbolKind::String => 15u32, SymbolKind::Number => 16u32, SymbolKind::Boolean => 17u32, SymbolKind::Array => 18u32, SymbolKind::Object => 19u32, SymbolKind::Key => 20u32, SymbolKind::Null => 21u32, SymbolKind::EnumMember => 22u32, SymbolKind::Struct => 23u32, SymbolKind::Event => 24u32, SymbolKind::Operator => 25u32, SymbolKind::TypeParameter => 26u32, } } } impl TryFrom for SymbolKind { type Error = String; fn try_from(v: u32) -> Result>::Error> { match v { 1u32 => Ok(Self::File), 2u32 => Ok(Self::Module), 3u32 => Ok(Self::Namespace), 4u32 => Ok(Self::Package), 5u32 => Ok(Self::Class), 6u32 => Ok(Self::Method), 7u32 => Ok(Self::Property), 8u32 => Ok(Self::Field), 9u32 => Ok(Self::Constructor), 10u32 => Ok(Self::Enum), 11u32 => Ok(Self::Interface), 12u32 => Ok(Self::Function), 13u32 => Ok(Self::Variable), 14u32 => Ok(Self::Constant), 15u32 => Ok(Self::String), 16u32 => Ok(Self::Number), 17u32 => Ok(Self::Boolean), 18u32 => Ok(Self::Array), 19u32 => Ok(Self::Object), 20u32 => Ok(Self::Key), 21u32 => Ok(Self::Null), 22u32 => Ok(Self::EnumMember), 23u32 => Ok(Self::Struct), 24u32 => Ok(Self::Event), 25u32 => Ok(Self::Operator), 26u32 => Ok(Self::TypeParameter), _ => Err(format!("Invalid SymbolKind: {v}")), } } } /// Symbol tags are extra annotations that tweak the rendering of a symbol. /// /// @since 3.16 #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)] #[serde(into = "u32", try_from = "u32")] pub enum SymbolTag { /// Render a symbol as obsolete, usually using a strike-out. Deprecated, } impl From for u32 { fn from(e: SymbolTag) -> Self { match e { SymbolTag::Deprecated => 1u32, } } } impl TryFrom for SymbolTag { type Error = String; fn try_from(v: u32) -> Result>::Error> { match v { 1u32 => Ok(Self::Deprecated), _ => Err(format!("Invalid SymbolTag: {v}")), } } } /// Moniker uniqueness level to define scope of the moniker. /// /// @since 3.16.0 #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)] #[serde(into = "String", try_from = "String")] pub enum UniquenessLevel { /// The moniker is only unique inside a document Document, /// The moniker is unique inside a project for which a dump got created Project, /// The moniker is unique inside the group to which a project belongs Group, /// The moniker is unique inside the moniker scheme. Scheme, /// The moniker is globally unique Global, } impl From for String { fn from(e: UniquenessLevel) -> Self { match e { UniquenessLevel::Document => "document".to_string(), UniquenessLevel::Project => "project".to_string(), UniquenessLevel::Group => "group".to_string(), UniquenessLevel::Scheme => "scheme".to_string(), UniquenessLevel::Global => "global".to_string(), } } } impl TryFrom for UniquenessLevel { type Error = String; fn try_from(v: String) -> Result>::Error> { match v.as_str() { "document" => Ok(Self::Document), "project" => Ok(Self::Project), "group" => Ok(Self::Group), "scheme" => Ok(Self::Scheme), "global" => Ok(Self::Global), _ => Err(format!("Invalid UniquenessLevel: {v}")), } } } impl fmt::Display for UniquenessLevel { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let s: String = (*self).into(); write!(f, "{s}") } } impl UniquenessLevel { #[must_use] pub fn as_str(&self) -> &str { match self { Self::Document => "document", Self::Project => "project", Self::Group => "group", Self::Scheme => "scheme", Self::Global => "global", } } } /// The moniker kind. /// /// @since 3.16.0 #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)] #[serde(into = "String", try_from = "String")] pub enum MonikerKind { /// The moniker represent a symbol that is imported into a project Import, /// The moniker represents a symbol that is exported from a project Export, /// The moniker represents a symbol that is local to a project (e.g. a local /// variable of a function, a class not visible outside the project, ...) Local, } impl From for String { fn from(e: MonikerKind) -> Self { match e { MonikerKind::Import => "import".to_string(), MonikerKind::Export => "export".to_string(), MonikerKind::Local => "local".to_string(), } } } impl TryFrom for MonikerKind { type Error = String; fn try_from(v: String) -> Result>::Error> { match v.as_str() { "import" => Ok(Self::Import), "export" => Ok(Self::Export), "local" => Ok(Self::Local), _ => Err(format!("Invalid MonikerKind: {v}")), } } } impl fmt::Display for MonikerKind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let s: String = (*self).into(); write!(f, "{s}") } } impl MonikerKind { #[must_use] pub fn as_str(&self) -> &str { match self { Self::Import => "import", Self::Export => "export", Self::Local => "local", } } } /// Inlay hint kinds. /// /// @since 3.17.0 #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)] #[serde(into = "u32", try_from = "u32")] pub enum InlayHintKind { /// An inlay hint that for a type annotation. Type, /// An inlay hint that is for a parameter. Parameter, } impl From for u32 { fn from(e: InlayHintKind) -> Self { match e { InlayHintKind::Type => 1u32, InlayHintKind::Parameter => 2u32, } } } impl TryFrom for InlayHintKind { type Error = String; fn try_from(v: u32) -> Result>::Error> { match v { 1u32 => Ok(Self::Type), 2u32 => Ok(Self::Parameter), _ => Err(format!("Invalid InlayHintKind: {v}")), } } } /// The message type #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)] #[serde(into = "u32", try_from = "u32")] pub enum MessageType { /// An error message. Error, /// A warning message. Warning, /// An information message. Info, /// A log message. Log, /// A debug message. /// /// @since 3.18.0 Debug, } impl From for u32 { fn from(e: MessageType) -> Self { match e { MessageType::Error => 1u32, MessageType::Warning => 2u32, MessageType::Info => 3u32, MessageType::Log => 4u32, MessageType::Debug => 5u32, } } } impl TryFrom for MessageType { type Error = String; fn try_from(v: u32) -> Result>::Error> { match v { 1u32 => Ok(Self::Error), 2u32 => Ok(Self::Warning), 3u32 => Ok(Self::Info), 4u32 => Ok(Self::Log), 5u32 => Ok(Self::Debug), _ => Err(format!("Invalid MessageType: {v}")), } } } /// Defines how the host (editor) should sync /// document changes to the language server. #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)] #[serde(into = "u32", try_from = "u32")] pub enum TextDocumentSyncKind { /// Documents should not be synced at all. None, /// Documents are synced by always sending the full content /// of the document. Full, /// Documents are synced by sending the full content on open. /// After that only incremental updates to the document are /// send. Incremental, } impl From for u32 { fn from(e: TextDocumentSyncKind) -> Self { match e { TextDocumentSyncKind::None => 0u32, TextDocumentSyncKind::Full => 1u32, TextDocumentSyncKind::Incremental => 2u32, } } } impl TryFrom for TextDocumentSyncKind { type Error = String; fn try_from(v: u32) -> Result>::Error> { match v { 0u32 => Ok(Self::None), 1u32 => Ok(Self::Full), 2u32 => Ok(Self::Incremental), _ => Err(format!("Invalid TextDocumentSyncKind: {v}")), } } } /// Represents reasons why a text document is saved. #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)] #[serde(into = "u32", try_from = "u32")] pub enum TextDocumentSaveReason { /// Manually triggered, e.g. by the user pressing save, by starting debugging, /// or by an API call. Manual, /// Automatic after a delay. AfterDelay, /// When the editor lost focus. FocusOut, } impl From for u32 { fn from(e: TextDocumentSaveReason) -> Self { match e { TextDocumentSaveReason::Manual => 1u32, TextDocumentSaveReason::AfterDelay => 2u32, TextDocumentSaveReason::FocusOut => 3u32, } } } impl TryFrom for TextDocumentSaveReason { type Error = String; fn try_from(v: u32) -> Result>::Error> { match v { 1u32 => Ok(Self::Manual), 2u32 => Ok(Self::AfterDelay), 3u32 => Ok(Self::FocusOut), _ => Err(format!("Invalid TextDocumentSaveReason: {v}")), } } } /// The kind of a completion entry. #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)] #[serde(into = "u32", try_from = "u32")] pub enum CompletionItemKind { Text, Method, Function, Constructor, Field, Variable, Class, Interface, Module, Property, Unit, Value, Enum, Keyword, Snippet, Color, File, Reference, Folder, EnumMember, Constant, Struct, Event, Operator, TypeParameter, } impl From for u32 { fn from(e: CompletionItemKind) -> Self { match e { CompletionItemKind::Text => 1u32, CompletionItemKind::Method => 2u32, CompletionItemKind::Function => 3u32, CompletionItemKind::Constructor => 4u32, CompletionItemKind::Field => 5u32, CompletionItemKind::Variable => 6u32, CompletionItemKind::Class => 7u32, CompletionItemKind::Interface => 8u32, CompletionItemKind::Module => 9u32, CompletionItemKind::Property => 10u32, CompletionItemKind::Unit => 11u32, CompletionItemKind::Value => 12u32, CompletionItemKind::Enum => 13u32, CompletionItemKind::Keyword => 14u32, CompletionItemKind::Snippet => 15u32, CompletionItemKind::Color => 16u32, CompletionItemKind::File => 17u32, CompletionItemKind::Reference => 18u32, CompletionItemKind::Folder => 19u32, CompletionItemKind::EnumMember => 20u32, CompletionItemKind::Constant => 21u32, CompletionItemKind::Struct => 22u32, CompletionItemKind::Event => 23u32, CompletionItemKind::Operator => 24u32, CompletionItemKind::TypeParameter => 25u32, } } } impl TryFrom for CompletionItemKind { type Error = String; fn try_from(v: u32) -> Result>::Error> { match v { 1u32 => Ok(Self::Text), 2u32 => Ok(Self::Method), 3u32 => Ok(Self::Function), 4u32 => Ok(Self::Constructor), 5u32 => Ok(Self::Field), 6u32 => Ok(Self::Variable), 7u32 => Ok(Self::Class), 8u32 => Ok(Self::Interface), 9u32 => Ok(Self::Module), 10u32 => Ok(Self::Property), 11u32 => Ok(Self::Unit), 12u32 => Ok(Self::Value), 13u32 => Ok(Self::Enum), 14u32 => Ok(Self::Keyword), 15u32 => Ok(Self::Snippet), 16u32 => Ok(Self::Color), 17u32 => Ok(Self::File), 18u32 => Ok(Self::Reference), 19u32 => Ok(Self::Folder), 20u32 => Ok(Self::EnumMember), 21u32 => Ok(Self::Constant), 22u32 => Ok(Self::Struct), 23u32 => Ok(Self::Event), 24u32 => Ok(Self::Operator), 25u32 => Ok(Self::TypeParameter), _ => Err(format!("Invalid CompletionItemKind: {v}")), } } } /// Completion item tags are extra annotations that tweak the rendering of a completion /// item. /// /// @since 3.15.0 #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)] #[serde(into = "u32", try_from = "u32")] pub enum CompletionItemTag { /// Render a completion as obsolete, usually using a strike-out. Deprecated, } impl From for u32 { fn from(e: CompletionItemTag) -> Self { match e { CompletionItemTag::Deprecated => 1u32, } } } impl TryFrom for CompletionItemTag { type Error = String; fn try_from(v: u32) -> Result>::Error> { match v { 1u32 => Ok(Self::Deprecated), _ => Err(format!("Invalid CompletionItemTag: {v}")), } } } /// Defines whether the insert text in a completion item should be interpreted as /// plain text or a snippet. #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)] #[serde(into = "u32", try_from = "u32")] pub enum InsertTextFormat { /// The primary text to be inserted is treated as a plain string. PlainText, /// The primary text to be inserted is treated as a snippet. /// /// 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. /// /// See also: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#snippet_syntax Snippet, } impl From for u32 { fn from(e: InsertTextFormat) -> Self { match e { InsertTextFormat::PlainText => 1u32, InsertTextFormat::Snippet => 2u32, } } } impl TryFrom for InsertTextFormat { type Error = String; fn try_from(v: u32) -> Result>::Error> { match v { 1u32 => Ok(Self::PlainText), 2u32 => Ok(Self::Snippet), _ => Err(format!("Invalid InsertTextFormat: {v}")), } } } /// How whitespace and indentation is handled during completion /// item insertion. /// /// @since 3.16.0 #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)] #[serde(into = "u32", try_from = "u32")] pub enum InsertTextMode { /// The insertion or replace strings is taken as it is. If the /// value is multi line the lines below the cursor will be /// inserted using the indentation defined in the string value. /// The client will not apply any kind of adjustments to the /// string. AsIs, /// The editor adjusts leading whitespace of new lines so that /// they match the indentation up to the cursor of the line for /// which the item is accepted. /// /// Consider a line like this: <2tabs><3tabs>foo. Accepting a /// multi line completion item is indented using 2 tabs and all /// following lines inserted will be indented using 2 tabs as well. AdjustIndentation, } impl From for u32 { fn from(e: InsertTextMode) -> Self { match e { InsertTextMode::AsIs => 1u32, InsertTextMode::AdjustIndentation => 2u32, } } } impl TryFrom for InsertTextMode { type Error = String; fn try_from(v: u32) -> Result>::Error> { match v { 1u32 => Ok(Self::AsIs), 2u32 => Ok(Self::AdjustIndentation), _ => Err(format!("Invalid InsertTextMode: {v}")), } } } /// A document highlight kind. #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)] #[serde(into = "u32", try_from = "u32")] pub enum DocumentHighlightKind { /// A textual occurrence. Text, /// Read-access of a symbol, like reading a variable. Read, /// Write-access of a symbol, like writing to a variable. Write, } impl From for u32 { fn from(e: DocumentHighlightKind) -> Self { match e { DocumentHighlightKind::Text => 1u32, DocumentHighlightKind::Read => 2u32, DocumentHighlightKind::Write => 3u32, } } } impl TryFrom for DocumentHighlightKind { type Error = String; fn try_from(v: u32) -> Result>::Error> { match v { 1u32 => Ok(Self::Text), 2u32 => Ok(Self::Read), 3u32 => Ok(Self::Write), _ => Err(format!("Invalid DocumentHighlightKind: {v}")), } } } /// A set of predefined code action kinds #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize)] #[serde(into = "String", from = "String")] pub enum CodeActionKind { /// Empty kind. Empty, /// Base kind for quickfix actions: 'quickfix' QuickFix, /// Base kind for refactoring actions: 'refactor' Refactor, /// Base kind for refactoring extraction actions: 'refactor.extract' /// /// Example extract actions: /// /// - Extract method /// - Extract function /// - Extract variable /// - Extract interface from class /// - ... RefactorExtract, /// Base kind for refactoring inline actions: 'refactor.inline' /// /// Example inline actions: /// /// - Inline function /// - Inline variable /// - Inline constant /// - ... RefactorInline, /// Base kind for refactoring move actions: `refactor.move` /// /// Example move actions: /// /// - Move a function to a new file /// - Move a property between classes /// - Move method to base class /// - ... /// /// @since 3.18.0 RefactorMove, /// 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 /// - ... RefactorRewrite, /// Base kind for source actions: `source` /// /// Source code actions apply to the entire file. Source, /// Base kind for an organize imports source action: `source.organizeImports` SourceOrganizeImports, /// 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 SourceFixAll, /// Base kind for all code actions applying to the entire notebook's scope. CodeActionKinds using /// this should always begin with `notebook.` /// /// @since 3.18.0 Notebook, /// A custom value. #[serde(untagged)] Custom(Cow<'static, str>), } impl From for String { fn from(e: CodeActionKind) -> Self { match e { CodeActionKind::Empty => "".to_string(), CodeActionKind::QuickFix => "quickfix".to_string(), CodeActionKind::Refactor => "refactor".to_string(), CodeActionKind::RefactorExtract => "refactor.extract".to_string(), CodeActionKind::RefactorInline => "refactor.inline".to_string(), CodeActionKind::RefactorMove => "refactor.move".to_string(), CodeActionKind::RefactorRewrite => "refactor.rewrite".to_string(), CodeActionKind::Source => "source".to_string(), CodeActionKind::SourceOrganizeImports => "source.organizeImports".to_string(), CodeActionKind::SourceFixAll => "source.fixAll".to_string(), CodeActionKind::Notebook => "notebook".to_string(), CodeActionKind::Custom(any) => any.into_owned(), } } } impl From for CodeActionKind { fn from(v: String) -> Self { match v.as_str() { "" => Self::Empty, "quickfix" => Self::QuickFix, "refactor" => Self::Refactor, "refactor.extract" => Self::RefactorExtract, "refactor.inline" => Self::RefactorInline, "refactor.move" => Self::RefactorMove, "refactor.rewrite" => Self::RefactorRewrite, "source" => Self::Source, "source.organizeImports" => Self::SourceOrganizeImports, "source.fixAll" => Self::SourceFixAll, "notebook" => Self::Notebook, _ => Self::Custom(Cow::Owned(v)), } } } impl CodeActionKind { /// Create a custom `CodeActionKind` from a string literal. #[must_use] pub const fn new(s: &'static str) -> Self { Self::Custom(Cow::Borrowed(s)) } } impl From<&'static str> for CodeActionKind { fn from(s: &'static str) -> Self { match s { "" => Self::Empty, "quickfix" => Self::QuickFix, "refactor" => Self::Refactor, "refactor.extract" => Self::RefactorExtract, "refactor.inline" => Self::RefactorInline, "refactor.move" => Self::RefactorMove, "refactor.rewrite" => Self::RefactorRewrite, "source" => Self::Source, "source.organizeImports" => Self::SourceOrganizeImports, "source.fixAll" => Self::SourceFixAll, "notebook" => Self::Notebook, _ => Self::Custom(Cow::Borrowed(s)), } } } impl fmt::Display for CodeActionKind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let s: String = self.clone().into(); write!(f, "{s}") } } impl CodeActionKind { #[must_use] pub fn as_str(&self) -> &str { match self { Self::Empty => "", Self::QuickFix => "quickfix", Self::Refactor => "refactor", Self::RefactorExtract => "refactor.extract", Self::RefactorInline => "refactor.inline", Self::RefactorMove => "refactor.move", Self::RefactorRewrite => "refactor.rewrite", Self::Source => "source", Self::SourceOrganizeImports => "source.organizeImports", Self::SourceFixAll => "source.fixAll", Self::Notebook => "notebook", Self::Custom(any) => any, } } } /// Code action tags are extra annotations that tweak the behavior of a code action. /// /// @since 3.18.0 - proposed #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)] #[serde(into = "u32", try_from = "u32")] pub enum CodeActionTag { /// Marks the code action as LLM-generated. LLMGenerated, } impl From for u32 { fn from(e: CodeActionTag) -> Self { match e { CodeActionTag::LLMGenerated => 1u32, } } } impl TryFrom for CodeActionTag { type Error = String; fn try_from(v: u32) -> Result>::Error> { match v { 1u32 => Ok(Self::LLMGenerated), _ => Err(format!("Invalid CodeActionTag: {v}")), } } } #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)] #[serde(into = "String", try_from = "String")] pub enum TraceValue { /// Turn tracing off. Off, /// Trace messages only. Messages, /// Verbose message tracing. Verbose, } impl From for String { fn from(e: TraceValue) -> Self { match e { TraceValue::Off => "off".to_string(), TraceValue::Messages => "messages".to_string(), TraceValue::Verbose => "verbose".to_string(), } } } impl TryFrom for TraceValue { type Error = String; fn try_from(v: String) -> Result>::Error> { match v.as_str() { "off" => Ok(Self::Off), "messages" => Ok(Self::Messages), "verbose" => Ok(Self::Verbose), _ => Err(format!("Invalid TraceValue: {v}")), } } } impl fmt::Display for TraceValue { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let s: String = (*self).into(); write!(f, "{s}") } } impl TraceValue { #[must_use] pub fn as_str(&self) -> &str { match self { Self::Off => "off", Self::Messages => "messages", Self::Verbose => "verbose", } } } /// Describes the content type that a client supports in various /// result literals like `Hover`, `ParameterInfo` or `CompletionItem`. /// /// Please note that `MarkupKinds` must not start with a `$`. This kinds /// are reserved for internal usage. #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)] #[serde(into = "String", try_from = "String")] pub enum MarkupKind { /// Plain text is supported as a content format PlainText, /// Markdown is supported as a content format Markdown, } impl From for String { fn from(e: MarkupKind) -> Self { match e { MarkupKind::PlainText => "plaintext".to_string(), MarkupKind::Markdown => "markdown".to_string(), } } } impl TryFrom for MarkupKind { type Error = String; fn try_from(v: String) -> Result>::Error> { match v.as_str() { "plaintext" => Ok(Self::PlainText), "markdown" => Ok(Self::Markdown), _ => Err(format!("Invalid MarkupKind: {v}")), } } } impl fmt::Display for MarkupKind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let s: String = (*self).into(); write!(f, "{s}") } } impl MarkupKind { #[must_use] pub fn as_str(&self) -> &str { match self { Self::PlainText => "plaintext", Self::Markdown => "markdown", } } } /// Predefined Language kinds /// @since 3.18.0 #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize)] #[serde(into = "String", from = "String")] pub enum LanguageKind { ABAP, WindowsBat, BibTeX, Clojure, Coffeescript, C, CPP, CSharp, CSS, /// @since 3.18.0 D, /// @since 3.18.0 Delphi, Diff, Dart, Dockerfile, Elixir, Erlang, FSharp, GitCommit, GitRebase, Go, Groovy, Handlebars, Haskell, HTML, Ini, Java, JavaScript, JavaScriptReact, JSON, LaTeX, Less, Lua, Makefile, Markdown, ObjectiveC, ObjectiveCPP, /// @since 3.18.0 Pascal, Perl, Perl6, PHP, Plaintext, Powershell, Pug, Python, R, Razor, Ruby, Rust, SCSS, SASS, Scala, ShaderLab, ShellScript, SQL, Swift, TypeScript, TypeScriptReact, TeX, VisualBasic, XML, XSL, YAML, /// A custom value. #[serde(untagged)] Custom(Cow<'static, str>), } impl From for String { fn from(e: LanguageKind) -> Self { match e { LanguageKind::ABAP => "abap".to_string(), LanguageKind::WindowsBat => "bat".to_string(), LanguageKind::BibTeX => "bibtex".to_string(), LanguageKind::Clojure => "clojure".to_string(), LanguageKind::Coffeescript => "coffeescript".to_string(), LanguageKind::C => "c".to_string(), LanguageKind::CPP => "cpp".to_string(), LanguageKind::CSharp => "csharp".to_string(), LanguageKind::CSS => "css".to_string(), LanguageKind::D => "d".to_string(), LanguageKind::Delphi => "pascal".to_string(), LanguageKind::Diff => "diff".to_string(), LanguageKind::Dart => "dart".to_string(), LanguageKind::Dockerfile => "dockerfile".to_string(), LanguageKind::Elixir => "elixir".to_string(), LanguageKind::Erlang => "erlang".to_string(), LanguageKind::FSharp => "fsharp".to_string(), LanguageKind::GitCommit => "git-commit".to_string(), LanguageKind::GitRebase => "git-rebase".to_string(), LanguageKind::Go => "go".to_string(), LanguageKind::Groovy => "groovy".to_string(), LanguageKind::Handlebars => "handlebars".to_string(), LanguageKind::Haskell => "haskell".to_string(), LanguageKind::HTML => "html".to_string(), LanguageKind::Ini => "ini".to_string(), LanguageKind::Java => "java".to_string(), LanguageKind::JavaScript => "javascript".to_string(), LanguageKind::JavaScriptReact => "javascriptreact".to_string(), LanguageKind::JSON => "json".to_string(), LanguageKind::LaTeX => "latex".to_string(), LanguageKind::Less => "less".to_string(), LanguageKind::Lua => "lua".to_string(), LanguageKind::Makefile => "makefile".to_string(), LanguageKind::Markdown => "markdown".to_string(), LanguageKind::ObjectiveC => "objective-c".to_string(), LanguageKind::ObjectiveCPP => "objective-cpp".to_string(), LanguageKind::Pascal => "pascal".to_string(), LanguageKind::Perl => "perl".to_string(), LanguageKind::Perl6 => "perl6".to_string(), LanguageKind::PHP => "php".to_string(), LanguageKind::Plaintext => "plaintext".to_string(), LanguageKind::Powershell => "powershell".to_string(), LanguageKind::Pug => "jade".to_string(), LanguageKind::Python => "python".to_string(), LanguageKind::R => "r".to_string(), LanguageKind::Razor => "razor".to_string(), LanguageKind::Ruby => "ruby".to_string(), LanguageKind::Rust => "rust".to_string(), LanguageKind::SCSS => "scss".to_string(), LanguageKind::SASS => "sass".to_string(), LanguageKind::Scala => "scala".to_string(), LanguageKind::ShaderLab => "shaderlab".to_string(), LanguageKind::ShellScript => "shellscript".to_string(), LanguageKind::SQL => "sql".to_string(), LanguageKind::Swift => "swift".to_string(), LanguageKind::TypeScript => "typescript".to_string(), LanguageKind::TypeScriptReact => "typescriptreact".to_string(), LanguageKind::TeX => "tex".to_string(), LanguageKind::VisualBasic => "vb".to_string(), LanguageKind::XML => "xml".to_string(), LanguageKind::XSL => "xsl".to_string(), LanguageKind::YAML => "yaml".to_string(), LanguageKind::Custom(any) => any.into_owned(), } } } impl From for LanguageKind { fn from(v: String) -> Self { match v.as_str() { "abap" => Self::ABAP, "bat" => Self::WindowsBat, "bibtex" => Self::BibTeX, "clojure" => Self::Clojure, "coffeescript" => Self::Coffeescript, "c" => Self::C, "cpp" => Self::CPP, "csharp" => Self::CSharp, "css" => Self::CSS, "d" => Self::D, "pascal" => Self::Delphi, "diff" => Self::Diff, "dart" => Self::Dart, "dockerfile" => Self::Dockerfile, "elixir" => Self::Elixir, "erlang" => Self::Erlang, "fsharp" => Self::FSharp, "git-commit" => Self::GitCommit, "git-rebase" => Self::GitRebase, "go" => Self::Go, "groovy" => Self::Groovy, "handlebars" => Self::Handlebars, "haskell" => Self::Haskell, "html" => Self::HTML, "ini" => Self::Ini, "java" => Self::Java, "javascript" => Self::JavaScript, "javascriptreact" => Self::JavaScriptReact, "json" => Self::JSON, "latex" => Self::LaTeX, "less" => Self::Less, "lua" => Self::Lua, "makefile" => Self::Makefile, "markdown" => Self::Markdown, "objective-c" => Self::ObjectiveC, "objective-cpp" => Self::ObjectiveCPP, "pascal" => Self::Pascal, "perl" => Self::Perl, "perl6" => Self::Perl6, "php" => Self::PHP, "plaintext" => Self::Plaintext, "powershell" => Self::Powershell, "jade" => Self::Pug, "python" => Self::Python, "r" => Self::R, "razor" => Self::Razor, "ruby" => Self::Ruby, "rust" => Self::Rust, "scss" => Self::SCSS, "sass" => Self::SASS, "scala" => Self::Scala, "shaderlab" => Self::ShaderLab, "shellscript" => Self::ShellScript, "sql" => Self::SQL, "swift" => Self::Swift, "typescript" => Self::TypeScript, "typescriptreact" => Self::TypeScriptReact, "tex" => Self::TeX, "vb" => Self::VisualBasic, "xml" => Self::XML, "xsl" => Self::XSL, "yaml" => Self::YAML, _ => Self::Custom(Cow::Owned(v)), } } } impl LanguageKind { /// Create a custom `LanguageKind` from a string literal. #[must_use] pub const fn new(s: &'static str) -> Self { Self::Custom(Cow::Borrowed(s)) } } impl From<&'static str> for LanguageKind { fn from(s: &'static str) -> Self { match s { "abap" => Self::ABAP, "bat" => Self::WindowsBat, "bibtex" => Self::BibTeX, "clojure" => Self::Clojure, "coffeescript" => Self::Coffeescript, "c" => Self::C, "cpp" => Self::CPP, "csharp" => Self::CSharp, "css" => Self::CSS, "d" => Self::D, "pascal" => Self::Delphi, "diff" => Self::Diff, "dart" => Self::Dart, "dockerfile" => Self::Dockerfile, "elixir" => Self::Elixir, "erlang" => Self::Erlang, "fsharp" => Self::FSharp, "git-commit" => Self::GitCommit, "git-rebase" => Self::GitRebase, "go" => Self::Go, "groovy" => Self::Groovy, "handlebars" => Self::Handlebars, "haskell" => Self::Haskell, "html" => Self::HTML, "ini" => Self::Ini, "java" => Self::Java, "javascript" => Self::JavaScript, "javascriptreact" => Self::JavaScriptReact, "json" => Self::JSON, "latex" => Self::LaTeX, "less" => Self::Less, "lua" => Self::Lua, "makefile" => Self::Makefile, "markdown" => Self::Markdown, "objective-c" => Self::ObjectiveC, "objective-cpp" => Self::ObjectiveCPP, "pascal" => Self::Pascal, "perl" => Self::Perl, "perl6" => Self::Perl6, "php" => Self::PHP, "plaintext" => Self::Plaintext, "powershell" => Self::Powershell, "jade" => Self::Pug, "python" => Self::Python, "r" => Self::R, "razor" => Self::Razor, "ruby" => Self::Ruby, "rust" => Self::Rust, "scss" => Self::SCSS, "sass" => Self::SASS, "scala" => Self::Scala, "shaderlab" => Self::ShaderLab, "shellscript" => Self::ShellScript, "sql" => Self::SQL, "swift" => Self::Swift, "typescript" => Self::TypeScript, "typescriptreact" => Self::TypeScriptReact, "tex" => Self::TeX, "vb" => Self::VisualBasic, "xml" => Self::XML, "xsl" => Self::XSL, "yaml" => Self::YAML, _ => Self::Custom(Cow::Borrowed(s)), } } } impl fmt::Display for LanguageKind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let s: String = self.clone().into(); write!(f, "{s}") } } impl LanguageKind { #[must_use] pub fn as_str(&self) -> &str { match self { Self::ABAP => "abap", Self::WindowsBat => "bat", Self::BibTeX => "bibtex", Self::Clojure => "clojure", Self::Coffeescript => "coffeescript", Self::C => "c", Self::CPP => "cpp", Self::CSharp => "csharp", Self::CSS => "css", Self::D => "d", Self::Delphi => "pascal", Self::Diff => "diff", Self::Dart => "dart", Self::Dockerfile => "dockerfile", Self::Elixir => "elixir", Self::Erlang => "erlang", Self::FSharp => "fsharp", Self::GitCommit => "git-commit", Self::GitRebase => "git-rebase", Self::Go => "go", Self::Groovy => "groovy", Self::Handlebars => "handlebars", Self::Haskell => "haskell", Self::HTML => "html", Self::Ini => "ini", Self::Java => "java", Self::JavaScript => "javascript", Self::JavaScriptReact => "javascriptreact", Self::JSON => "json", Self::LaTeX => "latex", Self::Less => "less", Self::Lua => "lua", Self::Makefile => "makefile", Self::Markdown => "markdown", Self::ObjectiveC => "objective-c", Self::ObjectiveCPP => "objective-cpp", Self::Pascal => "pascal", Self::Perl => "perl", Self::Perl6 => "perl6", Self::PHP => "php", Self::Plaintext => "plaintext", Self::Powershell => "powershell", Self::Pug => "jade", Self::Python => "python", Self::R => "r", Self::Razor => "razor", Self::Ruby => "ruby", Self::Rust => "rust", Self::SCSS => "scss", Self::SASS => "sass", Self::Scala => "scala", Self::ShaderLab => "shaderlab", Self::ShellScript => "shellscript", Self::SQL => "sql", Self::Swift => "swift", Self::TypeScript => "typescript", Self::TypeScriptReact => "typescriptreact", Self::TeX => "tex", Self::VisualBasic => "vb", Self::XML => "xml", Self::XSL => "xsl", Self::YAML => "yaml", Self::Custom(any) => any, } } } /// Describes how an [inline completion provider][InlineCompletionItemProvider] was triggered. /// /// @since 3.18.0 #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)] #[serde(into = "u32", try_from = "u32")] pub enum InlineCompletionTriggerKind { /// Completion was triggered explicitly by a user gesture. Invoked, /// Completion was triggered automatically while editing. Automatic, } impl From for u32 { fn from(e: InlineCompletionTriggerKind) -> Self { match e { InlineCompletionTriggerKind::Invoked => 1u32, InlineCompletionTriggerKind::Automatic => 2u32, } } } impl TryFrom for InlineCompletionTriggerKind { type Error = String; fn try_from(v: u32) -> Result>::Error> { match v { 1u32 => Ok(Self::Invoked), 2u32 => Ok(Self::Automatic), _ => Err(format!("Invalid InlineCompletionTriggerKind: {v}")), } } } /// A set of predefined position encoding kinds. /// /// @since 3.17.0 #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize)] #[serde(into = "String", from = "String")] pub enum PositionEncodingKind { /// Character offsets count UTF-8 code units (e.g. bytes). UTF8, /// Character offsets count UTF-16 code units. /// /// This is the default and must always be supported /// by servers UTF16, /// Character offsets count UTF-32 code units. /// /// Implementation note: these are the same as Unicode codepoints, /// so this `PositionEncodingKind` may also be used for an /// encoding-agnostic representation of character offsets. UTF32, /// A custom value. #[serde(untagged)] Custom(Cow<'static, str>), } impl From for String { fn from(e: PositionEncodingKind) -> Self { match e { PositionEncodingKind::UTF8 => "utf-8".to_string(), PositionEncodingKind::UTF16 => "utf-16".to_string(), PositionEncodingKind::UTF32 => "utf-32".to_string(), PositionEncodingKind::Custom(any) => any.into_owned(), } } } impl From for PositionEncodingKind { fn from(v: String) -> Self { match v.as_str() { "utf-8" => Self::UTF8, "utf-16" => Self::UTF16, "utf-32" => Self::UTF32, _ => Self::Custom(Cow::Owned(v)), } } } impl PositionEncodingKind { /// Create a custom `PositionEncodingKind` from a string literal. #[must_use] pub const fn new(s: &'static str) -> Self { Self::Custom(Cow::Borrowed(s)) } } impl From<&'static str> for PositionEncodingKind { fn from(s: &'static str) -> Self { match s { "utf-8" => Self::UTF8, "utf-16" => Self::UTF16, "utf-32" => Self::UTF32, _ => Self::Custom(Cow::Borrowed(s)), } } } impl fmt::Display for PositionEncodingKind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let s: String = self.clone().into(); write!(f, "{s}") } } impl PositionEncodingKind { #[must_use] pub fn as_str(&self) -> &str { match self { Self::UTF8 => "utf-8", Self::UTF16 => "utf-16", Self::UTF32 => "utf-32", Self::Custom(any) => any, } } } /// The file event type #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)] #[serde(into = "u32", try_from = "u32")] pub enum FileChangeType { /// The file got created. Created, /// The file got changed. Changed, /// The file got deleted. Deleted, } impl From for u32 { fn from(e: FileChangeType) -> Self { match e { FileChangeType::Created => 1u32, FileChangeType::Changed => 2u32, FileChangeType::Deleted => 3u32, } } } impl TryFrom for FileChangeType { type Error = String; fn try_from(v: u32) -> Result>::Error> { match v { 1u32 => Ok(Self::Created), 2u32 => Ok(Self::Changed), 3u32 => Ok(Self::Deleted), _ => Err(format!("Invalid FileChangeType: {v}")), } } } #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)] #[serde(into = "u32", from = "u32")] pub enum WatchKind { /// Interested in create events. Create, /// Interested in change events Change, /// Interested in delete events Delete, /// A custom value. #[serde(untagged)] Custom(u32), } impl From for u32 { fn from(e: WatchKind) -> Self { match e { WatchKind::Create => 1u32, WatchKind::Change => 2u32, WatchKind::Delete => 4u32, WatchKind::Custom(any) => any, } } } impl From for WatchKind { fn from(v: u32) -> Self { match v { 1u32 => Self::Create, 2u32 => Self::Change, 4u32 => Self::Delete, _ => Self::Custom(v), } } } /// The diagnostic's severity. #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)] #[serde(into = "u32", try_from = "u32")] pub enum DiagnosticSeverity { /// Reports an error. Error, /// Reports a warning. Warning, /// Reports an information. Information, /// Reports a hint. Hint, } impl From for u32 { fn from(e: DiagnosticSeverity) -> Self { match e { DiagnosticSeverity::Error => 1u32, DiagnosticSeverity::Warning => 2u32, DiagnosticSeverity::Information => 3u32, DiagnosticSeverity::Hint => 4u32, } } } impl TryFrom for DiagnosticSeverity { type Error = String; fn try_from(v: u32) -> Result>::Error> { match v { 1u32 => Ok(Self::Error), 2u32 => Ok(Self::Warning), 3u32 => Ok(Self::Information), 4u32 => Ok(Self::Hint), _ => Err(format!("Invalid DiagnosticSeverity: {v}")), } } } /// The diagnostic tags. /// /// @since 3.15.0 #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)] #[serde(into = "u32", try_from = "u32")] pub enum DiagnosticTag { /// Unused or unnecessary code. /// /// Clients are allowed to render diagnostics with this tag faded out instead of having /// an error squiggle. Unnecessary, /// Deprecated or obsolete code. /// /// Clients are allowed to rendered diagnostics with this tag strike through. Deprecated, } impl From for u32 { fn from(e: DiagnosticTag) -> Self { match e { DiagnosticTag::Unnecessary => 1u32, DiagnosticTag::Deprecated => 2u32, } } } impl TryFrom for DiagnosticTag { type Error = String; fn try_from(v: u32) -> Result>::Error> { match v { 1u32 => Ok(Self::Unnecessary), 2u32 => Ok(Self::Deprecated), _ => Err(format!("Invalid DiagnosticTag: {v}")), } } } /// How a completion was triggered #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)] #[serde(into = "u32", try_from = "u32")] pub enum CompletionTriggerKind { /// Completion was triggered by typing an identifier (24x7 code /// complete), manual invocation (e.g Ctrl+Space) or via API. Invoked, /// Completion was triggered by a trigger character specified by /// the `triggerCharacters` properties of the `CompletionRegistrationOptions`. TriggerCharacter, /// Completion was re-triggered as current completion list is incomplete TriggerForIncompleteCompletions, } impl From for u32 { fn from(e: CompletionTriggerKind) -> Self { match e { CompletionTriggerKind::Invoked => 1u32, CompletionTriggerKind::TriggerCharacter => 2u32, CompletionTriggerKind::TriggerForIncompleteCompletions => 3u32, } } } impl TryFrom for CompletionTriggerKind { type Error = String; fn try_from(v: u32) -> Result>::Error> { match v { 1u32 => Ok(Self::Invoked), 2u32 => Ok(Self::TriggerCharacter), 3u32 => Ok(Self::TriggerForIncompleteCompletions), _ => Err(format!("Invalid CompletionTriggerKind: {v}")), } } } /// Defines how values from a set of defaults and an individual item will be /// merged. /// /// @since 3.18.0 #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)] #[serde(into = "u32", try_from = "u32")] pub enum ApplyKind { /// The value from the individual item (if provided and not `null`) will be /// used instead of the default. Replace, /// The value from the item will be merged with the default. /// /// The specific rules for mergeing values are defined against each field /// that supports merging. Merge, } impl From for u32 { fn from(e: ApplyKind) -> Self { match e { ApplyKind::Replace => 1u32, ApplyKind::Merge => 2u32, } } } impl TryFrom for ApplyKind { type Error = String; fn try_from(v: u32) -> Result>::Error> { match v { 1u32 => Ok(Self::Replace), 2u32 => Ok(Self::Merge), _ => Err(format!("Invalid ApplyKind: {v}")), } } } /// How a signature help was triggered. /// /// @since 3.15.0 #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)] #[serde(into = "u32", try_from = "u32")] pub enum SignatureHelpTriggerKind { /// Signature help was invoked manually by the user or by a command. Invoked, /// Signature help was triggered by a trigger character. TriggerCharacter, /// Signature help was triggered by the cursor moving or by the document content changing. ContentChange, } impl From for u32 { fn from(e: SignatureHelpTriggerKind) -> Self { match e { SignatureHelpTriggerKind::Invoked => 1u32, SignatureHelpTriggerKind::TriggerCharacter => 2u32, SignatureHelpTriggerKind::ContentChange => 3u32, } } } impl TryFrom for SignatureHelpTriggerKind { type Error = String; fn try_from(v: u32) -> Result>::Error> { match v { 1u32 => Ok(Self::Invoked), 2u32 => Ok(Self::TriggerCharacter), 3u32 => Ok(Self::ContentChange), _ => Err(format!("Invalid SignatureHelpTriggerKind: {v}")), } } } /// The reason why code actions were requested. /// /// @since 3.17.0 #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)] #[serde(into = "u32", try_from = "u32")] pub enum CodeActionTriggerKind { /// Code actions were explicitly requested by the user or by an extension. Invoked, /// Code actions were requested automatically. /// /// This typically happens when current selection in a file changes, but can /// also be triggered when file content changes. Automatic, } impl From for u32 { fn from(e: CodeActionTriggerKind) -> Self { match e { CodeActionTriggerKind::Invoked => 1u32, CodeActionTriggerKind::Automatic => 2u32, } } } impl TryFrom for CodeActionTriggerKind { type Error = String; fn try_from(v: u32) -> Result>::Error> { match v { 1u32 => Ok(Self::Invoked), 2u32 => Ok(Self::Automatic), _ => Err(format!("Invalid CodeActionTriggerKind: {v}")), } } } /// A pattern kind describing if a glob pattern matches a file a folder or /// both. /// /// @since 3.16.0 #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)] #[serde(into = "String", try_from = "String")] pub enum FileOperationPatternKind { /// The pattern matches a file only. File, /// The pattern matches a folder only. Folder, } impl From for String { fn from(e: FileOperationPatternKind) -> Self { match e { FileOperationPatternKind::File => "file".to_string(), FileOperationPatternKind::Folder => "folder".to_string(), } } } impl TryFrom for FileOperationPatternKind { type Error = String; fn try_from(v: String) -> Result>::Error> { match v.as_str() { "file" => Ok(Self::File), "folder" => Ok(Self::Folder), _ => Err(format!("Invalid FileOperationPatternKind: {v}")), } } } impl fmt::Display for FileOperationPatternKind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let s: String = (*self).into(); write!(f, "{s}") } } impl FileOperationPatternKind { #[must_use] pub fn as_str(&self) -> &str { match self { Self::File => "file", Self::Folder => "folder", } } } /// A notebook cell kind. /// /// @since 3.17.0 #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)] #[serde(into = "u32", try_from = "u32")] pub enum NotebookCellKind { /// A markup-cell is formatted source that is used for display. Markup, /// A code-cell is source code. Code, } impl From for u32 { fn from(e: NotebookCellKind) -> Self { match e { NotebookCellKind::Markup => 1u32, NotebookCellKind::Code => 2u32, } } } impl TryFrom for NotebookCellKind { type Error = String; fn try_from(v: u32) -> Result>::Error> { match v { 1u32 => Ok(Self::Markup), 2u32 => Ok(Self::Code), _ => Err(format!("Invalid NotebookCellKind: {v}")), } } } #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)] #[serde(into = "String", try_from = "String")] pub enum ResourceOperationKind { /// Supports creating new files and folders. Create, /// Supports renaming existing files and folders. Rename, /// Supports deleting existing files and folders. Delete, } impl From for String { fn from(e: ResourceOperationKind) -> Self { match e { ResourceOperationKind::Create => "create".to_string(), ResourceOperationKind::Rename => "rename".to_string(), ResourceOperationKind::Delete => "delete".to_string(), } } } impl TryFrom for ResourceOperationKind { type Error = String; fn try_from(v: String) -> Result>::Error> { match v.as_str() { "create" => Ok(Self::Create), "rename" => Ok(Self::Rename), "delete" => Ok(Self::Delete), _ => Err(format!("Invalid ResourceOperationKind: {v}")), } } } impl fmt::Display for ResourceOperationKind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let s: String = (*self).into(); write!(f, "{s}") } } impl ResourceOperationKind { #[must_use] pub fn as_str(&self) -> &str { match self { Self::Create => "create", Self::Rename => "rename", Self::Delete => "delete", } } } #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)] #[serde(into = "String", try_from = "String")] pub enum FailureHandlingKind { /// Applying the workspace change is simply aborted if one of the changes provided /// fails. All operations executed before the failing operation stay executed. Abort, /// All operations are executed transactional. That means they either all /// succeed or no changes at all are applied to the workspace. Transactional, /// 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. TextOnlyTransactional, /// The client tries to undo the operations already executed. But there is no /// guarantee that this is succeeding. Undo, } impl From for String { fn from(e: FailureHandlingKind) -> Self { match e { FailureHandlingKind::Abort => "abort".to_string(), FailureHandlingKind::Transactional => "transactional".to_string(), FailureHandlingKind::TextOnlyTransactional => { "textOnlyTransactional".to_string() } FailureHandlingKind::Undo => "undo".to_string(), } } } impl TryFrom for FailureHandlingKind { type Error = String; fn try_from(v: String) -> Result>::Error> { match v.as_str() { "abort" => Ok(Self::Abort), "transactional" => Ok(Self::Transactional), "textOnlyTransactional" => Ok(Self::TextOnlyTransactional), "undo" => Ok(Self::Undo), _ => Err(format!("Invalid FailureHandlingKind: {v}")), } } } impl fmt::Display for FailureHandlingKind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let s: String = (*self).into(); write!(f, "{s}") } } impl FailureHandlingKind { #[must_use] pub fn as_str(&self) -> &str { match self { Self::Abort => "abort", Self::Transactional => "transactional", Self::TextOnlyTransactional => "textOnlyTransactional", Self::Undo => "undo", } } } #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)] #[serde(into = "u32", try_from = "u32")] pub enum PrepareSupportDefaultBehavior { /// The client's default behavior is to select the identifier /// according the to language's syntax rule. Identifier, } impl From for u32 { fn from(e: PrepareSupportDefaultBehavior) -> Self { match e { PrepareSupportDefaultBehavior::Identifier => 1u32, } } } impl TryFrom for PrepareSupportDefaultBehavior { type Error = String; fn try_from(v: u32) -> Result>::Error> { match v { 1u32 => Ok(Self::Identifier), _ => Err(format!("Invalid PrepareSupportDefaultBehavior: {v}")), } } } #[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)] #[serde(into = "String", try_from = "String")] pub enum TokenFormat { Relative, } impl From for String { fn from(e: TokenFormat) -> Self { match e { TokenFormat::Relative => "relative".to_string(), } } } impl TryFrom for TokenFormat { type Error = String; fn try_from(v: String) -> Result>::Error> { match v.as_str() { "relative" => Ok(Self::Relative), _ => Err(format!("Invalid TokenFormat: {v}")), } } } impl fmt::Display for TokenFormat { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let s: String = (*self).into(); write!(f, "{s}") } } impl TokenFormat { #[must_use] pub fn as_str(&self) -> &str { match self { Self::Relative => "relative", } } } impl std::ops::BitOr for WatchKind { type Output = Self; fn bitor(self, rhs: Self) -> Self { (Into::::into(self) | Into::::into(rhs)).into() } } impl std::ops::BitOrAssign for WatchKind { fn bitor_assign(&mut self, rhs: Self) { *self = (Into::::into(*self) | Into::::into(rhs)).into(); } } impl std::ops::BitAnd for WatchKind { type Output = Self; fn bitand(self, rhs: Self) -> Self { (Into::::into(self) & Into::::into(rhs)).into() } } impl std::ops::BitAndAssign for WatchKind { fn bitand_assign(&mut self, rhs: Self) { *self = (Into::::into(*self) & Into::::into(rhs)).into(); } } impl std::ops::BitXor for WatchKind { type Output = Self; fn bitxor(self, rhs: Self) -> Self { (Into::::into(self) ^ Into::::into(rhs)).into() } } impl std::ops::BitXorAssign for WatchKind { fn bitxor_assign(&mut self, rhs: Self) { *self = (Into::::into(*self) ^ Into::::into(rhs)).into(); } } gen-lsp-types-0.8.0/src/generated/notifications.rs000064400000000000000000000301101046102023000202770ustar 00000000000000#[allow(clippy::wildcard_imports)] use super::*; /// The `workspace/didChangeWorkspaceFolders` notification is sent from the client to the server when the workspace /// folder configuration changes. #[derive(Debug)] pub enum DidChangeWorkspaceFoldersNotification {} impl Notification for DidChangeWorkspaceFoldersNotification { const METHOD: LspNotificationMethod<'static> = LspNotificationMethod::WorkspaceDidChangeWorkspaceFolders; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = DidChangeWorkspaceFoldersParams; } /// The `window/workDoneProgress/cancel` notification is sent from the client to the server to cancel a progress /// initiated on the server side. #[derive(Debug)] pub enum WorkDoneProgressCancelNotification {} impl Notification for WorkDoneProgressCancelNotification { const METHOD: LspNotificationMethod<'static> = LspNotificationMethod::WindowWorkDoneProgressCancel; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = WorkDoneProgressCancelParams; } /// The did create files notification is sent from the client to the server when /// files were created from within the client. /// /// @since 3.16.0 #[derive(Debug)] pub enum DidCreateFilesNotification {} impl Notification for DidCreateFilesNotification { const METHOD: LspNotificationMethod<'static> = LspNotificationMethod::WorkspaceDidCreateFiles; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = CreateFilesParams; } /// The did rename files notification is sent from the client to the server when /// files were renamed from within the client. /// /// @since 3.16.0 #[derive(Debug)] pub enum DidRenameFilesNotification {} impl Notification for DidRenameFilesNotification { const METHOD: LspNotificationMethod<'static> = LspNotificationMethod::WorkspaceDidRenameFiles; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = RenameFilesParams; } /// The will delete files request is sent from the client to the server before files are actually /// deleted as long as the deletion is triggered from within the client. /// /// @since 3.16.0 #[derive(Debug)] pub enum DidDeleteFilesNotification {} impl Notification for DidDeleteFilesNotification { const METHOD: LspNotificationMethod<'static> = LspNotificationMethod::WorkspaceDidDeleteFiles; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = DeleteFilesParams; } /// A notification sent when a notebook opens. /// /// @since 3.17.0 #[derive(Debug)] pub enum DidOpenNotebookDocumentNotification {} impl Notification for DidOpenNotebookDocumentNotification { const METHOD: LspNotificationMethod<'static> = LspNotificationMethod::NotebookDocumentDidOpen; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = DidOpenNotebookDocumentParams; } #[derive(Debug)] pub enum DidChangeNotebookDocumentNotification {} impl Notification for DidChangeNotebookDocumentNotification { const METHOD: LspNotificationMethod<'static> = LspNotificationMethod::NotebookDocumentDidChange; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = DidChangeNotebookDocumentParams; } /// A notification sent when a notebook document is saved. /// /// @since 3.17.0 #[derive(Debug)] pub enum DidSaveNotebookDocumentNotification {} impl Notification for DidSaveNotebookDocumentNotification { const METHOD: LspNotificationMethod<'static> = LspNotificationMethod::NotebookDocumentDidSave; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = DidSaveNotebookDocumentParams; } /// A notification sent when a notebook closes. /// /// @since 3.17.0 #[derive(Debug)] pub enum DidCloseNotebookDocumentNotification {} impl Notification for DidCloseNotebookDocumentNotification { const METHOD: LspNotificationMethod<'static> = LspNotificationMethod::NotebookDocumentDidClose; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = DidCloseNotebookDocumentParams; } /// The initialized notification is sent from the client to the /// server after the client is fully initialized and the server /// is allowed to send requests from the server to the client. #[derive(Debug)] pub enum InitializedNotification {} impl Notification for InitializedNotification { const METHOD: LspNotificationMethod<'static> = LspNotificationMethod::Initialized; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = InitializedParams; } /// The exit event is sent from the client to the server to /// ask the server to exit its process. #[derive(Debug)] pub enum ExitNotification {} impl Notification for ExitNotification { const METHOD: LspNotificationMethod<'static> = LspNotificationMethod::Exit; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = (); } /// The configuration change notification is sent from the client to the server /// when the client's configuration has changed. The notification contains /// the changed configuration as defined by the language client. #[derive(Debug)] pub enum DidChangeConfigurationNotification {} impl Notification for DidChangeConfigurationNotification { const METHOD: LspNotificationMethod<'static> = LspNotificationMethod::WorkspaceDidChangeConfiguration; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = DidChangeConfigurationParams; } /// The show message notification is sent from a server to a client to ask /// the client to display a particular message in the user interface. #[derive(Debug)] pub enum ShowMessageNotification {} impl Notification for ShowMessageNotification { const METHOD: LspNotificationMethod<'static> = LspNotificationMethod::WindowShowMessage; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ServerToClient; type Params = ShowMessageParams; } /// The log message notification is sent from the server to the client to ask /// the client to log a particular message. #[derive(Debug)] pub enum LogMessageNotification {} impl Notification for LogMessageNotification { const METHOD: LspNotificationMethod<'static> = LspNotificationMethod::WindowLogMessage; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ServerToClient; type Params = LogMessageParams; } /// The telemetry event notification is sent from the server to the client to ask /// the client to log telemetry data. #[derive(Debug)] pub enum TelemetryEventNotification {} impl Notification for TelemetryEventNotification { const METHOD: LspNotificationMethod<'static> = LspNotificationMethod::TelemetryEvent; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ServerToClient; type Params = LspAny; } /// The document open notification is sent from the client to the server to signal /// newly opened text documents. The document's truth is now managed by the client /// and the server must not try to read the document's truth using the document's /// uri. Open in this sense means it is managed by the client. It doesn't necessarily /// mean that its content is presented in an editor. An open notification must not /// be sent more than once without a corresponding close notification send before. /// This means open and close notification must be balanced and the max open count /// is one. #[derive(Debug)] pub enum DidOpenTextDocumentNotification {} impl Notification for DidOpenTextDocumentNotification { const METHOD: LspNotificationMethod<'static> = LspNotificationMethod::TextDocumentDidOpen; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = DidOpenTextDocumentParams; } /// The document change notification is sent from the client to the server to signal /// changes to a text document. #[derive(Debug)] pub enum DidChangeTextDocumentNotification {} impl Notification for DidChangeTextDocumentNotification { const METHOD: LspNotificationMethod<'static> = LspNotificationMethod::TextDocumentDidChange; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = DidChangeTextDocumentParams; } /// The document close notification is sent from the client to the server when /// the document got closed in the client. The document's truth now exists where /// the document's uri points to (e.g. if the document's uri is a file uri the /// truth now exists on disk). As with the open notification the close notification /// is about managing the document's content. Receiving a close notification /// doesn't mean that the document was open in an editor before. A close /// notification requires a previous open notification to be sent. #[derive(Debug)] pub enum DidCloseTextDocumentNotification {} impl Notification for DidCloseTextDocumentNotification { const METHOD: LspNotificationMethod<'static> = LspNotificationMethod::TextDocumentDidClose; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = DidCloseTextDocumentParams; } /// The document save notification is sent from the client to the server when /// the document got saved in the client. #[derive(Debug)] pub enum DidSaveTextDocumentNotification {} impl Notification for DidSaveTextDocumentNotification { const METHOD: LspNotificationMethod<'static> = LspNotificationMethod::TextDocumentDidSave; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = DidSaveTextDocumentParams; } /// A document will save notification is sent from the client to the server before /// the document is actually saved. #[derive(Debug)] pub enum WillSaveTextDocumentNotification {} impl Notification for WillSaveTextDocumentNotification { const METHOD: LspNotificationMethod<'static> = LspNotificationMethod::TextDocumentWillSave; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = WillSaveTextDocumentParams; } /// The watched files notification is sent from the client to the server when /// the client detects changes to file watched by the language client. #[derive(Debug)] pub enum DidChangeWatchedFilesNotification {} impl Notification for DidChangeWatchedFilesNotification { const METHOD: LspNotificationMethod<'static> = LspNotificationMethod::WorkspaceDidChangeWatchedFiles; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = DidChangeWatchedFilesParams; } /// Diagnostics notification are sent from the server to the client to signal /// results of validation runs. #[derive(Debug)] pub enum PublishDiagnosticsNotification {} impl Notification for PublishDiagnosticsNotification { const METHOD: LspNotificationMethod<'static> = LspNotificationMethod::TextDocumentPublishDiagnostics; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ServerToClient; type Params = PublishDiagnosticsParams; } #[derive(Debug)] pub enum SetTraceNotification {} impl Notification for SetTraceNotification { const METHOD: LspNotificationMethod<'static> = LspNotificationMethod::SetTrace; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = SetTraceParams; } #[derive(Debug)] pub enum LogTraceNotification {} impl Notification for LogTraceNotification { const METHOD: LspNotificationMethod<'static> = LspNotificationMethod::LogTrace; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ServerToClient; type Params = LogTraceParams; } #[derive(Debug)] pub enum CancelNotification {} impl Notification for CancelNotification { const METHOD: LspNotificationMethod<'static> = LspNotificationMethod::CancelRequest; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::Both; type Params = CancelParams; } #[derive(Debug)] pub enum ProgressNotification {} impl Notification for ProgressNotification { const METHOD: LspNotificationMethod<'static> = LspNotificationMethod::Progress; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::Both; type Params = ProgressParams; } gen-lsp-types-0.8.0/src/generated/requests.rs000064400000000000000000001136641046102023000173210ustar 00000000000000#[allow(clippy::wildcard_imports)] use super::*; /// 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. #[derive(Debug)] pub enum ImplementationRequest {} impl Request for ImplementationRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TextDocumentImplementation; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = ImplementationParams; type Result = Option; } impl RequestWithPartialResults for ImplementationRequest { type PartialResult = ImplementationPartialResponse; } /// 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. #[derive(Debug)] pub enum TypeDefinitionRequest {} impl Request for TypeDefinitionRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TextDocumentTypeDefinition; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = TypeDefinitionParams; type Result = Option; } impl RequestWithPartialResults for TypeDefinitionRequest { type PartialResult = TypeDefinitionPartialResponse; } /// The `workspace/workspaceFolders` is sent from the server to the client to fetch the open workspace folders. #[derive(Debug)] pub enum WorkspaceFoldersRequest {} impl Request for WorkspaceFoldersRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::WorkspaceWorkspaceFolders; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ServerToClient; type Params = (); type Result = Option>; } /// The 'workspace/configuration' request is sent from the server to the client to fetch a certain /// configuration setting. /// /// This pull model replaces the old push model were the client signaled configuration change via an /// event. If the server still needs to react to configuration changes (since the server caches the /// result of `workspace/configuration` requests) the server should register for an empty configuration /// change event and empty the cache if such an event is received. #[derive(Debug)] pub enum ConfigurationRequest {} impl Request for ConfigurationRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::WorkspaceConfiguration; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ServerToClient; type Params = ConfigurationParams; type Result = Vec; } /// A request to list all color symbols found in a given text document. The request's /// parameter is of type [`DocumentColorParams`] the /// response is of type [ColorInformation[]][ColorInformation] or a Thenable /// that resolves to such. #[derive(Debug)] pub enum DocumentColorRequest {} impl Request for DocumentColorRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TextDocumentDocumentColor; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = DocumentColorParams; type Result = Vec; } impl RequestWithPartialResults for DocumentColorRequest { type PartialResult = Vec; } /// A request to list all presentation for a color. The request's /// parameter is of type [`ColorPresentationParams`] the /// response is of type [ColorPresentation[]][ColorPresentation] or a Thenable /// that resolves to such. #[derive(Debug)] pub enum ColorPresentationRequest {} impl Request for ColorPresentationRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TextDocumentColorPresentation; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = ColorPresentationParams; type Result = Vec; } impl RequestWithPartialResults for ColorPresentationRequest { type PartialResult = Vec; } /// 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. #[derive(Debug)] pub enum FoldingRangeRequest {} impl Request for FoldingRangeRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TextDocumentFoldingRange; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = FoldingRangeParams; type Result = Option>; } impl RequestWithPartialResults for FoldingRangeRequest { type PartialResult = Vec; } /// A request to refresh the folding ranges in a document. /// /// @since 3.18.0 #[derive(Debug)] pub enum FoldingRangeRefreshRequest {} impl Request for FoldingRangeRefreshRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::WorkspaceFoldingRangeRefresh; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ServerToClient; type Params = (); type Result = (); } /// 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. #[derive(Debug)] pub enum DeclarationRequest {} impl Request for DeclarationRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TextDocumentDeclaration; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = DeclarationParams; type Result = Option; } impl RequestWithPartialResults for DeclarationRequest { type PartialResult = DeclarationPartialResponse; } /// 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. #[derive(Debug)] pub enum SelectionRangeRequest {} impl Request for SelectionRangeRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TextDocumentSelectionRange; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = SelectionRangeParams; type Result = Option>; } impl RequestWithPartialResults for SelectionRangeRequest { type PartialResult = Vec; } /// The `window/workDoneProgress/create` request is sent from the server to the client to initiate progress /// reporting from the server. #[derive(Debug)] pub enum WorkDoneProgressCreateRequest {} impl Request for WorkDoneProgressCreateRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::WindowWorkDoneProgressCreate; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ServerToClient; type Params = WorkDoneProgressCreateParams; type Result = (); } /// 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 #[derive(Debug)] pub enum CallHierarchyPrepareRequest {} impl Request for CallHierarchyPrepareRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TextDocumentPrepareCallHierarchy; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = CallHierarchyPrepareParams; type Result = Option>; } /// A request to resolve the incoming calls for a given `CallHierarchyItem`. /// /// @since 3.16.0 #[derive(Debug)] pub enum CallHierarchyIncomingCallsRequest {} impl Request for CallHierarchyIncomingCallsRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::CallHierarchyIncomingCalls; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = CallHierarchyIncomingCallsParams; type Result = Option>; } impl RequestWithPartialResults for CallHierarchyIncomingCallsRequest { type PartialResult = Vec; } /// A request to resolve the outgoing calls for a given `CallHierarchyItem`. /// /// @since 3.16.0 #[derive(Debug)] pub enum CallHierarchyOutgoingCallsRequest {} impl Request for CallHierarchyOutgoingCallsRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::CallHierarchyOutgoingCalls; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = CallHierarchyOutgoingCallsParams; type Result = Option>; } impl RequestWithPartialResults for CallHierarchyOutgoingCallsRequest { type PartialResult = Vec; } /// @since 3.16.0 #[derive(Debug)] pub enum SemanticTokensRequest {} impl Request for SemanticTokensRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TextDocumentSemanticTokensFull; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = SemanticTokensParams; type Result = Option; } impl RequestWithPartialResults for SemanticTokensRequest { type PartialResult = SemanticTokensPartialResult; } /// @since 3.16.0 #[derive(Debug)] pub enum SemanticTokensDeltaRequest {} impl Request for SemanticTokensDeltaRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TextDocumentSemanticTokensFullDelta; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = SemanticTokensDeltaParams; type Result = Option; } impl RequestWithPartialResults for SemanticTokensDeltaRequest { type PartialResult = SemanticTokensDeltaPartialResponse; } /// @since 3.16.0 #[derive(Debug)] pub enum SemanticTokensRangeRequest {} impl Request for SemanticTokensRangeRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TextDocumentSemanticTokensRange; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = SemanticTokensRangeParams; type Result = Option; } impl RequestWithPartialResults for SemanticTokensRangeRequest { type PartialResult = SemanticTokensPartialResult; } /// @since 3.16.0 #[derive(Debug)] pub enum SemanticTokensRefreshRequest {} impl Request for SemanticTokensRefreshRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::WorkspaceSemanticTokensRefresh; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ServerToClient; type Params = (); type Result = (); } /// A request to show a document. This request might open an /// external program depending on the value of the URI to open. /// For example a request to open `https://code.visualstudio.com/` /// will very likely open the URI in a WEB browser. /// /// @since 3.16.0 #[derive(Debug)] pub enum ShowDocumentRequest {} impl Request for ShowDocumentRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::WindowShowDocument; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ServerToClient; type Params = ShowDocumentParams; type Result = ShowDocumentResult; } /// A request to provide ranges that can be edited together. /// /// @since 3.16.0 #[derive(Debug)] pub enum LinkedEditingRangeRequest {} impl Request for LinkedEditingRangeRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TextDocumentLinkedEditingRange; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = LinkedEditingRangeParams; type Result = Option; } /// 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. /// /// The request can return a `WorkspaceEdit` which will be applied to workspace before the /// files are created. Hence the `WorkspaceEdit` can not manipulate the content of the file /// to be created. /// /// @since 3.16.0 #[derive(Debug)] pub enum WillCreateFilesRequest {} impl Request for WillCreateFilesRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::WorkspaceWillCreateFiles; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = CreateFilesParams; type Result = Option; } /// 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 #[derive(Debug)] pub enum WillRenameFilesRequest {} impl Request for WillRenameFilesRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::WorkspaceWillRenameFiles; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = RenameFilesParams; type Result = Option; } /// 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 #[derive(Debug)] pub enum WillDeleteFilesRequest {} impl Request for WillDeleteFilesRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::WorkspaceWillDeleteFiles; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = DeleteFilesParams; type Result = Option; } /// 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`. #[derive(Debug)] pub enum MonikerRequest {} impl Request for MonikerRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TextDocumentMoniker; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = MonikerParams; type Result = Option>; } impl RequestWithPartialResults for MonikerRequest { type PartialResult = Vec; } /// 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 #[derive(Debug)] pub enum TypeHierarchyPrepareRequest {} impl Request for TypeHierarchyPrepareRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TextDocumentPrepareTypeHierarchy; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = TypeHierarchyPrepareParams; type Result = Option>; } /// A request to resolve the supertypes for a given `TypeHierarchyItem`. /// /// @since 3.17.0 #[derive(Debug)] pub enum TypeHierarchySupertypesRequest {} impl Request for TypeHierarchySupertypesRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TypeHierarchySupertypes; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = TypeHierarchySupertypesParams; type Result = Option>; } impl RequestWithPartialResults for TypeHierarchySupertypesRequest { type PartialResult = Vec; } /// A request to resolve the subtypes for a given `TypeHierarchyItem`. /// /// @since 3.17.0 #[derive(Debug)] pub enum TypeHierarchySubtypesRequest {} impl Request for TypeHierarchySubtypesRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TypeHierarchySubtypes; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = TypeHierarchySubtypesParams; type Result = Option>; } impl RequestWithPartialResults for TypeHierarchySubtypesRequest { type PartialResult = Vec; } /// 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 #[derive(Debug)] pub enum InlineValueRequest {} impl Request for InlineValueRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TextDocumentInlineValue; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = InlineValueParams; type Result = Option>; } impl RequestWithPartialResults for InlineValueRequest { type PartialResult = Vec; } /// @since 3.17.0 #[derive(Debug)] pub enum InlineValueRefreshRequest {} impl Request for InlineValueRefreshRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::WorkspaceInlineValueRefresh; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ServerToClient; type Params = (); type Result = (); } /// 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 #[derive(Debug)] pub enum InlayHintRequest {} impl Request for InlayHintRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TextDocumentInlayHint; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = InlayHintParams; type Result = Option>; } impl RequestWithPartialResults for InlayHintRequest { type PartialResult = Vec; } /// A request to resolve additional properties for an inlay hint. /// The request's parameter is of type [`InlayHint`], the response is /// of type [`InlayHint`] or a Thenable that resolves to such. /// /// @since 3.17.0 #[derive(Debug)] pub enum InlayHintResolveRequest {} impl Request for InlayHintResolveRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::InlayHintResolve; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = InlayHint; type Result = InlayHint; } /// @since 3.17.0 #[derive(Debug)] pub enum InlayHintRefreshRequest {} impl Request for InlayHintRefreshRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::WorkspaceInlayHintRefresh; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ServerToClient; type Params = (); type Result = (); } /// The document diagnostic request definition. /// /// @since 3.17.0 #[derive(Debug)] pub enum DocumentDiagnosticRequest {} impl Request for DocumentDiagnosticRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TextDocumentDiagnostic; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = DocumentDiagnosticParams; type Result = DocumentDiagnosticReport; } impl RequestWithPartialResults for DocumentDiagnosticRequest { type PartialResult = DocumentDiagnosticReportPartialResult; } /// The workspace diagnostic request definition. /// /// @since 3.17.0 #[derive(Debug)] pub enum WorkspaceDiagnosticRequest {} impl Request for WorkspaceDiagnosticRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::WorkspaceDiagnostic; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = WorkspaceDiagnosticParams; type Result = WorkspaceDiagnosticReport; } impl RequestWithPartialResults for WorkspaceDiagnosticRequest { type PartialResult = WorkspaceDiagnosticReportPartialResult; } /// The diagnostic refresh request definition. /// /// @since 3.17.0 #[derive(Debug)] pub enum DiagnosticRefreshRequest {} impl Request for DiagnosticRefreshRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::WorkspaceDiagnosticRefresh; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ServerToClient; type Params = (); type Result = (); } /// A request to provide inline completions in a document. The request's parameter is of /// type [`InlineCompletionParams`], the response is of type /// [InlineCompletion[]][InlineCompletion] or a Thenable that resolves to such. /// /// @since 3.18.0 #[derive(Debug)] pub enum InlineCompletionRequest {} impl Request for InlineCompletionRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TextDocumentInlineCompletion; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = InlineCompletionParams; type Result = Option; } impl RequestWithPartialResults for InlineCompletionRequest { type PartialResult = Vec; } /// The `workspace/textDocumentContent` request is sent from the client to the /// server to request the content of a text document. /// /// @since 3.18.0 #[derive(Debug)] pub enum TextDocumentContentRequest {} impl Request for TextDocumentContentRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::WorkspaceTextDocumentContent; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = TextDocumentContentParams; type Result = TextDocumentContentResult; } /// The `workspace/textDocumentContent` request is sent from the server to the client to refresh /// the content of a specific text document. /// /// @since 3.18.0 #[derive(Debug)] pub enum TextDocumentContentRefreshRequest {} impl Request for TextDocumentContentRefreshRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::WorkspaceTextDocumentContentRefresh; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ServerToClient; type Params = TextDocumentContentRefreshParams; type Result = (); } /// The `client/registerCapability` request is sent from the server to the client to register a new capability /// handler on the client side. #[derive(Debug)] pub enum RegistrationRequest {} impl Request for RegistrationRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::ClientRegisterCapability; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ServerToClient; type Params = RegistrationParams; type Result = (); } /// The `client/unregisterCapability` request is sent from the server to the client to unregister a previously registered capability /// handler on the client side. #[derive(Debug)] pub enum UnregistrationRequest {} impl Request for UnregistrationRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::ClientUnregisterCapability; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ServerToClient; type Params = UnregistrationParams; type Result = (); } /// The initialize request is sent from the client to the server. /// It is sent once as the request after starting up the server. /// The requests parameter is of type [`InitializeParams`] /// the response if of type [`InitializeResult`] of a Thenable that /// resolves to such. #[derive(Debug)] pub enum InitializeRequest {} impl Request for InitializeRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::Initialize; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = InitializeParams; type Result = InitializeResult; } /// A shutdown request is sent from the client to the server. /// It is sent once when the client decides to shutdown the /// server. The only notification that is sent after a shutdown request /// is the exit event. #[derive(Debug)] pub enum ShutdownRequest {} impl Request for ShutdownRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::Shutdown; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = (); type Result = (); } /// 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. #[derive(Debug)] pub enum ShowMessageRequest {} impl Request for ShowMessageRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::WindowShowMessageRequest; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ServerToClient; type Params = ShowMessageRequestParams; type Result = Option; } /// 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. #[derive(Debug)] pub enum WillSaveTextDocumentWaitUntilRequest {} impl Request for WillSaveTextDocumentWaitUntilRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TextDocumentWillSaveWaitUntil; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = WillSaveTextDocumentParams; type Result = Option>; } /// 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`][`CompletionItem::detail`] /// and [`documentation`][`CompletionItem::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. #[derive(Debug)] pub enum CompletionRequest {} impl Request for CompletionRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TextDocumentCompletion; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = CompletionParams; type Result = Option; } impl RequestWithPartialResults for CompletionRequest { type PartialResult = Vec; } /// Request to resolve additional information for a given completion item.The request's /// parameter is of type [`CompletionItem`] the response /// is of type [`CompletionItem`] or a Thenable that resolves to such. #[derive(Debug)] pub enum CompletionResolveRequest {} impl Request for CompletionResolveRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::CompletionItemResolve; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = CompletionItem; type Result = CompletionItem; } /// 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. #[derive(Debug)] pub enum HoverRequest {} impl Request for HoverRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TextDocumentHover; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = HoverParams; type Result = Option; } #[derive(Debug)] pub enum SignatureHelpRequest {} impl Request for SignatureHelpRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TextDocumentSignatureHelp; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = SignatureHelpParams; type Result = Option; } /// 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. #[derive(Debug)] pub enum DefinitionRequest {} impl Request for DefinitionRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TextDocumentDefinition; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = DefinitionParams; type Result = Option; } impl RequestWithPartialResults for DefinitionRequest { type PartialResult = DefinitionPartialResponse; } /// 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. #[derive(Debug)] pub enum ReferencesRequest {} impl Request for ReferencesRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TextDocumentReferences; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = ReferenceParams; type Result = Option>; } impl RequestWithPartialResults for ReferencesRequest { type PartialResult = Vec; } /// Request to resolve a [`DocumentHighlight`] for a given /// text document position. The request's parameter is of type [`TextDocumentPosition`] /// the request response is an array of type [`DocumentHighlight`] /// or a Thenable that resolves to such. #[derive(Debug)] pub enum DocumentHighlightRequest {} impl Request for DocumentHighlightRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TextDocumentDocumentHighlight; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = DocumentHighlightParams; type Result = Option>; } impl RequestWithPartialResults for DocumentHighlightRequest { type PartialResult = Vec; } /// 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. #[derive(Debug)] pub enum DocumentSymbolRequest {} impl Request for DocumentSymbolRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TextDocumentDocumentSymbol; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = DocumentSymbolParams; type Result = Option; } impl RequestWithPartialResults for DocumentSymbolRequest { type PartialResult = DocumentSymbolPartialResponse; } /// A request to provide commands for the given text document and range. #[derive(Debug)] pub enum CodeActionRequest {} impl Request for CodeActionRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TextDocumentCodeAction; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = CodeActionParams; type Result = Option>; } impl RequestWithPartialResults for CodeActionRequest { type PartialResult = Vec; } /// Request to resolve additional information for a given code action.The request's /// parameter is of type [`CodeAction`] the response /// is of type [`CodeAction`] or a Thenable that resolves to such. #[derive(Debug)] pub enum CodeActionResolveRequest {} impl Request for CodeActionResolveRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::CodeActionResolve; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = CodeAction; type Result = CodeAction; } /// 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`. /// #[derive(Debug)] pub enum WorkspaceSymbolRequest {} impl Request for WorkspaceSymbolRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::WorkspaceSymbol; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = WorkspaceSymbolParams; type Result = Option; } impl RequestWithPartialResults for WorkspaceSymbolRequest { type PartialResult = WorkspaceSymbolPartialResponse; } /// A request to resolve the range inside the workspace /// symbol's location. /// /// @since 3.17.0 #[derive(Debug)] pub enum WorkspaceSymbolResolveRequest {} impl Request for WorkspaceSymbolResolveRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::WorkspaceSymbolResolve; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = WorkspaceSymbol; type Result = WorkspaceSymbol; } /// A request to provide code lens for the given text document. #[derive(Debug)] pub enum CodeLensRequest {} impl Request for CodeLensRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TextDocumentCodeLens; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = CodeLensParams; type Result = Option>; } impl RequestWithPartialResults for CodeLensRequest { type PartialResult = Vec; } /// A request to resolve a command for a given code lens. #[derive(Debug)] pub enum CodeLensResolveRequest {} impl Request for CodeLensResolveRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::CodeLensResolve; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = CodeLens; type Result = CodeLens; } /// A request to refresh all code actions /// /// @since 3.16.0 #[derive(Debug)] pub enum CodeLensRefreshRequest {} impl Request for CodeLensRefreshRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::WorkspaceCodeLensRefresh; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ServerToClient; type Params = (); type Result = (); } /// A request to provide document links #[derive(Debug)] pub enum DocumentLinkRequest {} impl Request for DocumentLinkRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TextDocumentDocumentLink; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = DocumentLinkParams; type Result = Option>; } impl RequestWithPartialResults for DocumentLinkRequest { type PartialResult = Vec; } /// Request to resolve additional information for a given document link. The request's /// parameter is of type [`DocumentLink`] the response /// is of type [`DocumentLink`] or a Thenable that resolves to such. #[derive(Debug)] pub enum DocumentLinkResolveRequest {} impl Request for DocumentLinkResolveRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::DocumentLinkResolve; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = DocumentLink; type Result = DocumentLink; } /// A request to format a whole document. #[derive(Debug)] pub enum DocumentFormattingRequest {} impl Request for DocumentFormattingRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TextDocumentFormatting; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = DocumentFormattingParams; type Result = Option>; } /// A request to format a range in a document. #[derive(Debug)] pub enum DocumentRangeFormattingRequest {} impl Request for DocumentRangeFormattingRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TextDocumentRangeFormatting; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = DocumentRangeFormattingParams; type Result = Option>; } /// A request to format ranges in a document. /// /// @since 3.18.0 #[derive(Debug)] pub enum DocumentRangesFormattingRequest {} impl Request for DocumentRangesFormattingRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TextDocumentRangesFormatting; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = DocumentRangesFormattingParams; type Result = Option>; } /// A request to format a document on type. #[derive(Debug)] pub enum DocumentOnTypeFormattingRequest {} impl Request for DocumentOnTypeFormattingRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TextDocumentOnTypeFormatting; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = DocumentOnTypeFormattingParams; type Result = Option>; } /// A request to rename a symbol. #[derive(Debug)] pub enum RenameRequest {} impl Request for RenameRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TextDocumentRename; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = RenameParams; type Result = Option; } /// A request to test and perform the setup necessary for a rename. /// /// @since 3.16 - support for default behavior #[derive(Debug)] pub enum PrepareRenameRequest {} impl Request for PrepareRenameRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::TextDocumentPrepareRename; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = PrepareRenameParams; type Result = Option; } /// 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. #[derive(Debug)] pub enum ExecuteCommandRequest {} impl Request for ExecuteCommandRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::WorkspaceExecuteCommand; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; type Params = ExecuteCommandParams; type Result = Option; } /// A request sent from the server to the client to modified certain resources. #[derive(Debug)] pub enum ApplyWorkspaceEditRequest {} impl Request for ApplyWorkspaceEditRequest { const METHOD: LspRequestMethod<'static> = LspRequestMethod::WorkspaceApplyEdit; const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ServerToClient; type Params = ApplyWorkspaceEditParams; type Result = ApplyWorkspaceEditResult; } gen-lsp-types-0.8.0/src/generated/structures.rs000064400000000000000000014025021046102023000176620ustar 00000000000000use serde::{Deserialize, ser::SerializeSeq as _, Serialize}; use std::collections::HashMap; use crate::json_rpc::deserialize_some; #[allow(clippy::wildcard_imports)] use super::*; #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct ImplementationParams { #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub partial_result_params: PartialResultParams, #[serde(flatten)] pub text_document_position_params: TextDocumentPositionParams, } impl ImplementationParams { #[must_use] pub const fn new( work_done_progress_params: WorkDoneProgressParams, partial_result_params: PartialResultParams, text_document_position_params: TextDocumentPositionParams, ) -> Self { Self { work_done_progress_params, partial_result_params, text_document_position_params, } } } /// Represents a location inside a resource, such as a line /// inside a text file. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct Location { pub uri: Uri, pub range: Range, } impl Location { #[must_use] pub const fn new(uri: Uri, range: Range) -> Self { Self { uri, range } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct ImplementationRegistrationOptions { #[serde(flatten)] pub static_registration_options: StaticRegistrationOptions, #[serde(flatten)] pub text_document_registration_options: TextDocumentRegistrationOptions, #[serde(flatten)] pub implementation_options: ImplementationOptions, } impl ImplementationRegistrationOptions { #[must_use] pub const fn new( static_registration_options: StaticRegistrationOptions, text_document_registration_options: TextDocumentRegistrationOptions, implementation_options: ImplementationOptions, ) -> Self { Self { static_registration_options, text_document_registration_options, implementation_options, } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct TypeDefinitionParams { #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub partial_result_params: PartialResultParams, #[serde(flatten)] pub text_document_position_params: TextDocumentPositionParams, } impl TypeDefinitionParams { #[must_use] pub const fn new( work_done_progress_params: WorkDoneProgressParams, partial_result_params: PartialResultParams, text_document_position_params: TextDocumentPositionParams, ) -> Self { Self { work_done_progress_params, partial_result_params, text_document_position_params, } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct TypeDefinitionRegistrationOptions { #[serde(flatten)] pub static_registration_options: StaticRegistrationOptions, #[serde(flatten)] pub text_document_registration_options: TextDocumentRegistrationOptions, #[serde(flatten)] pub type_definition_options: TypeDefinitionOptions, } impl TypeDefinitionRegistrationOptions { #[must_use] pub const fn new( static_registration_options: StaticRegistrationOptions, text_document_registration_options: TextDocumentRegistrationOptions, type_definition_options: TypeDefinitionOptions, ) -> Self { Self { static_registration_options, text_document_registration_options, type_definition_options, } } } /// A workspace folder inside a client. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct WorkspaceFolder { /// The associated URI for this workspace folder. pub uri: Uri, /// The name of the workspace folder. Used to refer to this /// workspace folder in the user interface. pub name: String, } impl WorkspaceFolder { #[must_use] pub const fn new(uri: Uri, name: String) -> Self { Self { uri, name } } } /// The parameters of a `workspace/didChangeWorkspaceFolders` notification. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct DidChangeWorkspaceFoldersParams { /// The actual workspace folder change event. pub event: WorkspaceFoldersChangeEvent, } impl DidChangeWorkspaceFoldersParams { #[must_use] pub const fn new(event: WorkspaceFoldersChangeEvent) -> Self { Self { event } } } /// The parameters of a configuration request. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct ConfigurationParams { pub items: Vec, } impl ConfigurationParams { #[must_use] pub const fn new(items: Vec) -> Self { Self { items } } } /// Parameters for a [`DocumentColorRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct DocumentColorParams { /// The text document. pub text_document: TextDocumentIdentifier, #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub partial_result_params: PartialResultParams, } impl DocumentColorParams { #[must_use] pub const fn new( text_document: TextDocumentIdentifier, work_done_progress_params: WorkDoneProgressParams, partial_result_params: PartialResultParams, ) -> Self { Self { text_document, work_done_progress_params, partial_result_params, } } } /// Represents a color range from a document. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct ColorInformation { /// The range in the document where this color appears. pub range: Range, /// The actual color value for this color range. pub color: Color, } impl ColorInformation { #[must_use] pub const fn new(range: Range, color: Color) -> Self { Self { range, color } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct DocumentColorRegistrationOptions { #[serde(flatten)] pub static_registration_options: StaticRegistrationOptions, #[serde(flatten)] pub text_document_registration_options: TextDocumentRegistrationOptions, #[serde(flatten)] pub document_color_options: DocumentColorOptions, } impl DocumentColorRegistrationOptions { #[must_use] pub const fn new( static_registration_options: StaticRegistrationOptions, text_document_registration_options: TextDocumentRegistrationOptions, document_color_options: DocumentColorOptions, ) -> Self { Self { static_registration_options, text_document_registration_options, document_color_options, } } } /// Parameters for a [`ColorPresentationRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] #[serde(rename_all = "camelCase")] pub struct ColorPresentationParams { /// The text document. pub text_document: TextDocumentIdentifier, /// The color to request presentations for. pub color: Color, /// The range where the color would be inserted. Serves as a context. pub range: Range, #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub partial_result_params: PartialResultParams, } impl ColorPresentationParams { #[must_use] pub const fn new( text_document: TextDocumentIdentifier, color: Color, range: Range, work_done_progress_params: WorkDoneProgressParams, partial_result_params: PartialResultParams, ) -> Self { Self { text_document, color, range, work_done_progress_params, partial_result_params, } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct ColorPresentation { /// 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. pub label: String, /// An [edit][TextEdit] which is applied to a document when selecting /// this presentation for the color. When `falsy` the [label][`ColorPresentation::label`] /// is used. #[serde(skip_serializing_if = "Option::is_none")] pub text_edit: Option, /// An optional array of additional [text edits][TextEdit] that are applied when /// selecting this color presentation. Edits must not overlap with the main [edit][`ColorPresentation::textEdit`] nor with themselves. #[serde(skip_serializing_if = "Option::is_none")] pub additional_text_edits: Option>, } impl ColorPresentation { #[must_use] pub const fn new( label: String, text_edit: Option, additional_text_edits: Option>, ) -> Self { Self { label, text_edit, additional_text_edits, } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct WorkDoneProgressOptions { #[serde(skip_serializing_if = "Option::is_none")] pub work_done_progress: Option, } impl WorkDoneProgressOptions { #[must_use] pub const fn new(work_done_progress: Option) -> Self { Self { work_done_progress } } } /// General text document registration options. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct TextDocumentRegistrationOptions { /// 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. pub document_selector: Option, } impl TextDocumentRegistrationOptions { #[must_use] pub const fn new(document_selector: Option) -> Self { Self { document_selector } } } /// Parameters for a [`FoldingRangeRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct FoldingRangeParams { /// The text document. pub text_document: TextDocumentIdentifier, #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub partial_result_params: PartialResultParams, } impl FoldingRangeParams { #[must_use] pub const fn new( text_document: TextDocumentIdentifier, work_done_progress_params: WorkDoneProgressParams, partial_result_params: PartialResultParams, ) -> Self { Self { text_document, work_done_progress_params, partial_result_params, } } } /// 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. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct FoldingRange { /// 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. pub start_line: u32, /// The zero-based character offset from where the folded range starts. If not defined, defaults to the length of the start line. #[serde(skip_serializing_if = "Option::is_none")] pub start_character: Option, /// 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. pub end_line: u32, /// The zero-based character offset before the folded range ends. If not defined, defaults to the length of the end line. #[serde(skip_serializing_if = "Option::is_none")] pub end_character: Option, /// 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. #[serde(skip_serializing_if = "Option::is_none")] pub kind: Option, /// 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 #[serde(skip_serializing_if = "Option::is_none")] pub collapsed_text: Option, } impl FoldingRange { #[must_use] pub const fn new( start_line: u32, start_character: Option, end_line: u32, end_character: Option, kind: Option, collapsed_text: Option, ) -> Self { Self { start_line, start_character, end_line, end_character, kind, collapsed_text, } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct FoldingRangeRegistrationOptions { #[serde(flatten)] pub static_registration_options: StaticRegistrationOptions, #[serde(flatten)] pub text_document_registration_options: TextDocumentRegistrationOptions, #[serde(flatten)] pub folding_range_options: FoldingRangeOptions, } impl FoldingRangeRegistrationOptions { #[must_use] pub const fn new( static_registration_options: StaticRegistrationOptions, text_document_registration_options: TextDocumentRegistrationOptions, folding_range_options: FoldingRangeOptions, ) -> Self { Self { static_registration_options, text_document_registration_options, folding_range_options, } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct DeclarationParams { #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub partial_result_params: PartialResultParams, #[serde(flatten)] pub text_document_position_params: TextDocumentPositionParams, } impl DeclarationParams { #[must_use] pub const fn new( work_done_progress_params: WorkDoneProgressParams, partial_result_params: PartialResultParams, text_document_position_params: TextDocumentPositionParams, ) -> Self { Self { work_done_progress_params, partial_result_params, text_document_position_params, } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct DeclarationRegistrationOptions { #[serde(flatten)] pub static_registration_options: StaticRegistrationOptions, #[serde(flatten)] pub declaration_options: DeclarationOptions, #[serde(flatten)] pub text_document_registration_options: TextDocumentRegistrationOptions, } impl DeclarationRegistrationOptions { #[must_use] pub const fn new( static_registration_options: StaticRegistrationOptions, declaration_options: DeclarationOptions, text_document_registration_options: TextDocumentRegistrationOptions, ) -> Self { Self { static_registration_options, declaration_options, text_document_registration_options, } } } /// A parameter literal used in selection range requests. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct SelectionRangeParams { /// The text document. pub text_document: TextDocumentIdentifier, /// The positions inside the text document. pub positions: Vec, #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub partial_result_params: PartialResultParams, } impl SelectionRangeParams { #[must_use] pub const fn new( text_document: TextDocumentIdentifier, positions: Vec, work_done_progress_params: WorkDoneProgressParams, partial_result_params: PartialResultParams, ) -> Self { Self { text_document, positions, work_done_progress_params, partial_result_params, } } } /// A selection range represents a part of a selection hierarchy. A selection range /// may have a parent selection range that contains it. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct SelectionRange { /// The [range][Range] of this selection range. pub range: Range, /// The parent selection range containing this range. Therefore `parent.range` must contain `this.range`. #[serde(skip_serializing_if = "Option::is_none")] pub parent: Option>, } impl SelectionRange { #[must_use] pub const fn new(range: Range, parent: Option>) -> Self { Self { range, parent } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct SelectionRangeRegistrationOptions { #[serde(flatten)] pub static_registration_options: StaticRegistrationOptions, #[serde(flatten)] pub selection_range_options: SelectionRangeOptions, #[serde(flatten)] pub text_document_registration_options: TextDocumentRegistrationOptions, } impl SelectionRangeRegistrationOptions { #[must_use] pub const fn new( static_registration_options: StaticRegistrationOptions, selection_range_options: SelectionRangeOptions, text_document_registration_options: TextDocumentRegistrationOptions, ) -> Self { Self { static_registration_options, selection_range_options, text_document_registration_options, } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct WorkDoneProgressCreateParams { /// The token to be used to report progress. pub token: ProgressToken, } impl WorkDoneProgressCreateParams { #[must_use] pub const fn new(token: ProgressToken) -> Self { Self { token } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct WorkDoneProgressCancelParams { /// The token to be used to report progress. pub token: ProgressToken, } impl WorkDoneProgressCancelParams { #[must_use] pub const fn new(token: ProgressToken) -> Self { Self { token } } } /// The parameter of a `textDocument/prepareCallHierarchy` request. /// /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct CallHierarchyPrepareParams { #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub text_document_position_params: TextDocumentPositionParams, } impl CallHierarchyPrepareParams { #[must_use] pub const fn new( work_done_progress_params: WorkDoneProgressParams, text_document_position_params: TextDocumentPositionParams, ) -> Self { Self { work_done_progress_params, text_document_position_params, } } } /// Represents programming constructs like functions or constructors in the context /// of call hierarchy. /// /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct CallHierarchyItem { /// The name of this item. pub name: String, /// The kind of this item. pub kind: SymbolKind, /// Tags for this item. #[serde(skip_serializing_if = "Option::is_none")] pub tags: Option>, /// More detail for this item, e.g. the signature of a function. #[serde(skip_serializing_if = "Option::is_none")] pub detail: Option, /// The resource identifier of this item. pub uri: Uri, /// The range enclosing this symbol not including leading/trailing whitespace but everything else, e.g. comments and code. pub range: Range, /// The range that should be selected and revealed when this symbol is being picked, e.g. the name of a function. /// Must be contained by the [`range`][`CallHierarchyItem::range`]. pub selection_range: Range, /// A data entry field that is preserved between a call hierarchy prepare and /// incoming calls or outgoing calls requests. #[serde(skip_serializing_if = "Option::is_none")] pub data: Option, } impl CallHierarchyItem { #[must_use] pub const fn new( name: String, kind: SymbolKind, tags: Option>, detail: Option, uri: Uri, range: Range, selection_range: Range, data: Option, ) -> Self { Self { name, kind, tags, detail, uri, range, selection_range, data, } } } /// Call hierarchy options used during static or dynamic registration. /// /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct CallHierarchyRegistrationOptions { #[serde(flatten)] pub static_registration_options: StaticRegistrationOptions, #[serde(flatten)] pub text_document_registration_options: TextDocumentRegistrationOptions, #[serde(flatten)] pub call_hierarchy_options: CallHierarchyOptions, } impl CallHierarchyRegistrationOptions { #[must_use] pub const fn new( static_registration_options: StaticRegistrationOptions, text_document_registration_options: TextDocumentRegistrationOptions, call_hierarchy_options: CallHierarchyOptions, ) -> Self { Self { static_registration_options, text_document_registration_options, call_hierarchy_options, } } } /// The parameter of a `callHierarchy/incomingCalls` request. /// /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct CallHierarchyIncomingCallsParams { pub item: CallHierarchyItem, #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub partial_result_params: PartialResultParams, } impl CallHierarchyIncomingCallsParams { #[must_use] pub const fn new( item: CallHierarchyItem, work_done_progress_params: WorkDoneProgressParams, partial_result_params: PartialResultParams, ) -> Self { Self { item, work_done_progress_params, partial_result_params, } } } /// Represents an incoming call, e.g. a caller of a method or constructor. /// /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct CallHierarchyIncomingCall { /// The item that makes the call. pub from: CallHierarchyItem, /// The ranges at which the calls appear. This is relative to the caller /// denoted by [`this.from`][`CallHierarchyIncomingCall::from`]. pub from_ranges: Vec, } impl CallHierarchyIncomingCall { #[must_use] pub const fn new(from: CallHierarchyItem, from_ranges: Vec) -> Self { Self { from, from_ranges } } } /// The parameter of a `callHierarchy/outgoingCalls` request. /// /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct CallHierarchyOutgoingCallsParams { pub item: CallHierarchyItem, #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub partial_result_params: PartialResultParams, } impl CallHierarchyOutgoingCallsParams { #[must_use] pub const fn new( item: CallHierarchyItem, work_done_progress_params: WorkDoneProgressParams, partial_result_params: PartialResultParams, ) -> Self { Self { item, work_done_progress_params, partial_result_params, } } } /// Represents an outgoing call, e.g. calling a getter from a method or a method from a constructor etc. /// /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct CallHierarchyOutgoingCall { /// The item that is called. pub to: CallHierarchyItem, /// The range at which this item is called. This is the range relative to the caller, e.g the item /// passed to [`provideCallHierarchyOutgoingCalls`][`CallHierarchyItemProvider::provideCallHierarchyOutgoingCalls`] /// and not [`this.to`][`CallHierarchyOutgoingCall::to`]. pub from_ranges: Vec, } impl CallHierarchyOutgoingCall { #[must_use] pub const fn new(to: CallHierarchyItem, from_ranges: Vec) -> Self { Self { to, from_ranges } } } /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct SemanticTokensParams { /// The text document. pub text_document: TextDocumentIdentifier, #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub partial_result_params: PartialResultParams, } impl SemanticTokensParams { #[must_use] pub const fn new( text_document: TextDocumentIdentifier, work_done_progress_params: WorkDoneProgressParams, partial_result_params: PartialResultParams, ) -> Self { Self { text_document, work_done_progress_params, partial_result_params, } } } /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct SemanticTokens { /// An optional result id. If provided and clients support delta updating /// the client will include the result id in the next semantic token request. /// A server can then instead of computing all semantic tokens again simply /// send a delta. #[serde(skip_serializing_if = "Option::is_none")] pub result_id: Option, /// The actual tokens. #[serde( deserialize_with = "SemanticToken::deserialize_tokens", serialize_with = "SemanticToken::serialize_tokens" )] pub data: Vec, } impl SemanticTokens { #[must_use] pub const fn new(result_id: Option, data: Vec) -> Self { Self { result_id, data } } } /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct SemanticTokensPartialResult { #[serde( deserialize_with = "SemanticToken::deserialize_tokens", serialize_with = "SemanticToken::serialize_tokens" )] pub data: Vec, } impl SemanticTokensPartialResult { #[must_use] pub const fn new(data: Vec) -> Self { Self { data } } } /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct SemanticTokensRegistrationOptions { #[serde(flatten)] pub static_registration_options: StaticRegistrationOptions, #[serde(flatten)] pub text_document_registration_options: TextDocumentRegistrationOptions, #[serde(flatten)] pub semantic_tokens_options: SemanticTokensOptions, } impl SemanticTokensRegistrationOptions { #[must_use] pub const fn new( static_registration_options: StaticRegistrationOptions, text_document_registration_options: TextDocumentRegistrationOptions, semantic_tokens_options: SemanticTokensOptions, ) -> Self { Self { static_registration_options, text_document_registration_options, semantic_tokens_options, } } } /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct SemanticTokensDeltaParams { /// The text document. pub text_document: TextDocumentIdentifier, /// The result id of a previous response. The result Id can either point to a full response /// or a delta response depending on what was received last. pub previous_result_id: String, #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub partial_result_params: PartialResultParams, } impl SemanticTokensDeltaParams { #[must_use] pub const fn new( text_document: TextDocumentIdentifier, previous_result_id: String, work_done_progress_params: WorkDoneProgressParams, partial_result_params: PartialResultParams, ) -> Self { Self { text_document, previous_result_id, work_done_progress_params, partial_result_params, } } } /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct SemanticTokensDelta { #[serde(skip_serializing_if = "Option::is_none")] pub result_id: Option, /// The semantic token edits to transform a previous result into a new result. pub edits: Vec, } impl SemanticTokensDelta { #[must_use] pub const fn new(result_id: Option, edits: Vec) -> Self { Self { result_id, edits } } } /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct SemanticTokensDeltaPartialResult { pub edits: Vec, } impl SemanticTokensDeltaPartialResult { #[must_use] pub const fn new(edits: Vec) -> Self { Self { edits } } } /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct SemanticTokensRangeParams { /// The text document. pub text_document: TextDocumentIdentifier, /// The range the semantic tokens are requested for. pub range: Range, #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub partial_result_params: PartialResultParams, } impl SemanticTokensRangeParams { #[must_use] pub const fn new( text_document: TextDocumentIdentifier, range: Range, work_done_progress_params: WorkDoneProgressParams, partial_result_params: PartialResultParams, ) -> Self { Self { text_document, range, work_done_progress_params, partial_result_params, } } } /// Params to show a resource in the UI. /// /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct ShowDocumentParams { /// The uri to show. pub uri: Uri, /// Indicates to show the resource in an external program. /// To show, for example, `https://code.visualstudio.com/` /// in the default WEB browser set `external` to `true`. #[serde(skip_serializing_if = "Option::is_none")] pub external: Option, /// An optional property to indicate whether the editor /// showing the document should take focus or not. /// Clients might ignore this property if an external /// program is started. #[serde(skip_serializing_if = "Option::is_none")] pub take_focus: Option, /// An optional selection range if the document is a text /// document. Clients might ignore the property if an /// external program is started or the file is not a text /// file. #[serde(skip_serializing_if = "Option::is_none")] pub selection: Option, } impl ShowDocumentParams { #[must_use] pub const fn new( uri: Uri, external: Option, take_focus: Option, selection: Option, ) -> Self { Self { uri, external, take_focus, selection, } } } /// The result of a showDocument request. /// /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct ShowDocumentResult { /// A boolean indicating if the show was successful. pub success: bool, } impl ShowDocumentResult { #[must_use] pub const fn new(success: bool) -> Self { Self { success } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct LinkedEditingRangeParams { #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub text_document_position_params: TextDocumentPositionParams, } impl LinkedEditingRangeParams { #[must_use] pub const fn new( work_done_progress_params: WorkDoneProgressParams, text_document_position_params: TextDocumentPositionParams, ) -> Self { Self { work_done_progress_params, text_document_position_params, } } } /// The result of a linked editing range request. /// /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct LinkedEditingRanges { /// A list of ranges that can be edited together. The ranges must have /// identical length and contain identical text content. The ranges cannot overlap. pub ranges: Vec, /// An optional word pattern (regular expression) that describes valid contents for /// the given ranges. If no pattern is provided, the client configuration's word /// pattern will be used. #[serde(skip_serializing_if = "Option::is_none")] pub word_pattern: Option, } impl LinkedEditingRanges { #[must_use] pub const fn new(ranges: Vec, word_pattern: Option) -> Self { Self { ranges, word_pattern } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct LinkedEditingRangeRegistrationOptions { #[serde(flatten)] pub static_registration_options: StaticRegistrationOptions, #[serde(flatten)] pub text_document_registration_options: TextDocumentRegistrationOptions, #[serde(flatten)] pub linked_editing_range_options: LinkedEditingRangeOptions, } impl LinkedEditingRangeRegistrationOptions { #[must_use] pub const fn new( static_registration_options: StaticRegistrationOptions, text_document_registration_options: TextDocumentRegistrationOptions, linked_editing_range_options: LinkedEditingRangeOptions, ) -> Self { Self { static_registration_options, text_document_registration_options, linked_editing_range_options, } } } /// The parameters sent in notifications/requests for user-initiated creation of /// files. /// /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct CreateFilesParams { /// An array of all files/folders created in this operation. pub files: Vec, } impl CreateFilesParams { #[must_use] pub const fn new(files: Vec) -> Self { Self { files } } } /// A workspace edit represents changes to many resources managed in the workspace. The edit /// should either provide `changes` or `documentChanges`. If documentChanges are present /// they are preferred over `changes` if the client can handle versioned document edits. /// /// Since version 3.13.0 a workspace edit can contain resource operations as well. If resource /// operations are present clients need to execute the operations in the order in which they /// are provided. So a workspace edit for example can consist of the following two changes: /// (1) a create file a.txt and (2) a text document edit which insert text into file a.txt. /// /// An invalid sequence (e.g. (1) delete file a.txt and (2) insert text into file a.txt) will /// cause failure of the operation. How the client recovers from the failure is described by /// the client capability: `workspace.workspaceEdit.failureHandling` #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Default)] #[serde(rename_all = "camelCase")] pub struct WorkspaceEdit { /// Holds changes to existing resources. #[serde(skip_serializing_if = "Option::is_none")] pub changes: Option>>, /// Depending on the client capability `workspace.workspaceEdit.resourceOperations` document changes /// are either an array of `TextDocumentEdit`s to express changes to n different text documents /// where each text document edit addresses a specific version of a text document. Or it can contain /// above `TextDocumentEdit`s mixed with create, rename and delete file / folder operations. /// /// Whether a client supports versioned document edits is expressed via /// `workspace.workspaceEdit.documentChanges` client capability. /// /// If a client neither supports `documentChanges` nor `workspace.workspaceEdit.resourceOperations` then /// only plain `TextEdit`s using the `changes` property are supported. #[serde(skip_serializing_if = "Option::is_none")] pub document_changes: Option>, /// A map of change annotations that can be referenced in `AnnotatedTextEdit`s or create, rename and /// delete file / folder operations. /// /// Whether clients honor this property depends on the client capability `workspace.changeAnnotationSupport`. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub change_annotations: Option< HashMap, >, } impl WorkspaceEdit { #[must_use] pub const fn new( changes: Option>>, document_changes: Option>, change_annotations: Option>, ) -> Self { Self { changes, document_changes, change_annotations, } } } /// The options to register for file operations. /// /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct FileOperationRegistrationOptions { /// The actual filters. pub filters: Vec, } impl FileOperationRegistrationOptions { #[must_use] pub const fn new(filters: Vec) -> Self { Self { filters } } } /// The parameters sent in notifications/requests for user-initiated renames of /// files. /// /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct RenameFilesParams { /// An array of all files/folders renamed in this operation. When a folder is renamed, only /// the folder will be included, and not its children. pub files: Vec, } impl RenameFilesParams { #[must_use] pub const fn new(files: Vec) -> Self { Self { files } } } /// The parameters sent in notifications/requests for user-initiated deletes of /// files. /// /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct DeleteFilesParams { /// An array of all files/folders deleted in this operation. pub files: Vec, } impl DeleteFilesParams { #[must_use] pub const fn new(files: Vec) -> Self { Self { files } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct MonikerParams { #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub partial_result_params: PartialResultParams, #[serde(flatten)] pub text_document_position_params: TextDocumentPositionParams, } impl MonikerParams { #[must_use] pub const fn new( work_done_progress_params: WorkDoneProgressParams, partial_result_params: PartialResultParams, text_document_position_params: TextDocumentPositionParams, ) -> Self { Self { work_done_progress_params, partial_result_params, text_document_position_params, } } } /// Moniker definition to match LSIF 0.5 moniker definition. /// /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct Moniker { /// The scheme of the moniker. For example tsc or .Net pub scheme: String, /// The identifier of the moniker. The value is opaque in LSIF however /// schema owners are allowed to define the structure if they want. pub identifier: String, /// The scope in which the moniker is unique pub unique: UniquenessLevel, /// The moniker kind if known. #[serde(skip_serializing_if = "Option::is_none")] pub kind: Option, } impl Moniker { #[must_use] pub const fn new( scheme: String, identifier: String, unique: UniquenessLevel, kind: Option, ) -> Self { Self { scheme, identifier, unique, kind, } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct MonikerRegistrationOptions { #[serde(flatten)] pub text_document_registration_options: TextDocumentRegistrationOptions, #[serde(flatten)] pub moniker_options: MonikerOptions, } impl MonikerRegistrationOptions { #[must_use] pub const fn new( text_document_registration_options: TextDocumentRegistrationOptions, moniker_options: MonikerOptions, ) -> Self { Self { text_document_registration_options, moniker_options, } } } /// The parameter of a `textDocument/prepareTypeHierarchy` request. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct TypeHierarchyPrepareParams { #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub text_document_position_params: TextDocumentPositionParams, } impl TypeHierarchyPrepareParams { #[must_use] pub const fn new( work_done_progress_params: WorkDoneProgressParams, text_document_position_params: TextDocumentPositionParams, ) -> Self { Self { work_done_progress_params, text_document_position_params, } } } /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct TypeHierarchyItem { /// The name of this item. pub name: String, /// The kind of this item. pub kind: SymbolKind, /// Tags for this item. #[serde(skip_serializing_if = "Option::is_none")] pub tags: Option>, /// More detail for this item, e.g. the signature of a function. #[serde(skip_serializing_if = "Option::is_none")] pub detail: Option, /// The resource identifier of this item. pub uri: Uri, /// The range enclosing this symbol not including leading/trailing whitespace /// but everything else, e.g. comments and code. pub 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`][`TypeHierarchyItem::range`]. pub selection_range: Range, /// A data entry field that is preserved between a type hierarchy prepare and /// supertypes or subtypes requests. It could also be used to identify the /// type hierarchy in the server, helping improve the performance on /// resolving supertypes and subtypes. #[serde(skip_serializing_if = "Option::is_none")] pub data: Option, } impl TypeHierarchyItem { #[must_use] pub const fn new( name: String, kind: SymbolKind, tags: Option>, detail: Option, uri: Uri, range: Range, selection_range: Range, data: Option, ) -> Self { Self { name, kind, tags, detail, uri, range, selection_range, data, } } } /// Type hierarchy options used during static or dynamic registration. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct TypeHierarchyRegistrationOptions { #[serde(flatten)] pub static_registration_options: StaticRegistrationOptions, #[serde(flatten)] pub text_document_registration_options: TextDocumentRegistrationOptions, #[serde(flatten)] pub type_hierarchy_options: TypeHierarchyOptions, } impl TypeHierarchyRegistrationOptions { #[must_use] pub const fn new( static_registration_options: StaticRegistrationOptions, text_document_registration_options: TextDocumentRegistrationOptions, type_hierarchy_options: TypeHierarchyOptions, ) -> Self { Self { static_registration_options, text_document_registration_options, type_hierarchy_options, } } } /// The parameter of a `typeHierarchy/supertypes` request. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct TypeHierarchySupertypesParams { pub item: TypeHierarchyItem, #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub partial_result_params: PartialResultParams, } impl TypeHierarchySupertypesParams { #[must_use] pub const fn new( item: TypeHierarchyItem, work_done_progress_params: WorkDoneProgressParams, partial_result_params: PartialResultParams, ) -> Self { Self { item, work_done_progress_params, partial_result_params, } } } /// The parameter of a `typeHierarchy/subtypes` request. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct TypeHierarchySubtypesParams { pub item: TypeHierarchyItem, #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub partial_result_params: PartialResultParams, } impl TypeHierarchySubtypesParams { #[must_use] pub const fn new( item: TypeHierarchyItem, work_done_progress_params: WorkDoneProgressParams, partial_result_params: PartialResultParams, ) -> Self { Self { item, work_done_progress_params, partial_result_params, } } } /// A parameter literal used in inline value requests. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct InlineValueParams { /// The text document. pub text_document: TextDocumentIdentifier, /// The document range for which inline values information will be returned. pub range: Range, /// Additional information about the context in which inline values information was /// requested. */ pub context: InlineValueContext, #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, } impl InlineValueParams { #[must_use] pub const fn new( text_document: TextDocumentIdentifier, range: Range, context: InlineValueContext, work_done_progress_params: WorkDoneProgressParams, ) -> Self { Self { text_document, range, context, work_done_progress_params, } } } /// Inline value options used during static or dynamic registration. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct InlineValueRegistrationOptions { #[serde(flatten)] pub static_registration_options: StaticRegistrationOptions, #[serde(flatten)] pub inline_value_options: InlineValueOptions, #[serde(flatten)] pub text_document_registration_options: TextDocumentRegistrationOptions, } impl InlineValueRegistrationOptions { #[must_use] pub const fn new( static_registration_options: StaticRegistrationOptions, inline_value_options: InlineValueOptions, text_document_registration_options: TextDocumentRegistrationOptions, ) -> Self { Self { static_registration_options, inline_value_options, text_document_registration_options, } } } /// A parameter literal used in inlay hint requests. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct InlayHintParams { /// The text document. pub text_document: TextDocumentIdentifier, /// The document range for which inlay hints should be computed. pub range: Range, #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, } impl InlayHintParams { #[must_use] pub const fn new( text_document: TextDocumentIdentifier, range: Range, work_done_progress_params: WorkDoneProgressParams, ) -> Self { Self { text_document, range, work_done_progress_params, } } } /// Inlay hint information. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct InlayHint { /// The position of this hint. /// /// If multiple hints have the same position, they will be shown in the order /// they appear in the response. pub position: Position, /// The label of this hint. A human readable string or an array of /// InlayHintLabelPart label parts. /// /// *Note* that neither the string nor the label part can be empty. pub label: Label, /// The kind of this hint. Can be omitted in which case the client /// should fall back to a reasonable default. #[serde(skip_serializing_if = "Option::is_none")] pub kind: Option, /// Optional text edits that are performed when accepting this inlay hint. /// /// *Note* that edits are expected to change the document so that the inlay /// hint (or its nearest variant) is now part of the document and the inlay /// hint itself is now obsolete. #[serde(skip_serializing_if = "Option::is_none")] pub text_edits: Option>, /// The tooltip text when you hover over this item. #[serde(skip_serializing_if = "Option::is_none")] pub tooltip: Option, /// Render padding before the hint. /// /// Note: Padding should use the editor's background color, not the /// background color of the hint itself. That means padding can be used /// to visually align/separate an inlay hint. #[serde(skip_serializing_if = "Option::is_none")] pub padding_left: Option, /// Render padding after the hint. /// /// Note: Padding should use the editor's background color, not the /// background color of the hint itself. That means padding can be used /// to visually align/separate an inlay hint. #[serde(skip_serializing_if = "Option::is_none")] pub padding_right: Option, /// A data entry field that is preserved on an inlay hint between /// a `textDocument/inlayHint` and a `inlayHint/resolve` request. #[serde(skip_serializing_if = "Option::is_none")] pub data: Option, } impl InlayHint { #[must_use] pub const fn new( position: Position, label: Label, kind: Option, text_edits: Option>, tooltip: Option, padding_left: Option, padding_right: Option, data: Option, ) -> Self { Self { position, label, kind, text_edits, tooltip, padding_left, padding_right, data, } } } /// Inlay hint options used during static or dynamic registration. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct InlayHintRegistrationOptions { #[serde(flatten)] pub static_registration_options: StaticRegistrationOptions, #[serde(flatten)] pub inlay_hint_options: InlayHintOptions, #[serde(flatten)] pub text_document_registration_options: TextDocumentRegistrationOptions, } impl InlayHintRegistrationOptions { #[must_use] pub const fn new( static_registration_options: StaticRegistrationOptions, inlay_hint_options: InlayHintOptions, text_document_registration_options: TextDocumentRegistrationOptions, ) -> Self { Self { static_registration_options, inlay_hint_options, text_document_registration_options, } } } /// Parameters of the document diagnostic request. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct DocumentDiagnosticParams { /// The text document. pub text_document: TextDocumentIdentifier, /// The additional identifier provided during registration. #[serde(skip_serializing_if = "Option::is_none")] pub identifier: Option, /// The result id of a previous response if provided. #[serde(skip_serializing_if = "Option::is_none")] pub previous_result_id: Option, #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub partial_result_params: PartialResultParams, } impl DocumentDiagnosticParams { #[must_use] pub const fn new( text_document: TextDocumentIdentifier, identifier: Option, previous_result_id: Option, work_done_progress_params: WorkDoneProgressParams, partial_result_params: PartialResultParams, ) -> Self { Self { text_document, identifier, previous_result_id, work_done_progress_params, partial_result_params, } } } /// A partial result for a document diagnostic report. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Default)] #[serde(rename_all = "camelCase")] pub struct DocumentDiagnosticReportPartialResult { pub related_documents: HashMap, } impl DocumentDiagnosticReportPartialResult { #[must_use] pub const fn new(related_documents: HashMap) -> Self { Self { related_documents } } } /// Cancellation data returned from a diagnostic request. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct DiagnosticServerCancellationData { pub retrigger_request: bool, } impl DiagnosticServerCancellationData { #[must_use] pub const fn new(retrigger_request: bool) -> Self { Self { retrigger_request } } } /// Diagnostic registration options. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct DiagnosticRegistrationOptions { #[serde(flatten)] pub static_registration_options: StaticRegistrationOptions, #[serde(flatten)] pub text_document_registration_options: TextDocumentRegistrationOptions, #[serde(flatten)] pub diagnostic_options: DiagnosticOptions, } impl DiagnosticRegistrationOptions { #[must_use] pub const fn new( static_registration_options: StaticRegistrationOptions, text_document_registration_options: TextDocumentRegistrationOptions, diagnostic_options: DiagnosticOptions, ) -> Self { Self { static_registration_options, text_document_registration_options, diagnostic_options, } } } /// Parameters of the workspace diagnostic request. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct WorkspaceDiagnosticParams { /// The additional identifier provided during registration. #[serde(skip_serializing_if = "Option::is_none")] pub identifier: Option, /// The currently known diagnostic reports with their /// previous result ids. pub previous_result_ids: Vec, #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub partial_result_params: PartialResultParams, } impl WorkspaceDiagnosticParams { #[must_use] pub const fn new( identifier: Option, previous_result_ids: Vec, work_done_progress_params: WorkDoneProgressParams, partial_result_params: PartialResultParams, ) -> Self { Self { identifier, previous_result_ids, work_done_progress_params, partial_result_params, } } } /// A workspace diagnostic report. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct WorkspaceDiagnosticReport { pub items: Vec, } impl WorkspaceDiagnosticReport { #[must_use] pub const fn new(items: Vec) -> Self { Self { items } } } /// A partial result for a workspace diagnostic report. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct WorkspaceDiagnosticReportPartialResult { pub items: Vec, } impl WorkspaceDiagnosticReportPartialResult { #[must_use] pub const fn new(items: Vec) -> Self { Self { items } } } /// The params sent in an open notebook document notification. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct DidOpenNotebookDocumentParams { /// The notebook document that got opened. pub notebook_document: NotebookDocument, /// The text documents that represent the content /// of a notebook cell. pub cell_text_documents: Vec, } impl DidOpenNotebookDocumentParams { #[must_use] pub const fn new( notebook_document: NotebookDocument, cell_text_documents: Vec, ) -> Self { Self { notebook_document, cell_text_documents, } } } /// Registration options specific to a notebook. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct NotebookDocumentSyncRegistrationOptions { #[serde(flatten)] pub static_registration_options: StaticRegistrationOptions, #[serde(flatten)] pub notebook_document_sync_options: NotebookDocumentSyncOptions, } impl NotebookDocumentSyncRegistrationOptions { #[must_use] pub const fn new( static_registration_options: StaticRegistrationOptions, notebook_document_sync_options: NotebookDocumentSyncOptions, ) -> Self { Self { static_registration_options, notebook_document_sync_options, } } } /// The params sent in a change notebook document notification. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct DidChangeNotebookDocumentParams { /// 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. pub notebook_document: VersionedNotebookDocumentIdentifier, /// 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. pub change: NotebookDocumentChangeEvent, } impl DidChangeNotebookDocumentParams { #[must_use] pub const fn new( notebook_document: VersionedNotebookDocumentIdentifier, change: NotebookDocumentChangeEvent, ) -> Self { Self { notebook_document, change } } } /// The params sent in a save notebook document notification. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct DidSaveNotebookDocumentParams { /// The notebook document that got saved. pub notebook_document: NotebookDocumentIdentifier, } impl DidSaveNotebookDocumentParams { #[must_use] pub const fn new(notebook_document: NotebookDocumentIdentifier) -> Self { Self { notebook_document } } } /// The params sent in a close notebook document notification. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct DidCloseNotebookDocumentParams { /// The notebook document that got closed. pub notebook_document: NotebookDocumentIdentifier, /// The text documents that represent the content /// of a notebook cell that got closed. pub cell_text_documents: Vec, } impl DidCloseNotebookDocumentParams { #[must_use] pub const fn new( notebook_document: NotebookDocumentIdentifier, cell_text_documents: Vec, ) -> Self { Self { notebook_document, cell_text_documents, } } } /// A parameter literal used in inline completion requests. /// /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct InlineCompletionParams { /// Additional information about the context in which inline completions were /// requested. pub context: InlineCompletionContext, #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub text_document_position_params: TextDocumentPositionParams, } impl InlineCompletionParams { #[must_use] pub const fn new( context: InlineCompletionContext, work_done_progress_params: WorkDoneProgressParams, text_document_position_params: TextDocumentPositionParams, ) -> Self { Self { context, work_done_progress_params, text_document_position_params, } } } /// Represents a collection of [inline completion items][InlineCompletionItem] to be presented in the editor. /// /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct InlineCompletionList { /// The inline completion items pub items: Vec, } impl InlineCompletionList { #[must_use] pub const fn new(items: Vec) -> Self { Self { items } } } /// An inline completion item represents a text snippet that is proposed inline to complete text that is being typed. /// /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct InlineCompletionItem { /// The text to replace the range with. Must be set. pub insert_text: InsertText, /// A text that is used to decide if this inline completion should be shown. When `falsy` the [`InlineCompletionItem::insertText`] is used. #[serde(skip_serializing_if = "Option::is_none")] pub filter_text: Option, /// The range to replace. Must begin and end on the same line. #[serde(skip_serializing_if = "Option::is_none")] pub range: Option, /// An optional [`Command`] that is executed *after* inserting this completion. #[serde(skip_serializing_if = "Option::is_none")] pub command: Option, } impl InlineCompletionItem { #[must_use] pub const fn new( insert_text: InsertText, filter_text: Option, range: Option, command: Option, ) -> Self { Self { insert_text, filter_text, range, command, } } } /// Inline completion options used during static or dynamic registration. /// /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct InlineCompletionRegistrationOptions { #[serde(flatten)] pub static_registration_options: StaticRegistrationOptions, #[serde(flatten)] pub inline_completion_options: InlineCompletionOptions, #[serde(flatten)] pub text_document_registration_options: TextDocumentRegistrationOptions, } impl InlineCompletionRegistrationOptions { #[must_use] pub const fn new( static_registration_options: StaticRegistrationOptions, inline_completion_options: InlineCompletionOptions, text_document_registration_options: TextDocumentRegistrationOptions, ) -> Self { Self { static_registration_options, inline_completion_options, text_document_registration_options, } } } /// Parameters for the `workspace/textDocumentContent` request. /// /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct TextDocumentContentParams { /// The uri of the text document. pub uri: Uri, } impl TextDocumentContentParams { #[must_use] pub const fn new(uri: Uri) -> Self { Self { uri } } } /// Result of the `workspace/textDocumentContent` request. /// /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct TextDocumentContentResult { /// The text content of the text document. Please note, that the content of /// any subsequent open notifications for the text document might differ /// from the returned content due to whitespace and line ending /// normalizations done on the client pub text: String, } impl TextDocumentContentResult { #[must_use] pub const fn new(text: String) -> Self { Self { text } } } /// Text document content provider registration options. /// /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct TextDocumentContentRegistrationOptions { #[serde(flatten)] pub static_registration_options: StaticRegistrationOptions, #[serde(flatten)] pub text_document_content_options: TextDocumentContentOptions, } impl TextDocumentContentRegistrationOptions { #[must_use] pub const fn new( static_registration_options: StaticRegistrationOptions, text_document_content_options: TextDocumentContentOptions, ) -> Self { Self { static_registration_options, text_document_content_options, } } } /// Parameters for the `workspace/textDocumentContent/refresh` request. /// /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct TextDocumentContentRefreshParams { /// The uri of the text document to refresh. pub uri: Uri, } impl TextDocumentContentRefreshParams { #[must_use] pub const fn new(uri: Uri) -> Self { Self { uri } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct RegistrationParams { pub registrations: Vec, } impl RegistrationParams { #[must_use] pub const fn new(registrations: Vec) -> Self { Self { registrations } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct UnregistrationParams { pub unregisterations: Vec, } impl UnregistrationParams { #[must_use] pub const fn new(unregisterations: Vec) -> Self { Self { unregisterations } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct InitializeParams { /// The process Id of the parent process that started /// the server. /// /// Is `null` if the process has not been started by another process. /// If the parent process is not alive then the server should exit. pub process_id: Option, /// Information about the client /// /// @since 3.15.0 #[serde(skip_serializing_if = "Option::is_none")] pub client_info: Option, /// The locale the client is currently showing the user interface /// in. This must not necessarily be the locale of the operating /// system. /// /// Uses IETF language tags as the value's syntax /// (See https://en.wikipedia.org/wiki/IETF_language_tag) /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub locale: Option, /// The rootPath of the workspace. Is null /// if no folder is open. /// /// @deprecated in favour of rootUri. #[deprecated(note = "in favour of rootUri.")] #[serde(default, deserialize_with = "deserialize_some")] #[serde(skip_serializing_if = "Option::is_none")] pub root_path: Option, /// The rootUri of the workspace. Is null if no /// folder is open. If both `rootPath` and `rootUri` are set /// `rootUri` wins. /// /// @deprecated in favour of workspaceFolders. #[deprecated(note = "in favour of workspaceFolders.")] pub root_uri: Option, /// The capabilities provided by the client (editor or tool) pub capabilities: ClientCapabilities, /// User provided initialization options. #[serde(skip_serializing_if = "Option::is_none")] pub initialization_options: Option, /// The initial trace setting. If omitted trace is disabled ('off'). #[serde(skip_serializing_if = "Option::is_none")] pub trace: Option, #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub workspace_folders_initialize_params: WorkspaceFoldersInitializeParams, } impl InitializeParams { #[must_use] pub const fn new( process_id: Option, client_info: Option, locale: Option, root_path: Option, root_uri: Option, capabilities: ClientCapabilities, initialization_options: Option, trace: Option, work_done_progress_params: WorkDoneProgressParams, workspace_folders_initialize_params: WorkspaceFoldersInitializeParams, ) -> Self { Self { process_id, client_info, locale, root_path, root_uri, capabilities, initialization_options, trace, work_done_progress_params, workspace_folders_initialize_params, } } } /// The result returned from an initialize request. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct InitializeResult { /// The capabilities the language server provides. pub capabilities: ServerCapabilities, /// Information about the server. /// /// @since 3.15.0 #[serde(skip_serializing_if = "Option::is_none")] pub server_info: Option, } impl InitializeResult { #[must_use] pub const fn new( capabilities: ServerCapabilities, server_info: Option, ) -> Self { Self { capabilities, server_info } } } /// The data type of the ResponseError if the /// initialize request fails. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct InitializeError { /// Indicates whether the client execute the following retry logic: /// (1) show the message provided by the ResponseError to the user /// (2) user selects retry or cancel /// (3) if user selected retry the initialize method is sent again. pub retry: bool, } impl InitializeError { #[must_use] pub const fn new(retry: bool) -> Self { Self { retry } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct InitializedParams {} impl InitializedParams { #[must_use] pub const fn new() -> Self { Self {} } } /// The parameters of a change configuration notification. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct DidChangeConfigurationParams { /// The actual changed settings pub settings: LspAny, } impl DidChangeConfigurationParams { #[must_use] pub const fn new(settings: LspAny) -> Self { Self { settings } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct DidChangeConfigurationRegistrationOptions { #[serde(skip_serializing_if = "Option::is_none")] pub section: Option
, } impl DidChangeConfigurationRegistrationOptions { #[must_use] pub const fn new(section: Option
) -> Self { Self { section } } } /// The parameters of a notification message. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct ShowMessageParams { /// The message type. See [`MessageType`] #[serde(rename = "type")] pub kind: MessageType, /// The actual message. pub message: String, } impl ShowMessageParams { #[must_use] pub const fn new(kind: MessageType, message: String) -> Self { Self { kind, message } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq)] #[serde(rename_all = "camelCase")] pub struct ShowMessageRequestParams { /// The message type. See [`MessageType`] #[serde(rename = "type")] pub kind: MessageType, /// The actual message. pub message: String, /// The message action items to present. #[serde(skip_serializing_if = "Option::is_none")] pub actions: Option>, } impl ShowMessageRequestParams { #[must_use] pub const fn new( kind: MessageType, message: String, actions: Option>, ) -> Self { Self { kind, message, actions } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Default)] #[serde(rename_all = "camelCase")] pub struct MessageActionItem { /// A short title like 'Retry', 'Open Log' etc. pub title: String, /// Additional attributes that the client preserves and /// sends back to the server. This depends on the client /// capability window.messageActionItem.additionalPropertiesSupport. #[serde(flatten)] pub properties: HashMap, } impl MessageActionItem { #[must_use] pub const fn new( title: String, properties: HashMap, ) -> Self { Self { title, properties } } } /// The log message parameters. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct LogMessageParams { /// The message type. See [`MessageType`] #[serde(rename = "type")] pub kind: MessageType, /// The actual message. pub message: String, } impl LogMessageParams { #[must_use] pub const fn new(kind: MessageType, message: String) -> Self { Self { kind, message } } } /// The parameters sent in an open text document notification #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct DidOpenTextDocumentParams { /// The document that was opened. pub text_document: TextDocumentItem, } impl DidOpenTextDocumentParams { #[must_use] pub const fn new(text_document: TextDocumentItem) -> Self { Self { text_document } } } /// The change text document notification's parameters. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct DidChangeTextDocumentParams { /// The document that did change. The version number points /// to the version after all provided content changes have /// been applied. pub text_document: VersionedTextDocumentIdentifier, /// 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. pub content_changes: Vec, } impl DidChangeTextDocumentParams { #[must_use] pub const fn new( text_document: VersionedTextDocumentIdentifier, content_changes: Vec, ) -> Self { Self { text_document, content_changes, } } } /// Describe options to be used when registered for text document change events. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct TextDocumentChangeRegistrationOptions { /// How documents are synced to the server. pub sync_kind: TextDocumentSyncKind, #[serde(flatten)] pub text_document_registration_options: TextDocumentRegistrationOptions, } impl TextDocumentChangeRegistrationOptions { #[must_use] pub const fn new( sync_kind: TextDocumentSyncKind, text_document_registration_options: TextDocumentRegistrationOptions, ) -> Self { Self { sync_kind, text_document_registration_options, } } } /// The parameters sent in a close text document notification #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct DidCloseTextDocumentParams { /// The document that was closed. pub text_document: TextDocumentIdentifier, } impl DidCloseTextDocumentParams { #[must_use] pub const fn new(text_document: TextDocumentIdentifier) -> Self { Self { text_document } } } /// The parameters sent in a save text document notification #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct DidSaveTextDocumentParams { /// The document that was saved. pub text_document: TextDocumentIdentifier, /// Optional the content when saved. Depends on the includeText value /// when the save notification was requested. #[serde(skip_serializing_if = "Option::is_none")] pub text: Option, } impl DidSaveTextDocumentParams { #[must_use] pub const fn new( text_document: TextDocumentIdentifier, text: Option, ) -> Self { Self { text_document, text } } } /// Save registration options. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct TextDocumentSaveRegistrationOptions { #[serde(flatten)] pub text_document_registration_options: TextDocumentRegistrationOptions, #[serde(flatten)] pub save_options: SaveOptions, } impl TextDocumentSaveRegistrationOptions { #[must_use] pub const fn new( text_document_registration_options: TextDocumentRegistrationOptions, save_options: SaveOptions, ) -> Self { Self { text_document_registration_options, save_options, } } } /// The parameters sent in a will save text document notification. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct WillSaveTextDocumentParams { /// The document that will be saved. pub text_document: TextDocumentIdentifier, /// The 'TextDocumentSaveReason'. pub reason: TextDocumentSaveReason, } impl WillSaveTextDocumentParams { #[must_use] pub const fn new( text_document: TextDocumentIdentifier, reason: TextDocumentSaveReason, ) -> Self { Self { text_document, reason } } } /// A text edit applicable to a text document. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct TextEdit { /// The range of the text document to be manipulated. To insert /// text into a document create a range where start === end. pub range: Range, /// The string to be inserted. For delete operations use an /// empty string. pub new_text: String, } impl TextEdit { #[must_use] pub const fn new(range: Range, new_text: String) -> Self { Self { range, new_text } } } /// The watched files change notification's parameters. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct DidChangeWatchedFilesParams { /// The actual file events. pub changes: Vec, } impl DidChangeWatchedFilesParams { #[must_use] pub const fn new(changes: Vec) -> Self { Self { changes } } } /// Describe options to be used when registered for text document change events. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct DidChangeWatchedFilesRegistrationOptions { /// The watchers to register. pub watchers: Vec, } impl DidChangeWatchedFilesRegistrationOptions { #[must_use] pub const fn new(watchers: Vec) -> Self { Self { watchers } } } /// The publish diagnostic notification's parameters. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct PublishDiagnosticsParams { /// The URI for which diagnostic information is reported. pub uri: Uri, /// Optional the version number of the document the diagnostics are published for. /// /// @since 3.15.0 #[serde(skip_serializing_if = "Option::is_none")] pub version: Option, /// An array of diagnostic information items. pub diagnostics: Vec, } impl PublishDiagnosticsParams { #[must_use] pub const fn new( uri: Uri, version: Option, diagnostics: Vec, ) -> Self { Self { uri, version, diagnostics } } } /// Completion parameters #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct CompletionParams { /// The completion context. This is only available it the client specifies /// to send this using the client capability `textDocument.completion.contextSupport === true` #[serde(skip_serializing_if = "Option::is_none")] pub context: Option, #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub partial_result_params: PartialResultParams, #[serde(flatten)] pub text_document_position_params: TextDocumentPositionParams, } impl CompletionParams { #[must_use] pub const fn new( context: Option, work_done_progress_params: WorkDoneProgressParams, partial_result_params: PartialResultParams, text_document_position_params: TextDocumentPositionParams, ) -> Self { Self { context, work_done_progress_params, partial_result_params, text_document_position_params, } } } /// A completion item represents a text snippet that is /// proposed to complete text that is being typed. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct CompletionItem { /// 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. pub label: String, /// Additional details for the label /// /// @since 3.17.0 #[serde(skip_serializing_if = "Option::is_none")] pub label_details: Option, /// The kind of this completion item. Based of the kind /// an icon is chosen by the editor. #[serde(skip_serializing_if = "Option::is_none")] pub kind: Option, /// Tags for this completion item. /// /// @since 3.15.0 #[serde(skip_serializing_if = "Option::is_none")] pub tags: Option>, /// A human-readable string with additional information /// about this item, like type or symbol information. #[serde(skip_serializing_if = "Option::is_none")] pub detail: Option, /// A human-readable string that represents a doc-comment. #[serde(skip_serializing_if = "Option::is_none")] pub documentation: Option, /// Indicates if this item is deprecated. /// @deprecated Use `tags` instead. #[deprecated(note = "Use `tags` instead.")] #[serde(skip_serializing_if = "Option::is_none")] pub deprecated: Option, /// 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. #[serde(skip_serializing_if = "Option::is_none")] pub preselect: Option, /// A string that should be used when comparing this item /// with other items. When `falsy` the [label][`CompletionItem::label`] /// is used. #[serde(skip_serializing_if = "Option::is_none")] pub sort_text: Option, /// A string that should be used when filtering a set of /// completion items. When `falsy` the [label][`CompletionItem::label`] /// is used. #[serde(skip_serializing_if = "Option::is_none")] pub filter_text: Option, /// A string that should be inserted into a document when selecting /// this completion. When `falsy` the [label][`CompletionItem::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` 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. #[serde(skip_serializing_if = "Option::is_none")] pub insert_text: Option, /// 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`. #[serde(skip_serializing_if = "Option::is_none")] pub insert_text_format: Option, /// 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 #[serde(skip_serializing_if = "Option::is_none")] pub insert_text_mode: Option, /// An [edit][TextEdit] which is applied to a document when selecting /// this completion. When an edit is provided the value of /// [insertText][`CompletionItem::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` #[serde(skip_serializing_if = "Option::is_none")] pub text_edit: Option, /// 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 #[serde(skip_serializing_if = "Option::is_none")] pub text_edit_text: Option, /// An optional array of additional [text edits][TextEdit] that are applied when /// selecting this completion. Edits must not overlap (including the same insert position) /// with the main [edit][`CompletionItem::textEdit`] 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). #[serde(skip_serializing_if = "Option::is_none")] pub additional_text_edits: Option>, /// 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. #[serde(skip_serializing_if = "Option::is_none")] pub commit_characters: Option>, /// An optional [command][Command] that is executed *after* inserting this completion. *Note* that /// additional modifications to the current document should be described with the /// [additionalTextEdits][`CompletionItem::additionalTextEdits`]-property. #[serde(skip_serializing_if = "Option::is_none")] pub command: Option, /// A data entry field that is preserved on a completion item between a /// [`CompletionRequest`] and a [`CompletionResolveRequest`]. #[serde(skip_serializing_if = "Option::is_none")] pub data: Option, } impl CompletionItem { #[must_use] pub const fn new( label: String, label_details: Option, kind: Option, tags: Option>, detail: Option, documentation: Option, deprecated: Option, preselect: Option, sort_text: Option, filter_text: Option, insert_text: Option, insert_text_format: Option, insert_text_mode: Option, text_edit: Option, text_edit_text: Option, additional_text_edits: Option>, commit_characters: Option>, command: Option, data: Option, ) -> Self { Self { label, label_details, kind, tags, detail, documentation, deprecated, preselect, sort_text, filter_text, insert_text, insert_text_format, insert_text_mode, text_edit, text_edit_text, additional_text_edits, commit_characters, command, data, } } } /// Represents a collection of [completion items][CompletionItem] to be presented /// in the editor. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct CompletionList { /// 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. pub is_incomplete: bool, /// 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 rules for combining these are /// defined by `applyKinds` (if the client supports it), defaulting to /// ApplyKind.Replace. /// /// Servers are only allowed to return default values if the client /// signals support for this via the `completionList.itemDefaults` /// capability. /// /// @since 3.17.0 #[serde(skip_serializing_if = "Option::is_none")] pub item_defaults: Option, /// Specifies how fields from a completion item should be combined with those /// from `completionList.itemDefaults`. /// /// If unspecified, all fields will be treated as ApplyKind.Replace. /// /// If a field's value is ApplyKind.Replace, the value from a completion item /// (if provided and not `null`) will always be used instead of the value /// from `completionItem.itemDefaults`. /// /// If a field's value is ApplyKind.Merge, the values will be merged using /// the rules defined against each field below. /// /// Servers are only allowed to return `applyKind` if the client /// signals support for this via the `completionList.applyKindSupport` /// capability. /// /// @since 3.18.0 #[serde(skip_serializing_if = "Option::is_none")] pub apply_kind: Option, /// The completion items. pub items: Vec, } impl CompletionList { #[must_use] pub const fn new( is_incomplete: bool, item_defaults: Option, apply_kind: Option, items: Vec, ) -> Self { Self { is_incomplete, item_defaults, apply_kind, items, } } } /// Registration options for a [`CompletionRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct CompletionRegistrationOptions { #[serde(flatten)] pub text_document_registration_options: TextDocumentRegistrationOptions, #[serde(flatten)] pub completion_options: CompletionOptions, } impl CompletionRegistrationOptions { #[must_use] pub const fn new( text_document_registration_options: TextDocumentRegistrationOptions, completion_options: CompletionOptions, ) -> Self { Self { text_document_registration_options, completion_options, } } } /// Parameters for a [`HoverRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct HoverParams { #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub text_document_position_params: TextDocumentPositionParams, } impl HoverParams { #[must_use] pub const fn new( work_done_progress_params: WorkDoneProgressParams, text_document_position_params: TextDocumentPositionParams, ) -> Self { Self { work_done_progress_params, text_document_position_params, } } } /// The result of a hover request. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct Hover { /// The hover's content pub contents: Contents, /// An optional range inside the text document that is used to /// visualize the hover, e.g. by changing the background color. #[serde(skip_serializing_if = "Option::is_none")] pub range: Option, } impl Hover { #[must_use] pub const fn new(contents: Contents, range: Option) -> Self { Self { contents, range } } } /// Registration options for a [`HoverRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct HoverRegistrationOptions { #[serde(flatten)] pub text_document_registration_options: TextDocumentRegistrationOptions, #[serde(flatten)] pub hover_options: HoverOptions, } impl HoverRegistrationOptions { #[must_use] pub const fn new( text_document_registration_options: TextDocumentRegistrationOptions, hover_options: HoverOptions, ) -> Self { Self { text_document_registration_options, hover_options, } } } /// Parameters for a [`SignatureHelpRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct SignatureHelpParams { /// The signature help context. This is only available if the client specifies /// to send this using the client capability `textDocument.signatureHelp.contextSupport === true` /// /// @since 3.15.0 #[serde(skip_serializing_if = "Option::is_none")] pub context: Option, #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub text_document_position_params: TextDocumentPositionParams, } impl SignatureHelpParams { #[must_use] pub const fn new( context: Option, work_done_progress_params: WorkDoneProgressParams, text_document_position_params: TextDocumentPositionParams, ) -> Self { Self { context, work_done_progress_params, text_document_position_params, } } } /// Signature help represents the signature of something /// callable. There can be multiple signature but only one /// active and only one active parameter. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct SignatureHelp { /// One or more signatures. pub signatures: Vec, /// The active signature. If omitted or the value lies outside the /// range of `signatures` the value defaults to zero or is ignored if /// the `SignatureHelp` has no signatures. /// /// Whenever possible implementors should make an active decision about /// the active signature and shouldn't rely on a default value. /// /// In future version of the protocol this property might become /// mandatory to better express this. #[serde(skip_serializing_if = "Option::is_none")] pub active_signature: Option, /// The active parameter of the active signature. /// /// If `null`, no parameter of the signature is active (for example a named /// argument that does not match any declared parameters). This is only valid /// if the client specifies the client capability /// `textDocument.signatureHelp.noActiveParameterSupport === true` /// /// If omitted or the value lies outside the range of /// `signatures[activeSignature].parameters` defaults to 0 if the active /// signature has parameters. /// /// If the active signature has no parameters it is ignored. /// /// In future version of the protocol this property might become /// mandatory (but still nullable) to better express the active parameter if /// the active signature does have any. /// /// Since version 3.16.0 the `SignatureInformation` itself provides a /// `activeParameter` property and it should be used instead of this one. #[serde(default, deserialize_with = "deserialize_some")] #[serde(skip_serializing_if = "Option::is_none")] pub active_parameter: Option, } impl SignatureHelp { #[must_use] pub const fn new( signatures: Vec, active_signature: Option, active_parameter: Option, ) -> Self { Self { signatures, active_signature, active_parameter, } } } /// Registration options for a [`SignatureHelpRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct SignatureHelpRegistrationOptions { #[serde(flatten)] pub text_document_registration_options: TextDocumentRegistrationOptions, #[serde(flatten)] pub signature_help_options: SignatureHelpOptions, } impl SignatureHelpRegistrationOptions { #[must_use] pub const fn new( text_document_registration_options: TextDocumentRegistrationOptions, signature_help_options: SignatureHelpOptions, ) -> Self { Self { text_document_registration_options, signature_help_options, } } } /// Parameters for a [`DefinitionRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct DefinitionParams { #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub partial_result_params: PartialResultParams, #[serde(flatten)] pub text_document_position_params: TextDocumentPositionParams, } impl DefinitionParams { #[must_use] pub const fn new( work_done_progress_params: WorkDoneProgressParams, partial_result_params: PartialResultParams, text_document_position_params: TextDocumentPositionParams, ) -> Self { Self { work_done_progress_params, partial_result_params, text_document_position_params, } } } /// Registration options for a [`DefinitionRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct DefinitionRegistrationOptions { #[serde(flatten)] pub text_document_registration_options: TextDocumentRegistrationOptions, #[serde(flatten)] pub definition_options: DefinitionOptions, } impl DefinitionRegistrationOptions { #[must_use] pub const fn new( text_document_registration_options: TextDocumentRegistrationOptions, definition_options: DefinitionOptions, ) -> Self { Self { text_document_registration_options, definition_options, } } } /// Parameters for a [`ReferencesRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct ReferenceParams { pub context: ReferenceContext, #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub partial_result_params: PartialResultParams, #[serde(flatten)] pub text_document_position_params: TextDocumentPositionParams, } impl ReferenceParams { #[must_use] pub const fn new( context: ReferenceContext, work_done_progress_params: WorkDoneProgressParams, partial_result_params: PartialResultParams, text_document_position_params: TextDocumentPositionParams, ) -> Self { Self { context, work_done_progress_params, partial_result_params, text_document_position_params, } } } /// Registration options for a [`ReferencesRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct ReferenceRegistrationOptions { #[serde(flatten)] pub text_document_registration_options: TextDocumentRegistrationOptions, #[serde(flatten)] pub reference_options: ReferenceOptions, } impl ReferenceRegistrationOptions { #[must_use] pub const fn new( text_document_registration_options: TextDocumentRegistrationOptions, reference_options: ReferenceOptions, ) -> Self { Self { text_document_registration_options, reference_options, } } } /// Parameters for a [`DocumentHighlightRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct DocumentHighlightParams { #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub partial_result_params: PartialResultParams, #[serde(flatten)] pub text_document_position_params: TextDocumentPositionParams, } impl DocumentHighlightParams { #[must_use] pub const fn new( work_done_progress_params: WorkDoneProgressParams, partial_result_params: PartialResultParams, text_document_position_params: TextDocumentPositionParams, ) -> Self { Self { work_done_progress_params, partial_result_params, text_document_position_params, } } } /// 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. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct DocumentHighlight { /// The range this highlight applies to. pub range: Range, /// The highlight kind, default is [text][`DocumentHighlightKind::Text`]. #[serde(skip_serializing_if = "Option::is_none")] pub kind: Option, } impl DocumentHighlight { #[must_use] pub const fn new(range: Range, kind: Option) -> Self { Self { range, kind } } } /// Registration options for a [`DocumentHighlightRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct DocumentHighlightRegistrationOptions { #[serde(flatten)] pub text_document_registration_options: TextDocumentRegistrationOptions, #[serde(flatten)] pub document_highlight_options: DocumentHighlightOptions, } impl DocumentHighlightRegistrationOptions { #[must_use] pub const fn new( text_document_registration_options: TextDocumentRegistrationOptions, document_highlight_options: DocumentHighlightOptions, ) -> Self { Self { text_document_registration_options, document_highlight_options, } } } /// Parameters for a [`DocumentSymbolRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct DocumentSymbolParams { /// The text document. pub text_document: TextDocumentIdentifier, #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub partial_result_params: PartialResultParams, } impl DocumentSymbolParams { #[must_use] pub const fn new( text_document: TextDocumentIdentifier, work_done_progress_params: WorkDoneProgressParams, partial_result_params: PartialResultParams, ) -> Self { Self { text_document, work_done_progress_params, partial_result_params, } } } /// Represents information about programming constructs like variables, classes, /// interfaces etc. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct SymbolInformation { /// Indicates if this symbol is deprecated. /// /// @deprecated Use tags instead #[deprecated(note = "Use tags instead")] #[serde(skip_serializing_if = "Option::is_none")] pub deprecated: Option, /// The location of this symbol. The location's range is used by a tool /// to reveal the location in the editor. If the symbol is selected in the /// tool the range's start information is used to position the cursor. So /// the range usually spans more than the actual symbol's name and does /// normally include things like visibility modifiers. /// /// The range doesn't have to denote a node range in the sense of an abstract /// syntax tree. It can therefore not be used to re-construct a hierarchy of /// the symbols. pub location: Location, #[serde(flatten)] pub base_symbol_information: BaseSymbolInformation, } impl SymbolInformation { #[must_use] pub const fn new( deprecated: Option, location: Location, base_symbol_information: BaseSymbolInformation, ) -> Self { Self { deprecated, location, base_symbol_information, } } } /// 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. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct DocumentSymbol { /// 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. pub name: String, /// More detail for this symbol, e.g the signature of a function. #[serde(skip_serializing_if = "Option::is_none")] pub detail: Option, /// The kind of this symbol. pub kind: SymbolKind, /// Tags for this document symbol. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub tags: Option>, /// Indicates if this symbol is deprecated. /// /// @deprecated Use tags instead #[deprecated(note = "Use tags instead")] #[serde(skip_serializing_if = "Option::is_none")] pub deprecated: Option, /// 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. pub 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`. pub selection_range: Range, /// Children of this symbol, e.g. properties of a class. #[serde(skip_serializing_if = "Option::is_none")] pub children: Option>, } impl DocumentSymbol { #[must_use] pub const fn new( name: String, detail: Option, kind: SymbolKind, tags: Option>, deprecated: Option, range: Range, selection_range: Range, children: Option>, ) -> Self { Self { name, detail, kind, tags, deprecated, range, selection_range, children, } } } /// Registration options for a [`DocumentSymbolRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct DocumentSymbolRegistrationOptions { #[serde(flatten)] pub text_document_registration_options: TextDocumentRegistrationOptions, #[serde(flatten)] pub document_symbol_options: DocumentSymbolOptions, } impl DocumentSymbolRegistrationOptions { #[must_use] pub const fn new( text_document_registration_options: TextDocumentRegistrationOptions, document_symbol_options: DocumentSymbolOptions, ) -> Self { Self { text_document_registration_options, document_symbol_options, } } } /// The parameters of a [`CodeActionRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct CodeActionParams { /// The document in which the command was invoked. pub text_document: TextDocumentIdentifier, /// The range for which the command was invoked. pub range: Range, /// Context carrying additional information. pub context: CodeActionContext, #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub partial_result_params: PartialResultParams, } impl CodeActionParams { #[must_use] pub const fn new( text_document: TextDocumentIdentifier, range: Range, context: CodeActionContext, work_done_progress_params: WorkDoneProgressParams, partial_result_params: PartialResultParams, ) -> Self { Self { text_document, range, context, work_done_progress_params, partial_result_params, } } } /// 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. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct Command { /// Title of the command, like `save`. pub title: String, /// An optional tooltip. /// /// @since 3.18.0 #[serde(skip_serializing_if = "Option::is_none")] pub tooltip: Option, /// The identifier of the actual command handler. pub command: String, /// Arguments that the command handler should be /// invoked with. #[serde(skip_serializing_if = "Option::is_none")] pub arguments: Option>, } impl Command { #[must_use] pub const fn new( title: String, tooltip: Option, command: String, arguments: Option>, ) -> Self { Self { title, tooltip, command, arguments, } } } /// 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. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Default)] #[serde(rename_all = "camelCase")] pub struct CodeAction { /// A short, human-readable, title for this code action. pub title: String, /// The kind of the code action. /// /// Used to filter code actions. #[serde(skip_serializing_if = "Option::is_none")] pub kind: Option, /// The diagnostics that this code action resolves. #[serde(skip_serializing_if = "Option::is_none")] pub diagnostics: Option>, /// 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 #[serde(skip_serializing_if = "Option::is_none")] pub is_preferred: Option, /// 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 #[serde(skip_serializing_if = "Option::is_none")] pub disabled: Option, /// The workspace edit this code action performs. #[serde(skip_serializing_if = "Option::is_none")] pub edit: Option, /// 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. #[serde(skip_serializing_if = "Option::is_none")] pub command: Option, /// A data entry field that is preserved on a code action between /// a `textDocument/codeAction` and a `codeAction/resolve` request. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub data: Option, /// Tags for this code action. /// /// @since 3.18.0 - proposed #[serde(skip_serializing_if = "Option::is_none")] pub tags: Option>, } impl CodeAction { #[must_use] pub const fn new( title: String, kind: Option, diagnostics: Option>, is_preferred: Option, disabled: Option, edit: Option, command: Option, data: Option, tags: Option>, ) -> Self { Self { title, kind, diagnostics, is_preferred, disabled, edit, command, data, tags, } } } /// Registration options for a [`CodeActionRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct CodeActionRegistrationOptions { #[serde(flatten)] pub text_document_registration_options: TextDocumentRegistrationOptions, #[serde(flatten)] pub code_action_options: CodeActionOptions, } impl CodeActionRegistrationOptions { #[must_use] pub const fn new( text_document_registration_options: TextDocumentRegistrationOptions, code_action_options: CodeActionOptions, ) -> Self { Self { text_document_registration_options, code_action_options, } } } /// The parameters of a [`WorkspaceSymbolRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct WorkspaceSymbolParams { /// A query string to filter symbols by. Clients may send an empty /// string here to request all symbols. /// /// The `query`-parameter should be interpreted in a *relaxed way* as editors /// will apply their own highlighting and scoring on the results. A good rule /// of thumb is to match case-insensitive and to simply check that the /// characters of *query* appear in their order in a candidate symbol. /// Servers shouldn't use prefix, substring, or similar strict matching. pub query: String, #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub partial_result_params: PartialResultParams, } impl WorkspaceSymbolParams { #[must_use] pub const fn new( query: String, work_done_progress_params: WorkDoneProgressParams, partial_result_params: PartialResultParams, ) -> Self { Self { query, work_done_progress_params, partial_result_params, } } } /// A special workspace symbol that supports locations without a range. /// /// See also SymbolInformation. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct WorkspaceSymbol { /// The location of the symbol. Whether a server is allowed to /// return a location without a range depends on the client /// capability `workspace.symbol.resolveSupport`. /// /// See SymbolInformation#location for more details. pub location: WorkspaceSymbolLocation, /// A data entry field that is preserved on a workspace symbol between a /// workspace symbol request and a workspace symbol resolve request. #[serde(skip_serializing_if = "Option::is_none")] pub data: Option, #[serde(flatten)] pub base_symbol_information: BaseSymbolInformation, } impl WorkspaceSymbol { #[must_use] pub const fn new( location: WorkspaceSymbolLocation, data: Option, base_symbol_information: BaseSymbolInformation, ) -> Self { Self { location, data, base_symbol_information, } } } /// Registration options for a [`WorkspaceSymbolRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct WorkspaceSymbolRegistrationOptions { #[serde(flatten)] pub workspace_symbol_options: WorkspaceSymbolOptions, } impl WorkspaceSymbolRegistrationOptions { #[must_use] pub const fn new(workspace_symbol_options: WorkspaceSymbolOptions) -> Self { Self { workspace_symbol_options } } } /// The parameters of a [`CodeLensRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct CodeLensParams { /// The document to request code lens for. pub text_document: TextDocumentIdentifier, #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub partial_result_params: PartialResultParams, } impl CodeLensParams { #[must_use] pub const fn new( text_document: TextDocumentIdentifier, work_done_progress_params: WorkDoneProgressParams, partial_result_params: PartialResultParams, ) -> Self { Self { text_document, work_done_progress_params, partial_result_params, } } } /// A code lens represents a [command][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. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct CodeLens { /// The range in which this code lens is valid. Should only span a single line. pub range: Range, /// The command this code lens represents. #[serde(skip_serializing_if = "Option::is_none")] pub command: Option, /// A data entry field that is preserved on a code lens item between /// a [`CodeLensRequest`] and a [`CodeLensResolveRequest`] #[serde(skip_serializing_if = "Option::is_none")] pub data: Option, } impl CodeLens { #[must_use] pub const fn new( range: Range, command: Option, data: Option, ) -> Self { Self { range, command, data } } } /// Registration options for a [`CodeLensRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct CodeLensRegistrationOptions { #[serde(flatten)] pub text_document_registration_options: TextDocumentRegistrationOptions, #[serde(flatten)] pub code_lens_options: CodeLensOptions, } impl CodeLensRegistrationOptions { #[must_use] pub const fn new( text_document_registration_options: TextDocumentRegistrationOptions, code_lens_options: CodeLensOptions, ) -> Self { Self { text_document_registration_options, code_lens_options, } } } /// The parameters of a [`DocumentLinkRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct DocumentLinkParams { /// The document to provide document links for. pub text_document: TextDocumentIdentifier, #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub partial_result_params: PartialResultParams, } impl DocumentLinkParams { #[must_use] pub const fn new( text_document: TextDocumentIdentifier, work_done_progress_params: WorkDoneProgressParams, partial_result_params: PartialResultParams, ) -> Self { Self { text_document, work_done_progress_params, partial_result_params, } } } /// 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. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct DocumentLink { /// The range this link applies to. pub range: Range, /// The uri this link points to. If missing a resolve request is sent later. #[serde(skip_serializing_if = "Option::is_none")] pub target: Option, /// 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 #[serde(skip_serializing_if = "Option::is_none")] pub tooltip: Option, /// A data entry field that is preserved on a document link between a /// DocumentLinkRequest and a DocumentLinkResolveRequest. #[serde(skip_serializing_if = "Option::is_none")] pub data: Option, } impl DocumentLink { #[must_use] pub const fn new( range: Range, target: Option, tooltip: Option, data: Option, ) -> Self { Self { range, target, tooltip, data, } } } /// Registration options for a [`DocumentLinkRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct DocumentLinkRegistrationOptions { #[serde(flatten)] pub text_document_registration_options: TextDocumentRegistrationOptions, #[serde(flatten)] pub document_link_options: DocumentLinkOptions, } impl DocumentLinkRegistrationOptions { #[must_use] pub const fn new( text_document_registration_options: TextDocumentRegistrationOptions, document_link_options: DocumentLinkOptions, ) -> Self { Self { text_document_registration_options, document_link_options, } } } /// The parameters of a [`DocumentFormattingRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct DocumentFormattingParams { /// The document to format. pub text_document: TextDocumentIdentifier, /// The format options. pub options: FormattingOptions, #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, } impl DocumentFormattingParams { #[must_use] pub const fn new( text_document: TextDocumentIdentifier, options: FormattingOptions, work_done_progress_params: WorkDoneProgressParams, ) -> Self { Self { text_document, options, work_done_progress_params, } } } /// Registration options for a [`DocumentFormattingRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct DocumentFormattingRegistrationOptions { #[serde(flatten)] pub text_document_registration_options: TextDocumentRegistrationOptions, #[serde(flatten)] pub document_formatting_options: DocumentFormattingOptions, } impl DocumentFormattingRegistrationOptions { #[must_use] pub const fn new( text_document_registration_options: TextDocumentRegistrationOptions, document_formatting_options: DocumentFormattingOptions, ) -> Self { Self { text_document_registration_options, document_formatting_options, } } } /// The parameters of a [`DocumentRangeFormattingRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct DocumentRangeFormattingParams { /// The document to format. pub text_document: TextDocumentIdentifier, /// The range to format pub range: Range, /// The format options pub options: FormattingOptions, #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, } impl DocumentRangeFormattingParams { #[must_use] pub const fn new( text_document: TextDocumentIdentifier, range: Range, options: FormattingOptions, work_done_progress_params: WorkDoneProgressParams, ) -> Self { Self { text_document, range, options, work_done_progress_params, } } } /// Registration options for a [`DocumentRangeFormattingRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct DocumentRangeFormattingRegistrationOptions { #[serde(flatten)] pub text_document_registration_options: TextDocumentRegistrationOptions, #[serde(flatten)] pub document_range_formatting_options: DocumentRangeFormattingOptions, } impl DocumentRangeFormattingRegistrationOptions { #[must_use] pub const fn new( text_document_registration_options: TextDocumentRegistrationOptions, document_range_formatting_options: DocumentRangeFormattingOptions, ) -> Self { Self { text_document_registration_options, document_range_formatting_options, } } } /// The parameters of a [`DocumentRangesFormattingRequest`]. /// /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct DocumentRangesFormattingParams { /// The document to format. pub text_document: TextDocumentIdentifier, /// The ranges to format pub ranges: Vec, /// The format options pub options: FormattingOptions, #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, } impl DocumentRangesFormattingParams { #[must_use] pub const fn new( text_document: TextDocumentIdentifier, ranges: Vec, options: FormattingOptions, work_done_progress_params: WorkDoneProgressParams, ) -> Self { Self { text_document, ranges, options, work_done_progress_params, } } } /// The parameters of a [`DocumentOnTypeFormattingRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct DocumentOnTypeFormattingParams { /// The document to format. pub text_document: TextDocumentIdentifier, /// 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. pub position: Position, /// 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). pub ch: String, /// The formatting options. pub options: FormattingOptions, } impl DocumentOnTypeFormattingParams { #[must_use] pub const fn new( text_document: TextDocumentIdentifier, position: Position, ch: String, options: FormattingOptions, ) -> Self { Self { text_document, position, ch, options, } } } /// Registration options for a [`DocumentOnTypeFormattingRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct DocumentOnTypeFormattingRegistrationOptions { #[serde(flatten)] pub text_document_registration_options: TextDocumentRegistrationOptions, #[serde(flatten)] pub document_on_type_formatting_options: DocumentOnTypeFormattingOptions, } impl DocumentOnTypeFormattingRegistrationOptions { #[must_use] pub const fn new( text_document_registration_options: TextDocumentRegistrationOptions, document_on_type_formatting_options: DocumentOnTypeFormattingOptions, ) -> Self { Self { text_document_registration_options, document_on_type_formatting_options, } } } /// The parameters of a [`RenameRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct RenameParams { /// The new name of the symbol. If the given name is not valid the /// request must return a [`ResponseError`] with an /// appropriate message set. pub new_name: String, #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub text_document_position_params: TextDocumentPositionParams, } impl RenameParams { #[must_use] pub const fn new( new_name: String, work_done_progress_params: WorkDoneProgressParams, text_document_position_params: TextDocumentPositionParams, ) -> Self { Self { new_name, work_done_progress_params, text_document_position_params, } } } /// Registration options for a [`RenameRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct RenameRegistrationOptions { #[serde(flatten)] pub text_document_registration_options: TextDocumentRegistrationOptions, #[serde(flatten)] pub rename_options: RenameOptions, } impl RenameRegistrationOptions { #[must_use] pub const fn new( text_document_registration_options: TextDocumentRegistrationOptions, rename_options: RenameOptions, ) -> Self { Self { text_document_registration_options, rename_options, } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct PrepareRenameParams { #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, #[serde(flatten)] pub text_document_position_params: TextDocumentPositionParams, } impl PrepareRenameParams { #[must_use] pub const fn new( work_done_progress_params: WorkDoneProgressParams, text_document_position_params: TextDocumentPositionParams, ) -> Self { Self { work_done_progress_params, text_document_position_params, } } } /// The parameters of a [`ExecuteCommandRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct ExecuteCommandParams { /// The identifier of the actual command handler. pub command: String, /// Arguments that the command should be invoked with. #[serde(skip_serializing_if = "Option::is_none")] pub arguments: Option>, #[serde(flatten)] pub work_done_progress_params: WorkDoneProgressParams, } impl ExecuteCommandParams { #[must_use] pub const fn new( command: String, arguments: Option>, work_done_progress_params: WorkDoneProgressParams, ) -> Self { Self { command, arguments, work_done_progress_params, } } } /// Registration options for a [`ExecuteCommandRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct ExecuteCommandRegistrationOptions { #[serde(flatten)] pub execute_command_options: ExecuteCommandOptions, } impl ExecuteCommandRegistrationOptions { #[must_use] pub const fn new(execute_command_options: ExecuteCommandOptions) -> Self { Self { execute_command_options } } } /// The parameters passed via an apply workspace edit request. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Default)] #[serde(rename_all = "camelCase")] pub struct ApplyWorkspaceEditParams { /// 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. #[serde(skip_serializing_if = "Option::is_none")] pub label: Option, /// The edits to apply. pub edit: WorkspaceEdit, /// Additional data about the edit. /// /// @since 3.18.0 #[serde(skip_serializing_if = "Option::is_none")] pub metadata: Option, } impl ApplyWorkspaceEditParams { #[must_use] pub const fn new( label: Option, edit: WorkspaceEdit, metadata: Option, ) -> Self { Self { label, edit, metadata } } } /// The result returned from the apply workspace edit request. /// /// @since 3.17 renamed from ApplyWorkspaceEditResponse #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct ApplyWorkspaceEditResult { /// Indicates whether the edit was applied or not. pub applied: bool, /// 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. #[serde(skip_serializing_if = "Option::is_none")] pub failure_reason: Option, /// 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. #[serde(skip_serializing_if = "Option::is_none")] pub failed_change: Option, } impl ApplyWorkspaceEditResult { #[must_use] pub const fn new( applied: bool, failure_reason: Option, failed_change: Option, ) -> Self { Self { applied, failure_reason, failed_change, } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] #[serde(try_from = "ShadowWorkDoneProgressBegin", into = "ShadowWorkDoneProgressBegin")] pub struct WorkDoneProgressBegin { /// Mandatory title of the progress operation. Used to briefly inform about /// the kind of operation being performed. /// /// Examples: "Indexing" or "Linking dependencies". pub title: String, /// Controls if a cancel button should show to allow the user to cancel the /// long running operation. Clients that don't support cancellation are allowed /// to ignore the setting. #[serde(skip_serializing_if = "Option::is_none")] pub cancellable: Option, /// Optional, more detailed associated progress message. Contains /// complementary information to the `title`. /// /// Examples: "3/25 files", "project/src/module2", "node_modules/some_dep". /// If unset, the previous progress message (if any) is still valid. #[serde(skip_serializing_if = "Option::is_none")] pub message: Option, /// Optional progress percentage to display (value 100 is considered 100%). /// If not provided infinite progress is assumed and clients are allowed /// to ignore the `percentage` value in subsequent in report notifications. /// /// The value should be steadily rising. Clients are free to ignore values /// that are not following this rule. The value range is [0, 100]. #[serde(skip_serializing_if = "Option::is_none")] pub percentage: Option, } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] struct ShadowWorkDoneProgressBegin { /// Mandatory title of the progress operation. Used to briefly inform about /// the kind of operation being performed. /// /// Examples: "Indexing" or "Linking dependencies". pub title: String, /// Controls if a cancel button should show to allow the user to cancel the /// long running operation. Clients that don't support cancellation are allowed /// to ignore the setting. #[serde(skip_serializing_if = "Option::is_none")] pub cancellable: Option, /// Optional, more detailed associated progress message. Contains /// complementary information to the `title`. /// /// Examples: "3/25 files", "project/src/module2", "node_modules/some_dep". /// If unset, the previous progress message (if any) is still valid. #[serde(skip_serializing_if = "Option::is_none")] pub message: Option, /// Optional progress percentage to display (value 100 is considered 100%). /// If not provided infinite progress is assumed and clients are allowed /// to ignore the `percentage` value in subsequent in report notifications. /// /// The value should be steadily rising. Clients are free to ignore values /// that are not following this rule. The value range is [0, 100]. #[serde(skip_serializing_if = "Option::is_none")] pub percentage: Option, pub kind: String, } impl TryFrom for WorkDoneProgressBegin { type Error = String; fn try_from(shadow: ShadowWorkDoneProgressBegin) -> Result { if shadow.kind != "begin" { return Err(format!("Invalid value for prop kind: {}", shadow.kind)); } Ok(Self { title: shadow.title, cancellable: shadow.cancellable, message: shadow.message, percentage: shadow.percentage, }) } } impl From for ShadowWorkDoneProgressBegin { fn from(original: WorkDoneProgressBegin) -> Self { Self { title: original.title, cancellable: original.cancellable, message: original.message, percentage: original.percentage, kind: "begin".to_string(), } } } impl WorkDoneProgressBegin { #[must_use] pub const fn new( title: String, cancellable: Option, message: Option, percentage: Option, ) -> Self { Self { title, cancellable, message, percentage, } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] #[serde( try_from = "ShadowWorkDoneProgressReport", into = "ShadowWorkDoneProgressReport" )] pub struct WorkDoneProgressReport { /// Controls enablement state of a cancel button. /// /// Clients that don't support cancellation or don't support controlling the button's /// enablement state are allowed to ignore the property. #[serde(skip_serializing_if = "Option::is_none")] pub cancellable: Option, /// Optional, more detailed associated progress message. Contains /// complementary information to the `title`. /// /// Examples: "3/25 files", "project/src/module2", "node_modules/some_dep". /// If unset, the previous progress message (if any) is still valid. #[serde(skip_serializing_if = "Option::is_none")] pub message: Option, /// Optional progress percentage to display (value 100 is considered 100%). /// If not provided infinite progress is assumed and clients are allowed /// to ignore the `percentage` value in subsequent in report notifications. /// /// The value should be steadily rising. Clients are free to ignore values /// that are not following this rule. The value range is [0, 100] #[serde(skip_serializing_if = "Option::is_none")] pub percentage: Option, } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] struct ShadowWorkDoneProgressReport { /// Controls enablement state of a cancel button. /// /// Clients that don't support cancellation or don't support controlling the button's /// enablement state are allowed to ignore the property. #[serde(skip_serializing_if = "Option::is_none")] pub cancellable: Option, /// Optional, more detailed associated progress message. Contains /// complementary information to the `title`. /// /// Examples: "3/25 files", "project/src/module2", "node_modules/some_dep". /// If unset, the previous progress message (if any) is still valid. #[serde(skip_serializing_if = "Option::is_none")] pub message: Option, /// Optional progress percentage to display (value 100 is considered 100%). /// If not provided infinite progress is assumed and clients are allowed /// to ignore the `percentage` value in subsequent in report notifications. /// /// The value should be steadily rising. Clients are free to ignore values /// that are not following this rule. The value range is [0, 100] #[serde(skip_serializing_if = "Option::is_none")] pub percentage: Option, pub kind: String, } impl TryFrom for WorkDoneProgressReport { type Error = String; fn try_from(shadow: ShadowWorkDoneProgressReport) -> Result { if shadow.kind != "report" { return Err(format!("Invalid value for prop kind: {}", shadow.kind)); } Ok(Self { cancellable: shadow.cancellable, message: shadow.message, percentage: shadow.percentage, }) } } impl From for ShadowWorkDoneProgressReport { fn from(original: WorkDoneProgressReport) -> Self { Self { cancellable: original.cancellable, message: original.message, percentage: original.percentage, kind: "report".to_string(), } } } impl WorkDoneProgressReport { #[must_use] pub const fn new( cancellable: Option, message: Option, percentage: Option, ) -> Self { Self { cancellable, message, percentage, } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] #[serde(try_from = "ShadowWorkDoneProgressEnd", into = "ShadowWorkDoneProgressEnd")] pub struct WorkDoneProgressEnd { /// Optional, a final message indicating to for example indicate the outcome /// of the operation. #[serde(skip_serializing_if = "Option::is_none")] pub message: Option, } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] struct ShadowWorkDoneProgressEnd { /// Optional, a final message indicating to for example indicate the outcome /// of the operation. #[serde(skip_serializing_if = "Option::is_none")] pub message: Option, pub kind: String, } impl TryFrom for WorkDoneProgressEnd { type Error = String; fn try_from(shadow: ShadowWorkDoneProgressEnd) -> Result { if shadow.kind != "end" { return Err(format!("Invalid value for prop kind: {}", shadow.kind)); } Ok(Self { message: shadow.message }) } } impl From for ShadowWorkDoneProgressEnd { fn from(original: WorkDoneProgressEnd) -> Self { Self { message: original.message, kind: "end".to_string(), } } } impl WorkDoneProgressEnd { #[must_use] pub const fn new(message: Option) -> Self { Self { message } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Copy)] #[serde(rename_all = "camelCase")] pub struct SetTraceParams { pub value: TraceValue, } impl SetTraceParams { #[must_use] pub const fn new(value: TraceValue) -> Self { Self { value } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct LogTraceParams { pub message: String, #[serde(skip_serializing_if = "Option::is_none")] pub verbose: Option, } impl LogTraceParams { #[must_use] pub const fn new(message: String, verbose: Option) -> Self { Self { message, verbose } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct CancelParams { /// The request id to cancel. pub id: Id, } impl CancelParams { #[must_use] pub const fn new(id: Id) -> Self { Self { id } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct ProgressParams { /// The progress token provided by the client or server. pub token: ProgressToken, /// The progress data. pub value: LspAny, } impl ProgressParams { #[must_use] pub const fn new(token: ProgressToken, value: LspAny) -> Self { Self { token, value } } } /// A parameter literal used in requests to pass a text document and a position inside that /// document. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct TextDocumentPositionParams { /// The text document. pub text_document: TextDocumentIdentifier, /// The position inside the text document. pub position: Position, } impl TextDocumentPositionParams { #[must_use] pub const fn new(text_document: TextDocumentIdentifier, position: Position) -> Self { Self { text_document, position } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct WorkDoneProgressParams { /// An optional token that a server can use to report work done progress. #[serde(skip_serializing_if = "Option::is_none")] pub work_done_token: Option, } impl WorkDoneProgressParams { #[must_use] pub const fn new(work_done_token: Option) -> Self { Self { work_done_token } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct PartialResultParams { /// An optional token that a server can use to report partial results (e.g. streaming) to /// the client. #[serde(skip_serializing_if = "Option::is_none")] pub partial_result_token: Option, } impl PartialResultParams { #[must_use] pub const fn new(partial_result_token: Option) -> Self { Self { partial_result_token } } } /// Represents the connection of two locations. Provides additional metadata over normal [locations][Location], /// including an origin range. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct LocationLink { /// Span of the origin of this link. /// /// Used as the underlined span for mouse interaction. Defaults to the word range at /// the definition position. #[serde(skip_serializing_if = "Option::is_none")] pub origin_selection_range: Option, /// The target resource identifier of this link. pub target_uri: Uri, /// The full target range of this link. If the target for example is a symbol then target range is the /// range enclosing this symbol not including leading/trailing whitespace but everything else /// like comments. This information is typically used to highlight the range in the editor. pub target_range: Range, /// The range that should be selected and revealed when this link is being followed, e.g the name of a function. /// Must be contained by the `targetRange`. See also `DocumentSymbol#range` pub target_selection_range: Range, } impl LocationLink { #[must_use] pub const fn new( origin_selection_range: Option, target_uri: Uri, target_range: Range, target_selection_range: Range, ) -> Self { Self { origin_selection_range, target_uri, target_range, target_selection_range, } } } /// A range in a text document expressed as (zero-based) start and end positions. /// /// If you want to specify a range that contains a line including the line ending /// character(s) then use an end position denoting the start of the next line. /// For example: /// ```ts /// { /// start: { line: 5, character: 23 } /// end : { line 6, character : 0 } /// } /// ``` #[derive( Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy, PartialOrd, Ord )] #[serde(rename_all = "camelCase")] pub struct Range { /// The range's start position. pub start: Position, /// The range's end position. pub end: Position, } impl Range { #[must_use] pub const fn new(start: Position, end: Position) -> Self { Self { start, end } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct ImplementationOptions { #[serde(flatten)] pub work_done_progress_options: WorkDoneProgressOptions, } impl ImplementationOptions { #[must_use] pub const fn new(work_done_progress_options: WorkDoneProgressOptions) -> Self { Self { work_done_progress_options } } } /// Static registration options to be returned in the initialize /// request. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct StaticRegistrationOptions { /// The id used to register the request. The id can be used to deregister /// the request again. See also Registration#id. #[serde(skip_serializing_if = "Option::is_none")] pub id: Option, } impl StaticRegistrationOptions { #[must_use] pub const fn new(id: Option) -> Self { Self { id } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct TypeDefinitionOptions { #[serde(flatten)] pub work_done_progress_options: WorkDoneProgressOptions, } impl TypeDefinitionOptions { #[must_use] pub const fn new(work_done_progress_options: WorkDoneProgressOptions) -> Self { Self { work_done_progress_options } } } /// The workspace folder change event. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct WorkspaceFoldersChangeEvent { /// The array of added workspace folders pub added: Vec, /// The array of the removed workspace folders pub removed: Vec, } impl WorkspaceFoldersChangeEvent { #[must_use] pub const fn new( added: Vec, removed: Vec, ) -> Self { Self { added, removed } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct ConfigurationItem { /// The scope to get the configuration section for. #[serde(skip_serializing_if = "Option::is_none")] pub scope_uri: Option, /// The configuration section asked for. #[serde(skip_serializing_if = "Option::is_none")] pub section: Option, } impl ConfigurationItem { #[must_use] pub const fn new(scope_uri: Option, section: Option) -> Self { Self { scope_uri, section } } } /// A literal to identify a text document in the client. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct TextDocumentIdentifier { /// The text document's uri. pub uri: Uri, } impl TextDocumentIdentifier { #[must_use] pub const fn new(uri: Uri) -> Self { Self { uri } } } /// Represents a color in RGBA space. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct Color { /// The red component of this color in the range [0-1]. pub red: f32, /// The green component of this color in the range [0-1]. pub green: f32, /// The blue component of this color in the range [0-1]. pub blue: f32, /// The alpha component of this color in the range [0-1]. pub alpha: f32, } impl Color { #[must_use] pub const fn new(red: f32, green: f32, blue: f32, alpha: f32) -> Self { Self { red, green, blue, alpha } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct DocumentColorOptions { #[serde(flatten)] pub work_done_progress_options: WorkDoneProgressOptions, } impl DocumentColorOptions { #[must_use] pub const fn new(work_done_progress_options: WorkDoneProgressOptions) -> Self { Self { work_done_progress_options } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct FoldingRangeOptions { #[serde(flatten)] pub work_done_progress_options: WorkDoneProgressOptions, } impl FoldingRangeOptions { #[must_use] pub const fn new(work_done_progress_options: WorkDoneProgressOptions) -> Self { Self { work_done_progress_options } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct DeclarationOptions { #[serde(flatten)] pub work_done_progress_options: WorkDoneProgressOptions, } impl DeclarationOptions { #[must_use] pub const fn new(work_done_progress_options: WorkDoneProgressOptions) -> Self { Self { work_done_progress_options } } } /// Position in a text document expressed as zero-based line and character /// offset. Prior to 3.17 the offsets were always based on a UTF-16 string /// representation. So a string of the form `a𐐀b` the character offset of the /// character `a` is 0, the character offset of `𐐀` is 1 and the character /// offset of b is 3 since `𐐀` is represented using two code units in UTF-16. /// Since 3.17 clients and servers can agree on a different string encoding /// representation (e.g. UTF-8). The client announces it's supported encoding /// via the client capability [`general.positionEncodings`](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#clientCapabilities). /// The value is an array of position encodings the client supports, with /// decreasing preference (e.g. the encoding at index `0` is the most preferred /// one). To stay backwards compatible the only mandatory encoding is UTF-16 /// represented via the string `utf-16`. The server can pick one of the /// encodings offered by the client and signals that encoding back to the /// client via the initialize result's property /// [`capabilities.positionEncoding`](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#serverCapabilities). If the string value /// `utf-16` is missing from the client's capability `general.positionEncodings` /// servers can safely assume that the client supports UTF-16. If the server /// omits the position encoding in its initialize result the encoding defaults /// to the string value `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. /// /// Positions are line end character agnostic. So you can not specify a position /// that denotes `\r|\n` or `\n|` where `|` represents the character offset. /// /// @since 3.17.0 - support for negotiated position encoding. #[derive( Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy, PartialOrd, Ord )] #[serde(rename_all = "camelCase")] pub struct Position { /// Line position in a document (zero-based). pub line: u32, /// Character offset on a line in a document (zero-based). /// /// The meaning of this offset is determined by the negotiated /// `PositionEncodingKind`. pub character: u32, } impl Position { #[must_use] pub const fn new(line: u32, character: u32) -> Self { Self { line, character } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct SelectionRangeOptions { #[serde(flatten)] pub work_done_progress_options: WorkDoneProgressOptions, } impl SelectionRangeOptions { #[must_use] pub const fn new(work_done_progress_options: WorkDoneProgressOptions) -> Self { Self { work_done_progress_options } } } /// Call hierarchy options used during static registration. /// /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct CallHierarchyOptions { #[serde(flatten)] pub work_done_progress_options: WorkDoneProgressOptions, } impl CallHierarchyOptions { #[must_use] pub const fn new(work_done_progress_options: WorkDoneProgressOptions) -> Self { Self { work_done_progress_options } } } /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct SemanticTokensOptions { /// The legend used by the server pub legend: SemanticTokensLegend, /// Server supports providing semantic tokens for a specific range /// of a document. #[serde(skip_serializing_if = "Option::is_none")] pub range: Option, /// Server supports providing semantic tokens for a full document. #[serde(skip_serializing_if = "Option::is_none")] pub full: Option, #[serde(flatten)] pub work_done_progress_options: WorkDoneProgressOptions, } impl SemanticTokensOptions { #[must_use] pub const fn new( legend: SemanticTokensLegend, range: Option, full: Option, work_done_progress_options: WorkDoneProgressOptions, ) -> Self { Self { legend, range, full, work_done_progress_options, } } } /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct SemanticTokensEdit { /// The start offset of the edit. pub start: u32, /// The count of elements to remove. pub delete_count: u32, /// The elements to insert. #[serde( default, skip_serializing_if = "Option::is_none", deserialize_with = "SemanticToken::deserialize_optional_tokens", serialize_with = "SemanticToken::serialize_optional_tokens" )] pub data: Option>, } impl SemanticTokensEdit { #[must_use] pub const fn new( start: u32, delete_count: u32, data: Option>, ) -> Self { Self { start, delete_count, data } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct LinkedEditingRangeOptions { #[serde(flatten)] pub work_done_progress_options: WorkDoneProgressOptions, } impl LinkedEditingRangeOptions { #[must_use] pub const fn new(work_done_progress_options: WorkDoneProgressOptions) -> Self { Self { work_done_progress_options } } } /// Represents information on a file/folder create. /// /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct FileCreate { /// A file:// URI for the location of the file/folder being created. pub uri: String, } impl FileCreate { #[must_use] pub const fn new(uri: String) -> Self { Self { uri } } } /// Describes textual changes on a text document. A TextDocumentEdit describes all changes /// on a document version Si and after they are applied move the document to version Si+1. /// So the creator of a TextDocumentEdit doesn't need to sort the array of edits or do any /// kind of ordering. However the edits must be non overlapping. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct TextDocumentEdit { /// The text document to change. pub text_document: OptionalVersionedTextDocumentIdentifier, /// The edits to be applied. /// /// @since 3.16.0 - support for AnnotatedTextEdit. This is guarded using a /// client capability. /// /// @since 3.18.0 - support for SnippetTextEdit. This is guarded using a /// client capability. pub edits: Vec, } impl TextDocumentEdit { #[must_use] pub const fn new( text_document: OptionalVersionedTextDocumentIdentifier, edits: Vec, ) -> Self { Self { text_document, edits } } } /// Create file operation. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] #[serde(try_from = "ShadowCreateFile", into = "ShadowCreateFile")] pub struct CreateFile { /// The resource to create. pub uri: Uri, /// Additional options #[serde(skip_serializing_if = "Option::is_none")] pub options: Option, /// An optional annotation identifier describing the operation. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub annotation_id: Option, } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] struct ShadowCreateFile { /// The resource to create. pub uri: Uri, /// Additional options #[serde(skip_serializing_if = "Option::is_none")] pub options: Option, /// An optional annotation identifier describing the operation. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub annotation_id: Option, pub kind: String, } impl TryFrom for CreateFile { type Error = String; fn try_from(shadow: ShadowCreateFile) -> Result { if shadow.kind != "create" { return Err(format!("Invalid value for prop kind: {}", shadow.kind)); } Ok(Self { uri: shadow.uri, options: shadow.options, annotation_id: shadow.annotation_id, }) } } impl From for ShadowCreateFile { fn from(original: CreateFile) -> Self { Self { uri: original.uri, options: original.options, annotation_id: original.annotation_id, kind: "create".to_string(), } } } impl CreateFile { #[must_use] pub const fn new( uri: Uri, options: Option, annotation_id: Option, ) -> Self { Self { uri, options, annotation_id, } } } /// Rename file operation #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] #[serde(try_from = "ShadowRenameFile", into = "ShadowRenameFile")] pub struct RenameFile { /// The old (existing) location. pub old_uri: Uri, /// The new location. pub new_uri: Uri, /// Rename options. #[serde(skip_serializing_if = "Option::is_none")] pub options: Option, /// An optional annotation identifier describing the operation. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub annotation_id: Option, } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] struct ShadowRenameFile { /// The old (existing) location. pub old_uri: Uri, /// The new location. pub new_uri: Uri, /// Rename options. #[serde(skip_serializing_if = "Option::is_none")] pub options: Option, /// An optional annotation identifier describing the operation. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub annotation_id: Option, pub kind: String, } impl TryFrom for RenameFile { type Error = String; fn try_from(shadow: ShadowRenameFile) -> Result { if shadow.kind != "rename" { return Err(format!("Invalid value for prop kind: {}", shadow.kind)); } Ok(Self { old_uri: shadow.old_uri, new_uri: shadow.new_uri, options: shadow.options, annotation_id: shadow.annotation_id, }) } } impl From for ShadowRenameFile { fn from(original: RenameFile) -> Self { Self { old_uri: original.old_uri, new_uri: original.new_uri, options: original.options, annotation_id: original.annotation_id, kind: "rename".to_string(), } } } impl RenameFile { #[must_use] pub const fn new( old_uri: Uri, new_uri: Uri, options: Option, annotation_id: Option, ) -> Self { Self { old_uri, new_uri, options, annotation_id, } } } /// Delete file operation #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] #[serde(try_from = "ShadowDeleteFile", into = "ShadowDeleteFile")] pub struct DeleteFile { /// The file to delete. pub uri: Uri, /// Delete options. #[serde(skip_serializing_if = "Option::is_none")] pub options: Option, /// An optional annotation identifier describing the operation. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub annotation_id: Option, } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] struct ShadowDeleteFile { /// The file to delete. pub uri: Uri, /// Delete options. #[serde(skip_serializing_if = "Option::is_none")] pub options: Option, /// An optional annotation identifier describing the operation. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub annotation_id: Option, pub kind: String, } impl TryFrom for DeleteFile { type Error = String; fn try_from(shadow: ShadowDeleteFile) -> Result { if shadow.kind != "delete" { return Err(format!("Invalid value for prop kind: {}", shadow.kind)); } Ok(Self { uri: shadow.uri, options: shadow.options, annotation_id: shadow.annotation_id, }) } } impl From for ShadowDeleteFile { fn from(original: DeleteFile) -> Self { Self { uri: original.uri, options: original.options, annotation_id: original.annotation_id, kind: "delete".to_string(), } } } impl DeleteFile { #[must_use] pub const fn new( uri: Uri, options: Option, annotation_id: Option, ) -> Self { Self { uri, options, annotation_id, } } } /// Additional information that describes document changes. /// /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct ChangeAnnotation { /// A human-readable string describing the actual change. The string /// is rendered prominent in the user interface. pub label: String, /// A flag which indicates that user confirmation is needed /// before applying the change. #[serde(skip_serializing_if = "Option::is_none")] pub needs_confirmation: Option, /// A human-readable string which is rendered less prominent in /// the user interface. #[serde(skip_serializing_if = "Option::is_none")] pub description: Option, } impl ChangeAnnotation { #[must_use] pub const fn new( label: String, needs_confirmation: Option, description: Option, ) -> Self { Self { label, needs_confirmation, description, } } } /// A filter to describe in which file operation requests or notifications /// the server is interested in receiving. /// /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct FileOperationFilter { /// A Uri scheme like `file` or `untitled`. #[serde(skip_serializing_if = "Option::is_none")] pub scheme: Option, /// The actual file operation pattern. pub pattern: FileOperationPattern, } impl FileOperationFilter { #[must_use] pub const fn new(scheme: Option, pattern: FileOperationPattern) -> Self { Self { scheme, pattern } } } /// Represents information on a file/folder rename. /// /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct FileRename { /// A file:// URI for the original location of the file/folder being renamed. pub old_uri: String, /// A file:// URI for the new location of the file/folder being renamed. pub new_uri: String, } impl FileRename { #[must_use] pub const fn new(old_uri: String, new_uri: String) -> Self { Self { old_uri, new_uri } } } /// Represents information on a file/folder delete. /// /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct FileDelete { /// A file:// URI for the location of the file/folder being deleted. pub uri: String, } impl FileDelete { #[must_use] pub const fn new(uri: String) -> Self { Self { uri } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct MonikerOptions { #[serde(flatten)] pub work_done_progress_options: WorkDoneProgressOptions, } impl MonikerOptions { #[must_use] pub const fn new(work_done_progress_options: WorkDoneProgressOptions) -> Self { Self { work_done_progress_options } } } /// Type hierarchy options used during static registration. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct TypeHierarchyOptions { #[serde(flatten)] pub work_done_progress_options: WorkDoneProgressOptions, } impl TypeHierarchyOptions { #[must_use] pub const fn new(work_done_progress_options: WorkDoneProgressOptions) -> Self { Self { work_done_progress_options } } } /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct InlineValueContext { /// The stack frame (as a DAP Id) where the execution has stopped. pub frame_id: i32, /// The document range where execution has stopped. /// Typically the end position of the range denotes the line where the inline values are shown. pub stopped_location: Range, } impl InlineValueContext { #[must_use] pub const fn new(frame_id: i32, stopped_location: Range) -> Self { Self { frame_id, stopped_location } } } /// Returns inline value information as the complete text to be shown. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct InlineValueText { /// The document range for which the inline value applies. pub range: Range, /// The text of the inline value. pub text: String, } impl InlineValueText { #[must_use] pub const fn new(range: Range, text: String) -> Self { Self { range, text } } } /// To compute inline value through a variable lookup. /// /// If only a range is specified, the variable name should /// be extracted from the underlying document. /// /// An optional variable name could be used to lookup instead /// of the extracted name. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct InlineValueVariableLookup { /// The document range for which the inline value applies. /// /// The range could be used to extract the variable name /// from the underlying document. pub range: Range, /// If specified the name of the variable to look up. #[serde(skip_serializing_if = "Option::is_none")] pub variable_name: Option, /// How to perform the lookup. pub case_sensitive_lookup: bool, } impl InlineValueVariableLookup { #[must_use] pub const fn new( range: Range, variable_name: Option, case_sensitive_lookup: bool, ) -> Self { Self { range, variable_name, case_sensitive_lookup, } } } /// To compute an inline value through an expression evaluation. /// /// If only a range is specified, the expression should be /// extracted from the underlying document. /// /// An optional expression could be evaluated instead of /// the extracted expression. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct InlineValueEvaluatableExpression { /// The document range for which the inline value applies. /// /// The range could be used to extract the evaluatable expression /// from the underlying document. pub range: Range, /// If specified the expression could be evaluated instead. #[serde(skip_serializing_if = "Option::is_none")] pub expression: Option, } impl InlineValueEvaluatableExpression { #[must_use] pub const fn new(range: Range, expression: Option) -> Self { Self { range, expression } } } /// Inline value options used during static registration. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct InlineValueOptions { #[serde(flatten)] pub work_done_progress_options: WorkDoneProgressOptions, } impl InlineValueOptions { #[must_use] pub const fn new(work_done_progress_options: WorkDoneProgressOptions) -> Self { Self { work_done_progress_options } } } /// An inlay hint label part allows for interactive and composite labels /// of inlay hints. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct InlayHintLabelPart { /// The value of this label part. pub value: String, /// The tooltip text when you hover over this label part. Depending on /// the client capability `inlayHint.resolveSupport` clients might resolve /// this property late using the resolve request. #[serde(skip_serializing_if = "Option::is_none")] pub tooltip: Option, /// An optional source code location that represents this /// label part. /// /// The editor will use this location for the hover and for code navigation /// features: This part will become a clickable link that resolves to the /// definition of the symbol at the given location (not necessarily the /// location itself), it shows the hover that shows at the given location, /// and it shows a context menu with further code navigation commands. /// /// Depending on the client capability `inlayHint.resolveSupport` clients /// might resolve this property late using the resolve request. #[serde(skip_serializing_if = "Option::is_none")] pub location: Option, /// An optional command for this label part. /// /// Depending on the client capability `inlayHint.resolveSupport` clients /// might resolve this property late using the resolve request. #[serde(skip_serializing_if = "Option::is_none")] pub command: Option, } impl InlayHintLabelPart { #[must_use] pub const fn new( value: String, tooltip: Option, location: Option, command: Option, ) -> Self { Self { value, tooltip, location, command, } } } /// A `MarkupContent` literal represents a string value which content is interpreted base on its /// kind flag. Currently the protocol supports `plaintext` and `markdown` as markup kinds. /// /// If the kind is `markdown` then the value can contain fenced code blocks like in GitHub issues. /// See https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting /// /// Here is an example how such a string can be constructed using JavaScript / TypeScript: /// ```ts /// let markdown: MarkdownContent = { /// kind: MarkupKind.Markdown, /// value: [ /// '# Header', /// 'Some text', /// '```typescript', /// 'someCode();', /// '```' /// ].join('\n') /// }; /// ``` /// /// *Please Note* that clients might sanitize the return markdown. A client could decide to /// remove HTML from the markdown to avoid script execution. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct MarkupContent { /// The type of the Markup pub kind: MarkupKind, /// The content itself pub value: String, } impl MarkupContent { #[must_use] pub const fn new(kind: MarkupKind, value: String) -> Self { Self { kind, value } } } /// Inlay hint options used during static registration. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct InlayHintOptions { /// The server provides support to resolve additional /// information for an inlay hint item. #[serde(skip_serializing_if = "Option::is_none")] pub resolve_provider: Option, #[serde(flatten)] pub work_done_progress_options: WorkDoneProgressOptions, } impl InlayHintOptions { #[must_use] pub const fn new( resolve_provider: Option, work_done_progress_options: WorkDoneProgressOptions, ) -> Self { Self { resolve_provider, work_done_progress_options, } } } /// A full diagnostic report with a set of related documents. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Default)] #[serde(rename_all = "camelCase")] pub struct RelatedFullDocumentDiagnosticReport { /// Diagnostics of related documents. This information is useful /// in programming languages where code in a file A can generate /// diagnostics in a file B which A depends on. An example of /// such a language is C/C++ where marco definitions in a file /// a.cpp and result in errors in a header file b.hpp. /// /// @since 3.17.0 #[serde(skip_serializing_if = "Option::is_none")] pub related_documents: Option>, #[serde(flatten)] pub full_document_diagnostic_report: FullDocumentDiagnosticReport, } impl RelatedFullDocumentDiagnosticReport { #[must_use] pub const fn new( related_documents: Option>, full_document_diagnostic_report: FullDocumentDiagnosticReport, ) -> Self { Self { related_documents, full_document_diagnostic_report, } } } /// An unchanged diagnostic report with a set of related documents. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Default)] #[serde(rename_all = "camelCase")] pub struct RelatedUnchangedDocumentDiagnosticReport { /// Diagnostics of related documents. This information is useful /// in programming languages where code in a file A can generate /// diagnostics in a file B which A depends on. An example of /// such a language is C/C++ where marco definitions in a file /// a.cpp and result in errors in a header file b.hpp. /// /// @since 3.17.0 #[serde(skip_serializing_if = "Option::is_none")] pub related_documents: Option>, #[serde(flatten)] pub unchanged_document_diagnostic_report: UnchangedDocumentDiagnosticReport, } impl RelatedUnchangedDocumentDiagnosticReport { #[must_use] pub const fn new( related_documents: Option>, unchanged_document_diagnostic_report: UnchangedDocumentDiagnosticReport, ) -> Self { Self { related_documents, unchanged_document_diagnostic_report, } } } /// A diagnostic report with a full set of problems. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] #[serde( try_from = "ShadowFullDocumentDiagnosticReport", into = "ShadowFullDocumentDiagnosticReport" )] pub struct FullDocumentDiagnosticReport { /// An optional result id. If provided it will /// be sent on the next diagnostic request for the /// same document. #[serde(skip_serializing_if = "Option::is_none")] pub result_id: Option, /// The actual items. pub items: Vec, } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] struct ShadowFullDocumentDiagnosticReport { /// An optional result id. If provided it will /// be sent on the next diagnostic request for the /// same document. #[serde(skip_serializing_if = "Option::is_none")] pub result_id: Option, /// The actual items. pub items: Vec, pub kind: String, } impl TryFrom for FullDocumentDiagnosticReport { type Error = String; fn try_from( shadow: ShadowFullDocumentDiagnosticReport, ) -> Result { if shadow.kind != "full" { return Err(format!("Invalid value for prop kind: {}", shadow.kind)); } Ok(Self { result_id: shadow.result_id, items: shadow.items, }) } } impl From for ShadowFullDocumentDiagnosticReport { fn from(original: FullDocumentDiagnosticReport) -> Self { Self { result_id: original.result_id, items: original.items, kind: "full".to_string(), } } } impl FullDocumentDiagnosticReport { #[must_use] pub const fn new(result_id: Option, items: Vec) -> Self { Self { result_id, items } } } /// A diagnostic report indicating that the last returned /// report is still accurate. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] #[serde( try_from = "ShadowUnchangedDocumentDiagnosticReport", into = "ShadowUnchangedDocumentDiagnosticReport" )] pub struct UnchangedDocumentDiagnosticReport { /// A result id which will be sent on the next /// diagnostic request for the same document. pub result_id: String, } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] struct ShadowUnchangedDocumentDiagnosticReport { /// A result id which will be sent on the next /// diagnostic request for the same document. pub result_id: String, pub kind: String, } impl TryFrom for UnchangedDocumentDiagnosticReport { type Error = String; fn try_from( shadow: ShadowUnchangedDocumentDiagnosticReport, ) -> Result { if shadow.kind != "unchanged" { return Err(format!("Invalid value for prop kind: {}", shadow.kind)); } Ok(Self { result_id: shadow.result_id, }) } } impl From for ShadowUnchangedDocumentDiagnosticReport { fn from(original: UnchangedDocumentDiagnosticReport) -> Self { Self { result_id: original.result_id, kind: "unchanged".to_string(), } } } impl UnchangedDocumentDiagnosticReport { #[must_use] pub const fn new(result_id: String) -> Self { Self { result_id } } } /// Diagnostic options. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct DiagnosticOptions { /// An optional identifier under which the diagnostics are /// managed by the client. #[serde(skip_serializing_if = "Option::is_none")] pub identifier: Option, /// 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. pub inter_file_dependencies: bool, /// The server provides support for workspace diagnostics as well. pub workspace_diagnostics: bool, #[serde(flatten)] pub work_done_progress_options: WorkDoneProgressOptions, } impl DiagnosticOptions { #[must_use] pub const fn new( identifier: Option, inter_file_dependencies: bool, workspace_diagnostics: bool, work_done_progress_options: WorkDoneProgressOptions, ) -> Self { Self { identifier, inter_file_dependencies, workspace_diagnostics, work_done_progress_options, } } } /// A previous result id in a workspace pull request. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct PreviousResultId { /// The URI for which the client knowns a /// result id. pub uri: Uri, /// The value of the previous result id. pub value: String, } impl PreviousResultId { #[must_use] pub const fn new(uri: Uri, value: String) -> Self { Self { uri, value } } } /// A notebook document. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct NotebookDocument { /// The notebook document's uri. pub uri: Uri, /// The type of the notebook. pub notebook_type: String, /// The version number of this document (it will increase after each /// change, including undo/redo). pub version: i32, /// Additional metadata stored with the notebook /// document. /// /// Note: should always be an object literal (e.g. LSPObject) #[serde(skip_serializing_if = "Option::is_none")] pub metadata: Option, /// The cells of a notebook. pub cells: Vec, } impl NotebookDocument { #[must_use] pub const fn new( uri: Uri, notebook_type: String, version: i32, metadata: Option, cells: Vec, ) -> Self { Self { uri, notebook_type, version, metadata, cells, } } } /// An item to transfer a text document from the client to the /// server. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct TextDocumentItem { /// The text document's uri. pub uri: Uri, /// The text document's language identifier. pub language_id: LanguageKind, /// The version number of this document (it will increase after each /// change, including undo/redo). pub version: i32, /// The content of the opened text document. pub text: String, } impl TextDocumentItem { #[must_use] pub const fn new( uri: Uri, language_id: LanguageKind, version: i32, text: String, ) -> Self { Self { uri, language_id, version, text, } } } /// Options specific to a notebook plus its cells /// to be synced to the server. /// /// If a selector provides a notebook document /// filter but no cell selector all cells of a /// matching notebook document will be synced. /// /// If a selector provides no notebook document /// filter but only a cell selector all notebook /// document that contain at least one matching /// cell will be synced. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct NotebookDocumentSyncOptions { /// The notebooks to be synced pub notebook_selector: Vec, /// Whether save notification should be forwarded to /// the server. Will only be honored if mode === `notebook`. #[serde(skip_serializing_if = "Option::is_none")] pub save: Option, } impl NotebookDocumentSyncOptions { #[must_use] pub const fn new( notebook_selector: Vec, save: Option, ) -> Self { Self { notebook_selector, save } } } /// A versioned notebook document identifier. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct VersionedNotebookDocumentIdentifier { /// The version number of this notebook document. pub version: i32, /// The notebook document's uri. pub uri: Uri, } impl VersionedNotebookDocumentIdentifier { #[must_use] pub const fn new(version: i32, uri: Uri) -> Self { Self { version, uri } } } /// A change event for a notebook document. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct NotebookDocumentChangeEvent { /// The changed meta data if any. /// /// Note: should always be an object literal (e.g. LSPObject) #[serde(skip_serializing_if = "Option::is_none")] pub metadata: Option, /// Changes to cells #[serde(skip_serializing_if = "Option::is_none")] pub cells: Option, } impl NotebookDocumentChangeEvent { #[must_use] pub const fn new( metadata: Option, cells: Option, ) -> Self { Self { metadata, cells } } } /// A literal to identify a notebook document in the client. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct NotebookDocumentIdentifier { /// The notebook document's uri. pub uri: Uri, } impl NotebookDocumentIdentifier { #[must_use] pub const fn new(uri: Uri) -> Self { Self { uri } } } /// Provides information about the context in which an inline completion was requested. /// /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct InlineCompletionContext { /// Describes how the inline completion was triggered. pub trigger_kind: InlineCompletionTriggerKind, /// Provides information about the currently selected item in the autocomplete widget if it is visible. #[serde(skip_serializing_if = "Option::is_none")] pub selected_completion_info: Option, } impl InlineCompletionContext { #[must_use] pub const fn new( trigger_kind: InlineCompletionTriggerKind, selected_completion_info: Option, ) -> Self { Self { trigger_kind, selected_completion_info, } } } /// A string value used as a snippet is a template which allows to insert text /// and to control the editor cursor when insertion happens. /// /// 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. Variables are defined with `$name` and /// `${name:default value}`. /// /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] #[serde(try_from = "ShadowStringValue", into = "ShadowStringValue")] pub struct StringValue { /// The snippet string. pub value: String, } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] struct ShadowStringValue { /// The snippet string. pub value: String, pub kind: String, } impl TryFrom for StringValue { type Error = String; fn try_from(shadow: ShadowStringValue) -> Result { if shadow.kind != "snippet" { return Err(format!("Invalid value for prop kind: {}", shadow.kind)); } Ok(Self { value: shadow.value }) } } impl From for ShadowStringValue { fn from(original: StringValue) -> Self { Self { value: original.value, kind: "snippet".to_string(), } } } impl StringValue { #[must_use] pub const fn new(value: String) -> Self { Self { value } } } /// Inline completion options used during static registration. /// /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct InlineCompletionOptions { #[serde(flatten)] pub work_done_progress_options: WorkDoneProgressOptions, } impl InlineCompletionOptions { #[must_use] pub const fn new(work_done_progress_options: WorkDoneProgressOptions) -> Self { Self { work_done_progress_options } } } /// Text document content provider options. /// /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct TextDocumentContentOptions { /// The schemes for which the server provides content. pub schemes: Vec, } impl TextDocumentContentOptions { #[must_use] pub const fn new(schemes: Vec) -> Self { Self { schemes } } } /// General parameters to register for a notification or to register a provider. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct Registration { /// The id used to register the request. The id can be used to deregister /// the request again. pub id: String, /// The method / capability to register for. pub method: String, /// Options necessary for the registration. #[serde(skip_serializing_if = "Option::is_none")] pub register_options: Option, } impl Registration { #[must_use] pub const fn new( id: String, method: String, register_options: Option, ) -> Self { Self { id, method, register_options, } } } /// General parameters to unregister a request or notification. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct Unregistration { /// The id used to unregister the request or notification. Usually an id /// provided during the register request. pub id: String, /// The method to unregister for. pub method: String, } impl Unregistration { #[must_use] pub const fn new(id: String, method: String) -> Self { Self { id, method } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct WorkspaceFoldersInitializeParams { /// The workspace folders configured in the client when the server starts. /// /// This property is only available if the client supports workspace folders. /// It can be `null` if the client supports workspace folders but none are /// configured. /// /// @since 3.6.0 #[serde(default, deserialize_with = "deserialize_some")] #[serde(skip_serializing_if = "Option::is_none")] pub workspace_folders: Option, } impl WorkspaceFoldersInitializeParams { #[must_use] pub const fn new(workspace_folders: Option) -> Self { Self { workspace_folders } } } /// Defines the capabilities provided by a language /// server. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct ServerCapabilities { /// The position encoding the server picked from the encodings offered /// by the client via the client capability `general.positionEncodings`. /// /// If the client didn't provide any position encodings the only valid /// value that a server can return is 'utf-16'. /// /// If omitted it defaults to 'utf-16'. /// /// @since 3.17.0 #[serde(skip_serializing_if = "Option::is_none")] pub position_encoding: Option, /// Defines how text documents are synced. Is either a detailed structure /// defining each notification or for backwards compatibility the /// TextDocumentSyncKind number. #[serde(skip_serializing_if = "Option::is_none")] pub text_document_sync: Option, /// Defines how notebook documents are synced. /// /// @since 3.17.0 #[serde(skip_serializing_if = "Option::is_none")] pub notebook_document_sync: Option, /// The server provides completion support. #[serde(skip_serializing_if = "Option::is_none")] pub completion_provider: Option, /// The server provides hover support. #[serde(skip_serializing_if = "Option::is_none")] pub hover_provider: Option, /// The server provides signature help support. #[serde(skip_serializing_if = "Option::is_none")] pub signature_help_provider: Option, /// The server provides Goto Declaration support. #[serde(skip_serializing_if = "Option::is_none")] pub declaration_provider: Option, /// The server provides goto definition support. #[serde(skip_serializing_if = "Option::is_none")] pub definition_provider: Option, /// The server provides Goto Type Definition support. #[serde(skip_serializing_if = "Option::is_none")] pub type_definition_provider: Option, /// The server provides Goto Implementation support. #[serde(skip_serializing_if = "Option::is_none")] pub implementation_provider: Option, /// The server provides find references support. #[serde(skip_serializing_if = "Option::is_none")] pub references_provider: Option, /// The server provides document highlight support. #[serde(skip_serializing_if = "Option::is_none")] pub document_highlight_provider: Option, /// The server provides document symbol support. #[serde(skip_serializing_if = "Option::is_none")] pub document_symbol_provider: Option, /// The server provides code actions. CodeActionOptions may only be /// specified if the client states that it supports /// `codeActionLiteralSupport` in its initial `initialize` request. #[serde(skip_serializing_if = "Option::is_none")] pub code_action_provider: Option, /// The server provides code lens. #[serde(skip_serializing_if = "Option::is_none")] pub code_lens_provider: Option, /// The server provides document link support. #[serde(skip_serializing_if = "Option::is_none")] pub document_link_provider: Option, /// The server provides color provider support. #[serde(skip_serializing_if = "Option::is_none")] pub color_provider: Option, /// The server provides workspace symbol support. #[serde(skip_serializing_if = "Option::is_none")] pub workspace_symbol_provider: Option, /// The server provides document formatting. #[serde(skip_serializing_if = "Option::is_none")] pub document_formatting_provider: Option, /// The server provides document range formatting. #[serde(skip_serializing_if = "Option::is_none")] pub document_range_formatting_provider: Option, /// The server provides document formatting on typing. #[serde(skip_serializing_if = "Option::is_none")] pub document_on_type_formatting_provider: Option, /// The server provides rename support. RenameOptions may only be /// specified if the client states that it supports /// `prepareSupport` in its initial `initialize` request. #[serde(skip_serializing_if = "Option::is_none")] pub rename_provider: Option, /// The server provides folding provider support. #[serde(skip_serializing_if = "Option::is_none")] pub folding_range_provider: Option, /// The server provides selection range support. #[serde(skip_serializing_if = "Option::is_none")] pub selection_range_provider: Option, /// The server provides execute command support. #[serde(skip_serializing_if = "Option::is_none")] pub execute_command_provider: Option, /// The server provides call hierarchy support. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub call_hierarchy_provider: Option, /// The server provides linked editing range support. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub linked_editing_range_provider: Option, /// The server provides semantic tokens support. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub semantic_tokens_provider: Option, /// The server provides moniker support. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub moniker_provider: Option, /// The server provides type hierarchy support. /// /// @since 3.17.0 #[serde(skip_serializing_if = "Option::is_none")] pub type_hierarchy_provider: Option, /// The server provides inline values. /// /// @since 3.17.0 #[serde(skip_serializing_if = "Option::is_none")] pub inline_value_provider: Option, /// The server provides inlay hints. /// /// @since 3.17.0 #[serde(skip_serializing_if = "Option::is_none")] pub inlay_hint_provider: Option, /// The server has support for pull model diagnostics. /// /// @since 3.17.0 #[serde(skip_serializing_if = "Option::is_none")] pub diagnostic_provider: Option, /// Inline completion options used during static registration. /// /// @since 3.18.0 #[serde(skip_serializing_if = "Option::is_none")] pub inline_completion_provider: Option, /// Workspace specific server capabilities. #[serde(skip_serializing_if = "Option::is_none")] pub workspace: Option, /// Experimental server capabilities. #[serde(skip_serializing_if = "Option::is_none")] pub experimental: Option, } impl ServerCapabilities { #[must_use] pub const fn new( position_encoding: Option, text_document_sync: Option, notebook_document_sync: Option, completion_provider: Option, hover_provider: Option, signature_help_provider: Option, declaration_provider: Option, definition_provider: Option, type_definition_provider: Option, implementation_provider: Option, references_provider: Option, document_highlight_provider: Option, document_symbol_provider: Option, code_action_provider: Option, code_lens_provider: Option, document_link_provider: Option, color_provider: Option, workspace_symbol_provider: Option, document_formatting_provider: Option, document_range_formatting_provider: Option, document_on_type_formatting_provider: Option, rename_provider: Option, folding_range_provider: Option, selection_range_provider: Option, execute_command_provider: Option, call_hierarchy_provider: Option, linked_editing_range_provider: Option, semantic_tokens_provider: Option, moniker_provider: Option, type_hierarchy_provider: Option, inline_value_provider: Option, inlay_hint_provider: Option, diagnostic_provider: Option, inline_completion_provider: Option, workspace: Option, experimental: Option, ) -> Self { Self { position_encoding, text_document_sync, notebook_document_sync, completion_provider, hover_provider, signature_help_provider, declaration_provider, definition_provider, type_definition_provider, implementation_provider, references_provider, document_highlight_provider, document_symbol_provider, code_action_provider, code_lens_provider, document_link_provider, color_provider, workspace_symbol_provider, document_formatting_provider, document_range_formatting_provider, document_on_type_formatting_provider, rename_provider, folding_range_provider, selection_range_provider, execute_command_provider, call_hierarchy_provider, linked_editing_range_provider, semantic_tokens_provider, moniker_provider, type_hierarchy_provider, inline_value_provider, inlay_hint_provider, diagnostic_provider, inline_completion_provider, workspace, experimental, } } } /// Information about the server /// /// @since 3.15.0 /// @since 3.18.0 ServerInfo type name added. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct ServerInfo { /// The name of the server as defined by the server. pub name: String, /// The server's version as defined by the server. #[serde(skip_serializing_if = "Option::is_none")] pub version: Option, } impl ServerInfo { #[must_use] pub const fn new(name: String, version: Option) -> Self { Self { name, version } } } /// A text document identifier to denote a specific version of a text document. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct VersionedTextDocumentIdentifier { /// The version number of this document. pub version: i32, #[serde(flatten)] pub text_document_identifier: TextDocumentIdentifier, } impl VersionedTextDocumentIdentifier { #[must_use] pub const fn new( version: i32, text_document_identifier: TextDocumentIdentifier, ) -> Self { Self { version, text_document_identifier, } } } /// Save options. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct SaveOptions { /// The client is supposed to include the content on save. #[serde(skip_serializing_if = "Option::is_none")] pub include_text: Option, } impl SaveOptions { #[must_use] pub const fn new(include_text: Option) -> Self { Self { include_text } } } /// An event describing a file change. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct FileEvent { /// The file's uri. pub uri: Uri, /// The change type. #[serde(rename = "type")] pub kind: FileChangeType, } impl FileEvent { #[must_use] pub const fn new(uri: Uri, kind: FileChangeType) -> Self { Self { uri, kind } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct FileSystemWatcher { /// The glob pattern to watch. See [glob pattern][GlobPattern] for more detail. /// /// @since 3.17.0 support for relative patterns. pub glob_pattern: GlobPattern, /// The kind of events of interest. If omitted it defaults /// to WatchKind.Create | WatchKind.Change | WatchKind.Delete /// which is 7. #[serde(skip_serializing_if = "Option::is_none")] pub kind: Option, } impl FileSystemWatcher { #[must_use] pub const fn new(glob_pattern: GlobPattern, kind: Option) -> Self { Self { glob_pattern, kind } } } /// Represents a diagnostic, such as a compiler error or warning. Diagnostic objects /// are only valid in the scope of a resource. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct Diagnostic { /// The range at which the message applies pub range: Range, /// The diagnostic's severity. To avoid interpretation mismatches when a /// server is used with different clients it is highly recommended that servers /// always provide a severity value. #[serde(skip_serializing_if = "Option::is_none")] pub severity: Option, /// The diagnostic's code, which usually appear in the user interface. #[serde(skip_serializing_if = "Option::is_none")] pub code: Option, /// An optional property to describe the error code. /// Requires the code field (above) to be present/not null. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub code_description: Option, /// A human-readable string describing the source of this /// diagnostic, e.g. 'typescript' or 'super lint'. It usually /// appears in the user interface. #[serde(skip_serializing_if = "Option::is_none")] pub source: Option, /// The diagnostic's message. It usually appears in the user interface. /// /// @since 3.18.0 - support for MarkupContent. This is guarded by the client /// capability `textDocument.diagnostic.markupMessageSupport`. pub message: Message, /// Additional metadata about the diagnostic. /// /// @since 3.15.0 #[serde(skip_serializing_if = "Option::is_none")] pub tags: Option>, /// An array of related diagnostic information, e.g. when symbol-names within /// a scope collide all definitions can be marked via this property. #[serde(skip_serializing_if = "Option::is_none")] pub related_information: Option>, /// A data entry field that is preserved between a `textDocument/publishDiagnostics` /// notification and `textDocument/codeAction` request. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub data: Option, } impl Diagnostic { #[must_use] pub const fn new( range: Range, severity: Option, code: Option, code_description: Option, source: Option, message: Message, tags: Option>, related_information: Option>, data: Option, ) -> Self { Self { range, severity, code, code_description, source, message, tags, related_information, data, } } } /// Contains additional information about the context in which a completion request is triggered. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct CompletionContext { /// How the completion was triggered. pub trigger_kind: CompletionTriggerKind, /// The trigger character (a single character) that has trigger code complete. /// Is undefined if `triggerKind !== CompletionTriggerKind.TriggerCharacter` #[serde(skip_serializing_if = "Option::is_none")] pub trigger_character: Option, } impl CompletionContext { #[must_use] pub const fn new( trigger_kind: CompletionTriggerKind, trigger_character: Option, ) -> Self { Self { trigger_kind, trigger_character, } } } /// Additional details for a completion item label. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct CompletionItemLabelDetails { /// An optional string which is rendered less prominently directly after [label][`CompletionItem::label`], /// without any spacing. Should be used for function signatures and type annotations. #[serde(skip_serializing_if = "Option::is_none")] pub detail: Option, /// An optional string which is rendered less prominently after [`CompletionItem::detail`]. Should be used /// for fully qualified names and file paths. #[serde(skip_serializing_if = "Option::is_none")] pub description: Option, } impl CompletionItemLabelDetails { #[must_use] pub const fn new(detail: Option, description: Option) -> Self { Self { detail, description } } } /// A special text edit to provide an insert and a replace operation. /// /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct InsertReplaceEdit { /// The string to be inserted. pub new_text: String, /// The range if the insert is requested pub insert: Range, /// The range if the replace is requested. pub replace: Range, } impl InsertReplaceEdit { #[must_use] pub const fn new(new_text: String, insert: Range, replace: Range) -> Self { Self { new_text, insert, replace } } } /// 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 rules for combining these are /// defined by `applyKinds` (if the client supports it), defaulting to /// ApplyKind.Replace. /// /// Servers are only allowed to return default values if the client /// signals support for this via the `completionList.itemDefaults` /// capability. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct CompletionItemDefaults { /// A default commit character set. /// /// @since 3.17.0 #[serde(skip_serializing_if = "Option::is_none")] pub commit_characters: Option>, /// A default edit range. /// /// @since 3.17.0 #[serde(skip_serializing_if = "Option::is_none")] pub edit_range: Option, /// A default insert text format. /// /// @since 3.17.0 #[serde(skip_serializing_if = "Option::is_none")] pub insert_text_format: Option, /// A default insert text mode. /// /// @since 3.17.0 #[serde(skip_serializing_if = "Option::is_none")] pub insert_text_mode: Option, /// A default data value. /// /// @since 3.17.0 #[serde(skip_serializing_if = "Option::is_none")] pub data: Option, } impl CompletionItemDefaults { #[must_use] pub const fn new( commit_characters: Option>, edit_range: Option, insert_text_format: Option, insert_text_mode: Option, data: Option, ) -> Self { Self { commit_characters, edit_range, insert_text_format, insert_text_mode, data, } } } /// Specifies how fields from a completion item should be combined with those /// from `completionList.itemDefaults`. /// /// If unspecified, all fields will be treated as ApplyKind.Replace. /// /// If a field's value is ApplyKind.Replace, the value from a completion item (if /// provided and not `null`) will always be used instead of the value from /// `completionItem.itemDefaults`. /// /// If a field's value is ApplyKind.Merge, the values will be merged using the rules /// defined against each field below. /// /// Servers are only allowed to return `applyKind` if the client /// signals support for this via the `completionList.applyKindSupport` /// capability. /// /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct CompletionItemApplyKinds { /// Specifies whether commitCharacters on a completion will replace or be /// merged with those in `completionList.itemDefaults.commitCharacters`. /// /// If ApplyKind.Replace, the commit characters from the completion item will /// always be used unless not provided, in which case those from /// `completionList.itemDefaults.commitCharacters` will be used. An /// empty list can be used if a completion item does not have any commit /// characters and also should not use those from /// `completionList.itemDefaults.commitCharacters`. /// /// If ApplyKind.Merge the commitCharacters for the completion will be the /// union of all values in both `completionList.itemDefaults.commitCharacters` /// and the completion's own `commitCharacters`. /// /// @since 3.18.0 #[serde(skip_serializing_if = "Option::is_none")] pub commit_characters: Option, /// Specifies whether the `data` field on a completion will replace or /// be merged with data from `completionList.itemDefaults.data`. /// /// If ApplyKind.Replace, the data from the completion item will be used if /// provided (and not `null`), otherwise /// `completionList.itemDefaults.data` will be used. An empty object can /// be used if a completion item does not have any data but also should /// not use the value from `completionList.itemDefaults.data`. /// /// If ApplyKind.Merge, a shallow merge will be performed between /// `completionList.itemDefaults.data` and the completion's own data /// using the following rules: /// /// - If a completion's `data` field is not provided (or `null`), the /// entire `data` field from `completionList.itemDefaults.data` will be /// used as-is. /// - If a completion's `data` field is provided, each field will /// overwrite the field of the same name in /// `completionList.itemDefaults.data` but no merging of nested fields /// within that value will occur. /// /// @since 3.18.0 #[serde(skip_serializing_if = "Option::is_none")] pub data: Option, } impl CompletionItemApplyKinds { #[must_use] pub const fn new( commit_characters: Option, data: Option, ) -> Self { Self { commit_characters, data } } } /// Completion options. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct CompletionOptions { /// 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`. #[serde(skip_serializing_if = "Option::is_none")] pub trigger_characters: Option>, /// 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 #[serde(skip_serializing_if = "Option::is_none")] pub all_commit_characters: Option>, /// The server provides support to resolve additional /// information for a completion item. #[serde(skip_serializing_if = "Option::is_none")] pub resolve_provider: Option, /// The server supports the following `CompletionItem` specific /// capabilities. /// /// @since 3.17.0 #[serde(skip_serializing_if = "Option::is_none")] pub completion_item: Option, #[serde(flatten)] pub work_done_progress_options: WorkDoneProgressOptions, } impl CompletionOptions { #[must_use] pub const fn new( trigger_characters: Option>, all_commit_characters: Option>, resolve_provider: Option, completion_item: Option, work_done_progress_options: WorkDoneProgressOptions, ) -> Self { Self { trigger_characters, all_commit_characters, resolve_provider, completion_item, work_done_progress_options, } } } /// Hover options. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct HoverOptions { #[serde(flatten)] pub work_done_progress_options: WorkDoneProgressOptions, } impl HoverOptions { #[must_use] pub const fn new(work_done_progress_options: WorkDoneProgressOptions) -> Self { Self { work_done_progress_options } } } /// Additional information about the context in which a signature help request was triggered. /// /// @since 3.15.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct SignatureHelpContext { /// Action that caused signature help to be triggered. pub trigger_kind: SignatureHelpTriggerKind, /// Character that caused signature help to be triggered. /// /// This is undefined when `triggerKind !== SignatureHelpTriggerKind.TriggerCharacter` #[serde(skip_serializing_if = "Option::is_none")] pub trigger_character: Option, /// `true` if signature help was already showing when it was triggered. /// /// Retriggers occurs when the signature help is already active and can be caused by actions such as /// typing a trigger character, a cursor move, or document content changes. pub is_retrigger: bool, /// The currently active `SignatureHelp`. /// /// The `activeSignatureHelp` has its `SignatureHelp.activeSignature` field updated based on /// the user navigating through available signatures. #[serde(skip_serializing_if = "Option::is_none")] pub active_signature_help: Option, } impl SignatureHelpContext { #[must_use] pub const fn new( trigger_kind: SignatureHelpTriggerKind, trigger_character: Option, is_retrigger: bool, active_signature_help: Option, ) -> Self { Self { trigger_kind, trigger_character, is_retrigger, active_signature_help, } } } /// Represents the signature of something callable. A signature /// can have a label, like a function-name, a doc-comment, and /// a set of parameters. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct SignatureInformation { /// The label of this signature. Will be shown in /// the UI. pub label: String, /// The human-readable doc-comment of this signature. Will be shown /// in the UI but can be omitted. #[serde(skip_serializing_if = "Option::is_none")] pub documentation: Option, /// The parameters of this signature. #[serde(skip_serializing_if = "Option::is_none")] pub parameters: Option>, /// The index of the active parameter. /// /// If `null`, no parameter of the signature is active (for example a named /// argument that does not match any declared parameters). This is only valid /// if the client specifies the client capability /// `textDocument.signatureHelp.noActiveParameterSupport === true` /// /// If provided (or `null`), this is used in place of /// `SignatureHelp.activeParameter`. /// /// @since 3.16.0 #[serde(default, deserialize_with = "deserialize_some")] #[serde(skip_serializing_if = "Option::is_none")] pub active_parameter: Option, } impl SignatureInformation { #[must_use] pub const fn new( label: String, documentation: Option, parameters: Option>, active_parameter: Option, ) -> Self { Self { label, documentation, parameters, active_parameter, } } } /// Server Capabilities for a [`SignatureHelpRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct SignatureHelpOptions { /// List of characters that trigger signature help automatically. #[serde(skip_serializing_if = "Option::is_none")] pub trigger_characters: Option>, /// List of characters that re-trigger signature help. /// /// These trigger characters are only active when signature help is already showing. All trigger characters /// are also counted as re-trigger characters. /// /// @since 3.15.0 #[serde(skip_serializing_if = "Option::is_none")] pub retrigger_characters: Option>, #[serde(flatten)] pub work_done_progress_options: WorkDoneProgressOptions, } impl SignatureHelpOptions { #[must_use] pub const fn new( trigger_characters: Option>, retrigger_characters: Option>, work_done_progress_options: WorkDoneProgressOptions, ) -> Self { Self { trigger_characters, retrigger_characters, work_done_progress_options, } } } /// Server Capabilities for a [`DefinitionRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct DefinitionOptions { #[serde(flatten)] pub work_done_progress_options: WorkDoneProgressOptions, } impl DefinitionOptions { #[must_use] pub const fn new(work_done_progress_options: WorkDoneProgressOptions) -> Self { Self { work_done_progress_options } } } /// Value-object that contains additional information when /// requesting references. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct ReferenceContext { /// Include the declaration of the current symbol. pub include_declaration: bool, } impl ReferenceContext { #[must_use] pub const fn new(include_declaration: bool) -> Self { Self { include_declaration } } } /// Reference options. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct ReferenceOptions { #[serde(flatten)] pub work_done_progress_options: WorkDoneProgressOptions, } impl ReferenceOptions { #[must_use] pub const fn new(work_done_progress_options: WorkDoneProgressOptions) -> Self { Self { work_done_progress_options } } } /// Provider options for a [`DocumentHighlightRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct DocumentHighlightOptions { #[serde(flatten)] pub work_done_progress_options: WorkDoneProgressOptions, } impl DocumentHighlightOptions { #[must_use] pub const fn new(work_done_progress_options: WorkDoneProgressOptions) -> Self { Self { work_done_progress_options } } } /// A base for all symbol information. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct BaseSymbolInformation { /// The name of this symbol. pub name: String, /// The kind of this symbol. pub kind: SymbolKind, /// Tags for this symbol. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub tags: Option>, /// 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. #[serde(skip_serializing_if = "Option::is_none")] pub container_name: Option, } impl BaseSymbolInformation { #[must_use] pub const fn new( name: String, kind: SymbolKind, tags: Option>, container_name: Option, ) -> Self { Self { name, kind, tags, container_name, } } } /// Provider options for a [`DocumentSymbolRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct DocumentSymbolOptions { /// A human-readable string that is shown when multiple outlines trees /// are shown for the same document. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub label: Option, #[serde(flatten)] pub work_done_progress_options: WorkDoneProgressOptions, } impl DocumentSymbolOptions { #[must_use] pub const fn new( label: Option, work_done_progress_options: WorkDoneProgressOptions, ) -> Self { Self { label, work_done_progress_options, } } } /// Contains additional diagnostic information about the context in which /// a [code action][`CodeActionProvider::provideCodeActions`] is run. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct CodeActionContext { /// 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. pub diagnostics: Vec, /// 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. #[serde(skip_serializing_if = "Option::is_none")] pub only: Option>, /// The reason why code actions were requested. /// /// @since 3.17.0 #[serde(skip_serializing_if = "Option::is_none")] pub trigger_kind: Option, } impl CodeActionContext { #[must_use] pub const fn new( diagnostics: Vec, only: Option>, trigger_kind: Option, ) -> Self { Self { diagnostics, only, trigger_kind, } } } /// Captures why the code action is currently disabled. /// /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct CodeActionDisabled { /// Human readable description of why the code action is currently disabled. /// /// This is displayed in the code actions UI. pub reason: String, } impl CodeActionDisabled { #[must_use] pub const fn new(reason: String) -> Self { Self { reason } } } /// Provider options for a [`CodeActionRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct CodeActionOptions { /// 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. #[serde(skip_serializing_if = "Option::is_none")] pub code_action_kinds: Option>, /// Static documentation for a class of code actions. /// /// Documentation from the provider should be shown in the code actions menu if either: /// /// - Code actions of `kind` are requested by the editor. In this case, the editor will show the documentation that /// most closely matches the requested code action kind. For example, if a provider has documentation for /// both `Refactor` and `RefactorExtract`, when the user requests code actions for `RefactorExtract`, /// the editor will use the documentation for `RefactorExtract` instead of the documentation for `Refactor`. /// /// - Any code actions of `kind` are returned by the provider. /// /// At most one documentation entry should be shown per provider. /// /// @since 3.18.0 #[serde(skip_serializing_if = "Option::is_none")] pub documentation: Option>, /// The server provides support to resolve additional /// information for a code action. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub resolve_provider: Option, #[serde(flatten)] pub work_done_progress_options: WorkDoneProgressOptions, } impl CodeActionOptions { #[must_use] pub const fn new( code_action_kinds: Option>, documentation: Option>, resolve_provider: Option, work_done_progress_options: WorkDoneProgressOptions, ) -> Self { Self { code_action_kinds, documentation, resolve_provider, work_done_progress_options, } } } /// Location with only uri and does not include range. /// /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct LocationUriOnly { pub uri: Uri, } impl LocationUriOnly { #[must_use] pub const fn new(uri: Uri) -> Self { Self { uri } } } /// Server capabilities for a [`WorkspaceSymbolRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct WorkspaceSymbolOptions { /// The server provides support to resolve additional /// information for a workspace symbol. /// /// @since 3.17.0 #[serde(skip_serializing_if = "Option::is_none")] pub resolve_provider: Option, #[serde(flatten)] pub work_done_progress_options: WorkDoneProgressOptions, } impl WorkspaceSymbolOptions { #[must_use] pub const fn new( resolve_provider: Option, work_done_progress_options: WorkDoneProgressOptions, ) -> Self { Self { resolve_provider, work_done_progress_options, } } } /// Code Lens provider options of a [`CodeLensRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct CodeLensOptions { /// Code lens has a resolve provider as well. #[serde(skip_serializing_if = "Option::is_none")] pub resolve_provider: Option, #[serde(flatten)] pub work_done_progress_options: WorkDoneProgressOptions, } impl CodeLensOptions { #[must_use] pub const fn new( resolve_provider: Option, work_done_progress_options: WorkDoneProgressOptions, ) -> Self { Self { resolve_provider, work_done_progress_options, } } } /// Provider options for a [`DocumentLinkRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct DocumentLinkOptions { /// Document links have a resolve provider as well. #[serde(skip_serializing_if = "Option::is_none")] pub resolve_provider: Option, #[serde(flatten)] pub work_done_progress_options: WorkDoneProgressOptions, } impl DocumentLinkOptions { #[must_use] pub const fn new( resolve_provider: Option, work_done_progress_options: WorkDoneProgressOptions, ) -> Self { Self { resolve_provider, work_done_progress_options, } } } /// Value-object describing what options formatting should use. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct FormattingOptions { /// Size of a tab in spaces. pub tab_size: u32, /// Prefer spaces over tabs. pub insert_spaces: bool, /// Trim trailing whitespace on a line. /// /// @since 3.15.0 #[serde(skip_serializing_if = "Option::is_none")] pub trim_trailing_whitespace: Option, /// Insert a newline character at the end of the file if one does not exist. /// /// @since 3.15.0 #[serde(skip_serializing_if = "Option::is_none")] pub insert_final_newline: Option, /// Trim all newlines after the final newline at the end of the file. /// /// @since 3.15.0 #[serde(skip_serializing_if = "Option::is_none")] pub trim_final_newlines: Option, } impl FormattingOptions { #[must_use] pub const fn new( tab_size: u32, insert_spaces: bool, trim_trailing_whitespace: Option, insert_final_newline: Option, trim_final_newlines: Option, ) -> Self { Self { tab_size, insert_spaces, trim_trailing_whitespace, insert_final_newline, trim_final_newlines, } } } /// Provider options for a [`DocumentFormattingRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct DocumentFormattingOptions { #[serde(flatten)] pub work_done_progress_options: WorkDoneProgressOptions, } impl DocumentFormattingOptions { #[must_use] pub const fn new(work_done_progress_options: WorkDoneProgressOptions) -> Self { Self { work_done_progress_options } } } /// Provider options for a [`DocumentRangeFormattingRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct DocumentRangeFormattingOptions { /// Whether the server supports formatting multiple ranges at once. /// /// @since 3.18.0 #[serde(skip_serializing_if = "Option::is_none")] pub ranges_support: Option, #[serde(flatten)] pub work_done_progress_options: WorkDoneProgressOptions, } impl DocumentRangeFormattingOptions { #[must_use] pub const fn new( ranges_support: Option, work_done_progress_options: WorkDoneProgressOptions, ) -> Self { Self { ranges_support, work_done_progress_options, } } } /// Provider options for a [`DocumentOnTypeFormattingRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct DocumentOnTypeFormattingOptions { /// A character on which formatting should be triggered, like `{`. pub first_trigger_character: String, /// More trigger characters. #[serde(skip_serializing_if = "Option::is_none")] pub more_trigger_character: Option>, } impl DocumentOnTypeFormattingOptions { #[must_use] pub const fn new( first_trigger_character: String, more_trigger_character: Option>, ) -> Self { Self { first_trigger_character, more_trigger_character, } } } /// Provider options for a [`RenameRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct RenameOptions { /// Renames should be checked and tested before being executed. /// /// @since version 3.12.0 #[serde(skip_serializing_if = "Option::is_none")] pub prepare_provider: Option, #[serde(flatten)] pub work_done_progress_options: WorkDoneProgressOptions, } impl RenameOptions { #[must_use] pub const fn new( prepare_provider: Option, work_done_progress_options: WorkDoneProgressOptions, ) -> Self { Self { prepare_provider, work_done_progress_options, } } } /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct PrepareRenamePlaceholder { pub range: Range, pub placeholder: String, } impl PrepareRenamePlaceholder { #[must_use] pub const fn new(range: Range, placeholder: String) -> Self { Self { range, placeholder } } } /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct PrepareRenameDefaultBehavior { pub default_behavior: bool, } impl PrepareRenameDefaultBehavior { #[must_use] pub const fn new(default_behavior: bool) -> Self { Self { default_behavior } } } /// The server capabilities of a [`ExecuteCommandRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct ExecuteCommandOptions { /// The commands to be executed on the server pub commands: Vec, #[serde(flatten)] pub work_done_progress_options: WorkDoneProgressOptions, } impl ExecuteCommandOptions { #[must_use] pub const fn new( commands: Vec, work_done_progress_options: WorkDoneProgressOptions, ) -> Self { Self { commands, work_done_progress_options, } } } /// Additional data about a workspace edit. /// /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct WorkspaceEditMetadata { /// Signal to the editor that this edit is a refactoring. #[serde(skip_serializing_if = "Option::is_none")] pub is_refactoring: Option, } impl WorkspaceEditMetadata { #[must_use] pub const fn new(is_refactoring: Option) -> Self { Self { is_refactoring } } } /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct SemanticTokensLegend { /// The token types a server uses. pub token_types: Vec, /// The token modifiers a server uses. pub token_modifiers: Vec, } impl SemanticTokensLegend { #[must_use] pub const fn new(token_types: Vec, token_modifiers: Vec) -> Self { Self { token_types, token_modifiers, } } } /// Semantic tokens options to support deltas for full documents /// /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct SemanticTokensFullDelta { /// The server supports deltas for full documents. #[serde(skip_serializing_if = "Option::is_none")] pub delta: Option, } impl SemanticTokensFullDelta { #[must_use] pub const fn new(delta: Option) -> Self { Self { delta } } } /// A text document identifier to optionally denote a specific version of a text document. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct OptionalVersionedTextDocumentIdentifier { /// The version number of this document. If a versioned text document identifier /// is sent from the server to the client and the file is not open in the editor /// (the server has not received an open notification before) the server can send /// `null` to indicate that the version is unknown and the content on disk is the /// truth (as specified with document content ownership). pub version: Option, #[serde(flatten)] pub text_document_identifier: TextDocumentIdentifier, } impl OptionalVersionedTextDocumentIdentifier { #[must_use] pub const fn new( version: Option, text_document_identifier: TextDocumentIdentifier, ) -> Self { Self { version, text_document_identifier, } } } /// A special text edit with an additional change annotation. /// /// @since 3.16.0. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct AnnotatedTextEdit { /// The actual identifier of the change annotation pub annotation_id: ChangeAnnotationIdentifier, #[serde(flatten)] pub text_edit: TextEdit, } impl AnnotatedTextEdit { #[must_use] pub const fn new( annotation_id: ChangeAnnotationIdentifier, text_edit: TextEdit, ) -> Self { Self { annotation_id, text_edit } } } /// An interactive text edit. /// /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct SnippetTextEdit { /// The range of the text document to be manipulated. pub range: Range, /// The snippet to be inserted. pub snippet: StringValue, /// The actual identifier of the snippet edit. #[serde(skip_serializing_if = "Option::is_none")] pub annotation_id: Option, } impl SnippetTextEdit { #[must_use] pub const fn new( range: Range, snippet: StringValue, annotation_id: Option, ) -> Self { Self { range, snippet, annotation_id, } } } /// A generic resource operation. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct ResourceOperation { /// The resource operation kind. pub kind: String, /// An optional annotation identifier describing the operation. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub annotation_id: Option, } impl ResourceOperation { #[must_use] pub const fn new( kind: String, annotation_id: Option, ) -> Self { Self { kind, annotation_id } } } /// Options to create a file. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct CreateFileOptions { /// Overwrite existing file. Overwrite wins over `ignoreIfExists` #[serde(skip_serializing_if = "Option::is_none")] pub overwrite: Option, /// Ignore if exists. #[serde(skip_serializing_if = "Option::is_none")] pub ignore_if_exists: Option, } impl CreateFileOptions { #[must_use] pub const fn new(overwrite: Option, ignore_if_exists: Option) -> Self { Self { overwrite, ignore_if_exists, } } } /// Rename file options #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct RenameFileOptions { /// Overwrite target if existing. Overwrite wins over `ignoreIfExists` #[serde(skip_serializing_if = "Option::is_none")] pub overwrite: Option, /// Ignores if target exists. #[serde(skip_serializing_if = "Option::is_none")] pub ignore_if_exists: Option, } impl RenameFileOptions { #[must_use] pub const fn new(overwrite: Option, ignore_if_exists: Option) -> Self { Self { overwrite, ignore_if_exists, } } } /// Delete file options #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct DeleteFileOptions { /// Delete the content recursively if a folder is denoted. #[serde(skip_serializing_if = "Option::is_none")] pub recursive: Option, /// Ignore the operation if the file doesn't exist. #[serde(skip_serializing_if = "Option::is_none")] pub ignore_if_not_exists: Option, } impl DeleteFileOptions { #[must_use] pub const fn new( recursive: Option, ignore_if_not_exists: Option, ) -> Self { Self { recursive, ignore_if_not_exists, } } } /// A pattern to describe in which file operation requests or notifications /// the server is interested in receiving. /// /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct FileOperationPattern { /// The glob pattern to match. Glob patterns can have the following syntax: /// - `*` to match zero 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`) pub glob: String, /// Whether to match files or folders with this pattern. /// /// Matches both if undefined. #[serde(skip_serializing_if = "Option::is_none")] pub matches: Option, /// Additional options used during matching. #[serde(skip_serializing_if = "Option::is_none")] pub options: Option, } impl FileOperationPattern { #[must_use] pub const fn new( glob: String, matches: Option, options: Option, ) -> Self { Self { glob, matches, options } } } /// A full document diagnostic report for a workspace diagnostic result. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct WorkspaceFullDocumentDiagnosticReport { /// The URI for which diagnostic information is reported. pub uri: Uri, /// The version number for which the diagnostics are reported. /// If the document is not marked as open `null` can be provided. pub version: Option, #[serde(flatten)] pub full_document_diagnostic_report: FullDocumentDiagnosticReport, } impl WorkspaceFullDocumentDiagnosticReport { #[must_use] pub const fn new( uri: Uri, version: Option, full_document_diagnostic_report: FullDocumentDiagnosticReport, ) -> Self { Self { uri, version, full_document_diagnostic_report, } } } /// An unchanged document diagnostic report for a workspace diagnostic result. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct WorkspaceUnchangedDocumentDiagnosticReport { /// The URI for which diagnostic information is reported. pub uri: Uri, /// The version number for which the diagnostics are reported. /// If the document is not marked as open `null` can be provided. pub version: Option, #[serde(flatten)] pub unchanged_document_diagnostic_report: UnchangedDocumentDiagnosticReport, } impl WorkspaceUnchangedDocumentDiagnosticReport { #[must_use] pub const fn new( uri: Uri, version: Option, unchanged_document_diagnostic_report: UnchangedDocumentDiagnosticReport, ) -> Self { Self { uri, version, unchanged_document_diagnostic_report, } } } /// A notebook cell. /// /// A cell's document URI must be unique across ALL notebook /// cells and can therefore be used to uniquely identify a /// notebook cell or the cell's text document. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct NotebookCell { /// The cell's kind pub kind: NotebookCellKind, /// The URI of the cell's text document /// content. pub document: Uri, /// Additional metadata stored with the cell. /// /// Note: should always be an object literal (e.g. LSPObject) #[serde(skip_serializing_if = "Option::is_none")] pub metadata: Option, /// Additional execution summary information /// if supported by the client. #[serde(skip_serializing_if = "Option::is_none")] pub execution_summary: Option, } impl NotebookCell { #[must_use] pub const fn new( kind: NotebookCellKind, document: Uri, metadata: Option, execution_summary: Option, ) -> Self { Self { kind, document, metadata, execution_summary, } } } /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct NotebookDocumentFilterWithNotebook { /// The notebook to be synced If a string /// value is provided it matches against the /// notebook type. '*' matches every notebook. pub notebook: Notebook, /// The cells of the matching notebook to be synced. #[serde(skip_serializing_if = "Option::is_none")] pub cells: Option>, } impl NotebookDocumentFilterWithNotebook { #[must_use] pub const fn new( notebook: Notebook, cells: Option>, ) -> Self { Self { notebook, cells } } } /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct NotebookDocumentFilterWithCells { /// The notebook to be synced If a string /// value is provided it matches against the /// notebook type. '*' matches every notebook. #[serde(skip_serializing_if = "Option::is_none")] pub notebook: Option, /// The cells of the matching notebook to be synced. pub cells: Vec, } impl NotebookDocumentFilterWithCells { #[must_use] pub const fn new( notebook: Option, cells: Vec, ) -> Self { Self { notebook, cells } } } /// Cell changes to a notebook document. /// /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct NotebookDocumentCellChanges { /// Changes to the cell structure to add or /// remove cells. #[serde(skip_serializing_if = "Option::is_none")] pub structure: Option, /// Changes to notebook cells properties like its /// kind, execution summary or metadata. #[serde(skip_serializing_if = "Option::is_none")] pub data: Option>, /// Changes to the text content of notebook cells. #[serde(skip_serializing_if = "Option::is_none")] pub text_content: Option>, } impl NotebookDocumentCellChanges { #[must_use] pub const fn new( structure: Option, data: Option>, text_content: Option>, ) -> Self { Self { structure, data, text_content, } } } /// Describes the currently selected completion item. /// /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct SelectedCompletionInfo { /// The range that will be replaced if this completion item is accepted. pub range: Range, /// The text the range will be replaced with if this completion is accepted. pub text: String, } impl SelectedCompletionInfo { #[must_use] pub const fn new(range: Range, text: String) -> Self { Self { range, text } } } /// Information about the client /// /// @since 3.15.0 /// @since 3.18.0 ClientInfo type name added. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct ClientInfo { /// The name of the client as defined by the client. pub name: String, /// The client's version as defined by the client. #[serde(skip_serializing_if = "Option::is_none")] pub version: Option, } impl ClientInfo { #[must_use] pub const fn new(name: String, version: Option) -> Self { Self { name, version } } } /// Defines the capabilities provided by the client. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct ClientCapabilities { /// Workspace specific client capabilities. #[serde(skip_serializing_if = "Option::is_none")] pub workspace: Option, /// Text document specific client capabilities. #[serde(skip_serializing_if = "Option::is_none")] pub text_document: Option, /// Capabilities specific to the notebook document support. /// /// @since 3.17.0 #[serde(skip_serializing_if = "Option::is_none")] pub notebook_document: Option, /// Window specific client capabilities. #[serde(skip_serializing_if = "Option::is_none")] pub window: Option, /// General client capabilities. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub general: Option, /// Experimental client capabilities. #[serde(skip_serializing_if = "Option::is_none")] pub experimental: Option, } impl ClientCapabilities { #[must_use] pub const fn new( workspace: Option, text_document: Option, notebook_document: Option, window: Option, general: Option, experimental: Option, ) -> Self { Self { workspace, text_document, notebook_document, window, general, experimental, } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct TextDocumentSyncOptions { /// Open and close notifications are sent to the server. If omitted open close notification should not /// be sent. #[serde(skip_serializing_if = "Option::is_none")] pub open_close: Option, /// Change notifications are sent to the server. See TextDocumentSyncKind.None, TextDocumentSyncKind.Full /// and TextDocumentSyncKind.Incremental. If omitted it defaults to TextDocumentSyncKind.None. #[serde(skip_serializing_if = "Option::is_none")] pub change: Option, /// If present will save notifications are sent to the server. If omitted the notification should not be /// sent. #[serde(skip_serializing_if = "Option::is_none")] pub will_save: Option, /// If present will save wait until requests are sent to the server. If omitted the request should not be /// sent. #[serde(skip_serializing_if = "Option::is_none")] pub will_save_wait_until: Option, /// If present save notifications are sent to the server. If omitted the notification should not be /// sent. #[serde(skip_serializing_if = "Option::is_none")] pub save: Option, } impl TextDocumentSyncOptions { #[must_use] pub const fn new( open_close: Option, change: Option, will_save: Option, will_save_wait_until: Option, save: Option, ) -> Self { Self { open_close, change, will_save, will_save_wait_until, save, } } } /// Defines workspace specific capabilities of the server. /// /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct WorkspaceOptions { /// The server supports workspace folder. /// /// @since 3.6.0 #[serde(skip_serializing_if = "Option::is_none")] pub workspace_folders: Option, /// The server is interested in notifications/requests for operations on files. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub file_operations: Option, /// The server supports the `workspace/textDocumentContent` request. /// /// @since 3.18.0 #[serde(skip_serializing_if = "Option::is_none")] pub text_document_content: Option, } impl WorkspaceOptions { #[must_use] pub const fn new( workspace_folders: Option, file_operations: Option, text_document_content: Option, ) -> Self { Self { workspace_folders, file_operations, text_document_content, } } } /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct TextDocumentContentChangePartial { /// The range of the document that changed. pub range: Range, /// The optional length of the range that got replaced. /// /// @deprecated use range instead. #[deprecated(note = "use range instead.")] #[serde(skip_serializing_if = "Option::is_none")] pub range_length: Option, /// The new text for the provided range. pub text: String, } impl TextDocumentContentChangePartial { #[must_use] pub const fn new(range: Range, range_length: Option, text: String) -> Self { Self { range, range_length, text } } } /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct TextDocumentContentChangeWholeDocument { /// The new text of the whole document. pub text: String, } impl TextDocumentContentChangeWholeDocument { #[must_use] pub const fn new(text: String) -> Self { Self { text } } } /// Structure to capture a description for an error code. /// /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct CodeDescription { /// An URI to open with more information about the diagnostic error. pub href: Uri, } impl CodeDescription { #[must_use] pub const fn new(href: Uri) -> Self { Self { href } } } /// 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. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct DiagnosticRelatedInformation { /// The location of this related diagnostic information. pub location: Location, /// The message of this related diagnostic information. pub message: String, } impl DiagnosticRelatedInformation { #[must_use] pub const fn new(location: Location, message: String) -> Self { Self { location, message } } } /// Edit range variant that includes ranges for insert and replace operations. /// /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct EditRangeWithInsertReplace { pub insert: Range, pub replace: Range, } impl EditRangeWithInsertReplace { #[must_use] pub const fn new(insert: Range, replace: Range) -> Self { Self { insert, replace } } } /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct ServerCompletionItemOptions { /// 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 #[serde(skip_serializing_if = "Option::is_none")] pub label_details_support: Option, } impl ServerCompletionItemOptions { #[must_use] pub const fn new(label_details_support: Option) -> Self { Self { label_details_support } } } /// @since 3.18.0 /// @deprecated use MarkupContent instead. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] #[deprecated(note = "use MarkupContent instead.")] pub struct MarkedStringWithLanguage { pub language: String, pub value: String, } impl MarkedStringWithLanguage { #[must_use] pub const fn new(language: String, value: String) -> Self { Self { language, value } } } /// Represents a parameter of a callable-signature. A parameter can /// have a label and a doc-comment. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct ParameterInformation { /// The label of this parameter information. /// /// Either a string or an inclusive start and exclusive end offsets within its containing /// signature label. (see SignatureInformation.label). The offsets are based on a UTF-16 /// string representation as `Position` and `Range` does. /// /// To avoid ambiguities a server should use the [start, end] offset value instead of using /// a substring. Whether a client support this is controlled via `labelOffsetSupport` client /// capability. /// /// *Note*: a label of type string should be a substring of its containing signature label. /// Its intended use case is to highlight the parameter label part in the `SignatureInformation.label`. pub label: ParameterInformationLabel, /// The human-readable doc-comment of this parameter. Will be shown /// in the UI but can be omitted. #[serde(skip_serializing_if = "Option::is_none")] pub documentation: Option, } impl ParameterInformation { #[must_use] pub const fn new( label: ParameterInformationLabel, documentation: Option, ) -> Self { Self { label, documentation } } } /// Documentation for a class of code actions. /// /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct CodeActionKindDocumentation { /// The kind of the code action being documented. /// /// If the kind is generic, such as `CodeActionKind.Refactor`, the documentation will be shown whenever any /// refactorings are returned. If the kind if more specific, such as `CodeActionKind.RefactorExtract`, the /// documentation will only be shown when extract refactoring code actions are returned. pub kind: CodeActionKind, /// Command that is ued to display the documentation to the user. /// /// The title of this documentation code action is taken from [`Command::title`] pub command: Command, } impl CodeActionKindDocumentation { #[must_use] pub const fn new(kind: CodeActionKind, command: Command) -> Self { Self { kind, command } } } /// A notebook cell text document filter denotes a cell text /// document by different properties. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct NotebookCellTextDocumentFilter { /// A filter that matches against the notebook /// containing the notebook cell. If a string /// value is provided it matches against the /// notebook type. '*' matches every notebook. pub notebook: Notebook, /// A language id like `python`. /// /// Will be matched against the language id of the /// notebook cell document. '*' matches every language. #[serde(skip_serializing_if = "Option::is_none")] pub language: Option, } impl NotebookCellTextDocumentFilter { #[must_use] pub const fn new(notebook: Notebook, language: Option) -> Self { Self { notebook, language } } } /// Matching options for the file operation pattern. /// /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct FileOperationPatternOptions { /// The pattern should be matched ignoring casing. #[serde(skip_serializing_if = "Option::is_none")] pub ignore_case: Option, } impl FileOperationPatternOptions { #[must_use] pub const fn new(ignore_case: Option) -> Self { Self { ignore_case } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct ExecutionSummary { /// A strict monotonically increasing value /// indicating the execution order of a cell /// inside a notebook. pub execution_order: u32, /// Whether the execution was successful or /// not if known by the client. #[serde(skip_serializing_if = "Option::is_none")] pub success: Option, } impl ExecutionSummary { #[must_use] pub const fn new(execution_order: u32, success: Option) -> Self { Self { execution_order, success } } } /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct NotebookCellLanguage { pub language: String, } impl NotebookCellLanguage { #[must_use] pub const fn new(language: String) -> Self { Self { language } } } /// Structural changes to cells in a notebook document. /// /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct NotebookDocumentCellChangeStructure { /// The change to the cell array. pub array: NotebookCellArrayChange, /// Additional opened cell text documents. #[serde(skip_serializing_if = "Option::is_none")] pub did_open: Option>, /// Additional closed cell text documents. #[serde(skip_serializing_if = "Option::is_none")] pub did_close: Option>, } impl NotebookDocumentCellChangeStructure { #[must_use] pub const fn new( array: NotebookCellArrayChange, did_open: Option>, did_close: Option>, ) -> Self { Self { array, did_open, did_close } } } /// Content changes to a cell in a notebook document. /// /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct NotebookDocumentCellContentChanges { pub document: VersionedTextDocumentIdentifier, pub changes: Vec, } impl NotebookDocumentCellContentChanges { #[must_use] pub const fn new( document: VersionedTextDocumentIdentifier, changes: Vec, ) -> Self { Self { document, changes } } } /// Workspace specific client capabilities. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct WorkspaceClientCapabilities { /// The client supports applying batch edits /// to the workspace by supporting the request /// 'workspace/applyEdit' #[serde(skip_serializing_if = "Option::is_none")] pub apply_edit: Option, /// Capabilities specific to `WorkspaceEdit`s. #[serde(skip_serializing_if = "Option::is_none")] pub workspace_edit: Option, /// Capabilities specific to the `workspace/didChangeConfiguration` notification. #[serde(skip_serializing_if = "Option::is_none")] pub did_change_configuration: Option, /// Capabilities specific to the `workspace/didChangeWatchedFiles` notification. #[serde(skip_serializing_if = "Option::is_none")] pub did_change_watched_files: Option, /// Capabilities specific to the `workspace/symbol` request. #[serde(skip_serializing_if = "Option::is_none")] pub symbol: Option, /// Capabilities specific to the `workspace/executeCommand` request. #[serde(skip_serializing_if = "Option::is_none")] pub execute_command: Option, /// The client has support for workspace folders. /// /// @since 3.6.0 #[serde(skip_serializing_if = "Option::is_none")] pub workspace_folders: Option, /// The client supports `workspace/configuration` requests. /// /// @since 3.6.0 #[serde(skip_serializing_if = "Option::is_none")] pub configuration: Option, /// Capabilities specific to the semantic token requests scoped to the /// workspace. /// /// @since 3.16.0. #[serde(skip_serializing_if = "Option::is_none")] pub semantic_tokens: Option, /// Capabilities specific to the code lens requests scoped to the /// workspace. /// /// @since 3.16.0. #[serde(skip_serializing_if = "Option::is_none")] pub code_lens: Option, /// The client has support for file notifications/requests for user operations on files. /// /// Since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub file_operations: Option, /// Capabilities specific to the inline values requests scoped to the /// workspace. /// /// @since 3.17.0. #[serde(skip_serializing_if = "Option::is_none")] pub inline_value: Option, /// Capabilities specific to the inlay hint requests scoped to the /// workspace. /// /// @since 3.17.0. #[serde(skip_serializing_if = "Option::is_none")] pub inlay_hint: Option, /// Capabilities specific to the diagnostic requests scoped to the /// workspace. /// /// @since 3.17.0. #[serde(skip_serializing_if = "Option::is_none")] pub diagnostics: Option, /// Capabilities specific to the folding range requests scoped to the workspace. /// /// @since 3.18.0 #[serde(skip_serializing_if = "Option::is_none")] pub folding_range: Option, /// Capabilities specific to the `workspace/textDocumentContent` request. /// /// @since 3.18.0 #[serde(skip_serializing_if = "Option::is_none")] pub text_document_content: Option, } impl WorkspaceClientCapabilities { #[must_use] pub const fn new( apply_edit: Option, workspace_edit: Option, did_change_configuration: Option, did_change_watched_files: Option, symbol: Option, execute_command: Option, workspace_folders: Option, configuration: Option, semantic_tokens: Option, code_lens: Option, file_operations: Option, inline_value: Option, inlay_hint: Option, diagnostics: Option, folding_range: Option, text_document_content: Option, ) -> Self { Self { apply_edit, workspace_edit, did_change_configuration, did_change_watched_files, symbol, execute_command, workspace_folders, configuration, semantic_tokens, code_lens, file_operations, inline_value, inlay_hint, diagnostics, folding_range, text_document_content, } } } /// Text document specific client capabilities. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct TextDocumentClientCapabilities { /// Defines which synchronization capabilities the client supports. #[serde(skip_serializing_if = "Option::is_none")] pub synchronization: Option, /// Defines which filters the client supports. /// /// @since 3.18.0 #[serde(skip_serializing_if = "Option::is_none")] pub filters: Option, /// Capabilities specific to the `textDocument/completion` request. #[serde(skip_serializing_if = "Option::is_none")] pub completion: Option, /// Capabilities specific to the `textDocument/hover` request. #[serde(skip_serializing_if = "Option::is_none")] pub hover: Option, /// Capabilities specific to the `textDocument/signatureHelp` request. #[serde(skip_serializing_if = "Option::is_none")] pub signature_help: Option, /// Capabilities specific to the `textDocument/declaration` request. /// /// @since 3.14.0 #[serde(skip_serializing_if = "Option::is_none")] pub declaration: Option, /// Capabilities specific to the `textDocument/definition` request. #[serde(skip_serializing_if = "Option::is_none")] pub definition: Option, /// Capabilities specific to the `textDocument/typeDefinition` request. /// /// @since 3.6.0 #[serde(skip_serializing_if = "Option::is_none")] pub type_definition: Option, /// Capabilities specific to the `textDocument/implementation` request. /// /// @since 3.6.0 #[serde(skip_serializing_if = "Option::is_none")] pub implementation: Option, /// Capabilities specific to the `textDocument/references` request. #[serde(skip_serializing_if = "Option::is_none")] pub references: Option, /// Capabilities specific to the `textDocument/documentHighlight` request. #[serde(skip_serializing_if = "Option::is_none")] pub document_highlight: Option, /// Capabilities specific to the `textDocument/documentSymbol` request. #[serde(skip_serializing_if = "Option::is_none")] pub document_symbol: Option, /// Capabilities specific to the `textDocument/codeAction` request. #[serde(skip_serializing_if = "Option::is_none")] pub code_action: Option, /// Capabilities specific to the `textDocument/codeLens` request. #[serde(skip_serializing_if = "Option::is_none")] pub code_lens: Option, /// Capabilities specific to the `textDocument/documentLink` request. #[serde(skip_serializing_if = "Option::is_none")] pub document_link: Option, /// Capabilities specific to the `textDocument/documentColor` and the /// `textDocument/colorPresentation` request. /// /// @since 3.6.0 #[serde(skip_serializing_if = "Option::is_none")] pub color_provider: Option, /// Capabilities specific to the `textDocument/formatting` request. #[serde(skip_serializing_if = "Option::is_none")] pub formatting: Option, /// Capabilities specific to the `textDocument/rangeFormatting` request. #[serde(skip_serializing_if = "Option::is_none")] pub range_formatting: Option, /// Capabilities specific to the `textDocument/onTypeFormatting` request. #[serde(skip_serializing_if = "Option::is_none")] pub on_type_formatting: Option, /// Capabilities specific to the `textDocument/rename` request. #[serde(skip_serializing_if = "Option::is_none")] pub rename: Option, /// Capabilities specific to the `textDocument/foldingRange` request. /// /// @since 3.10.0 #[serde(skip_serializing_if = "Option::is_none")] pub folding_range: Option, /// Capabilities specific to the `textDocument/selectionRange` request. /// /// @since 3.15.0 #[serde(skip_serializing_if = "Option::is_none")] pub selection_range: Option, /// Capabilities specific to the `textDocument/publishDiagnostics` notification. #[serde(skip_serializing_if = "Option::is_none")] pub publish_diagnostics: Option, /// Capabilities specific to the various call hierarchy requests. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub call_hierarchy: Option, /// Capabilities specific to the various semantic token request. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub semantic_tokens: Option, /// Capabilities specific to the `textDocument/linkedEditingRange` request. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub linked_editing_range: Option, /// Client capabilities specific to the `textDocument/moniker` request. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub moniker: Option, /// Capabilities specific to the various type hierarchy requests. /// /// @since 3.17.0 #[serde(skip_serializing_if = "Option::is_none")] pub type_hierarchy: Option, /// Capabilities specific to the `textDocument/inlineValue` request. /// /// @since 3.17.0 #[serde(skip_serializing_if = "Option::is_none")] pub inline_value: Option, /// Capabilities specific to the `textDocument/inlayHint` request. /// /// @since 3.17.0 #[serde(skip_serializing_if = "Option::is_none")] pub inlay_hint: Option, /// Capabilities specific to the diagnostic pull model. /// /// @since 3.17.0 #[serde(skip_serializing_if = "Option::is_none")] pub diagnostic: Option, /// Client capabilities specific to inline completions. /// /// @since 3.18.0 #[serde(skip_serializing_if = "Option::is_none")] pub inline_completion: Option, } impl TextDocumentClientCapabilities { #[must_use] pub const fn new( synchronization: Option, filters: Option, completion: Option, hover: Option, signature_help: Option, declaration: Option, definition: Option, type_definition: Option, implementation: Option, references: Option, document_highlight: Option, document_symbol: Option, code_action: Option, code_lens: Option, document_link: Option, color_provider: Option, formatting: Option, range_formatting: Option, on_type_formatting: Option, rename: Option, folding_range: Option, selection_range: Option, publish_diagnostics: Option, call_hierarchy: Option, semantic_tokens: Option, linked_editing_range: Option, moniker: Option, type_hierarchy: Option, inline_value: Option, inlay_hint: Option, diagnostic: Option, inline_completion: Option, ) -> Self { Self { synchronization, filters, completion, hover, signature_help, declaration, definition, type_definition, implementation, references, document_highlight, document_symbol, code_action, code_lens, document_link, color_provider, formatting, range_formatting, on_type_formatting, rename, folding_range, selection_range, publish_diagnostics, call_hierarchy, semantic_tokens, linked_editing_range, moniker, type_hierarchy, inline_value, inlay_hint, diagnostic, inline_completion, } } } /// Capabilities specific to the notebook document support. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct NotebookDocumentClientCapabilities { /// Capabilities specific to notebook document synchronization /// /// @since 3.17.0 pub synchronization: NotebookDocumentSyncClientCapabilities, } impl NotebookDocumentClientCapabilities { #[must_use] pub const fn new(synchronization: NotebookDocumentSyncClientCapabilities) -> Self { Self { synchronization } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct WindowClientCapabilities { /// It indicates whether the client supports server initiated /// progress using the `window/workDoneProgress/create` request. /// /// The capability also controls Whether client supports handling /// of progress notifications. If set servers are allowed to report a /// `workDoneProgress` property in the request specific server /// capabilities. /// /// @since 3.15.0 #[serde(skip_serializing_if = "Option::is_none")] pub work_done_progress: Option, /// Capabilities specific to the showMessage request. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub show_message: Option, /// Capabilities specific to the showDocument request. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub show_document: Option, } impl WindowClientCapabilities { #[must_use] pub const fn new( work_done_progress: Option, show_message: Option, show_document: Option, ) -> Self { Self { work_done_progress, show_message, show_document, } } } /// General client capabilities. /// /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct GeneralClientCapabilities { /// 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 #[serde(skip_serializing_if = "Option::is_none")] pub stale_request_support: Option, /// Client capabilities specific to regular expressions. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub regular_expressions: Option, /// Client capabilities specific to the client's markdown parser. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub markdown: Option, /// 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 #[serde(skip_serializing_if = "Option::is_none")] pub position_encodings: Option>, } impl GeneralClientCapabilities { #[must_use] pub const fn new( stale_request_support: Option, regular_expressions: Option, markdown: Option, position_encodings: Option>, ) -> Self { Self { stale_request_support, regular_expressions, markdown, position_encodings, } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct WorkspaceFoldersServerCapabilities { /// The server has support for workspace folders #[serde(skip_serializing_if = "Option::is_none")] pub supported: Option, /// Whether the server wants to receive workspace folder /// change notifications. /// /// If a string is provided the string is treated as an ID /// under which the notification is registered on the client /// side. The ID can be used to unregister for these events /// using the `client/unregisterCapability` request. #[serde(skip_serializing_if = "Option::is_none")] pub change_notifications: Option, } impl WorkspaceFoldersServerCapabilities { #[must_use] pub const fn new( supported: Option, change_notifications: Option, ) -> Self { Self { supported, change_notifications, } } } /// Options for notifications/requests for user operations on files. /// /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct FileOperationOptions { /// The server is interested in receiving didCreateFiles notifications. #[serde(skip_serializing_if = "Option::is_none")] pub did_create: Option, /// The server is interested in receiving willCreateFiles requests. #[serde(skip_serializing_if = "Option::is_none")] pub will_create: Option, /// The server is interested in receiving didRenameFiles notifications. #[serde(skip_serializing_if = "Option::is_none")] pub did_rename: Option, /// The server is interested in receiving willRenameFiles requests. #[serde(skip_serializing_if = "Option::is_none")] pub will_rename: Option, /// The server is interested in receiving didDeleteFiles file notifications. #[serde(skip_serializing_if = "Option::is_none")] pub did_delete: Option, /// The server is interested in receiving willDeleteFiles file requests. #[serde(skip_serializing_if = "Option::is_none")] pub will_delete: Option, } impl FileOperationOptions { #[must_use] pub const fn new( did_create: Option, will_create: Option, did_rename: Option, will_rename: Option, did_delete: Option, will_delete: Option, ) -> Self { Self { did_create, will_create, did_rename, will_rename, did_delete, will_delete, } } } /// A relative pattern is a helper to construct glob patterns that are matched /// relatively to a base URI. The common value for a `baseUri` is a workspace /// folder root, but it can be another absolute URI as well. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct RelativePattern { /// A workspace folder or a base URI to which this pattern will be matched /// against relatively. pub base_uri: BaseUri, /// The actual glob pattern; pub pattern: Pattern, } impl RelativePattern { #[must_use] pub const fn new(base_uri: BaseUri, pattern: Pattern) -> Self { Self { base_uri, pattern } } } /// A document filter where `language` is required field. /// /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct TextDocumentFilterLanguage { /// A language id, like `typescript`. pub language: String, /// A Uri [scheme][`Uri::scheme`], like `file` or `untitled`. #[serde(skip_serializing_if = "Option::is_none")] pub scheme: Option, /// A glob pattern, like **/*.{ts,js}. See TextDocumentFilter for examples. /// /// @since 3.18.0 - support for relative patterns. Whether clients support /// relative patterns depends on the client capability /// `textDocuments.filters.relativePatternSupport`. #[serde(skip_serializing_if = "Option::is_none")] pub pattern: Option, } impl TextDocumentFilterLanguage { #[must_use] pub const fn new( language: String, scheme: Option, pattern: Option, ) -> Self { Self { language, scheme, pattern } } } /// A document filter where `scheme` is required field. /// /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct TextDocumentFilterScheme { /// A language id, like `typescript`. #[serde(skip_serializing_if = "Option::is_none")] pub language: Option, /// A Uri [scheme][`Uri::scheme`], like `file` or `untitled`. pub scheme: String, /// A glob pattern, like **/*.{ts,js}. See TextDocumentFilter for examples. /// /// @since 3.18.0 - support for relative patterns. Whether clients support /// relative patterns depends on the client capability /// `textDocuments.filters.relativePatternSupport`. #[serde(skip_serializing_if = "Option::is_none")] pub pattern: Option, } impl TextDocumentFilterScheme { #[must_use] pub const fn new( language: Option, scheme: String, pattern: Option, ) -> Self { Self { language, scheme, pattern } } } /// A document filter where `pattern` is required field. /// /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct TextDocumentFilterPattern { /// A language id, like `typescript`. #[serde(skip_serializing_if = "Option::is_none")] pub language: Option, /// A Uri [scheme][`Uri::scheme`], like `file` or `untitled`. #[serde(skip_serializing_if = "Option::is_none")] pub scheme: Option, /// A glob pattern, like **/*.{ts,js}. See TextDocumentFilter for examples. /// /// @since 3.18.0 - support for relative patterns. Whether clients support /// relative patterns depends on the client capability /// `textDocuments.filters.relativePatternSupport`. pub pattern: GlobPattern, } impl TextDocumentFilterPattern { #[must_use] pub const fn new( language: Option, scheme: Option, pattern: GlobPattern, ) -> Self { Self { language, scheme, pattern } } } /// A notebook document filter where `notebookType` is required field. /// /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct NotebookDocumentFilterNotebookType { /// The type of the enclosing notebook. pub notebook_type: String, /// A Uri [scheme][`Uri::scheme`], like `file` or `untitled`. #[serde(skip_serializing_if = "Option::is_none")] pub scheme: Option, /// A glob pattern. #[serde(skip_serializing_if = "Option::is_none")] pub pattern: Option, } impl NotebookDocumentFilterNotebookType { #[must_use] pub const fn new( notebook_type: String, scheme: Option, pattern: Option, ) -> Self { Self { notebook_type, scheme, pattern, } } } /// A notebook document filter where `scheme` is required field. /// /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct NotebookDocumentFilterScheme { /// The type of the enclosing notebook. #[serde(skip_serializing_if = "Option::is_none")] pub notebook_type: Option, /// A Uri [scheme][`Uri::scheme`], like `file` or `untitled`. pub scheme: String, /// A glob pattern. #[serde(skip_serializing_if = "Option::is_none")] pub pattern: Option, } impl NotebookDocumentFilterScheme { #[must_use] pub const fn new( notebook_type: Option, scheme: String, pattern: Option, ) -> Self { Self { notebook_type, scheme, pattern, } } } /// A notebook document filter where `pattern` is required field. /// /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash)] #[serde(rename_all = "camelCase")] pub struct NotebookDocumentFilterPattern { /// The type of the enclosing notebook. #[serde(skip_serializing_if = "Option::is_none")] pub notebook_type: Option, /// A Uri [scheme][`Uri::scheme`], like `file` or `untitled`. #[serde(skip_serializing_if = "Option::is_none")] pub scheme: Option, /// A glob pattern. pub pattern: GlobPattern, } impl NotebookDocumentFilterPattern { #[must_use] pub const fn new( notebook_type: Option, scheme: Option, pattern: GlobPattern, ) -> Self { Self { notebook_type, scheme, pattern, } } } /// A change describing how to move a `NotebookCell` /// array from state S to S'. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct NotebookCellArrayChange { /// The start oftest of the cell that changed. pub start: u32, /// The deleted cells pub delete_count: u32, /// The new cells, if any #[serde(skip_serializing_if = "Option::is_none")] pub cells: Option>, } impl NotebookCellArrayChange { #[must_use] pub const fn new( start: u32, delete_count: u32, cells: Option>, ) -> Self { Self { start, delete_count, cells } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct WorkspaceEditClientCapabilities { /// The client supports versioned document changes in `WorkspaceEdit`s #[serde(skip_serializing_if = "Option::is_none")] pub document_changes: Option, /// The resource operations the client supports. Clients should at least /// support 'create', 'rename' and 'delete' files and folders. /// /// @since 3.13.0 #[serde(skip_serializing_if = "Option::is_none")] pub resource_operations: Option>, /// The failure handling strategy of a client if applying the workspace edit /// fails. /// /// @since 3.13.0 #[serde(skip_serializing_if = "Option::is_none")] pub failure_handling: Option, /// Whether the client normalizes line endings to the client specific /// setting. /// If set to `true` the client will normalize line ending characters /// in a workspace edit to the client-specified new line /// character. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub normalizes_line_endings: Option, /// Whether the client in general supports change annotations on text edits, /// create file, rename file and delete file changes. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub change_annotation_support: Option, /// Whether the client supports `WorkspaceEditMetadata` in `WorkspaceEdit`s. /// /// @since 3.18.0 #[serde(skip_serializing_if = "Option::is_none")] pub metadata_support: Option, /// Whether the client supports snippets as text edits. /// /// @since 3.18.0 #[serde(skip_serializing_if = "Option::is_none")] pub snippet_edit_support: Option, } impl WorkspaceEditClientCapabilities { #[must_use] pub const fn new( document_changes: Option, resource_operations: Option>, failure_handling: Option, normalizes_line_endings: Option, change_annotation_support: Option, metadata_support: Option, snippet_edit_support: Option, ) -> Self { Self { document_changes, resource_operations, failure_handling, normalizes_line_endings, change_annotation_support, metadata_support, snippet_edit_support, } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct DidChangeConfigurationClientCapabilities { /// Did change configuration notification supports dynamic registration. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, } impl DidChangeConfigurationClientCapabilities { #[must_use] pub const fn new(dynamic_registration: Option) -> Self { Self { dynamic_registration } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct DidChangeWatchedFilesClientCapabilities { /// 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. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, /// Whether the client has support for [relative pattern][RelativePattern] /// or not. /// /// @since 3.17.0 #[serde(skip_serializing_if = "Option::is_none")] pub relative_pattern_support: Option, } impl DidChangeWatchedFilesClientCapabilities { #[must_use] pub const fn new( dynamic_registration: Option, relative_pattern_support: Option, ) -> Self { Self { dynamic_registration, relative_pattern_support, } } } /// Client capabilities for a [`WorkspaceSymbolRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct WorkspaceSymbolClientCapabilities { /// Symbol request supports dynamic registration. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, /// Specific capabilities for the `SymbolKind` in the `workspace/symbol` request. #[serde(skip_serializing_if = "Option::is_none")] pub symbol_kind: Option, /// The client supports tags on `SymbolInformation`. /// Clients supporting tags have to handle unknown tags gracefully. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub tag_support: Option, /// The client support partial workspace symbols. The client will send the /// request `workspaceSymbol/resolve` to the server to resolve additional /// properties. /// /// @since 3.17.0 #[serde(skip_serializing_if = "Option::is_none")] pub resolve_support: Option, } impl WorkspaceSymbolClientCapabilities { #[must_use] pub const fn new( dynamic_registration: Option, symbol_kind: Option, tag_support: Option, resolve_support: Option, ) -> Self { Self { dynamic_registration, symbol_kind, tag_support, resolve_support, } } } /// The client capabilities of a [`ExecuteCommandRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct ExecuteCommandClientCapabilities { /// Execute command supports dynamic registration. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, } impl ExecuteCommandClientCapabilities { #[must_use] pub const fn new(dynamic_registration: Option) -> Self { Self { dynamic_registration } } } /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct SemanticTokensWorkspaceClientCapabilities { /// 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 /// semantic tokens 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. #[serde(skip_serializing_if = "Option::is_none")] pub refresh_support: Option, } impl SemanticTokensWorkspaceClientCapabilities { #[must_use] pub const fn new(refresh_support: Option) -> Self { Self { refresh_support } } } /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct CodeLensWorkspaceClientCapabilities { /// 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. #[serde(skip_serializing_if = "Option::is_none")] pub refresh_support: Option, } impl CodeLensWorkspaceClientCapabilities { #[must_use] pub const fn new(refresh_support: Option) -> Self { Self { refresh_support } } } /// 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 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct FileOperationClientCapabilities { /// Whether the client supports dynamic registration for file requests/notifications. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, /// The client has support for sending didCreateFiles notifications. #[serde(skip_serializing_if = "Option::is_none")] pub did_create: Option, /// The client has support for sending willCreateFiles requests. #[serde(skip_serializing_if = "Option::is_none")] pub will_create: Option, /// The client has support for sending didRenameFiles notifications. #[serde(skip_serializing_if = "Option::is_none")] pub did_rename: Option, /// The client has support for sending willRenameFiles requests. #[serde(skip_serializing_if = "Option::is_none")] pub will_rename: Option, /// The client has support for sending didDeleteFiles notifications. #[serde(skip_serializing_if = "Option::is_none")] pub did_delete: Option, /// The client has support for sending willDeleteFiles requests. #[serde(skip_serializing_if = "Option::is_none")] pub will_delete: Option, } impl FileOperationClientCapabilities { #[must_use] pub const fn new( dynamic_registration: Option, did_create: Option, will_create: Option, did_rename: Option, will_rename: Option, did_delete: Option, will_delete: Option, ) -> Self { Self { dynamic_registration, did_create, will_create, did_rename, will_rename, did_delete, will_delete, } } } /// Client workspace capabilities specific to inline values. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct InlineValueWorkspaceClientCapabilities { /// 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 /// inline values 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. #[serde(skip_serializing_if = "Option::is_none")] pub refresh_support: Option, } impl InlineValueWorkspaceClientCapabilities { #[must_use] pub const fn new(refresh_support: Option) -> Self { Self { refresh_support } } } /// Client workspace capabilities specific to inlay hints. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct InlayHintWorkspaceClientCapabilities { /// 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 /// inlay hints 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. #[serde(skip_serializing_if = "Option::is_none")] pub refresh_support: Option, } impl InlayHintWorkspaceClientCapabilities { #[must_use] pub const fn new(refresh_support: Option) -> Self { Self { refresh_support } } } /// Workspace client capabilities specific to diagnostic pull requests. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct DiagnosticWorkspaceClientCapabilities { /// 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. #[serde(skip_serializing_if = "Option::is_none")] pub refresh_support: Option, } impl DiagnosticWorkspaceClientCapabilities { #[must_use] pub const fn new(refresh_support: Option) -> Self { Self { refresh_support } } } /// Client workspace capabilities specific to folding ranges /// /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct FoldingRangeWorkspaceClientCapabilities { /// 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 /// folding ranges 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. /// /// @since 3.18.0 #[serde(skip_serializing_if = "Option::is_none")] pub refresh_support: Option, } impl FoldingRangeWorkspaceClientCapabilities { #[must_use] pub const fn new(refresh_support: Option) -> Self { Self { refresh_support } } } /// Client capabilities for a text document content provider. /// /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct TextDocumentContentClientCapabilities { /// Text document content provider supports dynamic registration. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, } impl TextDocumentContentClientCapabilities { #[must_use] pub const fn new(dynamic_registration: Option) -> Self { Self { dynamic_registration } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct TextDocumentSyncClientCapabilities { /// Whether text document synchronization supports dynamic registration. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, /// The client supports sending will save notifications. #[serde(skip_serializing_if = "Option::is_none")] pub will_save: Option, /// The client supports sending a will save request and /// waits for a response providing text edits which will /// be applied to the document before it is saved. #[serde(skip_serializing_if = "Option::is_none")] pub will_save_wait_until: Option, /// The client supports did save notifications. #[serde(skip_serializing_if = "Option::is_none")] pub did_save: Option, } impl TextDocumentSyncClientCapabilities { #[must_use] pub const fn new( dynamic_registration: Option, will_save: Option, will_save_wait_until: Option, did_save: Option, ) -> Self { Self { dynamic_registration, will_save, will_save_wait_until, did_save, } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct TextDocumentFilterClientCapabilities { /// The client supports Relative Patterns. /// /// @since 3.18.0 #[serde(skip_serializing_if = "Option::is_none")] pub relative_pattern_support: Option, } impl TextDocumentFilterClientCapabilities { #[must_use] pub const fn new(relative_pattern_support: Option) -> Self { Self { relative_pattern_support } } } /// Completion client capabilities #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct CompletionClientCapabilities { /// Whether completion supports dynamic registration. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, /// The client supports the following `CompletionItem` specific /// capabilities. #[serde(skip_serializing_if = "Option::is_none")] pub completion_item: Option, /// The client supports the following completion item kinds. #[serde(skip_serializing_if = "Option::is_none")] pub completion_item_kind: Option, /// 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 #[serde(skip_serializing_if = "Option::is_none")] pub insert_text_mode: Option, /// The client supports to send additional context information for a /// `textDocument/completion` request. #[serde(skip_serializing_if = "Option::is_none")] pub context_support: Option, /// The client supports the following `CompletionList` specific /// capabilities. /// /// @since 3.17.0 #[serde(skip_serializing_if = "Option::is_none")] pub completion_list: Option, } impl CompletionClientCapabilities { #[must_use] pub const fn new( dynamic_registration: Option, completion_item: Option, completion_item_kind: Option, insert_text_mode: Option, context_support: Option, completion_list: Option, ) -> Self { Self { dynamic_registration, completion_item, completion_item_kind, insert_text_mode, context_support, completion_list, } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct HoverClientCapabilities { /// Whether hover supports dynamic registration. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, /// Client supports the following content formats for the content /// property. The order describes the preferred format of the client. #[serde(skip_serializing_if = "Option::is_none")] pub content_format: Option>, } impl HoverClientCapabilities { #[must_use] pub const fn new( dynamic_registration: Option, content_format: Option>, ) -> Self { Self { dynamic_registration, content_format, } } } /// Client Capabilities for a [`SignatureHelpRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct SignatureHelpClientCapabilities { /// Whether signature help supports dynamic registration. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, /// The client supports the following `SignatureInformation` /// specific properties. #[serde(skip_serializing_if = "Option::is_none")] pub signature_information: Option, /// The client supports to send additional context information for a /// `textDocument/signatureHelp` request. A client that opts into /// contextSupport will also support the `retriggerCharacters` on /// `SignatureHelpOptions`. /// /// @since 3.15.0 #[serde(skip_serializing_if = "Option::is_none")] pub context_support: Option, } impl SignatureHelpClientCapabilities { #[must_use] pub const fn new( dynamic_registration: Option, signature_information: Option, context_support: Option, ) -> Self { Self { dynamic_registration, signature_information, context_support, } } } /// @since 3.14.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct DeclarationClientCapabilities { /// 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. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, /// The client supports additional metadata in the form of declaration links. #[serde(skip_serializing_if = "Option::is_none")] pub link_support: Option, } impl DeclarationClientCapabilities { #[must_use] pub const fn new( dynamic_registration: Option, link_support: Option, ) -> Self { Self { dynamic_registration, link_support, } } } /// Client Capabilities for a [`DefinitionRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct DefinitionClientCapabilities { /// Whether definition supports dynamic registration. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, /// The client supports additional metadata in the form of definition links. /// /// @since 3.14.0 #[serde(skip_serializing_if = "Option::is_none")] pub link_support: Option, } impl DefinitionClientCapabilities { #[must_use] pub const fn new( dynamic_registration: Option, link_support: Option, ) -> Self { Self { dynamic_registration, link_support, } } } /// Since 3.6.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct TypeDefinitionClientCapabilities { /// Whether implementation supports dynamic registration. If this is set to `true` /// the client supports the new `TypeDefinitionRegistrationOptions` return value /// for the corresponding server capability as well. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, /// The client supports additional metadata in the form of definition links. /// /// Since 3.14.0 #[serde(skip_serializing_if = "Option::is_none")] pub link_support: Option, } impl TypeDefinitionClientCapabilities { #[must_use] pub const fn new( dynamic_registration: Option, link_support: Option, ) -> Self { Self { dynamic_registration, link_support, } } } /// @since 3.6.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct ImplementationClientCapabilities { /// Whether implementation supports dynamic registration. If this is set to `true` /// the client supports the new `ImplementationRegistrationOptions` return value /// for the corresponding server capability as well. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, /// The client supports additional metadata in the form of definition links. /// /// @since 3.14.0 #[serde(skip_serializing_if = "Option::is_none")] pub link_support: Option, } impl ImplementationClientCapabilities { #[must_use] pub const fn new( dynamic_registration: Option, link_support: Option, ) -> Self { Self { dynamic_registration, link_support, } } } /// Client Capabilities for a [`ReferencesRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct ReferenceClientCapabilities { /// Whether references supports dynamic registration. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, } impl ReferenceClientCapabilities { #[must_use] pub const fn new(dynamic_registration: Option) -> Self { Self { dynamic_registration } } } /// Client Capabilities for a [`DocumentHighlightRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct DocumentHighlightClientCapabilities { /// Whether document highlight supports dynamic registration. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, } impl DocumentHighlightClientCapabilities { #[must_use] pub const fn new(dynamic_registration: Option) -> Self { Self { dynamic_registration } } } /// Client Capabilities for a [`DocumentSymbolRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct DocumentSymbolClientCapabilities { /// Whether document symbol supports dynamic registration. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, /// Specific capabilities for the `SymbolKind` in the /// `textDocument/documentSymbol` request. #[serde(skip_serializing_if = "Option::is_none")] pub symbol_kind: Option, /// The client supports hierarchical document symbols. #[serde(skip_serializing_if = "Option::is_none")] pub hierarchical_document_symbol_support: Option, /// 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 #[serde(skip_serializing_if = "Option::is_none")] pub tag_support: Option, /// The client supports an additional label presented in the UI when /// registering a document symbol provider. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub label_support: Option, } impl DocumentSymbolClientCapabilities { #[must_use] pub const fn new( dynamic_registration: Option, symbol_kind: Option, hierarchical_document_symbol_support: Option, tag_support: Option, label_support: Option, ) -> Self { Self { dynamic_registration, symbol_kind, hierarchical_document_symbol_support, tag_support, label_support, } } } /// The Client Capabilities of a [`CodeActionRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct CodeActionClientCapabilities { /// Whether code action supports dynamic registration. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, /// 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 #[serde(skip_serializing_if = "Option::is_none")] pub code_action_literal_support: Option, /// Whether code action supports the `isPreferred` property. /// /// @since 3.15.0 #[serde(skip_serializing_if = "Option::is_none")] pub is_preferred_support: Option, /// Whether code action supports the `disabled` property. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub disabled_support: Option, /// Whether code action supports the `data` property which is /// preserved between a `textDocument/codeAction` and a /// `codeAction/resolve` request. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub data_support: Option, /// Whether the client supports resolving additional code action /// properties via a separate `codeAction/resolve` request. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub resolve_support: Option, /// 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 #[serde(skip_serializing_if = "Option::is_none")] pub honors_change_annotations: Option, /// Whether the client supports documentation for a class of /// code actions. /// /// @since 3.18.0 #[serde(skip_serializing_if = "Option::is_none")] pub documentation_support: Option, /// Client supports the tag property on a code action. Clients /// supporting tags have to handle unknown tags gracefully. /// /// @since 3.18.0 - proposed #[serde(skip_serializing_if = "Option::is_none")] pub tag_support: Option, } impl CodeActionClientCapabilities { #[must_use] pub const fn new( dynamic_registration: Option, code_action_literal_support: Option, is_preferred_support: Option, disabled_support: Option, data_support: Option, resolve_support: Option, honors_change_annotations: Option, documentation_support: Option, tag_support: Option, ) -> Self { Self { dynamic_registration, code_action_literal_support, is_preferred_support, disabled_support, data_support, resolve_support, honors_change_annotations, documentation_support, tag_support, } } } /// The client capabilities of a [`CodeLensRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct CodeLensClientCapabilities { /// Whether code lens supports dynamic registration. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, /// Whether the client supports resolving additional code lens /// properties via a separate `codeLens/resolve` request. /// /// @since 3.18.0 #[serde(skip_serializing_if = "Option::is_none")] pub resolve_support: Option, } impl CodeLensClientCapabilities { #[must_use] pub const fn new( dynamic_registration: Option, resolve_support: Option, ) -> Self { Self { dynamic_registration, resolve_support, } } } /// The client capabilities of a [`DocumentLinkRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct DocumentLinkClientCapabilities { /// Whether document link supports dynamic registration. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, /// Whether the client supports the `tooltip` property on `DocumentLink`. /// /// @since 3.15.0 #[serde(skip_serializing_if = "Option::is_none")] pub tooltip_support: Option, } impl DocumentLinkClientCapabilities { #[must_use] pub const fn new( dynamic_registration: Option, tooltip_support: Option, ) -> Self { Self { dynamic_registration, tooltip_support, } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct DocumentColorClientCapabilities { /// 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. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, } impl DocumentColorClientCapabilities { #[must_use] pub const fn new(dynamic_registration: Option) -> Self { Self { dynamic_registration } } } /// Client capabilities of a [`DocumentFormattingRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct DocumentFormattingClientCapabilities { /// Whether formatting supports dynamic registration. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, } impl DocumentFormattingClientCapabilities { #[must_use] pub const fn new(dynamic_registration: Option) -> Self { Self { dynamic_registration } } } /// Client capabilities of a [`DocumentRangeFormattingRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct DocumentRangeFormattingClientCapabilities { /// Whether range formatting supports dynamic registration. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, /// Whether the client supports formatting multiple ranges at once. /// /// @since 3.18.0 #[serde(skip_serializing_if = "Option::is_none")] pub ranges_support: Option, } impl DocumentRangeFormattingClientCapabilities { #[must_use] pub const fn new( dynamic_registration: Option, ranges_support: Option, ) -> Self { Self { dynamic_registration, ranges_support, } } } /// Client capabilities of a [`DocumentOnTypeFormattingRequest`]. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct DocumentOnTypeFormattingClientCapabilities { /// Whether on type formatting supports dynamic registration. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, } impl DocumentOnTypeFormattingClientCapabilities { #[must_use] pub const fn new(dynamic_registration: Option) -> Self { Self { dynamic_registration } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct RenameClientCapabilities { /// Whether rename supports dynamic registration. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, /// Client supports testing for validity of rename operations /// before execution. /// /// @since 3.12.0 #[serde(skip_serializing_if = "Option::is_none")] pub prepare_support: Option, /// Client supports the default behavior result. /// /// The value indicates the default behavior used by the /// client. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub prepare_support_default_behavior: Option, /// Whether the client honors the change annotations in /// text edits and resource operations returned via the /// rename request's workspace edit by for example presenting /// the workspace edit in the user interface and asking /// for confirmation. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub honors_change_annotations: Option, } impl RenameClientCapabilities { #[must_use] pub const fn new( dynamic_registration: Option, prepare_support: Option, prepare_support_default_behavior: Option, honors_change_annotations: Option, ) -> Self { Self { dynamic_registration, prepare_support, prepare_support_default_behavior, honors_change_annotations, } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct FoldingRangeClientCapabilities { /// 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. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, /// 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. #[serde(skip_serializing_if = "Option::is_none")] pub range_limit: Option, /// 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. #[serde(skip_serializing_if = "Option::is_none")] pub line_folding_only: Option, /// Specific options for the folding range kind. /// /// @since 3.17.0 #[serde(skip_serializing_if = "Option::is_none")] pub folding_range_kind: Option, /// Specific options for the folding range. /// /// @since 3.17.0 #[serde(skip_serializing_if = "Option::is_none")] pub folding_range: Option, } impl FoldingRangeClientCapabilities { #[must_use] pub const fn new( dynamic_registration: Option, range_limit: Option, line_folding_only: Option, folding_range_kind: Option, folding_range: Option, ) -> Self { Self { dynamic_registration, range_limit, line_folding_only, folding_range_kind, folding_range, } } } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct SelectionRangeClientCapabilities { /// Whether implementation supports dynamic registration for selection range providers. If this is set to `true` /// the client supports the new `SelectionRangeRegistrationOptions` return value for the corresponding server /// capability as well. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, } impl SelectionRangeClientCapabilities { #[must_use] pub const fn new(dynamic_registration: Option) -> Self { Self { dynamic_registration } } } /// The publish diagnostic client capabilities. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct PublishDiagnosticsClientCapabilities { /// Whether the client interprets the version property of the /// `textDocument/publishDiagnostics` notification's parameter. /// /// @since 3.15.0 #[serde(skip_serializing_if = "Option::is_none")] pub version_support: Option, #[serde(flatten)] pub diagnostics_capabilities: DiagnosticsCapabilities, } impl PublishDiagnosticsClientCapabilities { #[must_use] pub const fn new( version_support: Option, diagnostics_capabilities: DiagnosticsCapabilities, ) -> Self { Self { version_support, diagnostics_capabilities, } } } /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct CallHierarchyClientCapabilities { /// 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. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, } impl CallHierarchyClientCapabilities { #[must_use] pub const fn new(dynamic_registration: Option) -> Self { Self { dynamic_registration } } } /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct SemanticTokensClientCapabilities { /// 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. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, /// Which requests the client supports and might send to the server /// depending on the server's capability. Please note that clients might not /// show semantic tokens or degrade some of the user experience if a range /// or full request is advertised by the client but not provided by the /// server. If for example the client capability `requests.full` and /// `request.range` are both set to true but the server only provides a /// range provider the client might not render a minimap correctly or might /// even decide to not show any semantic tokens at all. pub requests: ClientSemanticTokensRequestOptions, /// The token types that the client supports. pub token_types: Vec, /// The token modifiers that the client supports. pub token_modifiers: Vec, /// The token formats the clients supports. pub formats: Vec, /// Whether the client supports tokens that can overlap each other. #[serde(skip_serializing_if = "Option::is_none")] pub overlapping_token_support: Option, /// Whether the client supports tokens that can span multiple lines. #[serde(skip_serializing_if = "Option::is_none")] pub multiline_token_support: Option, /// Whether the client allows the server to actively cancel a /// semantic token request, e.g. supports returning /// LSPErrorCodes.ServerCancelled. If a server does the client /// needs to retrigger the request. /// /// @since 3.17.0 #[serde(skip_serializing_if = "Option::is_none")] pub server_cancel_support: Option, /// Whether the client uses semantic tokens to augment existing /// syntax tokens. If set to `true` client side created syntax /// tokens and semantic tokens are both used for colorization. If /// set to `false` the client only uses the returned semantic tokens /// for colorization. /// /// If the value is `undefined` then the client behavior is not /// specified. /// /// @since 3.17.0 #[serde(skip_serializing_if = "Option::is_none")] pub augments_syntax_tokens: Option, } impl SemanticTokensClientCapabilities { #[must_use] pub const fn new( dynamic_registration: Option, requests: ClientSemanticTokensRequestOptions, token_types: Vec, token_modifiers: Vec, formats: Vec, overlapping_token_support: Option, multiline_token_support: Option, server_cancel_support: Option, augments_syntax_tokens: Option, ) -> Self { Self { dynamic_registration, requests, token_types, token_modifiers, formats, overlapping_token_support, multiline_token_support, server_cancel_support, augments_syntax_tokens, } } } /// Client capabilities for the linked editing range request. /// /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct LinkedEditingRangeClientCapabilities { /// 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. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, } impl LinkedEditingRangeClientCapabilities { #[must_use] pub const fn new(dynamic_registration: Option) -> Self { Self { dynamic_registration } } } /// Client capabilities specific to the moniker request. /// /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct MonikerClientCapabilities { /// Whether moniker supports dynamic registration. If this is set to `true` /// the client supports the new `MonikerRegistrationOptions` return value /// for the corresponding server capability as well. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, } impl MonikerClientCapabilities { #[must_use] pub const fn new(dynamic_registration: Option) -> Self { Self { dynamic_registration } } } /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct TypeHierarchyClientCapabilities { /// 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. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, } impl TypeHierarchyClientCapabilities { #[must_use] pub const fn new(dynamic_registration: Option) -> Self { Self { dynamic_registration } } } /// Client capabilities specific to inline values. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct InlineValueClientCapabilities { /// Whether implementation supports dynamic registration for inline value providers. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, } impl InlineValueClientCapabilities { #[must_use] pub const fn new(dynamic_registration: Option) -> Self { Self { dynamic_registration } } } /// Inlay hint client capabilities. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct InlayHintClientCapabilities { /// Whether inlay hints support dynamic registration. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, /// Indicates which properties a client can resolve lazily on an inlay /// hint. #[serde(skip_serializing_if = "Option::is_none")] pub resolve_support: Option, } impl InlayHintClientCapabilities { #[must_use] pub const fn new( dynamic_registration: Option, resolve_support: Option, ) -> Self { Self { dynamic_registration, resolve_support, } } } /// Client capabilities specific to diagnostic pull requests. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct DiagnosticClientCapabilities { /// 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. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, /// Whether the clients supports related documents for document diagnostic pulls. #[serde(skip_serializing_if = "Option::is_none")] pub related_document_support: Option, /// Whether the client supports `MarkupContent` in diagnostic messages. /// /// @since 3.18.0 #[serde(skip_serializing_if = "Option::is_none")] pub markup_message_support: Option, #[serde(flatten)] pub diagnostics_capabilities: DiagnosticsCapabilities, } impl DiagnosticClientCapabilities { #[must_use] pub const fn new( dynamic_registration: Option, related_document_support: Option, markup_message_support: Option, diagnostics_capabilities: DiagnosticsCapabilities, ) -> Self { Self { dynamic_registration, related_document_support, markup_message_support, diagnostics_capabilities, } } } /// Client capabilities specific to inline completions. /// /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct InlineCompletionClientCapabilities { /// Whether implementation supports dynamic registration for inline completion providers. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, } impl InlineCompletionClientCapabilities { #[must_use] pub const fn new(dynamic_registration: Option) -> Self { Self { dynamic_registration } } } /// Notebook specific client capabilities. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct NotebookDocumentSyncClientCapabilities { /// 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. #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_registration: Option, /// The client supports sending execution summary data per cell. #[serde(skip_serializing_if = "Option::is_none")] pub execution_summary_support: Option, } impl NotebookDocumentSyncClientCapabilities { #[must_use] pub const fn new( dynamic_registration: Option, execution_summary_support: Option, ) -> Self { Self { dynamic_registration, execution_summary_support, } } } /// Show message request client capabilities #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct ShowMessageRequestClientCapabilities { /// Capabilities specific to the `MessageActionItem` type. #[serde(skip_serializing_if = "Option::is_none")] pub message_action_item: Option, } impl ShowMessageRequestClientCapabilities { #[must_use] pub const fn new( message_action_item: Option, ) -> Self { Self { message_action_item } } } /// Client capabilities for the showDocument request. /// /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct ShowDocumentClientCapabilities { /// The client has support for the showDocument /// request. pub support: bool, } impl ShowDocumentClientCapabilities { #[must_use] pub const fn new(support: bool) -> Self { Self { support } } } /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct StaleRequestSupportOptions { /// The client will actively cancel the request. pub cancel: bool, /// The list of requests for which the client /// will retry the request if it receives a /// response with error code `ContentModified` pub retry_on_content_modified: Vec, } impl StaleRequestSupportOptions { #[must_use] pub const fn new(cancel: bool, retry_on_content_modified: Vec) -> Self { Self { cancel, retry_on_content_modified, } } } /// Client capabilities specific to regular expressions. /// /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct RegularExpressionsClientCapabilities { /// The engine's name. pub engine: RegularExpressionEngineKind, /// The engine's version. #[serde(skip_serializing_if = "Option::is_none")] pub version: Option, } impl RegularExpressionsClientCapabilities { #[must_use] pub const fn new( engine: RegularExpressionEngineKind, version: Option, ) -> Self { Self { engine, version } } } /// Client capabilities specific to the used markdown parser. /// /// @since 3.16.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct MarkdownClientCapabilities { /// The name of the parser. pub parser: String, /// The version of the parser. #[serde(skip_serializing_if = "Option::is_none")] pub version: Option, /// A list of HTML tags that the client allows / supports in /// Markdown. /// /// @since 3.17.0 #[serde(skip_serializing_if = "Option::is_none")] pub allowed_tags: Option>, } impl MarkdownClientCapabilities { #[must_use] pub const fn new( parser: String, version: Option, allowed_tags: Option>, ) -> Self { Self { parser, version, allowed_tags, } } } /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct ChangeAnnotationsSupportOptions { /// Whether the client groups edits with equal labels into tree nodes, /// for instance all edits labelled with "Changes in Strings" would /// be a tree node. #[serde(skip_serializing_if = "Option::is_none")] pub groups_on_label: Option, } impl ChangeAnnotationsSupportOptions { #[must_use] pub const fn new(groups_on_label: Option) -> Self { Self { groups_on_label } } } /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct ClientSymbolKindOptions { /// 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. #[serde(skip_serializing_if = "Option::is_none")] pub value_set: Option>, } impl ClientSymbolKindOptions { #[must_use] pub const fn new(value_set: Option>) -> Self { Self { value_set } } } /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct ClientSymbolTagOptions { /// The tags supported by the client. pub value_set: Vec, } impl ClientSymbolTagOptions { #[must_use] pub const fn new(value_set: Vec) -> Self { Self { value_set } } } /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct ClientSymbolResolveOptions { /// The properties that a client can resolve lazily. Usually /// `location.range` pub properties: Vec, } impl ClientSymbolResolveOptions { #[must_use] pub const fn new(properties: Vec) -> Self { Self { properties } } } /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct ClientCompletionItemOptions { /// 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. #[serde(skip_serializing_if = "Option::is_none")] pub snippet_support: Option, /// Client supports commit characters on a completion item. #[serde(skip_serializing_if = "Option::is_none")] pub commit_characters_support: Option, /// Client supports the following content formats for the documentation /// property. The order describes the preferred format of the client. #[serde(skip_serializing_if = "Option::is_none")] pub documentation_format: Option>, /// Client supports the deprecated property on a completion item. #[serde(skip_serializing_if = "Option::is_none")] pub deprecated_support: Option, /// Client supports the preselect property on a completion item. #[serde(skip_serializing_if = "Option::is_none")] pub preselect_support: Option, /// 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 #[serde(skip_serializing_if = "Option::is_none")] pub tag_support: Option, /// 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 #[serde(skip_serializing_if = "Option::is_none")] pub insert_replace_support: Option, /// 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 #[serde(skip_serializing_if = "Option::is_none")] pub resolve_support: Option, /// 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 #[serde(skip_serializing_if = "Option::is_none")] pub insert_text_mode_support: Option, /// The client has support for completion item label /// details (see also `CompletionItemLabelDetails`). /// /// @since 3.17.0 #[serde(skip_serializing_if = "Option::is_none")] pub label_details_support: Option, } impl ClientCompletionItemOptions { #[must_use] pub const fn new( snippet_support: Option, commit_characters_support: Option, documentation_format: Option>, deprecated_support: Option, preselect_support: Option, tag_support: Option, insert_replace_support: Option, resolve_support: Option, insert_text_mode_support: Option, label_details_support: Option, ) -> Self { Self { snippet_support, commit_characters_support, documentation_format, deprecated_support, preselect_support, tag_support, insert_replace_support, resolve_support, insert_text_mode_support, label_details_support, } } } /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct ClientCompletionItemOptionsKind { /// 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. #[serde(skip_serializing_if = "Option::is_none")] pub value_set: Option>, } impl ClientCompletionItemOptionsKind { #[must_use] pub const fn new(value_set: Option>) -> Self { Self { value_set } } } /// The client supports the following `CompletionList` specific /// capabilities. /// /// @since 3.17.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct CompletionListCapabilities { /// 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 #[serde(skip_serializing_if = "Option::is_none")] pub item_defaults: Option>, /// Specifies whether the client supports `CompletionList.applyKind` to /// indicate how supported values from `completionList.itemDefaults` /// and `completion` will be combined. /// /// If a client supports `applyKind` it must support it for all fields /// that it supports that are listed in `CompletionList.applyKind`. This /// means when clients add support for new/future fields in completion /// items the MUST also support merge for them if those fields are /// defined in `CompletionList.applyKind`. /// /// @since 3.18.0 #[serde(skip_serializing_if = "Option::is_none")] pub apply_kind_support: Option, } impl CompletionListCapabilities { #[must_use] pub const fn new( item_defaults: Option>, apply_kind_support: Option, ) -> Self { Self { item_defaults, apply_kind_support, } } } /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct ClientSignatureInformationOptions { /// Client supports the following content formats for the documentation /// property. The order describes the preferred format of the client. #[serde(skip_serializing_if = "Option::is_none")] pub documentation_format: Option>, /// Client capabilities specific to parameter information. #[serde(skip_serializing_if = "Option::is_none")] pub parameter_information: Option, /// The client supports the `activeParameter` property on `SignatureInformation` /// literal. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub active_parameter_support: Option, /// The client supports the `activeParameter` property on /// `SignatureHelp`/`SignatureInformation` being set to `null` to /// indicate that no parameter should be active. /// /// @since 3.18.0 #[serde(skip_serializing_if = "Option::is_none")] pub no_active_parameter_support: Option, } impl ClientSignatureInformationOptions { #[must_use] pub const fn new( documentation_format: Option>, parameter_information: Option, active_parameter_support: Option, no_active_parameter_support: Option, ) -> Self { Self { documentation_format, parameter_information, active_parameter_support, no_active_parameter_support, } } } /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct ClientCodeActionLiteralOptions { /// The code action kind is support with the following value /// set. pub code_action_kind: ClientCodeActionKindOptions, } impl ClientCodeActionLiteralOptions { #[must_use] pub const fn new(code_action_kind: ClientCodeActionKindOptions) -> Self { Self { code_action_kind } } } /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct ClientCodeActionResolveOptions { /// The properties that a client can resolve lazily. pub properties: Vec, } impl ClientCodeActionResolveOptions { #[must_use] pub const fn new(properties: Vec) -> Self { Self { properties } } } /// @since 3.18.0 - proposed #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct CodeActionTagOptions { /// The tags supported by the client. pub value_set: Vec, } impl CodeActionTagOptions { #[must_use] pub const fn new(value_set: Vec) -> Self { Self { value_set } } } /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct ClientCodeLensResolveOptions { /// The properties that a client can resolve lazily. pub properties: Vec, } impl ClientCodeLensResolveOptions { #[must_use] pub const fn new(properties: Vec) -> Self { Self { properties } } } /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct ClientFoldingRangeKindOptions { /// 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. #[serde(skip_serializing_if = "Option::is_none")] pub value_set: Option>, } impl ClientFoldingRangeKindOptions { #[must_use] pub const fn new(value_set: Option>) -> Self { Self { value_set } } } /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct ClientFoldingRangeOptions { /// 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 #[serde(skip_serializing_if = "Option::is_none")] pub collapsed_text: Option, } impl ClientFoldingRangeOptions { #[must_use] pub const fn new(collapsed_text: Option) -> Self { Self { collapsed_text } } } /// General diagnostics capabilities for pull and push model. #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct DiagnosticsCapabilities { /// Whether the clients accepts diagnostics with related information. #[serde(skip_serializing_if = "Option::is_none")] pub related_information: Option, /// Client supports the tag property to provide meta data about a diagnostic. /// Clients supporting tags have to handle unknown tags gracefully. /// /// @since 3.15.0 #[serde(skip_serializing_if = "Option::is_none")] pub tag_support: Option, /// Client supports a codeDescription property /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub code_description_support: Option, /// Whether code action supports the `data` property which is /// preserved between a `textDocument/publishDiagnostics` and /// `textDocument/codeAction` request. /// /// @since 3.16.0 #[serde(skip_serializing_if = "Option::is_none")] pub data_support: Option, } impl DiagnosticsCapabilities { #[must_use] pub const fn new( related_information: Option, tag_support: Option, code_description_support: Option, data_support: Option, ) -> Self { Self { related_information, tag_support, code_description_support, data_support, } } } /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct ClientSemanticTokensRequestOptions { /// The client will send the `textDocument/semanticTokens/range` request if /// the server provides a corresponding handler. #[serde(skip_serializing_if = "Option::is_none")] pub range: Option, /// The client will send the `textDocument/semanticTokens/full` request if /// the server provides a corresponding handler. #[serde(skip_serializing_if = "Option::is_none")] pub full: Option, } impl ClientSemanticTokensRequestOptions { #[must_use] pub const fn new( range: Option, full: Option, ) -> Self { Self { range, full } } } /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct ClientInlayHintResolveOptions { /// The properties that a client can resolve lazily. pub properties: Vec, } impl ClientInlayHintResolveOptions { #[must_use] pub const fn new(properties: Vec) -> Self { Self { properties } } } /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct ClientShowMessageActionItemOptions { /// Whether the client supports additional attributes which /// are preserved and send back to the server in the /// request's response. #[serde(skip_serializing_if = "Option::is_none")] pub additional_properties_support: Option, } impl ClientShowMessageActionItemOptions { #[must_use] pub const fn new(additional_properties_support: Option) -> Self { Self { additional_properties_support, } } } /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct CompletionItemTagOptions { /// The tags supported by the client. pub value_set: Vec, } impl CompletionItemTagOptions { #[must_use] pub const fn new(value_set: Vec) -> Self { Self { value_set } } } /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct ClientCompletionItemResolveOptions { /// The properties that a client can resolve lazily. pub properties: Vec, } impl ClientCompletionItemResolveOptions { #[must_use] pub const fn new(properties: Vec) -> Self { Self { properties } } } /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct ClientCompletionItemInsertTextModeOptions { pub value_set: Vec, } impl ClientCompletionItemInsertTextModeOptions { #[must_use] pub const fn new(value_set: Vec) -> Self { Self { value_set } } } /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct ClientSignatureParameterInformationOptions { /// The client supports processing label offsets instead of a /// simple label string. /// /// @since 3.14.0 #[serde(skip_serializing_if = "Option::is_none")] pub label_offset_support: Option, } impl ClientSignatureParameterInformationOptions { #[must_use] pub const fn new(label_offset_support: Option) -> Self { Self { label_offset_support } } } /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct ClientCodeActionKindOptions { /// 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. pub value_set: Vec, } impl ClientCodeActionKindOptions { #[must_use] pub const fn new(value_set: Vec) -> Self { Self { value_set } } } /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default)] #[serde(rename_all = "camelCase")] pub struct ClientDiagnosticsTagOptions { /// The tags supported by the client. pub value_set: Vec, } impl ClientDiagnosticsTagOptions { #[must_use] pub const fn new(value_set: Vec) -> Self { Self { value_set } } } /// @since 3.18.0 #[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Eq, Hash, Default, Copy)] #[serde(rename_all = "camelCase")] pub struct ClientSemanticTokensRequestFullDelta { /// The client will send the `textDocument/semanticTokens/full/delta` request if /// the server provides a corresponding handler. #[serde(skip_serializing_if = "Option::is_none")] pub delta: Option, } impl ClientSemanticTokensRequestFullDelta { #[must_use] pub const fn new(delta: Option) -> Self { Self { delta } } } impl Default for Message { fn default() -> Self { Message::String(String::default()) } } /// Represents a semantic token (serialized as five uintegers). #[derive(Debug, Eq, PartialEq, Copy, Clone, Default, Hash)] pub struct SemanticToken { /// Token line number, relative to the start of the previous token. pub delta_line: u32, /// Token start character, relative to the start of the previous token (relative to 0 or /// the previous token’s start if they are on the same line). pub delta_start: u32, /// The length of the token. pub length: u32, /// Will be looked up in [`SemanticTokensLegend::token_types`]. We currently ask that /// `tokenType` < 65536. pub token_type: u32, /// Each set bit will be looked up in [`SemanticTokensLegend::token_modifiers`]. pub token_modifiers_bitset: u32, } impl SemanticToken { fn deserialize_tokens<'de, D>( deserializer: D, ) -> Result, D::Error> where D: serde::Deserializer<'de>, { let data = Vec::::deserialize(deserializer)?; let chunks = data.chunks_exact(5); if !chunks.remainder().is_empty() { return Result::Err(serde::de::Error::custom("Length is not divisible by 5")); } Result::Ok( chunks .map(|chunk| Self { delta_line: chunk[0], delta_start: chunk[1], length: chunk[2], token_type: chunk[3], token_modifiers_bitset: chunk[4], }) .collect(), ) } fn serialize_tokens( tokens: &[SemanticToken], serializer: S, ) -> Result where S: serde::Serializer, { let mut seq = serializer.serialize_seq(Some(tokens.len() * 5))?; for token in tokens { seq.serialize_element(&token.delta_line)?; seq.serialize_element(&token.delta_start)?; seq.serialize_element(&token.length)?; seq.serialize_element(&token.token_type)?; seq.serialize_element(&token.token_modifiers_bitset)?; } seq.end() } fn deserialize_optional_tokens<'de, D>( deserializer: D, ) -> Result>, D::Error> where D: serde::Deserializer<'de>, { #[derive(Deserialize)] #[serde(transparent)] struct Wrapper { #[serde(deserialize_with = "SemanticToken::deserialize_tokens")] tokens: Vec, } Ok(Option::::deserialize(deserializer)?.map(|wrapper| wrapper.tokens)) } fn serialize_optional_tokens( data: &Option>, serializer: S, ) -> Result where S: serde::Serializer, { #[derive(Serialize)] #[serde(transparent)] struct Wrapper { #[serde(serialize_with = "SemanticToken::serialize_tokens")] tokens: Vec, } let opt = data.as_ref().map(|t| Wrapper { tokens: t.clone() }); opt.serialize(serializer) } } #[derive(Debug, Eq, Hash, PartialEq, Clone, Deserialize, Serialize)] #[serde(untagged)] pub enum MessageActionItemProperty { String(String), Bool(bool), Int(i32), Object(LspObject), } gen-lsp-types-0.8.0/src/generated/type_aliases.rs000064400000000000000000000044241046102023000201210ustar 00000000000000#[allow(clippy::wildcard_imports)] use super::*; /// Information about where a symbol is defined. /// /// Provides additional metadata over normal [location][Location] definitions, including the range of /// the defining symbol pub type DefinitionLink = LocationLink; /// LSP arrays. /// @since 3.17.0 pub type LspArray = Vec; /// The LSP any type. /// Please note that strictly speaking a property with the value `undefined` /// can't be converted into JSON preserving the property name. However for /// convenience it is allowed and assumed that all these properties are /// optional as well. /// @since 3.17.0 pub type LspAny = serde_json::Value; /// Information about where a symbol is declared. /// /// Provides additional metadata over normal [location][Location] declarations, including the range of /// the declaring symbol. /// /// Servers should prefer returning `DeclarationLink` over `Declaration` if supported /// by the client. pub type DeclarationLink = LocationLink; /// 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. pub type DocumentSelector = Vec; /// An identifier to refer to a change annotation stored with a workspace edit. pub type ChangeAnnotationIdentifier = String; /// LSP object definition. /// @since 3.17.0 pub type LspObject = serde_json::Map; /// The glob pattern to watch relative to the base path. Glob patterns can have the following syntax: /// - `*` to match zero 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 pub type Pattern = String; pub type RegularExpressionEngineKind = String; gen-lsp-types-0.8.0/src/generated.rs000064400000000000000000000014601046102023000154340ustar 00000000000000//! This module is automatically @generated by an xtask. Do not edit. #![allow( deprecated, clippy::doc_lazy_continuation, unreachable_patterns, clippy::large_enum_variant, clippy::too_many_arguments, clippy::too_long_first_doc_paragraph, clippy::doc_markdown, clippy::match_same_arms, clippy::missing_const_for_fn, clippy::doc_link_with_quotes, clippy::manual_string_new, clippy::use_self, clippy::ref_option, rustdoc::invalid_codeblock_attributes )] #![cfg_attr(any(), rustfmt::skip)] mod common; mod enum_ors; mod enumerations; mod notifications; mod requests; mod structures; mod type_aliases; pub use common::*; pub use enum_ors::*; pub use enumerations::*; pub use notifications::*; pub use requests::*; pub use structures::*; pub use type_aliases::*; gen-lsp-types-0.8.0/src/json_rpc.rs000064400000000000000000000217731046102023000153240ustar 00000000000000use serde::{Deserialize, Deserializer, Serialize}; use serde_json::Value; use crate::{ErrorCodes, Notification, Request}; pub(crate) fn deserialize_some<'de, T, D>(deserializer: D) -> Result, D::Error> where T: Deserialize<'de>, D: Deserializer<'de>, { T::deserialize(deserializer).map(Some) } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Hash)] enum Version { #[serde(rename = "2.0")] TwoPointZero, } /// A unique ID used to correlate requests and responses together. #[derive(Clone, Debug, Eq, Hash, PartialEq, Deserialize, Serialize)] #[serde(untagged)] pub enum Id { /// Numeric ID. Number(i64), /// String ID. String(String), /// Null ID. /// /// The use of Null as a value for the id member in a Request object is discouraged, because /// this specification uses a value of Null for Responses with an unknown id. Also, because /// JSON-RPC 1.0 uses an id value of Null for Notifications this could cause confusion in /// handling. Null, } impl From for Id { fn from(value: i64) -> Self { Self::Number(value) } } impl From for Id { fn from(value: i32) -> Self { Self::Number(value as i64) } } impl From for Id { fn from(value: String) -> Self { Self::String(value) } } impl From<()> for Id { fn from((): ()) -> Self { Self::Null } } impl From for Id { fn from(value: crate::Id) -> Self { match value { crate::Id::Int(int) => Self::Number(int as i64), crate::Id::String(string) => Self::String(string), } } } impl TryFrom for crate::Id { type Error = String; fn try_from(value: Id) -> Result { match value { Id::String(string) => Ok(Self::String(string)), Id::Number(number) => Ok(Self::Int( i32::try_from(number).map_err(|e| format!("Request ID int too big: {e}"))?, )), Id::Null => Err(Self::Error::from("Id cannot be null")), } } } /// A JSON-RPC Request (or Notification) object. #[derive(Clone, Debug, PartialEq, Deserialize, Serialize, Eq)] pub struct RequestObject { /// A String specifying the version of the JSON-RPC protocol. MUST be exactly "2.0". jsonrpc: Version, /// An identifier established by the Client that MUST contain a String, Number, or NULL value if /// included. If it is not included it is assumed to be a notification. The value SHOULD /// normally not be Null and Numbers SHOULD NOT contain fractional parts. #[serde(default, deserialize_with = "deserialize_some")] #[serde(skip_serializing_if = "Option::is_none")] id: Option, /// A String containing the name of the method to be invoked. Method names that begin with the /// word rpc followed by a period character (U+002E or ASCII 46) are reserved for rpc-internal /// methods and extensions and MUST NOT be used for anything else. #[serde(default)] method: String, /// A Structured value that holds the parameter values to be used during the invocation of the /// method. This member MAY be omitted. /// /// If present, parameters for the rpc call MUST be provided as a Structured value. Either /// by-position through an Array or by-name through an Object. #[serde(default, deserialize_with = "deserialize_some")] #[serde(skip_serializing_if = "Option::is_none")] params: Option, } impl RequestObject { /// Creates a JSON-RPC Request object from a server request. /// /// # Panics /// /// Will panic if `result` cannot be serialized (impossible unless the trait was implemented /// incorrectly). pub fn from_request(id: Id, params: R::Params) -> Self where R: Request, { let params = serde_json::to_value(params).expect("Invalid request params"); let params = match params { Value::Null => None, Value::Array(_) | Value::Object(_) => Some(params), _ => panic!("Parameters must be an object or array, if not omitted."), }; Self { jsonrpc: Version::TwoPointZero, id: Some(id), params, method: R::METHOD.into(), } } /// Creates a JSON-RPC Request object from a server notification. /// /// # Panics /// /// Will panic if `result` cannot be serialized (impossible unless the trait was implemented /// incorrectly). pub fn from_notification(params: N::Params) -> Self where N: Notification, { let params = serde_json::to_value(params).expect("Invalid request params"); let params = match params { Value::Null => None, Value::Array(_) | Value::Object(_) => Some(params), _ => panic!("Parameters must be an object or array, if not omitted."), }; Self { jsonrpc: Version::TwoPointZero, method: N::METHOD.to_string(), params, id: None, } } /// Returns the method to be invoked. #[must_use] pub fn method(&self) -> &str { self.method.as_ref() } /// Returns the id. #[must_use] pub const fn id(&self) -> Option<&Id> { self.id.as_ref() } /// Returns the params. #[must_use] pub const fn params(&self) -> Option<&Value> { self.params.as_ref() } /// Splits the request into the method name, request ID, and the parameters. #[must_use] pub fn into_parts(self) -> (String, Option, Option) { (self.method, self.id, self.params) } } #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] #[serde(untagged)] enum Kind { /// This member is REQUIRED on success. This member MUST NOT exist if there was an error /// invoking the method. The value of this member is determined by the method invoked on the /// Server. Ok { result: Value }, /// This member is REQUIRED on error. This member MUST NOT exist if there was no error triggered /// during invocation. The value for this member MUST be an Object as defined in section 5.1. Err { error: Error }, } /// A JSON-RPC Error object. #[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)] pub struct Error { /// A Number that indicates the error type that occurred. pub code: ErrorCodes, /// A String providing a short description of the error. The message SHOULD be limited to a /// concise single sentence. pub message: String, /// A Primitive or Structured value that contains additional information about the error. This /// may be omitted. The value of this member is defined by the Server (e.g. detailed error /// information, nested errors etc.). #[serde(skip_serializing_if = "Option::is_none")] pub data: Option, } /// A JSON-RPC Response object. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] pub struct ResponseObject { /// A String specifying the version of the JSON-RPC protocol. MUST be exactly "2.0". jsonrpc: Version, #[serde(flatten)] kind: Kind, /// This member is REQUIRED. It MUST be the same as the value of the id member in the /// Request Object. If there was an error in detecting the id in the Request object /// (e.g. Parse error/Invalid Request), it MUST be Null. id: Id, } impl ResponseObject { /// Creates a successful Response object from a result value. /// /// # Panics /// /// Will panic if `result` cannot be serialized (impossible unless the trait was implemented /// incorrectly). pub fn from_success(id: Id, result: R::Result) -> Self where R: Request, { let result = serde_json::to_value(result).unwrap(); Self { jsonrpc: Version::TwoPointZero, kind: Kind::Ok { result }, id, } } /// Creates an error Response object from an error value. #[must_use] pub const fn from_error(id: Id, error: Error) -> Self { Self { jsonrpc: Version::TwoPointZero, kind: Kind::Err { error }, id, } } /// Returns `true` if the Response object indicates success. #[must_use] pub const fn is_ok(&self) -> bool { matches!(self.kind, Kind::Ok { .. }) } /// Returns `true` if the Response object indicates failure. #[must_use] pub const fn is_error(&self) -> bool { !self.is_ok() } /// Returns the corresponding Response object ID. #[must_use] pub const fn id(&self) -> &Id { &self.id } /// Returns the `result` value, if present. #[must_use] pub const fn result(&self) -> Option<&Value> { match &self.kind { Kind::Ok { result } => Some(result), Kind::Err { .. } => None, } } /// Returns the `error` object, if present. #[must_use] pub const fn error(&self) -> Option<&Error> { match &self.kind { Kind::Err { error } => Some(error), Kind::Ok { .. } => None, } } } gen-lsp-types-0.8.0/src/lib.rs000064400000000000000000000772771046102023000142670ustar 00000000000000mod generated; pub mod json_rpc; pub use generated::*; /// # Tests for compilation success/failure. /// /// ## Should not leak internal symbols /// /// ```compile_fail /// use gen_lsp_types::generated; /// ``` /// /// ```compile_fail /// use gen_lsp_types::deserialize_some; /// ``` /// /// ```compile_fail /// use gen_lsp_types::SemanticToken::deserialize_tokens; /// ``` /// /// ``` /// use gen_lsp_types::SemanticToken; /// ``` /// /// ```compile_fail /// use gen_lsp_types::json_rpc::deserialize_some; /// ``` /// /// ## Should have newtype Lsp(Request|Notification)Method semantics /// /// ```compile_fail /// use gen_lsp_types::LspNotificationMethod; /// let foo: &str = LspNotificationMethod::CancelRequest; /// ``` mod compiletest {} /// Tests for default features. #[cfg(test)] #[cfg(all(not(feature = "url"), not(feature = "fluent-uri")))] mod test { #![allow(deprecated)] use std::{ borrow::Cow, collections::{HashMap, HashSet}, }; use serde_json::json; use crate::*; #[test] fn nullable_field() { let tdro = TextDocumentRegistrationOptions { document_selector: None, }; let tdro_str = serde_json::to_string(&tdro).unwrap(); assert_eq!(tdro_str, r#"{"documentSelector":null}"#); let tdro = serde_json::from_str::(&tdro_str).unwrap(); assert_eq!( tdro, TextDocumentRegistrationOptions { document_selector: None } ); // Missing documentSelector. Be liberal on deserialization, even though this is technically a // noncompliant representation. assert_eq!(tdro, serde_json::from_str("{}").unwrap()); } #[test] fn nullable_field_default() { let ip = InitializeParams::default(); let ip_str = serde_json::to_string(&ip).unwrap(); assert_eq!( ip_str, r#"{"processId":null,"rootUri":null,"capabilities":{}}"# ); assert_eq!( InitializeParams::default(), serde_json::from_str(&ip_str).unwrap() ); // Missing processId. Be liberal on deserialization, even though this is technically a // noncompliant representation. let bad_ip_str = r#"{"rootUri":null,"capabilities":{}}"#; assert_eq!( InitializeParams::default(), serde_json::from_str(bad_ip_str).unwrap() ); } #[test] fn optional_field() { let cp = ColorPresentation { label: "Label".to_string(), text_edit: None, ..Default::default() }; let cp_str = serde_json::to_string(&cp).unwrap(); assert_eq!(cp_str, r#"{"label":"Label"}"#); let cp = serde_json::from_str::(&cp_str).unwrap(); assert_eq!( cp, ColorPresentation { label: "Label".to_string(), text_edit: None, ..Default::default() } ); // While technically illegal in the spec, this library chooses to be more liberal with // DEserialization, in order to be tolerant of slightly spec-noncompliant communicators. assert_eq!( serde_json::from_str::(r#"{"label":"Label","textEdit":null}"#) .unwrap(), cp ); } #[test] fn optional_nullable_field() { let wfip = WorkspaceFoldersInitializeParams { workspace_folders: None, }; let wfip_str = serde_json::to_string(&wfip).unwrap(); assert_eq!(wfip_str, r"{}"); assert_eq!( serde_json::from_str::(&wfip_str).unwrap(), wfip ); let wfip = WorkspaceFoldersInitializeParams { workspace_folders: Some(crate::WorkspaceFolders::Null), }; let wfip_str = serde_json::to_string(&wfip).unwrap(); assert_eq!(wfip_str, r#"{"workspaceFolders":null}"#); assert_eq!( serde_json::from_str::(&wfip_str).unwrap(), wfip ); let wfip = WorkspaceFoldersInitializeParams { workspace_folders: Some(crate::WorkspaceFolders::WorkspaceFolderList(Vec::new())), }; let wfip_str = serde_json::to_string(&wfip).unwrap(); assert_eq!(wfip_str, r#"{"workspaceFolders":[]}"#); assert_eq!( serde_json::from_str::(&wfip_str).unwrap(), wfip ); } #[test] fn derives() { let pos = Position::default(); let table = HashMap::from([(pos, 123)]); assert_eq!(table.get(&pos), Some(&123)); let range = Range::default(); let table = HashSet::from([range]); assert!(table.contains(&range)); let doc_sym = DocumentSymbol { kind: crate::SymbolKind::Function, name: String::default(), detail: Option::default(), tags: Option::default(), deprecated: Option::default(), range: Range::default(), selection_range: Range::default(), children: Option::default(), }; let table = HashSet::from([doc_sym.clone()]); assert!(table.contains(&doc_sym)); // From let wfip = WorkspaceFoldersInitializeParams { workspace_folders: Some(Vec::new().into()), }; let wfip_str = serde_json::to_string(&wfip).unwrap(); assert_eq!(wfip_str, r#"{"workspaceFolders":[]}"#); assert_eq!( serde_json::from_str::(&wfip_str).unwrap(), wfip ); assert_eq!(WorkspaceFolders::Null, ().into()); let wfip = WorkspaceFoldersInitializeParams { workspace_folders: Some(().into()), }; let wfip_str = serde_json::to_string(&wfip).unwrap(); assert_eq!(wfip_str, r#"{"workspaceFolders":null}"#); assert_eq!( serde_json::from_str::(&wfip_str).unwrap(), wfip ); let wfsc = WorkspaceFoldersServerCapabilities { change_notifications: Some("some-noti-id".into()), ..Default::default() }; let wfsc_str = serde_json::to_string(&wfsc).unwrap(); assert_eq!(wfsc_str, r#"{"changeNotifications":"some-noti-id"}"#); let wfsc = WorkspaceFoldersServerCapabilities { change_notifications: Some(String::from("some-noti-id").into()), ..Default::default() }; let wfsc_str = serde_json::to_string(&wfsc).unwrap(); assert_eq!(wfsc_str, r#"{"changeNotifications":"some-noti-id"}"#); let wfsc = WorkspaceFoldersServerCapabilities { change_notifications: Some(false.into()), ..Default::default() }; let wfsc_str = serde_json::to_string(&wfsc).unwrap(); assert_eq!(wfsc_str, r#"{"changeNotifications":false}"#); let wfsc = WorkspaceFoldersServerCapabilities { change_notifications: Some('f'.into()), ..Default::default() }; let wfsc_str = serde_json::to_string(&wfsc).unwrap(); assert_eq!(wfsc_str, r#"{"changeNotifications":"f"}"#); let boxed_str: Box = Box::from("foo"); let wfsc = WorkspaceFoldersServerCapabilities { change_notifications: Some(boxed_str.into()), ..Default::default() }; let wfsc_str = serde_json::to_string(&wfsc).unwrap(); assert_eq!(wfsc_str, r#"{"changeNotifications":"foo"}"#); } #[test] fn special_impls() { let pos = Position { line: 2, character: 0, }; let pos2 = Position { line: 1, character: 9, }; assert!(pos2 < pos); // Copy let pos3 = pos2; assert_eq!(pos3, pos2); let range = Range { start: pos2, end: pos, }; // Copy let range2 = range; assert_eq!(range2, range); let range3 = Range { start: Position::default(), end: Position { line: 999, character: 999, }, }; assert!(range3 < range2); let range4 = Range::default(); assert!(range4 < range3); let method: String = LspRequestMethod::TextDocumentOnTypeFormatting.into(); assert_eq!(method, "textDocument/onTypeFormatting"); let method = LspRequestMethod::Shutdown.to_string(); assert_eq!(method, "shutdown"); let method = LspRequestMethod::Custom("foo").to_string(); assert_eq!(method, "foo"); let method = LspNotificationMethod::Custom("foo").to_string(); assert_eq!(method, "foo"); let method = LspNotificationMethod::CancelRequest.to_string(); assert_eq!(method, "$/cancelRequest"); let method = LspNotificationMethod::WorkspaceDidChangeWatchedFiles.to_string(); assert_eq!(method, "workspace/didChangeWatchedFiles"); let wk = WatchKind::Delete; let wk2 = WatchKind::Create; assert_eq!(wk | wk2, WatchKind::Custom(5)); assert_eq!(wk | wk2 | WatchKind::Change, WatchKind::Custom(7)); assert_eq!((wk | wk2) & wk, wk); assert_eq!(wk | wk, wk); assert_eq!((wk | wk2 | WatchKind::Change) & (wk | wk2), wk | wk2); assert_eq!(WatchKind::Delete ^ WatchKind::Delete, WatchKind::Custom(0)); assert_eq!(WatchKind::Custom(0) ^ WatchKind::Create, WatchKind::Create); let mut wk = WatchKind::Custom(0); wk |= WatchKind::Delete; assert_eq!(wk, WatchKind::Delete); wk &= WatchKind::Create; assert_eq!(wk, WatchKind::Custom(0)); wk ^= WatchKind::Delete; assert_eq!(wk, WatchKind::Delete); } #[test] fn string_literal_field() { let wdpe = WorkDoneProgressEnd { message: Some("change da world. my final message. goodbye".to_string()), }; let ser = serde_json::to_string(&wdpe).unwrap(); assert_eq!( ser, r#"{"message":"change da world. my final message. goodbye","kind":"end"}"# ); let deser = serde_json::from_str::(&ser).unwrap(); assert_eq!(deser, wdpe); let fake_ser = r#"{"message":"change da world. my final message. goodbye","kind":"begin"}"#; assert!(serde_json::from_str::(fake_ser).is_err()); let doc_change = CreateFile { uri: "file:///foo.txt".to_string().into(), options: None, annotation_id: None, }; let ser = serde_json::to_string(&doc_change).unwrap(); assert_eq!(ser, r#"{"uri":"file:///foo.txt","kind":"create"}"#); let ser = r#"{"uri":"file:///foo.txt","kind":"create"}"#; let deser = serde_json::from_str::(ser).unwrap(); assert_eq!(deser, doc_change.into()); let ser = r#"{"uri":"file:///foo.txt","kind":"delete","annotationId":"foo"}"#; let deser = serde_json::from_str::(ser).unwrap(); assert_eq!( deser, DocumentChange::DeleteFile(DeleteFile { uri: crate::Uri("file:///foo.txt".to_string()), options: None, annotation_id: Some(String::from("foo")) }) ); let bad_ser = r#"{"uri":"file:///foo.txt","kind":"delet"}"#; assert!(serde_json::from_str::(bad_ser).is_err()); } #[test] fn string_enum() { let frk = FoldingRangeKind::Comment; let ser = serde_json::to_string(&frk).unwrap(); assert_eq!(ser, "\"comment\""); assert_eq!( serde_json::from_str::(&ser).unwrap(), FoldingRangeKind::Comment ); let frk = FoldingRangeKind::Custom(Cow::Borrowed("foo")); let ser = serde_json::to_string(&frk).unwrap(); assert_eq!(ser, "\"foo\""); assert_eq!( serde_json::from_str::(&ser).unwrap(), FoldingRangeKind::Custom(Cow::Borrowed("foo")) ); assert_eq!("foo", frk.as_str()); let mk = MarkupKind::PlainText; assert_eq!("\"plaintext\"", serde_json::to_string(&mk).unwrap()); assert!(serde_json::from_str::("foo").is_err()); assert_eq!("plaintext", mk.as_str()); } #[test] fn str_enum_into() { const CONSTANT: &str = "my_custom_variant"; let _parsed: LspNotificationMethod = CONSTANT.into(); } #[test] fn int_enum() { let sk = SymbolKind::Namespace; let ser = serde_json::to_string(&sk).unwrap(); assert_eq!(ser, "3"); assert_eq!( serde_json::from_str::(&ser).unwrap(), SymbolKind::Namespace ); assert!(serde_json::from_str::("299").is_err()); let wk = WatchKind::Custom(123); let ser = serde_json::to_string(&wk).unwrap(); assert_eq!(ser, "123"); assert_eq!(wk, serde_json::from_str::(&ser).unwrap()); assert_eq!( WatchKind::Change, serde_json::from_str::("2").unwrap() ); } #[test] fn request_object_from_request() { let params = TypeDefinitionParams { work_done_progress_params: crate::WorkDoneProgressParams { work_done_token: None, }, partial_result_params: crate::PartialResultParams { partial_result_token: None, }, text_document_position_params: crate::TextDocumentPositionParams { text_document: crate::TextDocumentIdentifier { uri: "foo".into() }, position: Position::default(), }, }; let req = json_rpc::RequestObject::from_request::( json_rpc::Id::Number(123), params.clone(), ); let ser = serde_json::to_string(&req).unwrap(); assert_eq!( ser, r#"{"jsonrpc":"2.0","id":123,"method":"textDocument/typeDefinition","params":{"position":{"character":0,"line":0},"textDocument":{"uri":"foo"}}}"# ); assert_eq!(req.id(), Some(&json_rpc::Id::Number(123))); assert_eq!(req.method(), "textDocument/typeDefinition"); assert_eq!(req.params(), Some(&json!(params))); } #[test] fn request_object_from_request_no_params() { let req = json_rpc::RequestObject::from_request::( json_rpc::Id::String("foo".into()), (), ); let ser = serde_json::to_string(&req).unwrap(); assert_eq!( ser, r#"{"jsonrpc":"2.0","id":"foo","method":"workspace/workspaceFolders"}"# ); } #[test] fn request_object_from_notification() { let noti = json_rpc::RequestObject::from_notification::( InitializedParams {}, ); let ser = serde_json::to_string(¬i).unwrap(); assert_eq!( ser, r#"{"jsonrpc":"2.0","method":"initialized","params":{}}"# ); assert_eq!(noti.id(), None); assert_eq!(noti.method(), "initialized"); assert_eq!(noti.params(), Some(&json!(InitializedParams {}))); } #[test] fn request_object_from_notification_no_params() { let noti = json_rpc::RequestObject::from_notification::(()); let ser = serde_json::to_string(¬i).unwrap(); assert_eq!(ser, r#"{"jsonrpc":"2.0","method":"exit"}"#); } #[test] fn response_object_from_success() { let id = json_rpc::Id::Number(123); let res = json_rpc::ResponseObject::from_success::( id.clone(), Some(ImplementationResponse::DefinitionLinkList(Vec::new())), ); let ser = serde_json::to_string(&res).unwrap(); assert_eq!(r#"{"jsonrpc":"2.0","result":[],"id":123}"#, &ser); assert_eq!(res, serde_json::from_str(&ser).unwrap()); let res = json_rpc::ResponseObject::from_success::(id.clone(), None); let ser = serde_json::to_string(&res).unwrap(); assert_eq!(r#"{"jsonrpc":"2.0","result":null,"id":123}"#, &ser); assert_eq!(res, serde_json::from_str(&ser).unwrap()); let res = json_rpc::ResponseObject::from_success::(id.clone(), None); let ser = serde_json::to_string(&res).unwrap(); assert_eq!(r#"{"jsonrpc":"2.0","result":null,"id":123}"#, &ser); assert_eq!(res, serde_json::from_str(&ser).unwrap()); let res = json_rpc::ResponseObject::from_success::(id.clone(), None); let ser = serde_json::to_string(&res).unwrap(); assert_eq!(r#"{"jsonrpc":"2.0","result":null,"id":123}"#, &ser); assert_eq!(res, serde_json::from_str(&ser).unwrap()); let res = json_rpc::ResponseObject::from_success::( id.clone(), Some(MessageActionItem { title: "foo".into(), properties: HashMap::default(), }), ); let ser = serde_json::to_string(&res).unwrap(); assert_eq!( r#"{"jsonrpc":"2.0","result":{"title":"foo"},"id":123}"#, &ser ); assert_eq!(res, serde_json::from_str(&ser).unwrap()); let res = json_rpc::ResponseObject::from_success::( id.clone(), Some(MessageActionItem { title: "foo".into(), properties: HashMap::from([( String::from("bar"), MessageActionItemProperty::Int(321), )]), }), ); let ser = serde_json::to_string(&res).unwrap(); assert_eq!( r#"{"jsonrpc":"2.0","result":{"bar":321,"title":"foo"},"id":123}"#, &ser ); assert_eq!(res, serde_json::from_str(&ser).unwrap()); let res = json_rpc::ResponseObject::from_success::(id, ()); let ser = serde_json::to_string(&res).unwrap(); assert_eq!(r#"{"jsonrpc":"2.0","result":null,"id":123}"#, &ser); assert_eq!(res, serde_json::from_str(&ser).unwrap()); } #[test] fn response_object_from_error() { let id = json_rpc::Id::Null; let res = json_rpc::ResponseObject::from_error( id, json_rpc::Error { code: crate::ErrorCodes::ParseError, message: "invalid format".into(), data: None, }, ); let ser = serde_json::to_string(&res).unwrap(); assert_eq!( r#"{"jsonrpc":"2.0","error":{"code":-32700,"message":"invalid format"},"id":null}"#, &ser ); let id = json_rpc::Id::String("foo-req".into()); let res = json_rpc::ResponseObject::from_error( id, json_rpc::Error { code: crate::ErrorCodes::Custom(-32803), message: "failed to foo the bar".into(), data: Some(json!("hi")), }, ); let ser = serde_json::to_string(&res).unwrap(); assert_eq!( r#"{"jsonrpc":"2.0","error":{"code":-32803,"message":"failed to foo the bar","data":"hi"},"id":"foo-req"}"#, &ser ); let id = json_rpc::Id::String("foo-req".into()); let res = json_rpc::ResponseObject::from_error( id, json_rpc::Error { code: crate::ErrorCodes::Custom(crate::LspErrorCodes::ContentModified.into()), message: "failed to foo the bar".into(), data: Some(json!("hi")), }, ); let ser = serde_json::to_string(&res).unwrap(); assert_eq!( r#"{"jsonrpc":"2.0","error":{"code":-32801,"message":"failed to foo the bar","data":"hi"},"id":"foo-req"}"#, &ser ); } #[test] fn structures_new_constructor() { assert_eq!( Position::new(1, 2), Position { line: 1, character: 2 } ); assert_eq!( Range::new(Position::new(0, 0), Position::new(0, 99)), Range { start: Position::default(), end: Position { line: 0, character: 99 } } ); assert_eq!( Location::new(Uri("foo".into()), Range::default()), Location { uri: Uri("foo".into()), range: Range::default() } ); // For some structures, the new() constructor does not help as much. assert_eq!( Diagnostic::new( Range::default(), Some(DiagnosticSeverity::Warning), None, None, None, "bad".into(), None, None, None ), Diagnostic { range: Range::default(), message: "bad".into(), severity: Some(DiagnosticSeverity::Warning), ..Default::default() } ); } #[test] fn custom_request_object_methods() { struct ParentModule; impl Request for ParentModule { type Params = (); type Result = Option; const METHOD: LspRequestMethod<'_> = LspRequestMethod::Custom("experimental/parentModule"); const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; } let req = json_rpc::RequestObject::from_request::(json_rpc::Id::Number(123), ()); assert_eq!( r#"{"jsonrpc":"2.0","id":123,"method":"experimental/parentModule"}"#, serde_json::to_string(&req).unwrap() ); struct ServerStatusNotification; impl Notification for ServerStatusNotification { type Params = (); const METHOD: LspNotificationMethod<'_> = LspNotificationMethod::new("experimental/serverStatus"); const MESSAGE_DIRECTION: MessageDirection = MessageDirection::ClientToServer; } let noti = json_rpc::RequestObject::from_notification::(()); assert_eq!( r#"{"jsonrpc":"2.0","method":"experimental/serverStatus"}"#, serde_json::to_string(¬i).unwrap() ); // Compilation checks let method: &'static str = ::METHOD.as_str(); assert_eq!(method, "experimental/parentModule"); let method = LspRequestMethod::new("asdf"); let method_str: &'static str = method.as_str(); assert_eq!(method_str, "asdf"); let method = LspRequestMethod::Custom("asdf"); let method_str: &'static str = method.as_str(); assert_eq!(method_str, "asdf"); let owned = String::from("workspace/didCreateFiles"); let method: LspNotificationMethod<'_> = owned.as_str().into(); assert_eq!(method, LspNotificationMethod::WorkspaceDidCreateFiles); let owned = String::from("foo"); let method: LspNotificationMethod<'_> = owned.as_str().into(); assert_eq!(method, LspNotificationMethod::new("foo")); // Copy let method1 = LspRequestMethod::TextDocumentCompletion; let method2 = method1; assert_eq!(method1, method2); // We can `match` on local vars without extra allocations! Yay! #[allow(clippy::match_same_arms)] match method { LspNotificationMethod::TextDocumentWillSave => {} LspNotificationMethod::Custom("foo") => {} LspNotificationMethod::Custom(_) => {} _ => {} } } #[test] fn request_with_partial_results() { fn foo( _params: R::Params, _partial_result: R::PartialResult, ) { // Do nothing! } foo::( DocumentSymbolParams { text_document: TextDocumentIdentifier { uri: "".into() }, work_done_progress_params: WorkDoneProgressParams { work_done_token: None, }, partial_result_params: PartialResultParams { partial_result_token: None, }, }, DocumentSymbolPartialResponse::SymbolInformationList(vec![SymbolInformation { deprecated: None, location: Location { uri: "".into(), range: Range::default(), }, base_symbol_information: BaseSymbolInformation { name: String::new(), kind: SymbolKind::File, tags: None, container_name: None, }, }]), ); let partial_result = DocumentSymbolPartialResponse::DocumentSymbolList(Vec::new()); let _ = match partial_result { DocumentSymbolPartialResponse::SymbolInformationList(_) => 1, DocumentSymbolPartialResponse::DocumentSymbolList(_) => 2, // No `null` branch }; } #[test] #[allow(clippy::similar_names)] fn semantic_tokens() { let ste = SemanticTokensEdit { start: 0, delete_count: 1, data: None, }; let ste_ser = r#"{"start":0,"deleteCount":1}"#; assert_eq!(serde_json::to_string(&ste).unwrap(), ste_ser); assert_eq!(ste, serde_json::from_str(ste_ser).unwrap()); let ste = SemanticTokensEdit { start: 0, delete_count: 1, data: None, }; let ste_ser_fake = r#"{"start":0,"deleteCount":1,"data":null}"#; assert_eq!(serde_json::to_string(&ste).unwrap(), ste_ser); // Be permissive on technically incorrect deserialization. assert_eq!(ste, serde_json::from_str(ste_ser_fake).unwrap()); let ste = SemanticTokensEdit { start: 0, delete_count: 1, data: Some(vec![ SemanticToken { delta_line: 2, delta_start: 5, length: 3, token_type: 0, token_modifiers_bitset: 3, }, SemanticToken { delta_line: 0, delta_start: 5, length: 4, token_type: 1, token_modifiers_bitset: 0, }, ]), }; let ste_ser = r#"{"start":0,"deleteCount":1,"data":[2,5,3,0,3,0,5,4,1,0]}"#; assert_eq!(serde_json::to_string(&ste).unwrap(), ste_ser); assert_eq!(ste, serde_json::from_str(ste_ser).unwrap()); let ste = SemanticTokensEdit { start: 0, delete_count: 1, data: Some(Vec::new()), }; let ste_ser = r#"{"start":0,"deleteCount":1,"data":[]}"#; assert_eq!(serde_json::to_string(&ste).unwrap(), ste_ser); assert_eq!(ste, serde_json::from_str(ste_ser).unwrap()); let st = SemanticTokens { result_id: None, data: Vec::default(), }; let st_ser = r#"{"data":[]}"#; assert_eq!(serde_json::to_string(&st).unwrap(), st_ser); assert_eq!(st, serde_json::from_str(st_ser).unwrap()); let st = SemanticTokens { result_id: None, data: vec![ SemanticToken { delta_line: 2, delta_start: 5, length: 3, token_type: 0, token_modifiers_bitset: 3, }, SemanticToken { delta_line: 0, delta_start: 5, length: 4, token_type: 1, token_modifiers_bitset: 0, }, ], }; let st_ser = r#"{"data":[2,5,3,0,3,0,5,4,1,0]}"#; assert_eq!(serde_json::to_string(&st).unwrap(), st_ser); assert_eq!(st, serde_json::from_str(st_ser).unwrap()); let stpr = SemanticTokensPartialResult { data: vec![ SemanticToken { delta_line: 2, delta_start: 5, length: 3, token_type: 0, token_modifiers_bitset: 3, }, SemanticToken { delta_line: 0, delta_start: 5, length: 4, token_type: 1, token_modifiers_bitset: 0, }, ], }; let stpr_ser = r#"{"data":[2,5,3,0,3,0,5,4,1,0]}"#; assert_eq!(serde_json::to_string(&stpr).unwrap(), stpr_ser); assert_eq!(stpr, serde_json::from_str(stpr_ser).unwrap()); let stpr = SemanticTokensPartialResult { data: Vec::default(), }; let stpr_ser = r#"{"data":[]}"#; assert_eq!(serde_json::to_string(&stpr).unwrap(), stpr_ser); assert_eq!(stpr, serde_json::from_str(stpr_ser).unwrap()); } #[test] fn request_macro() { let req = json_rpc::RequestObject::from_request::( json_rpc::Id::Number(123), (), ); assert_eq!( r#"{"jsonrpc":"2.0","id":123,"method":"workspace/workspaceFolders"}"#, serde_json::to_string(&req).unwrap() ); } #[test] fn notification_macro() { let req = json_rpc::RequestObject::from_notification::(()); assert_eq!( r#"{"jsonrpc":"2.0","method":"exit"}"#, serde_json::to_string(&req).unwrap() ); } #[test] fn tuple_serialization() { let pil = ParameterInformationLabel::Tuple((1, 2)); assert_eq!("[1,2]", serde_json::to_string(&pil).unwrap()); assert_eq!(pil, serde_json::from_str("[1,2]").unwrap()); } #[test] fn lsp_object_derives() { // `LspObject` is `Hash`able let _: HashMap = HashMap::from([( NotebookCell::new(NotebookCellKind::Code, Uri("foo".to_owned()), None, None), 123, )]); // Structure literals are `Hash`able let _: HashMap = HashMap::from([(SemanticTokensRegistrationOptions::default(), 123)]); // `LspAny` is `Hash`able let _: HashMap = HashMap::from([(Command::default(), 123)]); } } /// Tests for the "url" feature. #[cfg(test)] #[cfg(all(feature = "url", not(feature = "fluent-uri")))] mod test { use crate::*; #[test] fn url_feature() { let url = url::Url::parse("file://tmp/foo.txt/").unwrap(); let tdi = TextDocumentIdentifier { uri: url }; let ser = r#"{"uri":"file://tmp/foo.txt/"}"#; assert_eq!(ser, serde_json::to_string(&tdi).unwrap()); assert_eq!(tdi, serde_json::from_str(ser).unwrap()); } } /// Tests for the "fluent-uri" feature. #[cfg(test)] #[cfg(all(feature = "fluent-uri", not(feature = "url")))] mod test { use crate::*; #[test] fn url_feature() { let uri = fluent_uri::Uri::try_from("file://tmp/foo.txt/".to_string()).unwrap(); let tdi = TextDocumentIdentifier { uri }; let ser = r#"{"uri":"file://tmp/foo.txt/"}"#; assert_eq!(ser, serde_json::to_string(&tdi).unwrap()); assert_eq!(tdi, serde_json::from_str(ser).unwrap()); } }