Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LSP functionality to Rover #2272

Merged
merged 10 commits into from
Jan 20, 2025
669 changes: 494 additions & 175 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ apollo-encoder = "0.8"
# https://github.com/apollographql/federation-rs
apollo-federation-types = "0.14.1"

apollo-language-server = { version = "0.3.4", default-features = false, features = ["tokio"] }
Copy link
Contributor

Choose a reason for hiding this comment

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

is the latest version? I want to say I saw a bump recently; might be worth a follow-up with it, if there was one

Copy link
Member

Choose a reason for hiding this comment

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


# crates.io dependencies
anyhow = "1"
ariadne = "0.5"
Expand Down Expand Up @@ -168,6 +170,7 @@ zip = "2.0"
anyhow = { workspace = true }
assert_fs = { workspace = true }
async-trait = { workspace = true }
apollo-language-server = { workspace = true}
apollo-federation-types = { workspace = true }
apollo-parser = { workspace = true }
billboard = { workspace = true }
Expand Down Expand Up @@ -223,6 +226,7 @@ tokio-stream = { workspace = true }
tokio-util = { workspace = true }
toml = { workspace = true }
tower = { workspace = true }
tower-lsp = { version = "0.20.0" }
tracing = { workspace = true }
which = { workspace = true }
uuid = { workspace = true }
Expand Down
6 changes: 3 additions & 3 deletions crates/robot-panic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ macro_rules! setup_panic {
#[cfg(not(debug_assertions))]
match ::std::env::var("RUST_BACKTRACE") {
Err(_) => {
panic::set_hook(Box::new(move |info: &PanicInfo| {
panic::set_hook(Box::new(move |info: &PanicHookInfo| {
let crash_report = get_report(&$meta, info);
print_msg(&crash_report, &$meta)
.expect("robot-panic: printing error message to console failed");
Expand All @@ -105,7 +105,7 @@ macro_rules! setup_panic {

() => {
#[allow(unused_imports)]
use std::panic::{self, PanicInfo};
use std::panic::{self, PanicHookInfo};
#[allow(unused_imports)]
use $crate::{get_report, print_msg, Metadata};

Expand All @@ -120,7 +120,7 @@ macro_rules! setup_panic {
repository: env!("CARGO_PKG_REPOSITORY").into(),
};

panic::set_hook(Box::new(move |info: &PanicInfo| {
panic::set_hook(Box::new(move |info: &PanicHookInfo| {
let crash_report = get_report(&meta, info);
print_msg(&crash_report, &meta)
.expect("robot-panic: printing error message to console failed");
Expand Down
2 changes: 0 additions & 2 deletions crates/rover-std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ notify = { workspace = true }
tap = { workspace = true }
tokio = { workspace = true, features = [ "macros", "rt", "rt-multi-thread", "time" ] }
tokio-util = { workspace = true}
tokio-stream = { workspace = true }
thiserror = { workspace = true }
tracing = { workspace = true }
url = { workspace = true }
console-subscriber = "0.4.0"

[dev-dependencies]
notify = { workspace = true }
Expand Down
18 changes: 18 additions & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,24 @@ version = "*"
expression = "(Apache-2.0 OR MIT) AND BSD-3-Clause"
license-files = [{ path = "COPYRIGHT", hash = 0x39f8ad31 }]

[[licenses.clarify]]
name = "apollo-language-server"
version = "*"
expression = "Elastic-2.0"
license-files = [{ path = "LICENSE.md", hash = 0x5fc4a573 }]

[[licenses.exceptions]]
name = "apollo-language-server"
allow = ["Elastic-2.0"]

[[licenses.exceptions]]
name = "apollo-federation"
allow = ["Elastic-2.0"]

[[licenses.exceptions]]
name = "apollo-composition"
allow = ["Elastic-2.0"]

# This section is considered when running `cargo deny check bans`.
# More documentation about the 'bans' section can be found here:
# https://embarkstudios.github.io/cargo-deny/checks/bans/cfg.html
Expand Down
7 changes: 7 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ impl Rover {
Command::Explain(command) => command.run(),
Command::PersistedQueries(command) => command.run(self.get_client_config()?).await,
Command::License(command) => command.run(self.get_client_config()?).await,
#[cfg(feature = "composition-js")]
Command::Lsp(command) => command.run(self.get_client_config()?).await,
}
}

Expand Down Expand Up @@ -432,6 +434,11 @@ pub enum Command {

/// Commands for fetching offline licenses
License(command::License),

/// Start the language server
#[cfg(feature = "composition-js")]
#[clap(hide = true)]
jonathanrainer marked this conversation as resolved.
Show resolved Hide resolved
Lsp(command::Lsp),
}

#[derive(Default, ValueEnum, Debug, Serialize, Clone, Copy, Eq, PartialEq)]
Expand Down
3 changes: 3 additions & 0 deletions src/command/dev/next/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use rover_std::{errln, infoln, warnln};
use semver::Version;
use tower::ServiceExt;

use crate::composition::supergraph::binary::OutputTarget;
use crate::{
command::{
dev::{OVERRIDE_DEV_COMPOSITION_VERSION, OVERRIDE_DEV_ROUTER_VERSION},
Expand Down Expand Up @@ -171,6 +172,8 @@ impl Dev {
fetch_remote_subgraph_factory.boxed_clone(),
self.opts.subgraph_opts.subgraph_polling_interval,
tmp_config_dir_path.clone(),
OutputTarget::Stdout,
false,
)
.await?;

Expand Down
25 changes: 25 additions & 0 deletions src/command/lsp/errors.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use anyhow::Error;
use camino::{FromPathBufError, Utf8PathBuf};

use crate::composition::pipeline::CompositionPipelineError;
use crate::composition::supergraph::config::resolver::ResolveSupergraphConfigError;
use crate::composition::supergraph::install::InstallSupergraphError;
use crate::composition::CompositionError;

#[derive(thiserror::Error, Debug)]
pub enum StartCompositionError {
#[error("Could not convert Supergraph path to URL")]
SupergraphYamlUrlConversionFailed(Utf8PathBuf),
#[error("Could not create HTTP service")]
HttpServiceCreationFailed(#[from] Error),
#[error("Could not initialise the composition pipeline")]
InitialisingCompositionPipelineFailed(#[from] CompositionPipelineError),
#[error("Could not run initial composition")]
InitialCompositionFailed(#[from] CompositionError),
#[error("Could not install supergraph plugin")]
InstallSupergraphPluginFailed(#[from] InstallSupergraphError),
#[error("Could not resolve Supergraph Config")]
ResolvingSupergraphConfigFailed(#[from] ResolveSupergraphConfigError),
#[error("Could not establish temporary directory")]
TemporaryDirectoryCouldNotBeEstablished(#[from] FromPathBufError),
}
Loading
Loading