Skip to content

Add Tasty compilation unit source file #4627

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

Merged
merged 1 commit into from
Jun 22, 2018

Conversation

nicolasstucki
Copy link
Contributor

No description provided.

def source: String = {
val thisPath = java.nio.file.Paths.get("").toAbsolutePath
val path = ctx.compilationUnit.source.file.jpath.toAbsolutePath
thisPath.relativize(path).toString
Copy link
Contributor

Choose a reason for hiding this comment

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

Some thoughts

  • Not sure if consistent cross-platform behavior is a goal, but this will produce different paths in Windows and Linux/macOS. If you want normalized paths you can use URI.normalize
thisPath.toUri.relativize(path.toUri).getPath
  • there are use-cases where you only care about the filename source.getFileName.toString, in that case it's kind of annoying to have to parse the string to extract the filename
  • this relies on an implicit working directory java.nio.file.Paths.get("").toAbsolutePath, what happens for example with virtual files?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was trying to relativize because our testing framework passes only absolute paths. I removed all this complication and just return the path as it was passed to the compiler.

@nicolasstucki nicolasstucki force-pushed the add-tasty-ctx-file branch 2 times, most recently from 05215ab to 4fdb527 Compare June 8, 2018 09:25
@nicolasstucki nicolasstucki self-assigned this Jun 8, 2018
Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

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

LGTM

@nicolasstucki nicolasstucki merged commit 497efb9 into scala:master Jun 22, 2018
@allanrenucci allanrenucci deleted the add-tasty-ctx-file branch June 22, 2018 16:36
@allanrenucci
Copy link
Contributor

@nicolasstucki This PR broke master. Can you have a look?

@nicolasstucki
Copy link
Contributor Author

@allanrenucci there is already a fix in #4708

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.

4 participants