2024-01-01 14:58:21 -05:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2021-06-01 07:53:08 -04:00
|
|
|
|
|
|
|
use deno_core::serde::Deserialize;
|
|
|
|
use deno_core::serde::Serialize;
|
2022-04-03 00:17:30 -04:00
|
|
|
use tower_lsp::lsp_types as lsp;
|
2021-06-01 07:53:08 -04:00
|
|
|
|
|
|
|
pub const CACHE_REQUEST: &str = "deno/cache";
|
|
|
|
pub const PERFORMANCE_REQUEST: &str = "deno/performance";
|
2023-10-12 11:07:27 -04:00
|
|
|
pub const TASK_REQUEST: &str = "deno/taskDefinitions";
|
2021-06-01 07:53:08 -04:00
|
|
|
pub const RELOAD_IMPORT_REGISTRIES_REQUEST: &str =
|
|
|
|
"deno/reloadImportRegistries";
|
|
|
|
pub const VIRTUAL_TEXT_DOCUMENT: &str = "deno/virtualTextDocument";
|
2023-05-26 02:10:18 -04:00
|
|
|
pub const LATEST_DIAGNOSTIC_BATCH_INDEX: &str =
|
|
|
|
"deno/internalLatestDiagnosticBatchIndex";
|
2021-06-01 07:53:08 -04:00
|
|
|
|
|
|
|
#[derive(Debug, Deserialize, Serialize)]
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
pub struct CacheParams {
|
|
|
|
/// The document currently open in the editor. If there are no `uris`
|
|
|
|
/// supplied, the referrer will be cached.
|
|
|
|
pub referrer: lsp::TextDocumentIdentifier,
|
|
|
|
/// Any documents that have been specifically asked to be cached via the
|
|
|
|
/// command.
|
|
|
|
pub uris: Vec<lsp::TextDocumentIdentifier>,
|
|
|
|
}
|
|
|
|
|
2023-10-12 11:07:27 -04:00
|
|
|
#[derive(Debug, Deserialize, Serialize)]
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
pub struct TaskDefinition {
|
|
|
|
pub name: String,
|
|
|
|
// TODO(nayeemrmn): Rename this to `command` in vscode_deno.
|
|
|
|
#[serde(rename = "detail")]
|
|
|
|
pub command: String,
|
|
|
|
pub source_uri: lsp::Url,
|
|
|
|
}
|
|
|
|
|
2021-06-01 07:53:08 -04:00
|
|
|
#[derive(Debug, Deserialize, Serialize)]
|
|
|
|
pub struct RegistryStateNotificationParams {
|
|
|
|
pub origin: String,
|
|
|
|
pub suggestions: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub enum RegistryStateNotification {}
|
|
|
|
|
|
|
|
impl lsp::notification::Notification for RegistryStateNotification {
|
|
|
|
type Params = RegistryStateNotificationParams;
|
|
|
|
|
|
|
|
const METHOD: &'static str = "deno/registryState";
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Deserialize, Serialize)]
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
pub struct VirtualTextDocumentParams {
|
|
|
|
pub text_document: lsp::TextDocumentIdentifier,
|
|
|
|
}
|
2023-05-26 02:10:18 -04:00
|
|
|
|
|
|
|
#[derive(Debug, Deserialize, Serialize)]
|
|
|
|
pub struct DiagnosticBatchNotificationParams {
|
|
|
|
pub batch_index: usize,
|
|
|
|
pub messages_len: usize,
|
|
|
|
}
|
|
|
|
|
2024-01-17 15:22:28 -05:00
|
|
|
#[derive(Debug, Eq, Hash, PartialEq, Copy, Clone, Deserialize, Serialize)]
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
pub enum DenoConfigurationChangeType {
|
|
|
|
Added,
|
|
|
|
Changed,
|
|
|
|
Removed,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl DenoConfigurationChangeType {
|
|
|
|
pub fn from_file_change_type(file_event: lsp::FileChangeType) -> Self {
|
|
|
|
match file_event {
|
|
|
|
lsp::FileChangeType::CREATED => Self::Added,
|
|
|
|
lsp::FileChangeType::CHANGED => Self::Changed,
|
|
|
|
lsp::FileChangeType::DELETED => Self::Removed,
|
|
|
|
_ => Self::Changed, // non-exhaustable enum
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-12 11:07:27 -04:00
|
|
|
#[derive(Debug, Eq, Hash, PartialEq, Copy, Clone, Deserialize, Serialize)]
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
pub enum DenoConfigurationType {
|
|
|
|
DenoJson,
|
|
|
|
PackageJson,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Eq, Hash, PartialEq, Clone, Deserialize, Serialize)]
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
pub struct DenoConfigurationChangeEvent {
|
2024-01-17 15:22:28 -05:00
|
|
|
pub uri: lsp::Url,
|
|
|
|
#[serde(rename = "type")]
|
|
|
|
pub typ: DenoConfigurationChangeType,
|
2023-10-12 11:07:27 -04:00
|
|
|
pub configuration_type: DenoConfigurationType,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Deserialize, Serialize)]
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
pub struct DidChangeDenoConfigurationNotificationParams {
|
|
|
|
pub changes: Vec<DenoConfigurationChangeEvent>,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub enum DidChangeDenoConfigurationNotification {}
|
|
|
|
|
|
|
|
impl lsp::notification::Notification
|
|
|
|
for DidChangeDenoConfigurationNotification
|
|
|
|
{
|
|
|
|
type Params = DidChangeDenoConfigurationNotificationParams;
|
|
|
|
|
|
|
|
const METHOD: &'static str = "deno/didChangeDenoConfiguration";
|
|
|
|
}
|
|
|
|
|
2023-11-14 17:10:51 -05:00
|
|
|
pub enum DidUpgradeCheckNotification {}
|
|
|
|
|
|
|
|
impl lsp::notification::Notification for DidUpgradeCheckNotification {
|
|
|
|
type Params = DidUpgradeCheckNotificationParams;
|
|
|
|
|
|
|
|
const METHOD: &'static str = "deno/didUpgradeCheck";
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Deserialize, Serialize)]
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
pub struct UpgradeAvailable {
|
|
|
|
pub latest_version: String,
|
|
|
|
pub is_canary: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Deserialize, Serialize)]
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
pub struct DidUpgradeCheckNotificationParams {
|
|
|
|
pub upgrade_available: Option<UpgradeAvailable>,
|
|
|
|
}
|
|
|
|
|
2023-05-26 02:10:18 -04:00
|
|
|
/// This notification is only sent for testing purposes
|
|
|
|
/// in order to know what the latest diagnostics are.
|
|
|
|
pub enum DiagnosticBatchNotification {}
|
|
|
|
|
|
|
|
impl lsp::notification::Notification for DiagnosticBatchNotification {
|
|
|
|
type Params = DiagnosticBatchNotificationParams;
|
|
|
|
|
|
|
|
const METHOD: &'static str = "deno/internalTestDiagnosticBatch";
|
|
|
|
}
|