lsp-types-0.94.1/.cargo_vcs_info.json 0000644 00000000136 00000000001 0013067 0 ustar {
"git": {
"sha1": "2b20769bd35f30b107784ae5a097f11991c76366"
},
"path_in_vcs": ""
} lsp-types-0.94.1/.clog.toml 0000644 0000000 0000000 00000000170 00726746425 0013604 0 ustar 0000000 0000000 [clog]
repository = "https://github.com/gluon-lang/lsp-types"
changelog = "CHANGELOG.md"
from-latest-tag = true
lsp-types-0.94.1/.github/workflows/rust.yml 0000644 0000000 0000000 00000001371 00726746425 0017026 0 ustar 0000000 0000000 name: Rust
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
env:
CARGO_TERM_COLOR: always
jobs:
build:
strategy:
matrix:
rust: [stable, nightly]
features: ["", proposed]
env:
CARGO_INCREMENTAL: 0 # Incremental compilation is slower and bloats the cache
RUST_BACKTRACE: 1
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- name: Build
run: cargo build
- name: Run tests
run: >
FEATURES=${{ matrix.features }}
cargo test --features ${FEATURES:-""}
lsp-types-0.94.1/.gitignore 0000644 0000000 0000000 00000000066 00726746425 0013701 0 ustar 0000000 0000000 target
Cargo.lock
/.settings/
/.project
/.vscode
lsp-types-0.94.1/CHANGELOG.md 0000644 0000000 0000000 00000013251 00726746425 0013522 0 ustar 0000000 0000000
### v0.94.1 (2023-08-07)
## v0.94.0 (2023-02-08)
### v0.93.2 (2022-10-21)
### v0.93.1 (2022-08-23)
## v0.93.0 (2022-04-08)
#### Features
* **helperTypes:** implement new JSON types ([bd9bb2e7](https://github.com/gluon-lang/lsp-types/commit/bd9bb2e74171b0194be51085c822c3ccbbb68b7b))
### v0.92.1 (2022-03-21)
#### Bug Fixes
* **inlayHint:** typo in prop name ([7f7ada31](https://github.com/gluon-lang/lsp-types/commit/7f7ada310fa045ef628dc36f97b8564408fcec6a))
#### Features
* **inlayHint:**
* add request impls ([393aefa1](https://github.com/gluon-lang/lsp-types/commit/393aefa18b3c900c3f1ac8f6337b7098bdc4365a))
* add inlayHint provider ([69f21e71](https://github.com/gluon-lang/lsp-types/commit/69f21e714df305643aa727cbf745b439bbd8c112))
* implement inlayHint basic types ([29a50e71](https://github.com/gluon-lang/lsp-types/commit/29a50e71461f72d2fa2aea90fa03f61adf062074))
## v0.92.0 (2022-02-07)
### v0.91.2 (2022-02-07)
#### Features
* Add a TryFrom<&str> implementation for enumerations ([19b85cf4](https://github.com/gluon-lang/lsp-types/commit/19b85cf4a7b5396a89d364e271c3867eb6c840e4), closes [#223](https://github.com/gluon-lang/lsp-types/issues/223))
#### Bug Fixes
* Ensure that the pascal_case_name is evaluated at compile time ([7337535b](https://github.com/gluon-lang/lsp-types/commit/7337535b79000912f859319455cd371af77d1899))
### v0.91.1 (2021-11-01)
#### Features
* Print the name of know enumerations ([2877b6a1](https://github.com/gluon-lang/lsp-types/commit/2877b6a131ef5c28310b972126f6d1b23cd97788))
## v0.91.0 (2021-10-18)
### v0.90.1 (2021-10-11)
#### Bug Fixes
* add missing rename_all serde attribute ([b403cba5](https://github.com/gluon-lang/lsp-types/commit/b403cba5fb568f7f1bda3ea2929822269797f7f3))
### v0.90.1 (2021-10-11)
#### Bug Fixes
* add missing rename_all serde attribute ([b403cba5](https://github.com/gluon-lang/lsp-types/commit/b403cba5fb568f7f1bda3ea2929822269797f7f3))
### v0.90.1 (2021-10-11)
#### Bug Fixes
* add missing rename_all serde attribute ([b403cba5](https://github.com/gluon-lang/lsp-types/commit/b403cba5fb568f7f1bda3ea2929822269797f7f3))
### v0.90.1 (2021-10-11)
#### Bug Fixes
* add missing rename_all serde attribute ([b403cba5](https://github.com/gluon-lang/lsp-types/commit/b403cba5fb568f7f1bda3ea2929822269797f7f3))
## v0.90.0 (2021-09-25)
### v0.61.1 (2021-06-10)
#### Features
* Add DeserializeOwned + Serialize bounds on request/notifications ([fb945a93](https://github.com/gluon-lang/lsp-types/commit/fb945a9347b353dd9bc5aab99a86731bebd94c15), closes [#140](https://github.com/gluon-lang/lsp-types/issues/140))
### v0.89.1 (2021-05-22)
## v0.89.0 (2021-04-07)
## v0.88.0 (2021-02-16)
## v0.87.0 (2021-02-14)
## v0.86.0 (2020-12-17)
## v0.85.0 (2020-12-01)
## v0.84.0 (2020-11-24)
### v0.83.1 (2020-11-16)
## v0.82.0 (2020-09-23)
## v0.80.0 (2020-09-18)
## v0.80.0 (2020-09-02)
## v0.79.0 (2020-07-26)
## v0.77.0 (2020-07-15)
### v0.76.1 (2020-07-14)
### v0.74.2 (2020-05-30)
### v0.74.1 (2020-05-01)
## v0.74.0 (2020-04-26)
## v0.74.0 (2020-04-26)
## v0.72.0 (2020-03-02)
#### Features
* Add DeserializeOwned + Serialize bounds on request/notifications ([fb945a93](https://github.com/gluon-lang/lsp-types/commit/fb945a9347b353dd9bc5aab99a86731bebd94c15), closes [#140](https://github.com/gluon-lang/lsp-types/issues/140))
## v0.72.0 (2020-03-02)
#### Features
* Add DeserializeOwned + Serialize bounds on request/notifications ([fb945a93](https://github.com/gluon-lang/lsp-types/commit/fb945a9347b353dd9bc5aab99a86731bebd94c15), closes [#140](https://github.com/gluon-lang/lsp-types/issues/140))
## v0.72.0 (2020-03-02)
#### Features
* Add DeserializeOwned + Serialize bounds on request/notifications ([fb945a93](https://github.com/gluon-lang/lsp-types/commit/fb945a9347b353dd9bc5aab99a86731bebd94c15), closes [#140](https://github.com/gluon-lang/lsp-types/issues/140))
## v0.72.0 (2020-03-02)
#### Features
* Add DeserializeOwned + Serialize bounds on request/notifications ([fb945a93](https://github.com/gluon-lang/lsp-types/commit/fb945a9347b353dd9bc5aab99a86731bebd94c15), closes [#140](https://github.com/gluon-lang/lsp-types/issues/140))
## v0.72.0 (2020-03-02)
#### Features
* Add DeserializeOwned + Serialize bounds on request/notifications ([fb945a93](https://github.com/gluon-lang/lsp-types/commit/fb945a9347b353dd9bc5aab99a86731bebd94c15), closes [#140](https://github.com/gluon-lang/lsp-types/issues/140))
lsp-types-0.94.1/Cargo.toml 0000644 00000002351 00000000001 0011066 0 ustar # 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 = "2018"
name = "lsp-types"
version = "0.94.1"
authors = [
"Markus Westerlind ",
"Bruno Medeiros ",
]
description = "Types for interaction with a language server, using VSCode's Language Server Protocol"
documentation = "https://docs.rs/lsp-types"
readme = "README.md"
keywords = [
"language",
"server",
"lsp",
"vscode",
"lsif",
]
license = "MIT"
repository = "https://github.com/gluon-lang/lsp-types"
[dependencies.bitflags]
version = "1.0.1"
[dependencies.serde]
version = "1.0.34"
features = ["derive"]
[dependencies.serde_json]
version = "1.0.50"
[dependencies.serde_repr]
version = "0.1"
[dependencies.url]
version = "2.0.0"
features = ["serde"]
[features]
default = []
proposed = []
lsp-types-0.94.1/Cargo.toml.orig 0000644 0000000 0000000 00000001440 00726746425 0014575 0 ustar 0000000 0000000 [package]
name = "lsp-types"
version = "0.94.1"
authors = ["Markus Westerlind ", "Bruno Medeiros "]
edition = "2018"
description = "Types for interaction with a language server, using VSCode's Language Server Protocol"
repository = "https://github.com/gluon-lang/lsp-types"
documentation = "https://docs.rs/lsp-types"
readme = "README.md"
keywords = ["language", "server", "lsp", "vscode", "lsif"]
license = "MIT"
[dependencies]
bitflags = "1.0.1"
serde = { version = "1.0.34", features = ["derive"] }
serde_json = "1.0.50"
serde_repr = "0.1"
url = {version = "2.0.0", features = ["serde"]}
[features]
default = []
# Enables proposed LSP extensions.
# NOTE: No semver compatibility is guaranteed for types enabled by this feature.
proposed = []
lsp-types-0.94.1/LICENSE 0000644 0000000 0000000 00000002123 00726746425 0012712 0 ustar 0000000 0000000 The MIT License (MIT)
Copyright (c) 2016 Markus Westerlind
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.
lsp-types-0.94.1/README.md 0000644 0000000 0000000 00000001535 00726746425 0013172 0 ustar 0000000 0000000 # lsp-types [](https://travis-ci.org/gluon-lang/lsp-types) [](https://docs.rs/crate/lsp-types)
Types useful for interacting with a [language server](https://code.visualstudio.com/blogs/2016/06/27/common-language-protocol).
Supports Language Server Protocol (LSP) version 3.16.0.
Proposed 3.17 features can be activated using the `proposed` feature flag.
- **NOTE** that these are unstable and may change between releases.
## Links
[Stable Protocol reference](https://github.com/microsoft/language-server-protocol/tree/gh-pages/_specifications/lsp/3.17/specification.md)
[Proposed Protocol reference](https://github.com/microsoft/language-server-protocol/blob/gh-pages/_specifications/lsp/3.18/specification.md)
lsp-types-0.94.1/release.sh 0000644 0000000 0000000 00000000342 00726746425 0013662 0 ustar 0000000 0000000 #!/bin/sh
set -ex
LEVEL=$1
if [ -z "$LEVEL" ]; then
echo "Expected patch, minor or major"
exit 1
fi
clog --$LEVEL
git add CHANGELOG.md
git commit -m "Update changelog"
cargo release $LEVEL --execute
lsp-types-0.94.1/release.toml 0000644 0000000 0000000 00000000045 00726746425 0014223 0 ustar 0000000 0000000 tag-message = "Version {{version}}"
lsp-types-0.94.1/src/call_hierarchy.rs 0000644 0000000 0000000 00000010457 00726746425 0016024 0 ustar 0000000 0000000 use serde::{Deserialize, Serialize};
use serde_json::Value;
use url::Url;
use crate::{
DynamicRegistrationClientCapabilities, PartialResultParams, Range, SymbolKind, SymbolTag,
TextDocumentPositionParams, WorkDoneProgressOptions, WorkDoneProgressParams,
};
pub type CallHierarchyClientCapabilities = DynamicRegistrationClientCapabilities;
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize, Copy)]
#[serde(rename_all = "camelCase")]
pub struct CallHierarchyOptions {
#[serde(flatten)]
pub work_done_progress_options: WorkDoneProgressOptions,
}
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize, Copy)]
#[serde(untagged)]
pub enum CallHierarchyServerCapability {
Simple(bool),
Options(CallHierarchyOptions),
}
impl From for CallHierarchyServerCapability {
fn from(from: CallHierarchyOptions) -> Self {
Self::Options(from)
}
}
impl From for CallHierarchyServerCapability {
fn from(from: bool) -> Self {
Self::Simple(from)
}
}
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CallHierarchyPrepareParams {
#[serde(flatten)]
pub text_document_position_params: TextDocumentPositionParams,
#[serde(flatten)]
pub work_done_progress_params: WorkDoneProgressParams,
}
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
#[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: Url,
/// 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,
}
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
#[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,
}
/// Represents an incoming call, e.g. a caller of a method or constructor.
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
#[serde(rename_all = "camelCase")]
pub struct CallHierarchyIncomingCall {
/// The item that makes the call.
pub from: CallHierarchyItem,
/// The range at which at which the calls appears. This is relative to the caller
/// denoted by [`this.from`](#CallHierarchyIncomingCall.from).
pub from_ranges: Vec,
}
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
#[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,
}
/// Represents an outgoing call, e.g. calling a getter from a method or a method from a constructor etc.
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
#[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,
}
lsp-types-0.94.1/src/code_action.rs 0000644 0000000 0000000 00000033066 00726746425 0015323 0 ustar 0000000 0000000 use crate::{
Command, Diagnostic, PartialResultParams, Range, TextDocumentIdentifier,
WorkDoneProgressOptions, WorkDoneProgressParams, WorkspaceEdit,
};
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::borrow::Cow;
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(untagged)]
pub enum CodeActionProviderCapability {
Simple(bool),
Options(CodeActionOptions),
}
impl From for CodeActionProviderCapability {
fn from(from: CodeActionOptions) -> Self {
Self::Options(from)
}
}
impl From for CodeActionProviderCapability {
fn from(from: bool) -> Self {
Self::Simple(from)
}
}
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CodeActionClientCapabilities {
///
/// This capability supports dynamic registration.
///
#[serde(skip_serializing_if = "Option::is_none")]
pub dynamic_registration: Option,
/// The client support code action literals as a valid
/// response of the `textDocument/codeAction` request.
#[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 resolving additional code action
/// properties via a separate `codeAction/resolve` request.
///
/// @since 3.16.0
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CodeActionCapabilityResolveSupport {
/// The properties that a client can resolve lazily.
pub properties: Vec,
}
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CodeActionLiteralSupport {
/// The code action kind is support with the following value set.
pub code_action_kind: CodeActionKindLiteralSupport,
}
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CodeActionKindLiteralSupport {
/// 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,
}
/// Params for the CodeActionRequest
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[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,
}
/// response for CodeActionRequest
pub type CodeActionResponse = Vec;
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
#[serde(untagged)]
pub enum CodeActionOrCommand {
Command(Command),
CodeAction(CodeAction),
}
impl From for CodeActionOrCommand {
fn from(command: Command) -> Self {
CodeActionOrCommand::Command(command)
}
}
impl From for CodeActionOrCommand {
fn from(action: CodeAction) -> Self {
CodeActionOrCommand::CodeAction(action)
}
}
#[derive(Debug, Eq, PartialEq, Hash, PartialOrd, Clone, Deserialize, Serialize)]
pub struct CodeActionKind(Cow<'static, str>);
impl CodeActionKind {
/// Empty kind.
pub const EMPTY: CodeActionKind = CodeActionKind::new("");
/// Base kind for quickfix actions: 'quickfix'
pub const QUICKFIX: CodeActionKind = CodeActionKind::new("quickfix");
/// Base kind for refactoring actions: 'refactor'
pub const REFACTOR: CodeActionKind = CodeActionKind::new("refactor");
/// Base kind for refactoring extraction actions: 'refactor.extract'
///
/// Example extract actions:
///
/// - Extract method
/// - Extract function
/// - Extract variable
/// - Extract interface from class
/// - ...
pub const REFACTOR_EXTRACT: CodeActionKind = CodeActionKind::new("refactor.extract");
/// Base kind for refactoring inline actions: 'refactor.inline'
///
/// Example inline actions:
///
/// - Inline function
/// - Inline variable
/// - Inline constant
/// - ...
pub const REFACTOR_INLINE: CodeActionKind = CodeActionKind::new("refactor.inline");
/// Base kind for refactoring rewrite actions: 'refactor.rewrite'
///
/// Example rewrite actions:
///
/// - Convert JavaScript function to class
/// - Add or remove parameter
/// - Encapsulate field
/// - Make method static
/// - Move method to base class
/// - ...
pub const REFACTOR_REWRITE: CodeActionKind = CodeActionKind::new("refactor.rewrite");
/// Base kind for source actions: `source`
///
/// Source code actions apply to the entire file.
pub const SOURCE: CodeActionKind = CodeActionKind::new("source");
/// Base kind for an organize imports source action: `source.organizeImports`
pub const SOURCE_ORGANIZE_IMPORTS: CodeActionKind =
CodeActionKind::new("source.organizeImports");
/// Base kind for a 'fix all' source action: `source.fixAll`.
///
/// 'Fix all' actions automatically fix errors that have a clear fix that
/// do not require user input. They should not suppress errors or perform
/// unsafe fixes such as generating new types or classes.
///
/// @since 3.17.0
pub const SOURCE_FIX_ALL: CodeActionKind = CodeActionKind::new("source.fixAll");
pub const fn new(tag: &'static str) -> Self {
CodeActionKind(Cow::Borrowed(tag))
}
pub fn as_str(&self) -> &str {
&self.0
}
}
impl From for CodeActionKind {
fn from(from: String) -> Self {
CodeActionKind(Cow::from(from))
}
}
impl From<&'static str> for CodeActionKind {
fn from(from: &'static str) -> Self {
CodeActionKind::new(from)
}
}
#[derive(Debug, PartialEq, Clone, Default, Deserialize, Serialize)]
#[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>,
/// 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,
/// 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
/// [lightbulb](https://code.visualstudio.com/docs/editor/editingevolved#_code-action)
/// code action menu.
///
/// - Disabled actions are shown as faded out in the code action menu when the user request
/// a more specific type of code action, such as refactorings.
///
/// - If the user has a keybinding that auto applies a code action and only a disabled code
/// actions are returned, the client should show the user an error message with `reason`
/// in the editor.
///
/// @since 3.16.0
#[serde(skip_serializing_if = "Option::is_none")]
pub disabled: 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,
}
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[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,
}
/// The reason why code actions were requested.
///
/// @since 3.17.0
#[derive(Eq, PartialEq, Clone, Copy, Deserialize, Serialize)]
#[serde(transparent)]
pub struct CodeActionTriggerKind(i32);
lsp_enum! {
impl CodeActionTriggerKind {
/// Code actions were explicitly requested by the user or by an extension.
pub const INVOKED: CodeActionTriggerKind = CodeActionTriggerKind(1);
/// Code actions were requested automatically.
///
/// This typically happens when current selection in a file changes, but can
/// also be triggered when file content changes.
pub const AUTOMATIC: CodeActionTriggerKind = CodeActionTriggerKind(2);
}
}
/// Contains additional diagnostic information about the context in which
/// a code action is run.
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CodeActionContext {
/// An array of diagnostics.
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,
}
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize, 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>,
#[serde(flatten)]
pub work_done_progress_options: WorkDoneProgressOptions,
/// 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,
}
#[cfg(test)]
mod tests {
use super::*;
use crate::tests::test_serialization;
#[test]
fn test_code_action_response() {
test_serialization(
&vec![
CodeActionOrCommand::Command(Command {
title: "title".to_string(),
command: "command".to_string(),
arguments: None,
}),
CodeActionOrCommand::CodeAction(CodeAction {
title: "title".to_string(),
kind: Some(CodeActionKind::QUICKFIX),
command: None,
diagnostics: None,
edit: None,
is_preferred: None,
..CodeAction::default()
}),
],
r#"[{"title":"title","command":"command"},{"title":"title","kind":"quickfix"}]"#,
)
}
}
lsp-types-0.94.1/src/code_lens.rs 0000644 0000000 0000000 00000005016 00726746425 0015001 0 ustar 0000000 0000000 use serde::{Deserialize, Serialize};
use serde_json::Value;
use crate::{
Command, DynamicRegistrationClientCapabilities, PartialResultParams, Range,
TextDocumentIdentifier, WorkDoneProgressParams,
};
pub type CodeLensClientCapabilities = DynamicRegistrationClientCapabilities;
/// Code Lens options.
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize, 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,
}
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[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,
}
/// A code lens represents a command that should be shown along with
/// source text, like the number of references, a way to run tests, etc.
///
/// A code lens is _unresolved_ when no command is associated to it. For performance
/// reasons the creation of a code lens and resolving should be done in two stages.
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
#[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 code lens and a code lens resolve request.
#[serde(skip_serializing_if = "Option::is_none")]
pub data: Option,
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
#[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,
}
lsp-types-0.94.1/src/color.rs 0000644 0000000 0000000 00000010275 00726746425 0014167 0 ustar 0000000 0000000 use crate::{
DocumentSelector, DynamicRegistrationClientCapabilities, PartialResultParams, Range,
TextDocumentIdentifier, TextEdit, WorkDoneProgressParams,
};
use serde::{Deserialize, Serialize};
pub type DocumentColorClientCapabilities = DynamicRegistrationClientCapabilities;
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ColorProviderOptions {}
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct StaticTextDocumentColorProviderOptions {
/// 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,
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option,
}
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(untagged)]
pub enum ColorProviderCapability {
Simple(bool),
ColorProvider(ColorProviderOptions),
Options(StaticTextDocumentColorProviderOptions),
}
impl From for ColorProviderCapability {
fn from(from: ColorProviderOptions) -> Self {
Self::ColorProvider(from)
}
}
impl From for ColorProviderCapability {
fn from(from: StaticTextDocumentColorProviderOptions) -> Self {
Self::Options(from)
}
}
impl From for ColorProviderCapability {
fn from(from: bool) -> Self {
Self::Simple(from)
}
}
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[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,
}
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
#[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,
}
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize, 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,
}
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ColorPresentationParams {
/// The text document.
pub text_document: TextDocumentIdentifier,
/// The color information 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,
}
#[derive(Debug, PartialEq, Eq, Deserialize, Serialize, Default, Clone)]
#[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>,
}
lsp-types-0.94.1/src/completion.rs 0000644 0000000 0000000 00000060174 00726746425 0015225 0 ustar 0000000 0000000 use serde::{Deserialize, Serialize};
use crate::{
Command, Documentation, MarkupKind, PartialResultParams, TagSupport,
TextDocumentPositionParams, TextDocumentRegistrationOptions, TextEdit, WorkDoneProgressOptions,
WorkDoneProgressParams,
};
use crate::Range;
use serde_json::Value;
use std::fmt::Debug;
/// Defines how to interpret the insert text in a completion item
#[derive(Eq, PartialEq, Clone, Copy, Serialize, Deserialize)]
#[serde(transparent)]
pub struct InsertTextFormat(i32);
lsp_enum! {
impl InsertTextFormat {
pub const PLAIN_TEXT: InsertTextFormat = InsertTextFormat(1);
pub const SNIPPET: InsertTextFormat = InsertTextFormat(2);
}
}
/// The kind of a completion entry.
#[derive(Eq, PartialEq, Clone, Copy, Serialize, Deserialize)]
#[serde(transparent)]
pub struct CompletionItemKind(i32);
lsp_enum! {
impl CompletionItemKind {
pub const TEXT: CompletionItemKind = CompletionItemKind(1);
pub const METHOD: CompletionItemKind = CompletionItemKind(2);
pub const FUNCTION: CompletionItemKind = CompletionItemKind(3);
pub const CONSTRUCTOR: CompletionItemKind = CompletionItemKind(4);
pub const FIELD: CompletionItemKind = CompletionItemKind(5);
pub const VARIABLE: CompletionItemKind = CompletionItemKind(6);
pub const CLASS: CompletionItemKind = CompletionItemKind(7);
pub const INTERFACE: CompletionItemKind = CompletionItemKind(8);
pub const MODULE: CompletionItemKind = CompletionItemKind(9);
pub const PROPERTY: CompletionItemKind = CompletionItemKind(10);
pub const UNIT: CompletionItemKind = CompletionItemKind(11);
pub const VALUE: CompletionItemKind = CompletionItemKind(12);
pub const ENUM: CompletionItemKind = CompletionItemKind(13);
pub const KEYWORD: CompletionItemKind = CompletionItemKind(14);
pub const SNIPPET: CompletionItemKind = CompletionItemKind(15);
pub const COLOR: CompletionItemKind = CompletionItemKind(16);
pub const FILE: CompletionItemKind = CompletionItemKind(17);
pub const REFERENCE: CompletionItemKind = CompletionItemKind(18);
pub const FOLDER: CompletionItemKind = CompletionItemKind(19);
pub const ENUM_MEMBER: CompletionItemKind = CompletionItemKind(20);
pub const CONSTANT: CompletionItemKind = CompletionItemKind(21);
pub const STRUCT: CompletionItemKind = CompletionItemKind(22);
pub const EVENT: CompletionItemKind = CompletionItemKind(23);
pub const OPERATOR: CompletionItemKind = CompletionItemKind(24);
pub const TYPE_PARAMETER: CompletionItemKind = CompletionItemKind(25);
}
}
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CompletionItemCapability {
/// 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 follow 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.
#[serde(
default,
skip_serializing_if = "Option::is_none",
deserialize_with = "TagSupport::deserialize_compat"
)]
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.
///
/// @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,
}
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CompletionItemCapabilityResolveSupport {
/// The properties that a client can resolve lazily.
pub properties: Vec,
}
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct InsertTextModeSupport {
pub value_set: Vec,
}
/// How whitespace and indentation is handled during completion
/// item insertion.
///
/// @since 3.16.0
#[derive(Eq, PartialEq, Clone, Copy, Serialize, Deserialize)]
#[serde(transparent)]
pub struct InsertTextMode(i32);
lsp_enum! {
impl 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.
pub const AS_IS: InsertTextMode = InsertTextMode(1);
/// 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 all
/// following lines inserted will be indented using 2 tabs as well.
pub const ADJUST_INDENTATION: InsertTextMode = InsertTextMode(2);
}
}
#[derive(Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(transparent)]
pub struct CompletionItemTag(i32);
lsp_enum! {
impl CompletionItemTag {
pub const DEPRECATED: CompletionItemTag = CompletionItemTag(1);
}
}
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CompletionItemKindCapability {
/// 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>,
}
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CompletionListCapability {
/// 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>,
}
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[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,
#[serde(skip_serializing_if = "Option::is_none")]
pub completion_item_kind: 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's default when the completion item doesn't provide a
/// `insertTextMode` property.
///
/// @since 3.17.0
#[serde(skip_serializing_if = "Option::is_none")]
pub insert_text_mode: Option,
/// The client supports the following `CompletionList` specific
/// capabilities.
///
/// @since 3.17.0
#[serde(skip_serializing_if = "Option::is_none")]
pub completion_list: Option,
}
/// A special text edit to provide an insert and a replace operation.
///
/// @since 3.16.0
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[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,
}
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(untagged)]
pub enum CompletionTextEdit {
Edit(TextEdit),
InsertAndReplace(InsertReplaceEdit),
}
impl From for CompletionTextEdit {
fn from(edit: TextEdit) -> Self {
CompletionTextEdit::Edit(edit)
}
}
impl From for CompletionTextEdit {
fn from(edit: InsertReplaceEdit) -> Self {
CompletionTextEdit::InsertAndReplace(edit)
}
}
/// Completion options.
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CompletionOptions {
/// The server provides support to resolve additional information for a completion item.
#[serde(skip_serializing_if = "Option::is_none")]
pub resolve_provider: Option,
/// 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 client capability
/// `completion.completionItem.commitCharactersSupport`.
///
/// If a server provides both `allCommitCharacters` and commit characters on
/// an individual completion item the ones on the completion item win.
///
/// @since 3.2.0
#[serde(skip_serializing_if = "Option::is_none")]
pub all_commit_characters: Option>,
#[serde(flatten)]
pub work_done_progress_options: WorkDoneProgressOptions,
/// The server supports the following `CompletionItem` specific
/// capabilities.
///
/// @since 3.17.0
#[serde(skip_serializing_if = "Option::is_none")]
pub completion_item: Option,
}
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CompletionOptionsCompletionItem {
/// 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,
}
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
pub struct CompletionRegistrationOptions {
#[serde(flatten)]
pub text_document_registration_options: TextDocumentRegistrationOptions,
#[serde(flatten)]
pub completion_options: CompletionOptions,
}
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CompletionResponse {
Array(Vec),
List(CompletionList),
}
impl From> for CompletionResponse {
fn from(items: Vec) -> Self {
CompletionResponse::Array(items)
}
}
impl From for CompletionResponse {
fn from(list: CompletionList) -> Self {
CompletionResponse::List(list)
}
}
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CompletionParams {
// This field was "mixed-in" from TextDocumentPositionParams
#[serde(flatten)]
pub text_document_position: TextDocumentPositionParams,
#[serde(flatten)]
pub work_done_progress_params: WorkDoneProgressParams,
#[serde(flatten)]
pub partial_result_params: PartialResultParams,
// CompletionParams properties:
#[serde(skip_serializing_if = "Option::is_none")]
pub context: Option,
}
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
#[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,
}
/// How a completion was triggered.
#[derive(Eq, PartialEq, Clone, Copy, Deserialize, Serialize)]
#[serde(transparent)]
pub struct CompletionTriggerKind(i32);
lsp_enum! {
impl CompletionTriggerKind {
pub const INVOKED: CompletionTriggerKind = CompletionTriggerKind(1);
pub const TRIGGER_CHARACTER: CompletionTriggerKind = CompletionTriggerKind(2);
pub const TRIGGER_FOR_INCOMPLETE_COMPLETIONS: CompletionTriggerKind = CompletionTriggerKind(3);
}
}
/// Represents a collection of [completion items](#CompletionItem) to be presented
/// in the editor.
#[derive(Debug, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CompletionList {
/// This list it not complete. Further typing should result in recomputing
/// this list.
pub is_incomplete: bool,
/// The completion items.
pub items: Vec,
}
#[derive(Debug, PartialEq, Default, Deserialize, Serialize, Clone)]
#[serde(rename_all = "camelCase")]
pub struct CompletionItem {
/// The label of this completion item. By default
/// also the text that is inserted when selecting
/// this completion.
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,
/// 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.
#[serde(skip_serializing_if = "Option::is_none")]
pub deprecated: Option,
/// Select this item when showing.
#[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 is used
/// as the sort text for this item.
#[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 is used as the
/// filter text for this item.
#[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 is used as the insert text
/// for this item.
///
/// The `insertText` is subject to interpretation by the client side.
/// Some tools might not take the string literally. For example
/// VS Code when code complete is requested in this example
/// `con` 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`.
///
/// @since 3.16.0
#[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 client's default value depends on
/// the `textDocument.completion.insertTextMode` client capability.
///
/// @since 3.16.0
/// @since 3.17.0 - support for `textDocument.completion.insertTextMode`
#[serde(skip_serializing_if = "Option::is_none")]
pub insert_text_mode: Option,
/// An edit which is applied to a document when selecting
/// this completion. When an edit is provided the value of
/// insertText is ignored.
///
/// Most editors support two different operation 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 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 a 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,
/// An optional array of additional text edits that are applied when
/// selecting this completion. Edits must not overlap with the main edit
/// nor with themselves.
#[serde(skip_serializing_if = "Option::is_none")]
pub additional_text_edits: Option>,
/// An optional command that is executed *after* inserting this completion. *Note* that
/// additional modifications to the current document should be described with the
/// additionalTextEdits-property.
#[serde(skip_serializing_if = "Option::is_none")]
pub command: 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 data entry field that is preserved on a completion item between
/// a completion and a completion resolve request.
#[serde(skip_serializing_if = "Option::is_none")]
pub data: Option,
/// Tags for this completion item.
#[serde(skip_serializing_if = "Option::is_none")]
pub tags: Option>,
}
impl CompletionItem {
/// Create a CompletionItem with the minimum possible info (label and detail).
pub fn new_simple(label: String, detail: String) -> CompletionItem {
CompletionItem {
label,
detail: Some(detail),
..Self::default()
}
}
}
/// Additional details for a completion item label.
///
/// @since 3.17.0
#[derive(Debug, PartialEq, Default, Deserialize, Serialize, Clone)]
#[serde(rename_all = "camelCase")]
pub struct CompletionItemLabelDetails {
/// An optional string which is rendered less prominently directly after
/// {@link CompletionItemLabel.label label}, without any spacing. Should be
/// used for function signatures or type annotations.
#[serde(skip_serializing_if = "Option::is_none")]
pub detail: Option,
/// An optional string which is rendered less prominently after
/// {@link CompletionItemLabel.detail}. Should be used for fully qualified
/// names or file path.
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option,
}
#[cfg(test)]
mod tests {
use super::*;
use crate::tests::test_deserialization;
#[test]
fn test_tag_support_deserialization() {
let mut empty = CompletionItemCapability::default();
empty.tag_support = None;
test_deserialization(r#"{}"#, &empty);
test_deserialization(r#"{"tagSupport": false}"#, &empty);
let mut t = CompletionItemCapability::default();
t.tag_support = Some(TagSupport { value_set: vec![] });
test_deserialization(r#"{"tagSupport": true}"#, &t);
let mut t = CompletionItemCapability::default();
t.tag_support = Some(TagSupport {
value_set: vec![CompletionItemTag::DEPRECATED],
});
test_deserialization(r#"{"tagSupport": {"valueSet": [1]}}"#, &t);
}
#[test]
fn test_debug_enum() {
assert_eq!(format!("{:?}", CompletionItemKind::TEXT), "Text");
assert_eq!(
format!("{:?}", CompletionItemKind::TYPE_PARAMETER),
"TypeParameter"
);
}
#[test]
fn test_try_from_enum() {
use std::convert::TryInto;
assert_eq!("Text".try_into(), Ok(CompletionItemKind::TEXT));
assert_eq!(
"TypeParameter".try_into(),
Ok(CompletionItemKind::TYPE_PARAMETER)
);
}
}
lsp-types-0.94.1/src/document_diagnostic.rs 0000644 0000000 0000000 00000023541 00726746425 0017073 0 ustar 0000000 0000000 use std::collections::HashMap;
use serde::{Deserialize, Serialize};
use url::Url;
use crate::{
Diagnostic, PartialResultParams, StaticRegistrationOptions, TextDocumentIdentifier,
TextDocumentRegistrationOptions, WorkDoneProgressOptions, WorkDoneProgressParams,
};
/// Client capabilities specific to diagnostic pull requests.
///
/// @since 3.17.0
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[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,
}
/// Diagnostic options.
///
/// @since 3.17.0
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[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,
}
/// Diagnostic registration options.
///
/// @since 3.17.0
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DiagnosticRegistrationOptions {
#[serde(flatten)]
pub text_document_registration_options: TextDocumentRegistrationOptions,
#[serde(flatten)]
pub diagnostic_options: DiagnosticOptions,
#[serde(flatten)]
pub static_registration_options: StaticRegistrationOptions,
}
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(untagged)]
pub enum DiagnosticServerCapabilities {
Options(DiagnosticOptions),
RegistrationOptions(DiagnosticRegistrationOptions),
}
/// Parameters of the document diagnostic request.
///
/// @since 3.17.0
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DocumentDiagnosticParams {
/// The text document.
pub text_document: TextDocumentIdentifier,
/// The additional identifier provided during registration.
pub identifier: Option,
/// The result ID of a previous response if provided.
pub previous_result_id: Option,
#[serde(flatten)]
pub work_done_progress_params: WorkDoneProgressParams,
#[serde(flatten)]
pub partial_result_params: PartialResultParams,
}
/// A diagnostic report with a full set of problems.
///
/// @since 3.17.0
#[derive(Debug, PartialEq, Default, Deserialize, Serialize, Clone)]
#[serde(rename_all = "camelCase")]
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,
}
/// A diagnostic report indicating that the last returned report is still accurate.
///
/// A server can only return `unchanged` if result ids are provided.
///
/// @since 3.17.0
#[derive(Debug, PartialEq, Deserialize, Serialize, Clone)]
#[serde(rename_all = "camelCase")]
pub struct UnchangedDocumentDiagnosticReport {
/// A result ID which will be sent on the next diagnostic request for the same document.
pub result_id: String,
}
/// The document diagnostic report kinds.
///
/// @since 3.17.0
#[derive(Debug, PartialEq, Deserialize, Serialize, Clone)]
#[serde(tag = "kind", rename_all = "lowercase")]
pub enum DocumentDiagnosticReportKind {
/// A diagnostic report with a full set of problems.
Full(FullDocumentDiagnosticReport),
/// A report indicating that the last returned report is still accurate.
Unchanged(UnchangedDocumentDiagnosticReport),
}
impl From for DocumentDiagnosticReportKind {
fn from(from: FullDocumentDiagnosticReport) -> Self {
DocumentDiagnosticReportKind::Full(from)
}
}
impl From for DocumentDiagnosticReportKind {
fn from(from: UnchangedDocumentDiagnosticReport) -> Self {
DocumentDiagnosticReportKind::Unchanged(from)
}
}
/// A full diagnostic report with a set of related documents.
///
/// @since 3.17.0
#[derive(Debug, PartialEq, Default, Deserialize, Serialize, Clone)]
#[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
/// macro definitions in a file `a.cpp` result in errors in a header file `b.hpp`.
///
/// @since 3.17.0
#[serde(with = "crate::url_map")]
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default)]
pub related_documents: Option>,
// relatedDocuments?: { [uri: string]: FullDocumentDiagnosticReport | UnchangedDocumentDiagnosticReport; };
#[serde(flatten)]
pub full_document_diagnostic_report: FullDocumentDiagnosticReport,
}
/// An unchanged diagnostic report with a set of related documents.
///
/// @since 3.17.0
#[derive(Debug, PartialEq, Deserialize, Serialize, Clone)]
#[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
/// macro definitions in a file `a.cpp` result in errors in a header file `b.hpp`.
///
/// @since 3.17.0
#[serde(with = "crate::url_map")]
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default)]
pub related_documents: Option>,
// relatedDocuments?: { [uri: string]: FullDocumentDiagnosticReport | UnchangedDocumentDiagnosticReport; };
#[serde(flatten)]
pub unchanged_document_diagnostic_report: UnchangedDocumentDiagnosticReport,
}
/// 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(Debug, PartialEq, Deserialize, Serialize, Clone)]
#[serde(tag = "kind", rename_all = "lowercase")]
pub enum DocumentDiagnosticReport {
/// A diagnostic report with a full set of problems.
Full(RelatedFullDocumentDiagnosticReport),
/// A report indicating that the last returned report is still accurate.
Unchanged(RelatedUnchangedDocumentDiagnosticReport),
}
impl From for DocumentDiagnosticReport {
fn from(from: RelatedFullDocumentDiagnosticReport) -> Self {
DocumentDiagnosticReport::Full(from)
}
}
impl From for DocumentDiagnosticReport {
fn from(from: RelatedUnchangedDocumentDiagnosticReport) -> Self {
DocumentDiagnosticReport::Unchanged(from)
}
}
/// A partial result for a document diagnostic report.
///
/// @since 3.17.0
#[derive(Debug, PartialEq, Default, Deserialize, Serialize, Clone)]
#[serde(rename_all = "camelCase")]
pub struct DocumentDiagnosticReportPartialResult {
#[serde(with = "crate::url_map")]
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default)]
pub related_documents: Option>,
// relatedDocuments?: { [uri: string]: FullDocumentDiagnosticReport | UnchangedDocumentDiagnosticReport; };
}
#[derive(Debug, PartialEq, Deserialize, Serialize, Clone)]
#[serde(untagged)]
pub enum DocumentDiagnosticReportResult {
Report(DocumentDiagnosticReport),
Partial(DocumentDiagnosticReportPartialResult),
}
impl From for DocumentDiagnosticReportResult {
fn from(from: DocumentDiagnosticReport) -> Self {
DocumentDiagnosticReportResult::Report(from)
}
}
impl From for DocumentDiagnosticReportResult {
fn from(from: DocumentDiagnosticReportPartialResult) -> Self {
DocumentDiagnosticReportResult::Partial(from)
}
}
/// Cancellation data returned from a diagnostic request.
///
/// If no data is provided, it defaults to `{ retrigger_request: true }`.
///
/// @since 3.17.0
#[derive(Debug, PartialEq, Deserialize, Serialize, Clone)]
#[serde(rename_all = "camelCase")]
pub struct DiagnosticServerCancellationData {
pub retrigger_request: bool,
}
impl Default for DiagnosticServerCancellationData {
fn default() -> Self {
DiagnosticServerCancellationData {
retrigger_request: true,
}
}
}
lsp-types-0.94.1/src/document_highlight.rs 0000644 0000000 0000000 00000003374 00726746425 0016720 0 ustar 0000000 0000000 use serde::{Deserialize, Serialize};
use crate::{
DynamicRegistrationClientCapabilities, PartialResultParams, Range, TextDocumentPositionParams,
WorkDoneProgressParams,
};
pub type DocumentHighlightClientCapabilities = DynamicRegistrationClientCapabilities;
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DocumentHighlightParams {
#[serde(flatten)]
pub text_document_position_params: TextDocumentPositionParams,
#[serde(flatten)]
pub work_done_progress_params: WorkDoneProgressParams,
#[serde(flatten)]
pub partial_result_params: PartialResultParams,
}
/// 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(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
pub struct DocumentHighlight {
/// The range this highlight applies to.
pub range: Range,
/// The highlight kind, default is DocumentHighlightKind.Text.
#[serde(skip_serializing_if = "Option::is_none")]
pub kind: Option,
}
/// A document highlight kind.
#[derive(Eq, PartialEq, Copy, Clone, Deserialize, Serialize)]
#[serde(transparent)]
pub struct DocumentHighlightKind(i32);
lsp_enum! {
impl DocumentHighlightKind {
/// A textual occurrence.
pub const TEXT: DocumentHighlightKind = DocumentHighlightKind(1);
/// Read-access of a symbol, like reading a variable.
pub const READ: DocumentHighlightKind = DocumentHighlightKind(2);
/// Write-access of a symbol, like writing to a variable.
pub const WRITE: DocumentHighlightKind = DocumentHighlightKind(3);
}
}
lsp-types-0.94.1/src/document_link.rs 0000644 0000000 0000000 00000004751 00726746425 0015706 0 ustar 0000000 0000000 use crate::{
PartialResultParams, Range, TextDocumentIdentifier, WorkDoneProgressOptions,
WorkDoneProgressParams,
};
use serde::{Deserialize, Serialize};
use serde_json::Value;
use url::Url;
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[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 support the `tooltip` property on `DocumentLink`.
#[serde(skip_serializing_if = "Option::is_none")]
pub tooltip_support: Option,
}
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[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,
}
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[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,
}
/// 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(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
pub struct DocumentLink {
/// The range this link applies to.
pub range: Range,
/// The uri this link points to.
#[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.
#[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,
}
lsp-types-0.94.1/src/document_symbols.rs 0000644 0000000 0000000 00000011550 00726746425 0016434 0 ustar 0000000 0000000 use crate::{
Location, PartialResultParams, Range, SymbolKind, SymbolKindCapability, TextDocumentIdentifier,
WorkDoneProgressParams,
};
use crate::{SymbolTag, TagSupport};
use serde::{Deserialize, Serialize};
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DocumentSymbolClientCapabilities {
/// This capability supports dynamic registration.
#[serde(skip_serializing_if = "Option::is_none")]
pub dynamic_registration: Option,
/// Specific capabilities for the `SymbolKind`.
#[serde(skip_serializing_if = "Option::is_none")]
pub symbol_kind: Option,
/// The client support 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(
default,
skip_serializing_if = "Option::is_none",
deserialize_with = "TagSupport::deserialize_compat"
)]
pub tag_support: Option>,
}
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DocumentSymbolResponse {
Flat(Vec),
Nested(Vec),
}
impl From> for DocumentSymbolResponse {
fn from(info: Vec) -> Self {
DocumentSymbolResponse::Flat(info)
}
}
impl From> for DocumentSymbolResponse {
fn from(symbols: Vec) -> Self {
DocumentSymbolResponse::Nested(symbols)
}
}
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[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,
}
/// 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(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DocumentSymbol {
/// The name of this symbol.
pub name: String,
/// More detail for this symbol, e.g the signature of a function. If not provided the
/// name is used.
#[serde(skip_serializing_if = "Option::is_none")]
pub detail: Option,
/// The kind of this symbol.
pub kind: SymbolKind,
/// Tags for this completion item.
///
/// @since 3.15.0
#[serde(skip_serializing_if = "Option::is_none")]
pub tags: Option>,
/// Indicates if this symbol is deprecated.
#[serde(skip_serializing_if = "Option::is_none")]
#[deprecated(note = "Use tags instead")]
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 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 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>,
}
/// Represents information about programming constructs like variables, classes,
/// interfaces etc.
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SymbolInformation {
/// The name of this symbol.
pub name: String,
/// The kind of this symbol.
pub kind: SymbolKind,
/// Tags for this completion item.
///
/// @since 3.16.0
#[serde(skip_serializing_if = "Option::is_none")]
pub tags: Option>,
/// Indicates if this symbol is deprecated.
#[serde(skip_serializing_if = "Option::is_none")]
#[deprecated(note = "Use tags instead")]
pub deprecated: Option,
/// The location of this symbol.
pub location: Location,
/// The name of the symbol containing this symbol.
#[serde(skip_serializing_if = "Option::is_none")]
pub container_name: Option,
}
lsp-types-0.94.1/src/error_codes.rs 0000644 0000000 0000000 00000002511 00726746425 0015351 0 ustar 0000000 0000000 //! In this module we only define constants for lsp specific error codes.
//! There are other error codes that are defined in the
//! [JSON RPC specification](https://www.jsonrpc.org/specification#error_object).
// This is the start range of LSP reserved error codes.
// It doesn't denote a real error code.
//
// @since 3.16.0
pub const LSP_RESERVED_ERROR_RANGE_START: i64 = -32899;
// The server cancelled the request. This error code should
// only be used for requests that explicitly support being
// server cancellable.
//
// @since 3.17.0
pub const SERVER_CANCELLED: i64 = -32802;
// 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.
pub const CONTENT_MODIFIED: i64 = -32801;
// The client has canceled a request and a server as detected
// the cancel.
pub const REQUEST_CANCELLED: i64 = -32800;
// This is the end range of LSP reserved error codes.
// It doesn't denote a real error code.
//
// @since 3.16.0
pub const LSP_RESERVED_ERROR_RANGE_END: i64 = -32800;
lsp-types-0.94.1/src/file_operations.rs 0000644 0000000 0000000 00000017374 00726746425 0016242 0 ustar 0000000 0000000 use serde::{Deserialize, Serialize};
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct WorkspaceFileOperationsClientCapabilities {
/// 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 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 requests.
#[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 requests.
#[serde(skip_serializing_if = "Option::is_none")]
pub did_delete: Option,
/// The server is interested in receiving willDeleteFiles requests.
#[serde(skip_serializing_if = "Option::is_none")]
pub will_delete: Option,
}
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct WorkspaceFileOperationsServerCapabilities {
/// 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,
}
/// The options to register for file operations.
///
/// @since 3.16.0
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct FileOperationRegistrationOptions {
/// The actual filters.
pub filters: Vec,
}
/// A filter to describe in which file operation requests or notifications
/// the server is interested in.
///
/// @since 3.16.0
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct FileOperationFilter {
/// A Uri like `file` or `untitled`.
pub scheme: Option,
/// The actual file operation pattern.
pub pattern: FileOperationPattern,
}
/// A pattern kind describing if a glob pattern matches a file a folder or
/// both.
///
/// @since 3.16.0
#[derive(Debug, Eq, PartialEq, Deserialize, Serialize, Clone)]
#[serde(rename_all = "lowercase")]
pub enum FileOperationPatternKind {
/// The pattern matches a file only.
File,
/// The pattern matches a folder only.
Folder,
}
/// Matching options for the file operation pattern.
///
/// @since 3.16.0
///
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[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,
}
/// A pattern to describe in which file operation requests or notifications
/// the server is interested in.
///
/// @since 3.16.0
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct FileOperationPattern {
/// The glob pattern to match. Glob patterns can have the following syntax:
/// - `*` to match one or more characters in a path segment
/// - `?` to match on one character in a path segment
/// - `**` to match any number of path segments, including none
/// - `{}` to group 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`)
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,
}
/// The parameters sent in notifications/requests for user-initiated creation
/// of files.
///
/// @since 3.16.0
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CreateFilesParams {
/// An array of all files/folders created in this operation.
pub files: Vec,
}
/// Represents information on a file/folder create.
///
/// @since 3.16.0
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct FileCreate {
/// A file:// URI for the location of the file/folder being created.
pub uri: String,
}
/// The parameters sent in notifications/requests for user-initiated renames
/// of files.
///
/// @since 3.16.0
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[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,
}
/// Represents information on a file/folder rename.
///
/// @since 3.16.0
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[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,
}
/// The parameters sent in notifications/requests for user-initiated deletes
/// of files.
///
/// @since 3.16.0
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DeleteFilesParams {
/// An array of all files/folders deleted in this operation.
pub files: Vec,
}
/// Represents information on a file/folder delete.
///
/// @since 3.16.0
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct FileDelete {
/// A file:// URI for the location of the file/folder being deleted.
pub uri: String,
}
lsp-types-0.94.1/src/folding_range.rs 0000644 0000000 0000000 00000013141 00726746425 0015642 0 ustar 0000000 0000000 use crate::{
PartialResultParams, StaticTextDocumentColorProviderOptions, TextDocumentIdentifier,
WorkDoneProgressParams,
};
use serde::{Deserialize, Serialize};
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[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,
}
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(untagged)]
pub enum FoldingRangeProviderCapability {
Simple(bool),
FoldingProvider(FoldingProviderOptions),
Options(StaticTextDocumentColorProviderOptions),
}
impl From for FoldingRangeProviderCapability {
fn from(from: StaticTextDocumentColorProviderOptions) -> Self {
Self::Options(from)
}
}
impl From for FoldingRangeProviderCapability {
fn from(from: FoldingProviderOptions) -> Self {
Self::FoldingProvider(from)
}
}
impl From for FoldingRangeProviderCapability {
fn from(from: bool) -> Self {
Self::Simple(from)
}
}
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
pub struct FoldingProviderOptions {}
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct FoldingRangeKindCapability {
/// 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>,
}
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct FoldingRangeCapability {
/// 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,
}
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[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 `(FoldingRangeProviderOptions & TextDocumentRegistrationOptions & StaticRegistrationOptions)`
/// 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,
}
/// Enum of known range kinds
#[derive(Debug, Eq, PartialEq, Deserialize, Serialize, Clone)]
#[serde(rename_all = "lowercase")]
pub enum FoldingRangeKind {
/// Folding range for a comment
Comment,
/// Folding range for a imports or includes
Imports,
/// Folding range for a region (e.g. `#region`)
Region,
}
/// Represents a folding range.
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct FoldingRange {
/// The zero-based line number from where the folded range starts.
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 line number where the folded range ends.
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](#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,
}
lsp-types-0.94.1/src/formatting.rs 0000644 0000000 0000000 00000011737 00726746425 0015227 0 ustar 0000000 0000000 use serde::{Deserialize, Serialize};
use crate::{
DocumentSelector, DynamicRegistrationClientCapabilities, Range, TextDocumentIdentifier,
TextDocumentPositionParams, WorkDoneProgressParams,
};
use std::collections::HashMap;
pub type DocumentFormattingClientCapabilities = DynamicRegistrationClientCapabilities;
pub type DocumentRangeFormattingClientCapabilities = DynamicRegistrationClientCapabilities;
pub type DocumentOnTypeFormattingClientCapabilities = DynamicRegistrationClientCapabilities;
/// Format document on type options
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[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>,
}
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
#[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,
}
/// Value-object describing what options formatting should use.
#[derive(Debug, PartialEq, Clone, Default, Serialize, Deserialize)]
#[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,
/// Signature for further properties.
#[serde(flatten)]
pub properties: HashMap,
/// Trim trailing whitespace on a line.
#[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.
#[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.
#[serde(skip_serializing_if = "Option::is_none")]
pub trim_final_newlines: Option,
}
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
#[serde(untagged)]
pub enum FormattingProperty {
Bool(bool),
Number(i32),
String(String),
}
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
#[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,
}
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DocumentOnTypeFormattingParams {
/// Text Document and Position fields.
#[serde(flatten)]
pub text_document_position: TextDocumentPositionParams,
/// The character that has been typed.
pub ch: String,
/// The format options.
pub options: FormattingOptions,
}
/// Extends TextDocumentRegistrationOptions
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DocumentOnTypeFormattingRegistrationOptions {
/// 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,
/// 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>,
}
#[cfg(test)]
mod tests {
use super::*;
use crate::tests::test_serialization;
#[test]
fn formatting_options() {
test_serialization(
&FormattingOptions {
tab_size: 123,
insert_spaces: true,
properties: HashMap::new(),
trim_trailing_whitespace: None,
insert_final_newline: None,
trim_final_newlines: None,
},
r#"{"tabSize":123,"insertSpaces":true}"#,
);
test_serialization(
&FormattingOptions {
tab_size: 123,
insert_spaces: true,
properties: vec![("prop".to_string(), FormattingProperty::Number(1))]
.into_iter()
.collect(),
trim_trailing_whitespace: None,
insert_final_newline: None,
trim_final_newlines: None,
},
r#"{"tabSize":123,"insertSpaces":true,"prop":1}"#,
);
}
}
lsp-types-0.94.1/src/hover.rs 0000644 0000000 0000000 00000005324 00726746425 0014173 0 ustar 0000000 0000000 use serde::{Deserialize, Serialize};
use crate::{
MarkedString, MarkupContent, MarkupKind, Range, TextDocumentPositionParams,
TextDocumentRegistrationOptions, WorkDoneProgressOptions, WorkDoneProgressParams,
};
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct HoverClientCapabilities {
/// Whether completion supports dynamic registration.
#[serde(skip_serializing_if = "Option::is_none")]
pub dynamic_registration: Option,
/// Client supports the follow 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>,
}
/// Hover options.
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct HoverOptions {
#[serde(flatten)]
pub work_done_progress_options: WorkDoneProgressOptions,
}
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct HoverRegistrationOptions {
#[serde(flatten)]
pub text_document_registration_options: TextDocumentRegistrationOptions,
#[serde(flatten)]
pub hover_options: HoverOptions,
}
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(untagged)]
pub enum HoverProviderCapability {
Simple(bool),
Options(HoverOptions),
}
impl From for HoverProviderCapability {
fn from(from: HoverOptions) -> Self {
Self::Options(from)
}
}
impl From for HoverProviderCapability {
fn from(from: bool) -> Self {
Self::Simple(from)
}
}
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct HoverParams {
#[serde(flatten)]
pub text_document_position_params: TextDocumentPositionParams,
#[serde(flatten)]
pub work_done_progress_params: WorkDoneProgressParams,
}
/// The result of a hover request.
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
pub struct Hover {
/// The hover's content
pub contents: HoverContents,
/// An optional range is a range inside a text document
/// that is used to visualize a hover, e.g. by changing the background color.
#[serde(skip_serializing_if = "Option::is_none")]
pub range: Option,
}
/// Hover contents could be single entry or multiple entries.
#[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum HoverContents {
Scalar(MarkedString),
Array(Vec),
Markup(MarkupContent),
}
lsp-types-0.94.1/src/inlay_hint.rs 0000644 0000000 0000000 00000022715 00726746425 0015211 0 ustar 0000000 0000000 use crate::{
Command, LSPAny, Location, MarkupContent, Position, Range, StaticRegistrationOptions,
TextDocumentIdentifier, TextDocumentRegistrationOptions, TextEdit, WorkDoneProgressOptions,
WorkDoneProgressParams,
};
use serde::{Deserialize, Serialize};
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
#[serde(untagged)]
pub enum InlayHintServerCapabilities {
Options(InlayHintOptions),
RegistrationOptions(InlayHintRegistrationOptions),
}
/// Inlay hint client capabilities.
///
/// @since 3.17.0
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[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 a inlay
/// hint.
#[serde(skip_serializing_if = "Option::is_none")]
pub resolve_support: Option,
}
/// Inlay hint options used during static registration.
///
/// @since 3.17.0
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct InlayHintOptions {
#[serde(flatten)]
pub work_done_progress_options: WorkDoneProgressOptions,
/// The server provides support to resolve additional
/// information for an inlay hint item.
#[serde(skip_serializing_if = "Option::is_none")]
pub resolve_provider: Option,
}
/// Inlay hint options used during static or dynamic registration.
///
/// @since 3.17.0
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct InlayHintRegistrationOptions {
#[serde(flatten)]
pub inlay_hint_options: InlayHintOptions,
#[serde(flatten)]
pub text_document_registration_options: TextDocumentRegistrationOptions,
#[serde(flatten)]
pub static_registration_options: StaticRegistrationOptions,
}
/// A parameter literal used in inlay hint requests.
///
/// @since 3.17.0
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct InlayHintParams {
#[serde(flatten)]
pub work_done_progress_params: WorkDoneProgressParams,
/// The text document.
pub text_document: TextDocumentIdentifier,
/// The visible document range for which inlay hints should be computed.
pub range: Range,
}
/// Inlay hint information.
///
/// @since 3.17.0
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct InlayHint {
/// The position of this hint.
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: InlayHintLabel,
/// 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.
///
/// 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 text_edits: Option>,
/// The tooltip text when you hover over this item.
///
/// 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,
/// 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 a inlay hint between
/// a `textDocument/inlayHint` and a `inlayHint/resolve` request.
#[serde(skip_serializing_if = "Option::is_none")]
pub data: Option,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(untagged)]
pub enum InlayHintLabel {
String(String),
LabelParts(Vec),
}
impl From for InlayHintLabel {
#[inline]
fn from(from: String) -> Self {
Self::String(from)
}
}
impl From> for InlayHintLabel {
#[inline]
fn from(from: Vec) -> Self {
Self::LabelParts(from)
}
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(untagged)]
pub enum InlayHintTooltip {
String(String),
MarkupContent(MarkupContent),
}
impl From for InlayHintTooltip {
#[inline]
fn from(from: String) -> Self {
Self::String(from)
}
}
impl From for InlayHintTooltip {
#[inline]
fn from(from: MarkupContent) -> Self {
Self::MarkupContent(from)
}
}
/// An inlay hint label part allows for interactive and composite labels
/// of inlay hints.
#[derive(Debug, Clone, Default, Deserialize, Serialize)]
#[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,
}
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(untagged)]
pub enum InlayHintLabelPartTooltip {
String(String),
MarkupContent(MarkupContent),
}
impl From for InlayHintLabelPartTooltip {
#[inline]
fn from(from: String) -> Self {
Self::String(from)
}
}
impl From for InlayHintLabelPartTooltip {
#[inline]
fn from(from: MarkupContent) -> Self {
Self::MarkupContent(from)
}
}
/// Inlay hint kinds.
///
/// @since 3.17.0
#[derive(Eq, PartialEq, Copy, Clone, Serialize, Deserialize)]
#[serde(transparent)]
pub struct InlayHintKind(i32);
lsp_enum! {
impl InlayHintKind {
/// An inlay hint that for a type annotation.
pub const TYPE: InlayHintKind = InlayHintKind(1);
/// An inlay hint that is for a parameter.
pub const PARAMETER: InlayHintKind = InlayHintKind(2);
}
}
/// Inlay hint client capabilities.
///
/// @since 3.17.0
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct InlayHintResolveClientCapabilities {
/// The properties that a client can resolve lazily.
pub properties: Vec,
}
/// Client workspace capabilities specific to inlay hints.
///
/// @since 3.17.0
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[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,
}
// TODO(sno2): add tests once stabilized
lsp-types-0.94.1/src/inline_value.rs 0000644 0000000 0000000 00000016527 00726746425 0015531 0 ustar 0000000 0000000 use crate::{
DynamicRegistrationClientCapabilities, Range, StaticRegistrationOptions,
TextDocumentIdentifier, TextDocumentRegistrationOptions, WorkDoneProgressOptions,
WorkDoneProgressParams,
};
use serde::{Deserialize, Serialize};
pub type InlineValueClientCapabilities = DynamicRegistrationClientCapabilities;
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(untagged)]
pub enum InlineValueServerCapabilities {
Options(InlineValueOptions),
RegistrationOptions(InlineValueRegistrationOptions),
}
/// Inline value options used during static registration.
///
/// @since 3.17.0
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
pub struct InlineValueOptions {
#[serde(flatten)]
pub work_done_progress_options: WorkDoneProgressOptions,
}
/// Inline value options used during static or dynamic registration.
///
/// @since 3.17.0
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
pub struct InlineValueRegistrationOptions {
#[serde(flatten)]
pub inline_value_options: InlineValueOptions,
#[serde(flatten)]
pub text_document_registration_options: TextDocumentRegistrationOptions,
#[serde(flatten)]
pub static_registration_options: StaticRegistrationOptions,
}
/// A parameter literal used in inline value requests.
///
/// @since 3.17.0
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct InlineValueParams {
#[serde(flatten)]
pub work_done_progress_params: WorkDoneProgressParams,
/// The text document.
pub text_document: TextDocumentIdentifier,
/// The document range for which inline values should be computed.
pub range: Range,
/// Additional information about the context in which inline values were
/// requested.
pub context: InlineValueContext,
}
/// @since 3.17.0
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[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,
}
/// Provide inline value as text.
///
/// @since 3.17.0
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
pub struct InlineValueText {
/// The document range for which the inline value applies.
pub range: Range,
/// The text of the inline value.
pub text: String,
}
/// Provide inline value through a variable lookup.
///
/// If only a range is specified, the variable name will be extracted from
/// the underlying document.
///
/// An optional variable name can be used to override the extracted name.
///
/// @since 3.17.0
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct InlineValueVariableLookup {
/// The document range for which the inline value applies.
/// The range is 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,
}
/// Provide an inline value through an expression evaluation.
///
/// If only a range is specified, the expression will be extracted from the
/// underlying document.
///
/// An optional expression can be used to override the extracted expression.
///
/// @since 3.17.0
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct InlineValueEvaluatableExpression {
/// The document range for which the inline value applies.
/// The range is used to extract the evaluatable expression from the
/// underlying document.
pub range: Range,
/// If specified the expression overrides the extracted expression.
#[serde(skip_serializing_if = "Option::is_none")]
pub expression: Option,
}
/// 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(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(untagged)]
pub enum InlineValue {
Text(InlineValueText),
VariableLookup(InlineValueVariableLookup),
EvaluatableExpression(InlineValueEvaluatableExpression),
}
impl From for InlineValue {
#[inline]
fn from(from: InlineValueText) -> Self {
Self::Text(from)
}
}
impl From for InlineValue {
#[inline]
fn from(from: InlineValueVariableLookup) -> Self {
Self::VariableLookup(from)
}
}
impl From for InlineValue {
#[inline]
fn from(from: InlineValueEvaluatableExpression) -> Self {
Self::EvaluatableExpression(from)
}
}
/// Client workspace capabilities specific to inline values.
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
///
/// @since 3.17.0
#[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 detect a project wide
/// change that requires such a calculation.
#[serde(skip_serializing_if = "Option::is_none")]
pub refresh_support: Option,
}
#[cfg(test)]
mod tests {
use super::*;
use crate::tests::test_serialization;
use crate::Position;
#[test]
fn inline_values() {
test_serialization(
&InlineValueText {
range: Range::new(Position::new(0, 0), Position::new(0, 4)),
text: "one".to_owned(),
},
r#"{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":4}},"text":"one"}"#,
);
test_serialization(
&InlineValue::VariableLookup(InlineValueVariableLookup {
range: Range::new(Position::new(1, 0), Position::new(1, 4)),
variable_name: None,
case_sensitive_lookup: false,
}),
r#"{"range":{"start":{"line":1,"character":0},"end":{"line":1,"character":4}},"caseSensitiveLookup":false}"#,
);
test_serialization(
&InlineValue::EvaluatableExpression(InlineValueEvaluatableExpression {
range: Range::new(Position::new(2, 0), Position::new(2, 4)),
expression: None,
}),
r#"{"range":{"start":{"line":2,"character":0},"end":{"line":2,"character":4}}}"#,
);
}
}
lsp-types-0.94.1/src/lib.rs 0000644 0000000 0000000 00000305266 00726746425 0013626 0 ustar 0000000 0000000 /*!
Language Server Protocol types for Rust.
Based on:
This library uses the URL crate for parsing URIs. Note that there is
some confusion on the meaning of URLs vs URIs:
. According to that
information, on the classical sense of "URLs", "URLs" are a subset of
URIs, But on the modern/new meaning of URLs, they are the same as
URIs. The important take-away aspect is that the URL crate should be
able to parse any URI, such as `urn:isbn:0451450523`.
*/
#![allow(non_upper_case_globals)]
#![forbid(unsafe_code)]
#[macro_use]
extern crate bitflags;
use std::{collections::HashMap, fmt::Debug};
use serde::{de, de::Error as Error_, Deserialize, Serialize};
use serde_json::Value;
pub use url::Url;
// Large enough to contain any enumeration name defined in this crate
type PascalCaseBuf = [u8; 32];
const fn fmt_pascal_case_const(name: &str) -> (PascalCaseBuf, usize) {
let mut buf = [0; 32];
let mut buf_i = 0;
let mut name_i = 0;
let name = name.as_bytes();
while name_i < name.len() {
let first = name[name_i];
name_i += 1;
buf[buf_i] = first;
buf_i += 1;
while name_i < name.len() {
let rest = name[name_i];
name_i += 1;
if rest == b'_' {
break;
}
buf[buf_i] = rest.to_ascii_lowercase();
buf_i += 1;
}
}
(buf, buf_i)
}
fn fmt_pascal_case(f: &mut std::fmt::Formatter<'_>, name: &str) -> std::fmt::Result {
for word in name.split('_') {
let mut chars = word.chars();
let first = chars.next().unwrap();
write!(f, "{}", first)?;
for rest in chars {
write!(f, "{}", rest.to_lowercase())?;
}
}
Ok(())
}
macro_rules! lsp_enum {
(impl $typ: ident { $( $(#[$attr:meta])* pub const $name: ident : $enum_type: ty = $value: expr; )* }) => {
impl $typ {
$(
$(#[$attr])*
pub const $name: $enum_type = $value;
)*
}
impl std::fmt::Debug for $typ {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match *self {
$(
Self::$name => crate::fmt_pascal_case(f, stringify!($name)),
)*
_ => write!(f, "{}({})", stringify!($typ), self.0),
}
}
}
impl std::convert::TryFrom<&str> for $typ {
type Error = &'static str;
fn try_from(value: &str) -> Result {
match () {
$(
_ if {
const X: (crate::PascalCaseBuf, usize) = crate::fmt_pascal_case_const(stringify!($name));
let (buf, len) = X;
&buf[..len] == value.as_bytes()
} => Ok(Self::$name),
)*
_ => Err("unknown enum variant"),
}
}
}
}
}
pub mod error_codes;
pub mod notification;
pub mod request;
mod call_hierarchy;
pub use call_hierarchy::*;
mod code_action;
pub use code_action::*;
mod code_lens;
pub use code_lens::*;
mod color;
pub use color::*;
mod completion;
pub use completion::*;
mod document_diagnostic;
pub use document_diagnostic::*;
mod document_highlight;
pub use document_highlight::*;
mod document_link;
pub use document_link::*;
mod document_symbols;
pub use document_symbols::*;
mod file_operations;
pub use file_operations::*;
mod folding_range;
pub use folding_range::*;
mod formatting;
pub use formatting::*;
mod hover;
pub use hover::*;
mod inlay_hint;
pub use inlay_hint::*;
mod inline_value;
pub use inline_value::*;
mod moniker;
pub use moniker::*;
mod progress;
pub use progress::*;
mod references;
pub use references::*;
mod rename;
pub use rename::*;
pub mod selection_range;
pub use selection_range::*;
mod semantic_tokens;
pub use semantic_tokens::*;
mod signature_help;
pub use signature_help::*;
mod type_hierarchy;
pub use type_hierarchy::*;
mod linked_editing;
pub use linked_editing::*;
mod window;
pub use window::*;
mod workspace_diagnostic;
pub use workspace_diagnostic::*;
mod workspace_folders;
pub use workspace_folders::*;
mod workspace_symbols;
pub use workspace_symbols::*;
pub mod lsif;
mod trace;
pub use trace::*;
/* ----------------- Auxiliary types ----------------- */
#[derive(Debug, Eq, Hash, PartialEq, Clone, Deserialize, Serialize)]
#[serde(untagged)]
pub enum NumberOrString {
Number(i32),
String(String),
}
/* ----------------- Cancel support ----------------- */
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
pub struct CancelParams {
/// The request id to cancel.
pub id: NumberOrString,
}
/* ----------------- Basic JSON Structures ----------------- */
/// The LSP any type
///
/// @since 3.17.0
pub type LSPAny = serde_json::Value;
/// LSP object definition.
///
/// @since 3.17.0
pub type LSPObject = serde_json::Map;
/// LSP arrays.
///
/// @since 3.17.0
pub type LSPArray = Vec;
/// Position in a text document expressed as zero-based line and character offset.
/// A position is between two characters like an 'insert' cursor in a editor.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Copy, Clone, Default, Deserialize, Serialize)]
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`.
///
/// If the character value is greater than the line length it defaults back
/// to the line length.
pub character: u32,
}
impl Position {
pub fn new(line: u32, character: u32) -> Position {
Position { line, character }
}
}
/// A range in a text document expressed as (zero-based) start and end positions.
/// A range is comparable to a selection in an editor. Therefore the end position is exclusive.
#[derive(Debug, Eq, PartialEq, Copy, Clone, Default, Deserialize, Serialize)]
pub struct Range {
/// The range's start position.
pub start: Position,
/// The range's end position.
pub end: Position,
}
impl Range {
pub fn new(start: Position, end: Position) -> Range {
Range { start, end }
}
}
/// Represents a location inside a resource, such as a line inside a text file.
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
pub struct Location {
pub uri: Url,
pub range: Range,
}
impl Location {
pub fn new(uri: Url, range: Range) -> Location {
Location { uri, range }
}
}
/// Represents a link between a source and a target location.
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[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 mouse position.
#[serde(skip_serializing_if = "Option::is_none")]
pub origin_selection_range: Option,
/// The target resource identifier of this link.
pub target_uri: Url,
/// The full target range of this link.
pub target_range: Range,
/// The span of this link.
pub target_selection_range: Range,
}
/// A type indicating how positions are encoded,
/// specifically what column offsets mean.
///
/// @since 3.17.0
#[derive(Debug, Eq, PartialEq, Hash, PartialOrd, Clone, Deserialize, Serialize)]
pub struct PositionEncodingKind(std::borrow::Cow<'static, str>);
impl PositionEncodingKind {
/// Character offsets count UTF-8 code units.
pub const UTF8: PositionEncodingKind = PositionEncodingKind::new("utf-8");
/// Character offsets count UTF-16 code units.
///
/// This is the default and must always be supported
/// by servers
pub const UTF16: PositionEncodingKind = PositionEncodingKind::new("utf-16");
/// Character offsets count UTF-32 code units.
///
/// Implementation note: these are the same as Unicode code points,
/// so this `PositionEncodingKind` may also be used for an
/// encoding-agnostic representation of character offsets.
pub const UTF32: PositionEncodingKind = PositionEncodingKind::new("utf-32");
pub const fn new(tag: &'static str) -> Self {
PositionEncodingKind(std::borrow::Cow::Borrowed(tag))
}
pub fn as_str(&self) -> &str {
&self.0
}
}
impl From for PositionEncodingKind {
fn from(from: String) -> Self {
PositionEncodingKind(std::borrow::Cow::from(from))
}
}
impl From<&'static str> for PositionEncodingKind {
fn from(from: &'static str) -> Self {
PositionEncodingKind::new(from)
}
}
/// Represents a diagnostic, such as a compiler error or warning.
/// Diagnostic objects are only valid in the scope of a resource.
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Diagnostic {
/// The range at which the message applies.
pub range: Range,
/// The diagnostic's severity. Can be omitted. If omitted it is up to the
/// client to interpret diagnostics as error, warning, info or hint.
#[serde(skip_serializing_if = "Option::is_none")]
pub severity: Option,
/// The diagnostic's code. Can be omitted.
#[serde(skip_serializing_if = "Option::is_none")]
pub code: Option,
/// An optional property to describe the error code.
///
/// @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'.
#[serde(skip_serializing_if = "Option::is_none")]
pub source: Option,
/// The diagnostic's message.
pub message: String,
/// 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>,
/// Additional metadata about the diagnostic.
#[serde(skip_serializing_if = "Option::is_none")]
pub tags: 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,
}
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CodeDescription {
pub href: Url,
}
impl Diagnostic {
pub fn new(
range: Range,
severity: Option,
code: Option,
source: Option,
message: String,
related_information: Option>,
tags: Option>,
) -> Diagnostic {
Diagnostic {
range,
severity,
code,
source,
message,
related_information,
tags,
..Diagnostic::default()
}
}
pub fn new_simple(range: Range, message: String) -> Diagnostic {
Self::new(range, None, None, None, message, None, None)
}
pub fn new_with_code_number(
range: Range,
severity: DiagnosticSeverity,
code_number: i32,
source: Option,
message: String,
) -> Diagnostic {
let code = Some(NumberOrString::Number(code_number));
Self::new(range, Some(severity), code, source, message, None, None)
}
}
/// The protocol currently supports the following diagnostic severities:
#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Deserialize, Serialize)]
#[serde(transparent)]
pub struct DiagnosticSeverity(i32);
lsp_enum! {
impl DiagnosticSeverity {
/// Reports an error.
pub const ERROR: DiagnosticSeverity = DiagnosticSeverity(1);
/// Reports a warning.
pub const WARNING: DiagnosticSeverity = DiagnosticSeverity(2);
/// Reports an information.
pub const INFORMATION: DiagnosticSeverity = DiagnosticSeverity(3);
/// Reports a hint.
pub const HINT: DiagnosticSeverity = DiagnosticSeverity(4);
}
}
/// 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(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
pub struct DiagnosticRelatedInformation {
/// The location of this related diagnostic information.
pub location: Location,
/// The message of this related diagnostic information.
pub message: String,
}
/// The diagnostic tags.
#[derive(Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(transparent)]
pub struct DiagnosticTag(i32);
lsp_enum! {
impl DiagnosticTag {
/// Unused or unnecessary code.
/// Clients are allowed to render diagnostics with this tag faded out instead of having
/// an error squiggle.
pub const UNNECESSARY: DiagnosticTag = DiagnosticTag(1);
/// Deprecated or obsolete code.
/// Clients are allowed to rendered diagnostics with this tag strike through.
pub const DEPRECATED: DiagnosticTag = DiagnosticTag(2);
}
}
/// Represents a reference to a command. Provides a title which will be used to represent a command in the UI.
/// Commands are identified by a string identifier. The recommended way to handle commands is to implement
/// their execution on the server side if the client and server provides the corresponding capabilities.
/// Alternatively the tool extension code could handle the command.
/// The protocol currently doesn’t specify a set of well-known commands.
#[derive(Debug, PartialEq, Clone, Default, Deserialize, Serialize)]
pub struct Command {
/// Title of the command, like `save`.
pub title: String,
/// 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 {
pub fn new(title: String, command: String, arguments: Option>) -> Command {
Command {
title,
command,
arguments,
}
}
}
/// A textual edit applicable to a text document.
///
/// If n `TextEdit`s are applied to a text document all text edits describe changes to the initial document version.
/// Execution wise text edits should applied from the bottom to the top of the text document. Overlapping text edits
/// are not supported.
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[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 {
pub fn new(range: Range, new_text: String) -> TextEdit {
TextEdit { range, new_text }
}
}
/// An identifier referring to a change annotation managed by a workspace
/// edit.
///
/// @since 3.16.0
pub type ChangeAnnotationIdentifier = String;
/// A special text edit with an additional change annotation.
///
/// @since 3.16.0
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct AnnotatedTextEdit {
#[serde(flatten)]
pub text_edit: TextEdit,
/// The actual annotation
pub annotation_id: ChangeAnnotationIdentifier,
}
/// Describes textual changes on a single text document. The text document is referred to as a
/// `OptionalVersionedTextDocumentIdentifier` to allow clients to check the text document version before an
/// edit is applied. A `TextDocumentEdit` describes all changes on a 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 or do any kind of ordering. However the edits must be non overlapping.
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[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 by the
/// client capability `workspace.workspaceEdit.changeAnnotationSupport`
pub edits: Vec>,
}
/// Additional information that describes document changes.
///
/// @since 3.16.0
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[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,
}
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ChangeAnnotationWorkspaceEditClientCapabilities {
/// 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,
}
/// Options to create a file.
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[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,
}
/// Create file operation
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CreateFile {
/// The resource to create.
pub uri: Url,
/// 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,
}
/// Rename file options
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[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,
}
/// Rename file operation
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct RenameFile {
/// The old (existing) location.
pub old_uri: Url,
/// The new location.
pub new_uri: Url,
/// 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,
}
/// Delete file options
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[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