Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/ty_server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ ty_python_semantic = { workspace = true }
ty_vendored = { workspace = true }

anyhow = { workspace = true }
bitflags = { workspace = true }
crossbeam = { workspace = true }
jod-thread = { workspace = true }
lsp-server = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/ty_server/src/server/api/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub(super) fn clear_diagnostics(key: &DocumentKey, client: &Client) {
///
/// [publish diagnostics notification]: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_publishDiagnostics
pub(super) fn publish_diagnostics(session: &Session, key: &DocumentKey, client: &Client) {
if session.client_capabilities().pull_diagnostics {
if session.client_capabilities().supports_pull_diagnostics() {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl SyncNotificationHandler for DidChangeWatchedFiles {
let client_capabilities = session.client_capabilities();

if project_changed {
if client_capabilities.diagnostics_refresh {
if client_capabilities.supports_workspace_diagnostic_refresh() {
client.send_request::<types::request::WorkspaceDiagnosticRefresh>(
session,
(),
Expand All @@ -111,7 +111,7 @@ impl SyncNotificationHandler for DidChangeWatchedFiles {
// TODO: always publish diagnostics for notebook files (since they don't use pull diagnostics)
}

if client_capabilities.inlay_refresh {
if client_capabilities.supports_inlay_hint_refresh() {
client.send_request::<types::request::InlayHintRefreshRequest>(session, (), |_, ()| {});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl BackgroundDocumentRequestHandler for GotoDeclarationRequestHandler {

if snapshot
.resolved_client_capabilities()
.type_definition_link_support
.supports_declaration_link()
{
let src = Some(ranged.range);
let links: Vec<_> = ranged
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl BackgroundDocumentRequestHandler for GotoDefinitionRequestHandler {

if snapshot
.resolved_client_capabilities()
.type_definition_link_support
.supports_definition_link()
{
let src = Some(ranged.range);
let links: Vec<_> = ranged
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl BackgroundDocumentRequestHandler for GotoTypeDefinitionRequestHandler {

if snapshot
.resolved_client_capabilities()
.type_definition_link_support
.supports_type_definition_link()
{
let src = Some(ranged.range);
let links: Vec<_> = ranged
Expand Down
2 changes: 1 addition & 1 deletion crates/ty_server/src/server/api/requests/hover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl BackgroundDocumentRequestHandler for HoverRequestHandler {

let (markup_kind, lsp_markup_kind) = if snapshot
.resolved_client_capabilities()
.hover_prefer_markdown
.prefers_markdown_in_hover()
{
(MarkupKind::Markdown, lsp_types::MarkupKind::Markdown)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl BackgroundDocumentRequestHandler for SemanticTokensRequestHandler {
snapshot.encoding(),
snapshot
.resolved_client_capabilities()
.semantic_tokens_multiline_support,
.supports_multiline_semantic_tokens(),
);

Ok(Some(SemanticTokensResult::Tokens(SemanticTokens {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl BackgroundDocumentRequestHandler for SemanticTokensRangeRequestHandler {
snapshot.encoding(),
snapshot
.resolved_client_capabilities()
.semantic_tokens_multiline_support,
.supports_multiline_semantic_tokens(),
);

Ok(Some(SemanticTokensRangeResult::Tokens(SemanticTokens {
Expand Down
13 changes: 7 additions & 6 deletions crates/ty_server/src/server/api/requests/signature_help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl BackgroundDocumentRequestHandler for SignatureHelpRequestHandler {
.parameters
.into_iter()
.map(|param| {
let label = if resolved_capabilities.signature_label_offset_support {
let label = if resolved_capabilities.supports_signature_label_offset() {
// Find the parameter's offset in the signature label
if let Some(start) = sig.label.find(&param.label) {
let encoding = snapshot.encoding();
Expand Down Expand Up @@ -114,11 +114,12 @@ impl BackgroundDocumentRequestHandler for SignatureHelpRequestHandler {
})
.collect();

let active_parameter = if resolved_capabilities.signature_active_parameter_support {
sig.active_parameter.and_then(|p| u32::try_from(p).ok())
} else {
None
};
let active_parameter =
if resolved_capabilities.supports_signature_active_parameter() {
sig.active_parameter.and_then(|p| u32::try_from(p).ok())
} else {
None
};

SignatureInformation {
label: sig.label,
Expand Down
18 changes: 8 additions & 10 deletions crates/ty_server/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub(crate) struct Session {
position_encoding: PositionEncoding,

/// Tracks what LSP features the client supports and doesn't support.
resolved_client_capabilities: Arc<ResolvedClientCapabilities>,
resolved_client_capabilities: ResolvedClientCapabilities,

/// Tracks the pending requests between client and server.
request_queue: RequestQueue,
Expand Down Expand Up @@ -94,9 +94,7 @@ impl Session {
index: Some(index),
default_project: DefaultProject::new(),
projects: BTreeMap::new(),
resolved_client_capabilities: Arc::new(ResolvedClientCapabilities::new(
client_capabilities,
)),
resolved_client_capabilities: ResolvedClientCapabilities::new(client_capabilities),
request_queue: RequestQueue::new(),
shutdown_requested: false,
})
Expand Down Expand Up @@ -332,7 +330,7 @@ impl Session {
pub(crate) fn take_document_snapshot(&self, url: Url) -> DocumentSnapshot {
let index = self.index();
DocumentSnapshot {
resolved_client_capabilities: self.resolved_client_capabilities.clone(),
resolved_client_capabilities: self.resolved_client_capabilities,
client_settings: index.global_settings(),
position_encoding: self.position_encoding,
document_query_result: self
Expand Down Expand Up @@ -432,8 +430,8 @@ impl Session {
}
}

pub(crate) fn client_capabilities(&self) -> &ResolvedClientCapabilities {
&self.resolved_client_capabilities
pub(crate) fn client_capabilities(&self) -> ResolvedClientCapabilities {
self.resolved_client_capabilities
}

pub(crate) fn global_settings(&self) -> Arc<ClientSettings> {
Expand Down Expand Up @@ -483,16 +481,16 @@ impl Drop for MutIndexGuard<'_> {
/// An immutable snapshot of [`Session`] that references a specific document.
#[derive(Debug)]
pub(crate) struct DocumentSnapshot {
resolved_client_capabilities: Arc<ResolvedClientCapabilities>,
resolved_client_capabilities: ResolvedClientCapabilities,
client_settings: Arc<ClientSettings>,
position_encoding: PositionEncoding,
document_query_result: Result<DocumentQuery, DocumentQueryError>,
}

impl DocumentSnapshot {
/// Returns the resolved client capabilities that were captured during initialization.
pub(crate) fn resolved_client_capabilities(&self) -> &ResolvedClientCapabilities {
&self.resolved_client_capabilities
pub(crate) fn resolved_client_capabilities(&self) -> ResolvedClientCapabilities {
self.resolved_client_capabilities
}

/// Returns the position encoding that was negotiated during initialization.
Expand Down
Loading
Loading