Fix absolute path handling in SemanticdbTaskListener.absolutePathFromUri#827
Fix absolute path handling in SemanticdbTaskListener.absolutePathFromUri#827lihaoyi wants to merge 1 commit into
SemanticdbTaskListener.absolutePathFromUri#827Conversation
|
CC @antonsviridov-src since you seem to be the most active maintainer |
|
Thanks for the contribution. Unfortunately, we've recently dropped support for Scala and no longer use SBT/Zinc. Closing this PR as no longer needed. |
|
That's a quite interesting reason to reject a PR. You prefer to have erroneous code in your code base because you don't use it. Strange. Why you don't delete the whole support for SBT/Zinc then? |
|
We did delete the whole support for SBT/Zinc. This PR is no longer relevant. |
|
We've inlined the whole implementation into metals v2 for quicker iteration, so this is not an issue https://github.com/scalameta/metals/tree/main-v2/semanticdb-javac/src/main |
My bad. I looked in |
That's honestly good to hear. I was not aware that Thanks for paying attention and looking into this. |
The previous code was off by one:
vf://tmp/foo/bar/baz, it would crash withunsupported URIvf://tmp//foo/bar/baz, it would incorrectly produce a relative pathfoo/bar/bazusing the absolute path's segments, which would typically duplicate the-sourcerootvalue and result in an invalid pathLooking at the code, it seems like it is simply splitting by 1 too many slashes: if we want everything after the
vf://tmp/, we need to.split('/', 4)rather than.split('/', 5). This seems fixes both misbehaviors listed above:vf://tmp/foo/bar/baz, it extracts the relativefoo/bar/baz, which is then appended as a sub-path byoptions.sourceroot.resolvevf://tmp//foo/bar/baz, it extracts the absolute/foo/bar/baz, which then remains unchanged and is returned byoptions.sourceroot.resolveTest plan
Tested manually, a local
sbt publishLocalwith these changes fixes downstream issues in tools that consume the semanticdb e.g. scalameta/metals#7913