Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Switch to standard implementation method. #936

Merged
merged 2 commits into from
Jul 14, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 3 additions & 3 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ json = "0.11"
[features]
default = []
clippy = ["clippy_lints"]

[patch.crates-io]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just to get the ci builds to pass until languageserver-types merges their PR and releases a version.

languageserver-types = { git = 'https://github.com/dgriffen/languageserver-types', branch = 'server-capabilities-3.6' }
4 changes: 2 additions & 2 deletions src/actions/requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub use lsp_data::request::{
DocumentSymbol as Symbols,
HoverRequest as Hover,
GotoDefinition as Definition,
GotoImplementation as Implementation,
References,
Completion,
DocumentHighlightRequest as DocumentHighlight,
Expand All @@ -46,7 +47,6 @@ pub use lsp_data::request::{
ResolveCompletionItem as ResolveCompletion,
CodeLensRequest,
};
pub use lsp_data::FindImpls;

use std::collections::HashMap;
use std::path::Path;
Expand Down Expand Up @@ -174,7 +174,7 @@ impl RequestAction for Hover {
}
}

impl RequestAction for FindImpls {
impl RequestAction for Implementation {
type Response = Vec<Location>;

fn fallback_response() -> Result<Self::Response, ResponseError> {
Expand Down
12 changes: 0 additions & 12 deletions src/lsp_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,18 +350,6 @@ impl LSPNotification for BeginBuild {
const METHOD: &'static str = "rustDocument/beginBuild";
}

/* ------------------ Custom JSON-RPC requests ---------------- */

/// Find all the implementations of a given trait.
#[derive(Debug)]
pub enum FindImpls { }

impl LSPRequest for FindImpls {
type Params = TextDocumentPositionParams;
type Result = Vec<Location>;
const METHOD: &'static str = "rustDocument/implementations";
}

/* ---------- Temporary LSP type until window/progress proposal is done --------- */

// Notification from server to client for build progress.
Expand Down
2 changes: 1 addition & 1 deletion src/server/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ define_dispatch_request_enum!(
WorkspaceSymbol,
Symbols,
Hover,
FindImpls,
Implementation,
DocumentHighlight,
Rename,
CodeAction,
Expand Down
10 changes: 7 additions & 3 deletions src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ pub use ls_types::notification::Exit as ExitNotification;
pub use ls_types::request::Initialize as InitializeRequest;
pub use ls_types::request::Shutdown as ShutdownRequest;
use ls_types::{
CompletionOptions, ExecuteCommandOptions, InitializeParams, InitializeResult,
ServerCapabilities, TextDocumentSyncCapability, TextDocumentSyncKind, CodeLensOptions
CompletionOptions, ExecuteCommandOptions, ImplementationProviderCapability, InitializeParams, InitializeResult,
ServerCapabilities, TextDocumentSyncCapability, TextDocumentSyncKind, CodeLensOptions,
};
use lsp_data;
use lsp_data::{InitializationOptions, LSPNotification, LSPRequest};
Expand Down Expand Up @@ -270,7 +270,7 @@ impl<O: Output> LsService<O> {
requests::Rename,
requests::CodeAction,
requests::DocumentHighlight,
requests::FindImpls,
requests::Implementation,
requests::Symbols,
requests::Hover,
requests::WorkspaceSymbol,
Expand Down Expand Up @@ -360,6 +360,8 @@ fn server_caps(ctx: &ActionContext) -> ServerCapabilities {
trigger_characters: Some(vec![".".to_string(), ":".to_string()]),
}),
definition_provider: Some(true),
type_definition_provider: None,
implementation_provider: Some(ImplementationProviderCapability::Simple(true)),
references_provider: Some(true),
document_highlight_provider: Some(true),
document_symbol_provider: Some(true),
Expand All @@ -376,6 +378,8 @@ fn server_caps(ctx: &ActionContext) -> ServerCapabilities {
],
}),
rename_provider: Some(true),
color_provider: None,

// These are supported if the `unstable_features` option is set.
// We'll update these capabilities dynamically when we get config
// info from the client.
Expand Down
6 changes: 3 additions & 3 deletions src/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1148,14 +1148,14 @@ fn test_find_impls() {

let messages = vec![
initialize(0, root_path.as_os_str().to_str().map(|x| x.to_owned())).to_string(),
request::<requests::FindImpls>(
request::<requests::Implementation>(
1,
TextDocumentPositionParams {
text_document: TextDocumentIdentifier::new(url.clone()),
position: env.cache.mk_ls_position(src(&source_file_path, 13, "Bar")),
},
).to_string(),
request::<requests::FindImpls>(
request::<requests::Implementation>(
2,
TextDocumentPositionParams {
text_document: TextDocumentIdentifier::new(url.clone()),
Expand All @@ -1164,7 +1164,7 @@ fn test_find_impls() {
},
).to_string(),
// FIXME Does not work on Travis
// request::<requests::FindImpls>(
// request::<requests::Implementation>(
// 3,
// TextDocumentPositionParams {
// text_document: TextDocumentIdentifier::new(url),
Expand Down