The IDE you know, rebuilt in Rust. IntelliJ IDEA–style keymap, tool windows and search-everywhere in a fast native app: editor, code insight, debugger, Git, terminal, database and HTTP clients for 60+ languages.
TypeScript code-editorcross-platformdapdatabase-clientdebuggerdesktop-appdeveloper-toolsgithttp-clientideintellijlsprusttauriterminal
fix(maven): refresh jdtls project configurations after a Maven reload (#446)
arookieofc2b1add64db92
diff --git a/crates/ide-host/src/ops/build.rs b/crates/ide-host/src/ops/build.rsindex 0a0f3a936..82f3d4339 100644--- a/crates/ide-host/src/ops/build.rs+++ b/crates/ide-host/src/ops/build.rs@@ -123,12 +123,27 @@ pub async fn build_sync(BuildTool::Maven => ide_build::sync_maven(&root, &cache, &options, &token, &progress)?,BuildTool::Gradle => ide_build::sync_gradle(&root, &cache, &options, &token, &progress)?,}- Ok(load(&root, &cache, &settings))+ Ok::<BuildModel, IdeError>(load(&root, &cache, &settings))}).await.map_err(join_err);host.end_request(request);- result?+ let model = result??;+ if tool == BuildTool::Maven+ && let Some(maven) = &model.maven+ {+ // jdtls re-imports on pom changes but misses artifacts added to ~/.m2+ // meanwhile ("missing artifact" stays until Invalidate Caches); asking it+ // to update the project configurations re-resolves them (#436).+ let lsp = project.lsp.clone();+ let uris = maven.projects.iter().map(|p| ide_lsp::path_to_uri_string(&project.root.join(&p.pom))).collect();+ tokio::spawn(async move {+ if let Err(e) = lsp.java_update_project_configs(&project.root, uris).await {+ tracing::debug!("java/projectConfigurationsUpdate: {e}");+ }+ });+ }+ Ok(model)}/// The POM declaring `dependency` for the Maven module `pom` (project-relative): thediff --git a/crates/ide-lsp/src/jdtls.rs b/crates/ide-lsp/src/jdtls.rsindex 9f93618fa..15279fbe5 100644--- a/crates/ide-lsp/src/jdtls.rs+++ b/crates/ide-lsp/src/jdtls.rs@@ -225,6 +225,24 @@ impl LspManager {}}+ /// Tells jdtls the build files of `uris` changed (`java/projectConfigurationsUpdate`),+ /// so it re-imports their projects (e.g. after `~/.m2` gained an artifact it could+ /// not resolve). Best-effort: skipped while jdtls is not already running.+ pub async fn java_update_project_configs(&self, path: &Path, uris: Vec<String>) -> IdeResult<()> {+ if uris.is_empty() {+ return Ok(());+ }+ let java = LanguageId::new("java");+ let Some(server) = self.servers_for(&java, path).into_iter().find(|s| s.name == SERVER) else {+ return Ok(());+ };+ let Some(run) = server.running() else { return Ok(()) };+ let identifiers: Vec<Value> = uris.iter().map(|u| json!({ "uri": u })).collect();+ run.peer+ .notify("java/projectConfigurationsUpdate", json!({ "identifiers": identifiers }))+ .map_err(|e| crate::rpc_err(&server.name, "java/projectConfigurationsUpdate", e))+ }+/// Incremental build of the jdtls workspace (`java/buildWorkspace`), so/// class files are up to date before a launch.pub async fn java_build(&self, path: &Path) -> IdeResult<JavaBuildStatus> {