tokens.rs is now one tokenizer behind three pure steps — absolute() classifies and splits, within() filters by overlap, encode() delta- encodes — so textDocument/semanticTokens/range and /full share one implementation and cannot drift; QA proved the refactor byte-identical to the old encoder over a 41k-token corpus file against the pre-change binary. Range answers are self-contained (overlapping tokens kept whole, re-encoded from the document start) and carry no resultId — a delta never diffs against a partial view. /full/delta remembers each open buffer's last answer under a per-answer id (dropped on didClose; stale or foreign ids answer full) and diffs by common-prefix/suffix trim to a single edit, the suffix counted over what the prefix left — the classic overlap trap, deliberately broken by dev and QA separately and caught by the suite both times. Edit indices are wire-array u32 positions (5 per token), pinned. No token request touches the pull-diagnostics generation. 38 tests added (dev 29 + QA 9), including two independently written edit appliers cross-checked over 200 random pairs and two differently seeded randomized sweeps through the real tokenizer. docs/features/semantic-tokens-delta/README.md Co-Authored-By: Claude Fable 5 <[email protected]>
531 lines
24 KiB
Rust
531 lines
24 KiB
Rust
//! `lucisv-server` — the lucisv language server, speaking LSP over stdio.
|
|
//!
|
|
//! One binary for every editor: VS Code through a thin extension, Vim/Neovim
|
|
//! through built-in LSP config. No editor-specific logic lives below the
|
|
//! protocol layer, and no language logic lives in it — every answer comes from
|
|
//! `vlog_parser`, `vlog_semantic` or `vlog_formatter`. See
|
|
//! `docs/features/lucisv-server/README.md`.
|
|
|
|
mod candidates;
|
|
mod code_action;
|
|
mod completion;
|
|
mod convert;
|
|
mod diagnostics;
|
|
mod expand;
|
|
mod folding;
|
|
mod format;
|
|
mod hierarchy;
|
|
mod hover;
|
|
mod includes;
|
|
mod inlay;
|
|
mod inline;
|
|
mod instantiations;
|
|
mod lint;
|
|
mod locate;
|
|
mod nav;
|
|
mod pairs;
|
|
mod ports;
|
|
mod rename;
|
|
mod selection;
|
|
mod server;
|
|
mod settings;
|
|
mod signature;
|
|
mod state;
|
|
mod symbols;
|
|
mod sync;
|
|
mod templates;
|
|
mod tokens;
|
|
mod uri;
|
|
mod watch;
|
|
|
|
use std::error::Error;
|
|
use std::path::PathBuf;
|
|
|
|
use lsp_server::Connection;
|
|
use lsp_types::{
|
|
CallHierarchyServerCapability, CodeActionKind, CodeActionOptions, CodeActionProviderCapability,
|
|
CompletionOptions, DiagnosticOptions, DiagnosticServerCapabilities, DocumentLinkOptions,
|
|
ExecuteCommandOptions, FoldingRangeProviderCapability, InitializeParams, InlayHintOptions,
|
|
InlayHintServerCapabilities, OneOf, PositionEncodingKind, RenameOptions, SaveOptions,
|
|
SelectionRangeProviderCapability, SemanticTokensFullOptions, SemanticTokensLegend,
|
|
SemanticTokensOptions, SemanticTokensServerCapabilities, ServerCapabilities,
|
|
SignatureHelpOptions, TextDocumentSyncCapability, TextDocumentSyncKind,
|
|
TextDocumentSyncOptions, TextDocumentSyncSaveOptions, WorkDoneProgressOptions,
|
|
};
|
|
|
|
use crate::server::{ClientAbilities, Server};
|
|
use crate::uri::uri_to_path;
|
|
|
|
fn main() -> Result<(), Box<dyn Error + Sync + Send>> {
|
|
let (connection, io_threads) = Connection::stdio();
|
|
|
|
let (id, params) = connection.initialize_start()?;
|
|
// A client that sends params we cannot read still gets a server; every
|
|
// field we want is optional anyway.
|
|
let params: InitializeParams = serde_json::from_value(params).unwrap_or_default();
|
|
let roots = workspace_roots(¶ms);
|
|
let abilities = ClientAbilities {
|
|
snippets: snippet_support(¶ms),
|
|
file_watching: watch::dynamic_registration(¶ms),
|
|
apply_edit: apply_edit_support(¶ms),
|
|
pull_diagnostics: pull_diagnostics_support(¶ms),
|
|
};
|
|
connection.initialize_finish(id, serde_json::to_value(initialize_result())?)?;
|
|
|
|
Server::new(connection, roots, abilities).run()?;
|
|
io_threads.join()?;
|
|
Ok(())
|
|
}
|
|
|
|
/// What the server tells the client it can do. Nothing is advertised that is
|
|
/// not implemented: a capability an editor discovers to be a lie is worse than
|
|
/// one it never had.
|
|
fn capabilities() -> ServerCapabilities {
|
|
ServerCapabilities {
|
|
// The protocol default, and what the conversion in `convert.rs`
|
|
// implements. Stated rather than left implicit.
|
|
position_encoding: Some(PositionEncodingKind::UTF16),
|
|
// Incremental sync: a keystroke costs one range, not the whole file.
|
|
// Spelled out as options rather than a bare kind because a bare kind
|
|
// says nothing about open/close or save, and clients fill that in
|
|
// themselves — this states the same defaults a bare kind resolved to,
|
|
// so nothing but `change` moves. `includeText: false` keeps a save
|
|
// from re-sending a buffer the server already tracks edit by edit;
|
|
// the `didSave` handler still honours text if a client sends it.
|
|
text_document_sync: Some(TextDocumentSyncCapability::Options(TextDocumentSyncOptions {
|
|
open_close: Some(true),
|
|
change: Some(TextDocumentSyncKind::INCREMENTAL),
|
|
// The plain `willSave` notification carries nothing this server
|
|
// can act on, so it is left unadvertised; `willSaveWaitUntil` is
|
|
// the format-on-save hook, for the editors that have no
|
|
// format-on-save of their own. It answers `null` unless
|
|
// `lucisv.formatOnSave` is on — see
|
|
// `docs/features/will-save-wait-until/README.md`.
|
|
will_save: None,
|
|
will_save_wait_until: Some(true),
|
|
save: Some(TextDocumentSyncSaveOptions::SaveOptions(SaveOptions {
|
|
include_text: Some(false),
|
|
})),
|
|
})),
|
|
document_formatting_provider: Some(OneOf::Left(true)),
|
|
document_range_formatting_provider: Some(OneOf::Left(true)),
|
|
definition_provider: Some(OneOf::Left(true)),
|
|
references_provider: Some(OneOf::Left(true)),
|
|
// `` `include`` lines, underlined and ctrl-clickable. Every link is
|
|
// returned with its target already resolved, so there is nothing for
|
|
// `documentLink/resolve` to do — and go-to-definition answers the same
|
|
// lines, for the editors that have no ctrl-click.
|
|
document_link_provider: Some(DocumentLinkOptions {
|
|
resolve_provider: Some(false),
|
|
work_done_progress_options: WorkDoneProgressOptions::default(),
|
|
}),
|
|
// The cursor on a `begin` highlights its own `end`, matched over the
|
|
// token stream; anywhere else, the symbol under it highlights its own
|
|
// other occurrences in this file. The handler declines a position
|
|
// that is neither, which leaves the editor's word highlighting in
|
|
// charge there.
|
|
document_highlight_provider: Some(OneOf::Left(true)),
|
|
// One range per matched scope pair and per multi-line block comment,
|
|
// off the same matcher the rainbow reads.
|
|
folding_range_provider: Some(FoldingRangeProviderCapability::Simple(true)),
|
|
hover_provider: Some(lsp_types::HoverProviderCapability::Simple(true)),
|
|
document_symbol_provider: Some(OneOf::Left(true)),
|
|
workspace_symbol_provider: Some(OneOf::Left(true)),
|
|
// `prepareProvider` is what stops an editor from offering a rename the
|
|
// engine would refuse: the client asks first, and a refusal there costs
|
|
// the user nothing.
|
|
rename_provider: Some(OneOf::Right(RenameOptions {
|
|
prepare_provider: Some(true),
|
|
work_done_progress_options: WorkDoneProgressOptions::default(),
|
|
})),
|
|
// The kinds are listed rather than `Simple(true)` so a client can ask
|
|
// for one of them alone — which is how fix-on-save is configured.
|
|
code_action_provider: Some(CodeActionProviderCapability::Options(CodeActionOptions {
|
|
code_action_kinds: Some(vec![
|
|
CodeActionKind::QUICKFIX,
|
|
CodeActionKind::new(code_action::FIX_ALL),
|
|
CodeActionKind::new(ports::REFACTOR_PORTS),
|
|
]),
|
|
work_done_progress_options: WorkDoneProgressOptions::default(),
|
|
// Every action is returned complete; there is nothing to resolve.
|
|
resolve_provider: None,
|
|
})),
|
|
// The port refactorings. `lucisv.addPort` needs a declaration typed by
|
|
// the user, which no code action can carry, and a Vim user has no
|
|
// lightbulb at all — so all three are commands as well.
|
|
execute_command_provider: Some(ExecuteCommandOptions {
|
|
commands: ports::commands(),
|
|
work_done_progress_options: WorkDoneProgressOptions::default(),
|
|
}),
|
|
// Module hinting. No trigger characters: an identifier being typed is
|
|
// what asks for these, and the handler declines every position that is
|
|
// not a module item, so an unprompted request costs a token scan.
|
|
completion_provider: Some(CompletionOptions {
|
|
// Every item is returned complete — skeleton, documentation and
|
|
// all — so there is nothing for `completionItem/resolve` to do.
|
|
resolve_provider: None,
|
|
trigger_characters: None,
|
|
all_commit_characters: None,
|
|
work_done_progress_options: WorkDoneProgressOptions::default(),
|
|
completion_item: None,
|
|
}),
|
|
// `(` opens a connection or parameter list and `,` moves to the next
|
|
// entry; between them they cover every place the ports are worth
|
|
// showing.
|
|
signature_help_provider: Some(SignatureHelpOptions {
|
|
trigger_characters: Some(
|
|
signature::TRIGGERS.iter().map(|t| (*t).to_string()).collect(),
|
|
),
|
|
retrigger_characters: None,
|
|
work_done_progress_options: WorkDoneProgressOptions::default(),
|
|
}),
|
|
// Port and parameter names on ordered connection lists. Every hint is
|
|
// returned complete — a label, a position and nothing to fetch later —
|
|
// so there is no `inlayHint/resolve`.
|
|
inlay_hint_provider: Some(OneOf::Right(InlayHintServerCapabilities::Options(
|
|
InlayHintOptions {
|
|
work_done_progress_options: WorkDoneProgressOptions::default(),
|
|
resolve_provider: None,
|
|
},
|
|
))),
|
|
// The module hierarchy, both directions: modules are the nodes and an
|
|
// instantiation is the call. Every item is complete when it is
|
|
// returned, and the client drives the expansion one hop at a time.
|
|
call_hierarchy_provider: Some(CallHierarchyServerCapability::Simple(true)),
|
|
// Ghost text for `if (` and `begin`, LSP 3.18. `true` rather than
|
|
// options: there is nothing to configure on the server side, and the
|
|
// one thing a user can say — `lucisv.inlineTemplates` — is a setting the
|
|
// handler reads, not a registration option. The VS Code client only
|
|
// sends the request after opting into `ProposedFeatures`, so an
|
|
// extension older than this server simply never asks.
|
|
inline_completion_provider: Some(OneOf::Left(true)),
|
|
// Expand-selection. Nothing to configure: the chain is computed from
|
|
// the buffer alone, and every position is answered.
|
|
selection_range_provider: Some(SelectionRangeProviderCapability::Simple(true)),
|
|
// Pull diagnostics (3.17), served from the same parse+lint pass the
|
|
// push model publishes. `inter_file_dependencies` because a save
|
|
// rebuilds the workspace index and *that* changes what other files
|
|
// report; `workspace_diagnostics` because `workspace/diagnostic` is
|
|
// answered — over the open buffers, which is the only scope this
|
|
// server has ever diagnosed.
|
|
diagnostic_provider: Some(DiagnosticServerCapabilities::Options(DiagnosticOptions {
|
|
identifier: Some(diagnostics::SOURCE.to_string()),
|
|
inter_file_dependencies: true,
|
|
workspace_diagnostics: true,
|
|
work_done_progress_options: WorkDoneProgressOptions::default(),
|
|
})),
|
|
semantic_tokens_provider: Some(SemanticTokensServerCapabilities::SemanticTokensOptions(
|
|
SemanticTokensOptions {
|
|
work_done_progress_options: WorkDoneProgressOptions::default(),
|
|
legend: SemanticTokensLegend {
|
|
token_types: tokens::token_types(),
|
|
token_modifiers: tokens::token_modifiers(),
|
|
},
|
|
// The visible lines, for the first paint of a large file:
|
|
// the same tokenizer, filtered, and re-encoded from the
|
|
// start of the document so the answer stands on its own.
|
|
range: Some(true),
|
|
// `delta: true` rather than a bare `full: true`, so a client
|
|
// that has an answer already asks what changed instead of
|
|
// re-fetching the file's whole token set on every keystroke.
|
|
// `full` itself stays served — the enum's `Delta` variant is
|
|
// the full capability plus deltas, not a replacement.
|
|
full: Some(SemanticTokensFullOptions::Delta { delta: Some(true) }),
|
|
},
|
|
)),
|
|
..Default::default()
|
|
}
|
|
}
|
|
|
|
fn initialize_result() -> lsp_types::InitializeResult {
|
|
lsp_types::InitializeResult {
|
|
capabilities: capabilities(),
|
|
server_info: Some(lsp_types::ServerInfo {
|
|
name: "lucisv-server".to_string(),
|
|
version: Some(env!("CARGO_PKG_VERSION").to_string()),
|
|
}),
|
|
// `lsp-types`' `proposed` feature adds an `offsetEncoding` field here
|
|
// (clangd's unofficial extension). It is not ours to send.
|
|
..Default::default()
|
|
}
|
|
}
|
|
|
|
/// Whether the client can expand `${1:x}` tabstops in a completion item.
|
|
///
|
|
/// A client that did not say so gets the skeleton as plain text: a literal
|
|
/// `${1:clk}` written into a buffer is worse than no tabstops at all, and the
|
|
/// protocol gives no way to find out after the fact.
|
|
fn snippet_support(params: &InitializeParams) -> bool {
|
|
params
|
|
.capabilities
|
|
.text_document
|
|
.as_ref()
|
|
.and_then(|text_document| text_document.completion.as_ref())
|
|
.and_then(|completion| completion.completion_item.as_ref())
|
|
.and_then(|item| item.snippet_support)
|
|
.unwrap_or(false)
|
|
}
|
|
|
|
/// Whether the client applies a `workspace/applyEdit` request.
|
|
///
|
|
/// A client that did not say so gets a command's edit back as the request
|
|
/// result — which is what every client got before this was read, and is the
|
|
/// only thing left to try for one that cannot be pushed an edit.
|
|
fn apply_edit_support(params: &InitializeParams) -> bool {
|
|
params
|
|
.capabilities
|
|
.workspace
|
|
.as_ref()
|
|
.and_then(|workspace| workspace.apply_edit)
|
|
.unwrap_or(false)
|
|
}
|
|
|
|
/// Whether the client pulls diagnostics (LSP 3.17).
|
|
///
|
|
/// Sending the capability at all is what says so; its two fields are about
|
|
/// dynamic registration and related documents, neither of which this server
|
|
/// uses. A client that says nothing keeps the push model unchanged.
|
|
fn pull_diagnostics_support(params: &InitializeParams) -> bool {
|
|
params
|
|
.capabilities
|
|
.text_document
|
|
.as_ref()
|
|
.is_some_and(|text_document| text_document.diagnostic.is_some())
|
|
}
|
|
|
|
/// The directories to index: the client's workspace folders, or the
|
|
/// deprecated single root when that is all it sent.
|
|
fn workspace_roots(params: &InitializeParams) -> Vec<PathBuf> {
|
|
if let Some(folders) = ¶ms.workspace_folders {
|
|
let roots: Vec<PathBuf> = folders.iter().filter_map(|f| uri_to_path(&f.uri)).collect();
|
|
if !roots.is_empty() {
|
|
return roots;
|
|
}
|
|
}
|
|
#[allow(deprecated)] // `root_uri` is how older clients name the workspace.
|
|
params.root_uri.as_ref().and_then(uri_to_path).into_iter().collect()
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn every_advertised_capability_is_implemented() {
|
|
let caps = capabilities();
|
|
assert!(caps.document_formatting_provider.is_some());
|
|
assert!(caps.document_range_formatting_provider.is_some());
|
|
assert!(caps.definition_provider.is_some());
|
|
assert!(caps.references_provider.is_some());
|
|
assert!(caps.document_link_provider.is_some());
|
|
assert!(caps.document_highlight_provider.is_some());
|
|
assert!(caps.folding_range_provider.is_some());
|
|
assert!(caps.hover_provider.is_some());
|
|
assert!(caps.document_symbol_provider.is_some());
|
|
assert!(caps.workspace_symbol_provider.is_some());
|
|
assert!(caps.semantic_tokens_provider.is_some());
|
|
assert!(caps.code_action_provider.is_some());
|
|
assert!(caps.rename_provider.is_some());
|
|
assert!(caps.execute_command_provider.is_some());
|
|
assert!(caps.completion_provider.is_some());
|
|
assert!(caps.signature_help_provider.is_some());
|
|
assert!(caps.inlay_hint_provider.is_some());
|
|
assert!(caps.call_hierarchy_provider.is_some());
|
|
assert!(caps.inline_completion_provider.is_some());
|
|
assert!(caps.selection_range_provider.is_some());
|
|
assert!(caps.diagnostic_provider.is_some());
|
|
}
|
|
|
|
#[test]
|
|
fn the_semantic_token_capability_asks_for_ranges_and_for_deltas() {
|
|
// A client keys entirely off this: it sends `full/delta` only where
|
|
// `full.delta` is `true`, and `range` only where `range` is.
|
|
let Some(SemanticTokensServerCapabilities::SemanticTokensOptions(options)) =
|
|
capabilities().semantic_tokens_provider
|
|
else {
|
|
panic!("the options form, not a registration");
|
|
};
|
|
assert_eq!(options.range, Some(true));
|
|
assert_eq!(options.full, Some(SemanticTokensFullOptions::Delta { delta: Some(true) }));
|
|
assert_eq!(options.legend.token_types.len(), 14, "the legend is unchanged");
|
|
}
|
|
|
|
#[test]
|
|
fn the_sync_options_ask_for_the_save_hook_and_not_the_notification() {
|
|
let Some(TextDocumentSyncCapability::Options(options)) = capabilities().text_document_sync
|
|
else {
|
|
panic!("the options form, not a bare kind");
|
|
};
|
|
assert_eq!(options.change, Some(TextDocumentSyncKind::INCREMENTAL));
|
|
assert_eq!(options.will_save_wait_until, Some(true), "the format-on-save hook is answered");
|
|
assert_eq!(options.will_save, None, "the plain notification has nothing for us");
|
|
}
|
|
|
|
#[test]
|
|
fn the_diagnostic_options_say_what_this_server_actually_does() {
|
|
let Some(DiagnosticServerCapabilities::Options(options)) =
|
|
capabilities().diagnostic_provider
|
|
else {
|
|
panic!("plain options, not a dynamic registration");
|
|
};
|
|
assert_eq!(options.identifier.as_deref(), Some(diagnostics::SOURCE), "same tag as a push");
|
|
assert!(options.inter_file_dependencies, "a save changes other files' diagnostics");
|
|
assert!(options.workspace_diagnostics, "`workspace/diagnostic` is answered");
|
|
}
|
|
|
|
#[test]
|
|
fn apply_edit_support_is_read_from_the_clients_own_capabilities() {
|
|
use lsp_types::{ClientCapabilities, WorkspaceClientCapabilities};
|
|
assert!(!apply_edit_support(&InitializeParams::default()), "silence means no");
|
|
|
|
let saying = |apply_edit: Option<bool>| InitializeParams {
|
|
capabilities: ClientCapabilities {
|
|
workspace: Some(WorkspaceClientCapabilities { apply_edit, ..Default::default() }),
|
|
..Default::default()
|
|
},
|
|
..Default::default()
|
|
};
|
|
assert!(apply_edit_support(&saying(Some(true))));
|
|
assert!(!apply_edit_support(&saying(Some(false))));
|
|
assert!(!apply_edit_support(&saying(None)));
|
|
}
|
|
|
|
#[test]
|
|
fn a_client_that_sent_the_diagnostic_capability_at_all_is_a_pulling_client() {
|
|
use lsp_types::{
|
|
ClientCapabilities, DiagnosticClientCapabilities, TextDocumentClientCapabilities,
|
|
};
|
|
assert!(!pull_diagnostics_support(&InitializeParams::default()), "silence means push");
|
|
|
|
let pulling = InitializeParams {
|
|
capabilities: ClientCapabilities {
|
|
text_document: Some(TextDocumentClientCapabilities {
|
|
// Both fields left unset: sending the capability is the
|
|
// whole of the statement, and neither field is about
|
|
// whether the client pulls.
|
|
diagnostic: Some(DiagnosticClientCapabilities::default()),
|
|
..Default::default()
|
|
}),
|
|
..Default::default()
|
|
},
|
|
..Default::default()
|
|
};
|
|
assert!(pull_diagnostics_support(&pulling));
|
|
}
|
|
|
|
#[test]
|
|
fn the_call_hierarchy_is_advertised_as_a_plain_capability() {
|
|
// Nothing about it is optional or resolvable: the three requests are
|
|
// either all served or none are.
|
|
assert_eq!(
|
|
capabilities().call_hierarchy_provider,
|
|
Some(CallHierarchyServerCapability::Simple(true))
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn document_links_resolve_nothing_because_every_target_is_already_known() {
|
|
let options = capabilities().document_link_provider.expect("document links");
|
|
assert_eq!(options.resolve_provider, Some(false));
|
|
}
|
|
|
|
#[test]
|
|
fn inlay_hints_resolve_nothing_because_every_hint_is_complete() {
|
|
let Some(OneOf::Right(InlayHintServerCapabilities::Options(options))) =
|
|
capabilities().inlay_hint_provider
|
|
else {
|
|
panic!("inlay hints must carry options, not a bare `true`");
|
|
};
|
|
assert_eq!(options.resolve_provider, None);
|
|
}
|
|
|
|
#[test]
|
|
fn signature_help_advertises_the_characters_the_handler_answers_on() {
|
|
let options = capabilities().signature_help_provider.expect("signature help");
|
|
assert_eq!(options.trigger_characters, Some(vec!["(".to_string(), ",".to_string()]));
|
|
}
|
|
|
|
#[test]
|
|
fn completion_resolves_nothing_because_every_item_is_complete() {
|
|
let options = capabilities().completion_provider.expect("completion");
|
|
assert_eq!(options.resolve_provider, None);
|
|
assert_eq!(options.trigger_characters, None);
|
|
}
|
|
|
|
#[test]
|
|
fn snippet_support_is_read_from_the_clients_own_capabilities() {
|
|
use lsp_types::{
|
|
ClientCapabilities, CompletionClientCapabilities, CompletionItemCapability,
|
|
TextDocumentClientCapabilities,
|
|
};
|
|
assert!(!snippet_support(&InitializeParams::default()), "silence means no");
|
|
|
|
let saying = |snippet_support: Option<bool>| InitializeParams {
|
|
capabilities: ClientCapabilities {
|
|
text_document: Some(TextDocumentClientCapabilities {
|
|
completion: Some(CompletionClientCapabilities {
|
|
completion_item: Some(CompletionItemCapability {
|
|
snippet_support,
|
|
..Default::default()
|
|
}),
|
|
..Default::default()
|
|
}),
|
|
..Default::default()
|
|
}),
|
|
..Default::default()
|
|
},
|
|
..Default::default()
|
|
};
|
|
assert!(super::snippet_support(&saying(Some(true))));
|
|
assert!(!super::snippet_support(&saying(Some(false))));
|
|
assert!(!super::snippet_support(&saying(None)));
|
|
}
|
|
|
|
#[test]
|
|
fn rename_advertises_prepare_so_the_editor_asks_before_offering() {
|
|
let Some(OneOf::Right(options)) = capabilities().rename_provider else {
|
|
panic!("rename must carry options, not a bare `true`");
|
|
};
|
|
assert_eq!(options.prepare_provider, Some(true));
|
|
}
|
|
|
|
#[test]
|
|
fn the_legend_and_the_encoder_agree_on_length() {
|
|
// The wire format carries indices into these arrays, so a mismatch
|
|
// between the legend and the encoder is a silent mis-colouring.
|
|
assert_eq!(tokens::token_types().len(), 14);
|
|
assert_eq!(tokens::token_modifiers().len(), 1);
|
|
}
|
|
|
|
#[test]
|
|
fn the_code_action_kinds_are_named_in_the_capability() {
|
|
// A client filtering by kind (fix-on-save does) sees nothing unless the
|
|
// kinds it may ask for are advertised.
|
|
let Some(CodeActionProviderCapability::Options(options)) =
|
|
capabilities().code_action_provider
|
|
else {
|
|
panic!("the kinds must be listed, not just `true`");
|
|
};
|
|
let kinds = options.code_action_kinds.expect("kinds");
|
|
assert!(kinds.contains(&CodeActionKind::QUICKFIX));
|
|
assert!(kinds.contains(&CodeActionKind::new(code_action::FIX_ALL)));
|
|
assert!(kinds.contains(&CodeActionKind::new(ports::REFACTOR_PORTS)));
|
|
}
|
|
|
|
#[test]
|
|
fn every_advertised_command_is_one_the_server_runs() {
|
|
let options = capabilities().execute_command_provider.expect("commands");
|
|
assert_eq!(options.commands, ports::commands());
|
|
assert!(
|
|
options.commands.iter().all(|c| c.starts_with("lucisv.")),
|
|
"{:?}",
|
|
options.commands
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn utf16_is_advertised_because_that_is_what_convert_implements() {
|
|
assert_eq!(capabilities().position_encoding, Some(PositionEncodingKind::UTF16));
|
|
}
|
|
}
|