Skip to content

Commit

Permalink
Bump crossbeam from 0.7 to 0.8, lsp from 0.3 to 0.5, lsp-types from 0…
Browse files Browse the repository at this point in the history
….73 to 0.89

Reviewed By: alunyov, dtolnay

Differential Revision: D29056473

fbshipit-source-id: 9434e9e0895d82482f4c70afa01a2f77702b965f
  • Loading branch information
Pedro Rittner authored and facebook-github-bot committed Jun 12, 2021
1 parent 8fe6980 commit f1f07ff
Show file tree
Hide file tree
Showing 21 changed files with 60 additions and 46 deletions.
2 changes: 1 addition & 1 deletion compiler/crates/common/Cargo.toml
Expand Up @@ -10,5 +10,5 @@ license = "MIT"
colored = "1.9"
interner = { path = "../interner" }
log = { version = "0.4.8", features = ["kv_unstable"] }
lsp-types = "0.73.0"
lsp-types = "0.89.0"
rayon = "1.2"
4 changes: 2 additions & 2 deletions compiler/crates/common/src/span.rs
Expand Up @@ -71,10 +71,10 @@ impl Span {
character = 0;
}
if index == start {
start_position = lsp_types::Position::new(line as u64, character as u64);
start_position = lsp_types::Position::new(line as u32, character as u32);
}
if index == end {
end_position = lsp_types::Position::new(line as u64, character as u64);
end_position = lsp_types::Position::new(line as u32, character as u32);
break;
}
// Make sure to only increment the character offset if this
Expand Down
2 changes: 1 addition & 1 deletion compiler/crates/graphql-syntax/Cargo.toml
Expand Up @@ -14,7 +14,7 @@ path = "tests/print_test.rs"
common = { path = "../common" }
interner = { path = "../interner" }
logos = "0.11"
lsp-types = "0.73.0"
lsp-types = "0.89.0"
serde = { version = "=1.0.118", features = ["derive", "rc"] }
thiserror = "1.0"

Expand Down
4 changes: 2 additions & 2 deletions compiler/crates/graphql-syntax/src/source.rs
Expand Up @@ -35,7 +35,7 @@ impl GraphQLSource {
// Zero-indexed character offset on the line
let mut character = self.column_index;
let mut chars = self.text.chars().peekable();
let start_position = Position::new(line as u64, character as u64);
let start_position = Position::new(line as u32, character as u32);
while let Some(chr) = chars.next() {
let is_newline = match chr {
// Line terminators: https://www.ecma-international.org/ecma-262/#sec-line-terminators
Expand All @@ -57,7 +57,7 @@ impl GraphQLSource {
character += 1;
}
}
let end_position = Position::new(line as u64, character as u64);
let end_position = Position::new(line as u32, character as u32);
Range::new(start_position, end_position)
}
}
6 changes: 3 additions & 3 deletions compiler/crates/relay-lsp/Cargo.toml
Expand Up @@ -8,7 +8,7 @@ license = "MIT"

[dependencies]
common = { path = "../common" }
crossbeam = "0.7"
crossbeam = "0.8"
dashmap = { version = "4.0.2", features = ["serde"] }
extract-graphql = { path = "../extract-graphql" }
fnv = "1.0"
Expand All @@ -18,8 +18,8 @@ graphql-text-printer = { path = "../graphql-text-printer" }
interner = { path = "../interner" }
lazy_static = "1.0"
log = { version = "0.4.8", features = ["kv_unstable"] }
lsp-server = "0.3.2"
lsp-types = "0.73.0"
lsp-server = "0.5"
lsp-types = "0.89.0"
rand = { version = "0.7", features = ["small_rng"] }
rayon = "1.2"
relay-compiler = { path = "../relay-compiler" }
Expand Down
2 changes: 1 addition & 1 deletion compiler/crates/relay-lsp/src/client.rs
Expand Up @@ -16,7 +16,7 @@ use lsp_types::{

#[cfg(test)]
pub fn initialize(client: &Connection, params: &InitializeParams, request_id: u64) {
let request_id = RequestId::from(request_id);
let request_id = RequestId::from(request_id.to_string());
let request = ServerRequest {
id: request_id,
method: Initialize::METHOD.to_string(),
Expand Down
4 changes: 3 additions & 1 deletion compiler/crates/relay-lsp/src/code_action/mod.rs
Expand Up @@ -193,13 +193,15 @@ fn create_name_suggestion_action(

CodeActionOrCommand::CodeAction(CodeAction {
title,
kind: Some("quickfix".to_string()),
kind: Some(lsp_types::CodeActionKind::QUICKFIX),
diagnostics: None,
edit: Some(WorkspaceEdit {
changes: Some(changes),
document_changes: None,
..Default::default()
}),
command: None,
is_preferred: Some(false),
..Default::default()
})
}
5 changes: 5 additions & 0 deletions compiler/crates/relay-lsp/src/completion/mod.rs
Expand Up @@ -669,6 +669,7 @@ fn resolve_completion_items_for_argument_name<T: ArgumentLike>(
)),
data: None,
tags: None,
..Default::default()
}
}
})
Expand Down Expand Up @@ -731,6 +732,7 @@ fn resolve_completion_items_for_inline_fragment_type(
)),
data: None,
tags: None,
..Default::default()
}
}
})
Expand Down Expand Up @@ -842,6 +844,7 @@ fn resolve_completion_items_from_fields<T: TypeWithFields>(
command,
data: None,
tags: None,
..Default::default()
}
})
.collect()
Expand Down Expand Up @@ -889,6 +892,7 @@ fn resolve_completion_items_for_fragment_spread(
)),
data: None,
tags: None,
..Default::default()
}
});
}
Expand Down Expand Up @@ -944,6 +948,7 @@ fn completion_item_from_directive(
)),
data: None,
tags: None,
..Default::default()
}
}

Expand Down
9 changes: 5 additions & 4 deletions compiler/crates/relay-lsp/src/diagnostic_reporter.rs
Expand Up @@ -11,7 +11,7 @@ use crate::lsp::{
Url,
};
use common::{Diagnostic as CompilerDiagnostic, Location};
use crossbeam::crossbeam_channel::Sender;
use crossbeam::channel::Sender;
use dashmap::mapref::entry::Entry;
use dashmap::DashMap;
use lsp_server::Message;
Expand Down Expand Up @@ -194,6 +194,7 @@ impl DiagnosticReporter {
severity: Some(DiagnosticSeverity::Error),
source: None,
tags: None,
..Default::default()
};
self.add_diagnostic(url, diagnostic);
}
Expand Down Expand Up @@ -225,6 +226,7 @@ impl DiagnosticReporter {
severity: Some(DiagnosticSeverity::Error),
source: None,
tags: None,
..Default::default()
};
let url = Url::from_directory_path(&self.root_dir)
.expect("print_generic_error: Could not convert self.root_dir to Url");
Expand All @@ -236,7 +238,6 @@ impl DiagnosticReporter {
mod tests {
use super::DiagnosticReporter;
use common::{Diagnostic, Location, SourceLocationKey, Span};
use crossbeam::crossbeam_channel;
use interner::Intern;
use relay_compiler::SourceReader;
use std::path::PathBuf;
Expand All @@ -252,7 +253,7 @@ mod tests {
#[test]
fn report_diagnostic_test() {
let root_dir = PathBuf::from("/tmp");
let (sender, _) = crossbeam_channel::unbounded();
let (sender, _) = crossbeam::channel::unbounded();
let mut reporter = DiagnosticReporter::new(root_dir, sender);
reporter.set_source_reader(Box::new(MockSourceReader("Content".to_string())));
let source_location = SourceLocationKey::Standalone {
Expand All @@ -271,7 +272,7 @@ mod tests {
#[test]
fn do_not_report_diagnostic_without_url_test() {
let root_dir = PathBuf::from("/tmp");
let (sender, _) = crossbeam_channel::unbounded();
let (sender, _) = crossbeam::channel::unbounded();

let mut reporter = DiagnosticReporter::new(root_dir, sender);
reporter.set_source_reader(Box::new(MockSourceReader("".to_string())));
Expand Down
9 changes: 6 additions & 3 deletions compiler/crates/relay-lsp/src/goto_definition.rs
Expand Up @@ -234,7 +234,7 @@ pub(crate) fn on_goto_definition<TPerfLogger: PerfLogger + 'static>(
params: <GotoDefinition as Request>::Params,
) -> LSPRuntimeResult<<GotoDefinition as Request>::Result> {
let (document, position_span, project_name) =
state.extract_executable_document_from_text(&params, 1)?;
state.extract_executable_document_from_text(&params.text_document_position_params, 1)?;
let path = document.resolve((), position_span);

let goto_definition_response = get_goto_definition_response(
Expand All @@ -249,7 +249,10 @@ pub(crate) fn on_goto_definition<TPerfLogger: PerfLogger + 'static>(
}

fn get_location(path: &str, line: u64) -> Result<lsp_types::Location, LSPRuntimeError> {
let start = lsp_types::Position { line, character: 0 };
let start = lsp_types::Position {
line: line as u32,
character: 0,
};
let range = lsp_types::Range { start, end: start };

let uri = Url::parse(&format!("file://{}", path)).map_err(|e| {
Expand Down Expand Up @@ -302,7 +305,7 @@ mod test {
use graphql_ir::Program;
use graphql_syntax::{parse_executable_with_features, ParserFeatures};
use interner::Intern;
use lsp_types::{request::GotoDefinitionResponse, Location};
use lsp_types::{GotoDefinitionResponse, Location};
use relay_test_schema::get_test_schema_with_extensions;
use schema_documentation::SchemaDocumentation;

Expand Down
2 changes: 1 addition & 1 deletion compiler/crates/relay-lsp/src/hover.rs
Expand Up @@ -288,7 +288,7 @@ pub(crate) fn on_hover<TPerfLogger: PerfLogger + 'static>(
state: &mut LSPState<TPerfLogger>,
params: <HoverRequest as Request>::Params,
) -> LSPRuntimeResult<<HoverRequest as Request>::Result> {
let node_resolution_info = state.resolve_node(params)?;
let node_resolution_info = state.resolve_node(params.text_document_position_params)?;

log::debug!("Hovering over {:?}", node_resolution_info);
if let Some(schema) = state.get_schemas().get(&node_resolution_info.project_name) {
Expand Down
1 change: 1 addition & 0 deletions compiler/crates/relay-lsp/src/lib.rs
Expand Up @@ -99,6 +99,7 @@ mod tests {
trace: None,
workspace_folders: None,
client_info: None,
locale: None,
};
client::initialize(&client, &init_params, 0);
let params = server::initialize(&connection)?;
Expand Down
8 changes: 4 additions & 4 deletions compiler/crates/relay-lsp/src/location.rs
Expand Up @@ -79,12 +79,12 @@ fn read_file_and_get_range(
source.text.to_string(),
lsp_types::Range {
start: lsp_types::Position {
line: source.line_index as u64,
character: source.column_index as u64,
line: source.line_index as u32,
character: source.column_index as u32,
},
end: lsp_types::Position {
line: (source.line_index + line_count) as u64,
character: last_line.len() as u64,
line: (source.line_index + line_count) as u32,
character: last_line.len() as u32,
},
},
))
Expand Down
2 changes: 1 addition & 1 deletion compiler/crates/relay-lsp/src/lsp.rs
Expand Up @@ -10,7 +10,7 @@
// types from both so that we have a central source-of-truth for all LSP-related utilities.

use crate::lsp_process_error::LSPProcessResult;
use crossbeam::{crossbeam_channel::Sender, SendError};
use crossbeam::channel::{SendError, Sender};
pub use lsp_server::{Connection, Message};
pub use lsp_server::{
Notification as ServerNotification, ProtocolError, Request as ServerRequest,
Expand Down
2 changes: 1 addition & 1 deletion compiler/crates/relay-lsp/src/lsp_process_error.rs
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

use crossbeam::SendError;
use crossbeam::channel::SendError;
use lsp_server::{Message, ProtocolError};
use relay_compiler::errors::Error as CompilerError;
use serde_json::Error as SerdeError;
Expand Down
Expand Up @@ -21,8 +21,8 @@ pub(crate) enum ResolvedTypesAtLocation {}
#[derive(Deserialize, Serialize)]
pub(crate) struct ResolvedTypesAtLocationParams {
file_name: String,
line: u64,
character: u64,
line: u32,
character: u32,
}

impl ResolvedTypesAtLocationParams {
Expand Down
3 changes: 2 additions & 1 deletion compiler/crates/relay-lsp/src/server/lsp_state.rs
Expand Up @@ -15,7 +15,7 @@ use crate::{
};
use crate::{ExtensionConfig, LSPExtraDataProvider};
use common::{Diagnostic as CompilerDiagnostic, PerfLogger, SourceLocationKey, Span};
use crossbeam::Sender;
use crossbeam::channel::Sender;
use dashmap::{mapref::entry::Entry, DashMap};
use fnv::FnvBuildHasher;
use graphql_ir::{
Expand Down Expand Up @@ -326,5 +326,6 @@ fn convert_diagnostic(
severity: Some(DiagnosticSeverity::Error),
source: None,
tags: None,
..Default::default()
}
}
Expand Up @@ -8,7 +8,7 @@
use std::sync::{Arc, RwLock};

use common::{PerfLogEvent, PerfLogger};
use crossbeam::Sender;
use crossbeam::channel::Sender;
use dashmap::mapref::entry::Entry;
use fnv::FnvHashMap;
use interner::StringKey;
Expand Down
9 changes: 5 additions & 4 deletions compiler/crates/relay-lsp/src/server/mod.rs
Expand Up @@ -41,7 +41,7 @@ use crate::{
ExtensionConfig,
};
use common::{PerfLogEvent, PerfLogger};
use crossbeam::{SendError, Sender};
use crossbeam::channel::{SendError, Sender};
use log::debug;
use lsp_notification_dispatch::LSPNotificationDispatch;
use lsp_request_dispatch::LSPRequestDispatch;
Expand Down Expand Up @@ -76,11 +76,12 @@ pub fn initialize(connection: &Connection) -> LSPProcessResult<InitializeParams>
work_done_progress_options: WorkDoneProgressOptions {
work_done_progress: None,
},
..Default::default()
}),

hover_provider: Some(true),
definition_provider: Some(true),
references_provider: Some(true),
hover_provider: Some(lsp_types::HoverProviderCapability::Simple(true)),
definition_provider: Some(lsp_types::OneOf::Left(true)),
references_provider: Some(lsp_types::OneOf::Left(true)),
code_action_provider: Some(CodeActionProviderCapability::Simple(true)),
..Default::default()
};
Expand Down
2 changes: 1 addition & 1 deletion compiler/crates/relay-lsp/src/status_reporting.rs
Expand Up @@ -10,7 +10,7 @@ use crate::{
diagnostic_reporter::DiagnosticReporter,
lsp::{set_ready_status, update_in_progress_status},
};
use crossbeam::crossbeam_channel::Sender;
use crossbeam::channel::Sender;
use lsp_server::Message;
use relay_compiler::{
errors::{BuildProjectError, Result as CompilerResult},
Expand Down

0 comments on commit f1f07ff

Please sign in to comment.