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

let AbsolutePath do the Uri encoding #277

Closed
wants to merge 1 commit into from

Conversation

martijnhoekstra
Copy link
Contributor

on Windows, more than just prepending file: is needed

on Windows, more than just prepending file: is needed
Copy link
Member

@olafurpg olafurpg left a comment

Choose a reason for hiding this comment

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

LGTM 👍

laughedelic
laughedelic previously approved these changes Apr 9, 2018
Copy link
Member

@laughedelic laughedelic left a comment

Choose a reason for hiding this comment

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

Good 👍 Does it fix some failures in #276?

@laughedelic laughedelic added the bug Something that is making a piece of functionality unusable label Apr 9, 2018
@martijnhoekstra
Copy link
Contributor Author

It locally fixes some bugs in #276 - maybe all URI bugs - but CI isn't positive. I probably need to use your CI as my unix test env.

@olafurpg
Copy link
Member

olafurpg commented Apr 9, 2018

Heads up on #275, it touches a big chunk of the codebase.

The test failures may be cause by the implicit requirement that those uris need to be formatted as file:/ with single slash instead of ///.

@martijnhoekstra
Copy link
Contributor Author

* - Both file:///path and file:/path are valid URIs while we only use
seems to suggest the opposite - is that a typo?

@laughedelic
Copy link
Member

That comment is correct (also see the linked issue) and without your change I see in my local logs file:/// absolute paths. So the issue should be somewhere else.

@olafurpg
Copy link
Member

olafurpg commented Apr 9, 2018

I thought as well that all URIs should be file:/// but my repl says Semanticdbs.scala was using another convention

@ Paths.get("").toAbsolutePath.toUri
res1: java.net.URI = file:///Users/ollie/dev/metals/

@ "file:" + Paths.get("").toAbsolutePath
res2: String = "file:/Users/ollie/dev/metals"

@laughedelic
Copy link
Member

laughedelic commented Apr 9, 2018

@martijnhoekstra it fails because the same hack is hardcoded in the tests 😬

So you need to change it there too.

UPD: no, I guess it's not the reason either. There are several places in the code doing these conversions in different way. At some point scala.meta.metals.Uri was introduced to unify it.

Copy link
Member

@olafurpg olafurpg left a comment

Choose a reason for hiding this comment

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

Good catch @laughedelic !

Uri was intended to unify all usages of URIs in the codebase, so that what we should be using here. java.net.URI is not used because they do not have structural equality in their string form.

val filename = s"file:${cwd.resolve(d.filename)}"
sdb.documents.map { d => //round and round we go
val absolute = cwd.resolve(d.filename)
val filename = absolute.toURI.toString
Copy link
Member

Choose a reason for hiding this comment

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

Let's do Uri(absolute).value and then fix the broken implementation of Uri.apply

  def apply(uri: URI): Uri =
    new Uri(uri.toString) {}

This part here

    if (uri.getScheme == "file") {
      // nio.Path.toUri.toString produces file:/// while LSP expected file:/
      new Uri(s"file://${uri.getPath}") {}

is broken since URI.getPath looses the URI encoding 🤦‍♂️

Copy link
Member

@olafurpg olafurpg left a comment

Choose a reason for hiding this comment

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

Good catch @laughedelic !

Uri was intended to unify all usages of URIs in the codebase, so that what we should be using here. java.net.URI is not used because they do not have structural equality in their string form.

@laughedelic laughedelic dismissed their stale review April 9, 2018 20:30

prematurely accepted

@martijnhoekstra
Copy link
Contributor Author

I can't push this to completion today, unfortunately. Will do so tomorrow.

@laughedelic
Copy link
Member

@martijnhoekstra no problem. It's even better if you do it after the big refactoring in #275 is merged.

@gabro
Copy link
Member

gabro commented Apr 10, 2018

@martijnhoekstra AppVeyor landed on master, you can rebase if you want to check that the CI is happy too.

@martijnhoekstra
Copy link
Contributor Author

@gabro It might be better if I wait on #275 and rebase when that lands. I'll also enable CI for all tests that pass after rebasing.

@gabro
Copy link
Member

gabro commented Apr 10, 2018

👍 sounds like a plan

@olafurpg
Copy link
Member

Superseded by #275

I hit on this bug while making the test suite pass

@olafurpg olafurpg closed this Apr 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that is making a piece of functionality unusable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants