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

Handle colons in file names when producing SemanticDB #15863

Merged
merged 1 commit into from
Aug 17, 2022

Conversation

kierendavies
Copy link
Contributor

Fixes #15860

This solution feels pretty hacky to me, but it passes all existing tests... 🤷

@kierendavies
Copy link
Contributor Author

Apparently in CI it does not pass all existing tests. I'm not sure how to interpret the job failure messages though. Can someone help me out?

@bishabosha
Copy link
Member

bishabosha commented Aug 15, 2022

Apparently in CI it does not pass all existing tests. I'm not sure how to interpret the job failure messages though. Can someone help me out?

something changed in the output of semanticdb - you can test if this was intentional by running

sbt 'scala3-compiler-bootstrapped/test:runMain dotty.tools.dotc.semanticdb.updateExpect'

which will update some "expect" files, (used for regression testing semanticdb output) and then comparing the diff with git.

@kierendavies
Copy link
Contributor Author

Thank you @bishabosha. It was a bug, which I've fixed.

// treating the part as an absolute path, and then remove it afterwards.
val uriParts =
for part <- path.asScala
yield new java.net.URI(null, null, "/" + part.toString, null).toString().stripPrefix("/")
uriParts.mkString("/")
Copy link
Member

@bishabosha bishabosha Aug 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it have the same result if you don't strip the prefix from each individual part, but instead do uriParts.mkString("").stripPrefix("/")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea - I completely missed that. I think it'll have the same result.

@bishabosha
Copy link
Member

hopefully CI passes, thank you!

uriParts.mkString("/")
// To prevent colon `:` from being treated as a scheme separator, prepend a slash `/` to each part to trick the URI
// parser into treating it as an absolute path, and then strip the spurious leading slash from the final result.
val uriParts = for part <- path.asScala yield new java.net.URI(null, null, "/" + part.toString, null)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like this URI constructor is just not the right tool for the job...

Copy link
Contributor Author

@kierendavies kierendavies Aug 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a poor fit for sure, but sadly the Java standard library doesn't provide anything better. I considered copy-pasting the OpenJDK private method on java.net.URI that does the quoting, but it's, uh, very Java. And then there's also license compatibility.

This comment was marked as duplicate.

@bishabosha bishabosha merged commit d670018 into scala:main Aug 17, 2022
@Kordyjan Kordyjan added this to the 3.2.1 milestone Aug 1, 2023
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 this pull request may close these issues.

SemanticDB URISyntaxException
4 participants