Repository navigation
fix(navigation): 修复 Gradle 项目无法跳转到已缓存依赖(#4) - #13
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
… indexable Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…ons together Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Devin Review found 2 new potential issues.
4 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
| dir := filepath.Dir(p) | ||
| if _, ok := projects[dir]; !ok { | ||
| directories = append(directories, dir) | ||
| projects[dir] = gradleDeclarations(readGradleFile(p), catalog) | ||
| } | ||
| } | ||
| var primary, extra []*model | ||
| for _, dir := range directories { |
There was a problem hiding this comment.
🔴 Scriptless subprojects lose dependency navigation
GradleJars skips included subprojects without build scripts, even when the root configures them through subprojects. Their cached dependencies never enter the navigation index.
Learn more
Gradle can configure an included project entirely from the root build script, so that project does not need its own build file. depInputs passes only existing build scripts to the dependency resolver. gradleDeclarations puts dependencies declared in subprojects into the child-only group. No model consumes that group when all included projects lack build scripts, so the cached JARs never enter the index.
Example: The root settings declares include(":service"). The root build script applies the Java plugin and declares Guava inside subprojects. service has Java sources but no build script. Gradle compiles the sources against Guava, but Go to Definition cannot open Guava classes from those sources.
Recommended fix: Discover conventional subproject directories from literal include declarations in the settings files and create an empty local dependency model for each included project without a script, then merge the inherited declarations. Add a regression test with only a root build script and a scriptless included Java subproject.
Was this helpful? React with 👍 or 👎 to provide feedback.
| for child := dir; filepath.Dir(child) != child; child = filepath.Dir(child) { | ||
| // A nested build with its own settings does not inherit the | ||
| // outer build's subprojects declarations. | ||
| if _, err := os.Stat(filepath.Join(child, "settings.gradle")); err == nil { | ||
| break | ||
| } | ||
| if _, err := os.Stat(filepath.Join(child, "settings.gradle.kts")); err == nil { | ||
| break | ||
| } | ||
| for group, shared := range projects[filepath.Dir(child)].children { |
There was a problem hiding this comment.
🟡 Outer dependencies override buildSrc versions
GradleJars merges outer subprojects dependencies into buildSrc when it has no settings file. A higher outer version displaces the JAR that buildSrc actually compiles against.
Learn more
Gradle treats the root’s buildSrc directory as a separate build even without a settings file in that directory. depInputs collects its build script alongside ordinary subproject scripts. The directory walk merges the outer project’s declarations into that independent model. resolveGradle chooses a single winning version per dependency, so the actual buildSrc JAR is never indexed when only that model requests it and the inherited version wins.
Example: buildSrc/build.gradle declares org.example:helper:1, and the root’s subprojects block declares org.example:helper:2 for the application modules. buildSrc compiles against version 1, but the index drops it. A class found only in version 1 no longer has a definition target.
Recommended fix: Treat a Gradle build’s conventional buildSrc directory as a build boundary even without a local settings file. Preserve inheritance inside buildSrc while preventing inheritance across that boundary. Cover this with conflicting dependency versions in the outer build and buildSrc.
Was this helpful? React with 👍 or 👎 to provide feedback.
Closes #4
Summary
Java Support Lite 现在能从 Gradle 项目跳到已缓存依赖的源码或签名存根。此前,即使 Spring Boot 工程已成功编译,插件仍然会报告 0 个依赖 JAR。
licenses/,避免根目录vendor/意外启用 Go 的 vendor 模式。复现与复测
在 Linux x64 上通过真实 LSP 对 Spring 官方 REST 示例发起定义请求。使用 Gradle 构建,保留已下载的依赖,前后各启动三个独立的语言服务器,种子和 33 个位置一致。复现评论
7 个新增目标均位于 Spring 依赖中,包括
SpringApplication.run与@RestController。两组均未加载 JDK 源码。版本目录变更后跳转的回归测试在修复前失败,修复后通过。另有用例覆盖分散在不同哈希目录的源码与二进制、传递 POM、指定版本缺失、忽略注释及未声明的依赖。已通过
go vet ./...、全量 Go 竞态测试、六个平台归档构建、Linux 归档校验和 Linux x64 安装包 LSP 冒烟测试。Link to Devin session: https://app.devin.ai/sessions/8968c13d203f4024bb0c72024a73dde1
Open in Devin Desktop: https://app.devin.ai/desktop/session/8968c13d203f4024bb0c72024a73dde1?variant=devin
Requested by: @1lck