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

Produce semanticDB for Java #2226

Closed
ckipp01 opened this issue Jan 2, 2023 · 5 comments · Fixed by #2227
Closed

Produce semanticDB for Java #2226

ckipp01 opened this issue Jan 2, 2023 · 5 comments · Fixed by #2227
Milestone

Comments

@ckipp01
Copy link
Contributor

ckipp01 commented Jan 2, 2023

#1977 introduced much better support for Metals users since they will now get semanticDB support for Scala. One follow-up to that pr is that Java modules still don't produce semanticDB for Java. This means that when using Metals you will be warned upon your build import that something is not fully working with your build. When you then look at the Doctor you see:

## Metals Info
  - Metals Server version: 0.11.9+243-3cbb04ef-SNAPSHOT
  - Build server currently being used is mill-bsp v0.10.10.
  - Metals Java: 17.0.5 from Eclipse Adoptium located at /Users/ckipp/.sdkman/candidates/java/17.0.5-tem

These are the installed build targets for this workspace. One build target corresponds to one classpath. For example, normally one sbt project maps to two build targets: main and test.

## Build Targets

### mill-build
  - target type: Scala 2.13.10
  - compilation: ✅ 
  - diagnostics: ✅ 
  - interactive: ✅ 
  - semanticdb: ✅ 
  - debugging: ❌
  - java: ⚠️ 
  - recommendation: Semanticdb is required for code navigation to work correctly in your project, however the Java semanticdb plugin doesn't seem to be enabled. Please enable the Java semanticdb plugin for this project in order for code navigation to work correctly

### milltest
  - target type: Scala 2.13.10
  - compilation: ✅ 
  - diagnostics: ✅ 
  - interactive: ✅ 
  - semanticdb: ✅ 
  - debugging: ❌
  - java: ⚠️ 
  - recommendation: Semanticdb is required for code navigation to work correctly in your project, however the Java semanticdb plugin doesn't seem to be enabled. Please enable the Java semanticdb plugin for this project in order for code navigation to work correctly

### milltest.test
  - target type: Scala 2.13.10
  - compilation: ✅ 
  - diagnostics: ✅ 
  - interactive: ✅ 
  - semanticdb: ✅ 
  - debugging: ✅ 
  - java: ⚠️ 
  - recommendation: Running single tests in Test Explorer will not work properly with this version of munit, please update it to at least org.scalameta.munit.1.0.0-M3

## Explanations

### Compilation status:
✅  - code is compiling

### Diagnostics:
✅  - diagnostics correctly being reported by the build server

### Interactive features (completions, hover):
✅  - supported Scala version

### Semanticdb features (references, renames, go to implementation):
✅  - build tool automatically creating needed semanticdb files

### Debugging (run/test, breakpoints, evaluation):
✅  - users can run or test their code with debugging capabilities
❌ - the tool does not support debugging in this target

### Java Support:
✅  - working non-interactive features (references, rename etc.)
❌ - missing semanticdb plugin, might not be added automatically by the build server (which is only done when using Bloop)
ℹ️  - build target doesn't support Java files

We should be able to follow a similar way that we do for Scala, but utilizing https://github.com/sourcegraph/scip-java. I do also have an example of this working in https://github.com/ckipp01/mill-scip/blob/487f6dc806e91eb22bb625fa139a2538fb29ad97/plugin/src/io/kipp/mill/scip/Scip.scala#L144-L215.

@lefou
Copy link
Member

lefou commented Jan 2, 2023

I already started this integration in a branch (https://github.com/com-lihaoyi/mill/compare/semantic-db-task-java, commit: b830c1d). I don't remember exactly what the issue was, but I think it was not working for Java 8 and 11.

@ckipp01
Copy link
Contributor Author

ckipp01 commented Jan 2, 2023

I already started this integration in a branch (https://github.com/com-lihaoyi/mill/compare/semantic-db-task-java, commit: b830c1d). I don't remember exactly what the issue was, but I think it was not working for Java 8 and 11.

I think it might be the other way around. I know when I worked on mill-scip it worked with 8 and 11, but in order to get it to work with 17 I needed to add https://github.com/ckipp01/mill-scip/blob/487f6dc806e91eb22bb625fa139a2538fb29ad97/plugin/src/io/kipp/mill/scip/Scip.scala#L181-L193.

@lefou
Copy link
Member

lefou commented Jan 2, 2023

I already started this integration in a branch (https://github.com/com-lihaoyi/mill/compare/semantic-db-task-java, commit: b830c1d). I don't remember exactly what the issue was, but I think it was not working for Java 8 and 11.

I think it might be the other way around. I know when I worked on mill-scip it worked with 8 and 11, but in order to get it to work with 17 I needed to add https://github.com/ckipp01/mill-scip/blob/487f6dc806e91eb22bb625fa139a2538fb29ad97/plugin/src/io/kipp/mill/scip/Scip.scala#L181-L193.

Hmm, no. I tried to resurrect that branch and created a draft PR with an example project.
It fails with an java.nio.file.FileSystemNotFoundException: Provider "vf" not installed.

@ckipp01
Copy link
Contributor Author

ckipp01 commented Jan 2, 2023

Hmm, no. I tried to resurrect that branch and created a draft PR with an example project.
It fails with an java.nio.file.FileSystemNotFoundException: Provider "vf" not installed.

Commented in the pr. But I hit on that as well in the past and I believe it's due to a missing flag.

@lefou lefou added this to the 0.11.0-M2 milestone Jan 5, 2023
@ckipp01
Copy link
Contributor Author

ckipp01 commented Jan 5, 2023

Just to tie these together. If anyone is trying this out and still getting a warning when using Metals, you'll need to make sure you're using a version of Metals that has this commit: scalameta/metals#4816.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants