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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
673 changes: 496 additions & 177 deletions Cargo.lock

Large diffs are not rendered by default.

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

apollo-language-server = { version = "0.3.3", default-features = false, features = ["tokio"] }


# crates.io dependencies
anyhow = "1"
ariadne = "0.5"
Expand Down Expand Up @@ -168,6 +171,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 @@ -222,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
19 changes: 19 additions & 0 deletions src/command/lsp/errors.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use camino::{FromPathBufError, Utf8PathBuf};

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 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