Skip to content

Add jpath to VirtualFile (for pc) #23203

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kasiaMarek
Copy link
Member

@kasiaMarek kasiaMarek changed the title Metals i7460 Add jpath to VirtualFile (for pc) May 20, 2025
@kasiaMarek kasiaMarek requested a review from tgodzik May 21, 2025 09:53

override def sizeOption: Option[Int] = Some(content.length)

override def exists: Boolean = true
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need the overwrite? It's already (jpath eq null) || Files.exists(jpath)

Copy link
Member Author

Choose a reason for hiding this comment

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

In presentation compiler tests it won't exist. Also MCP makes a fake file to get completions. Maybe the fie passed to pc should have the information if it's virtual of a not, so we could create a correct kind of source file here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ach right, maybe it's worth a comment it explain it.

* @return the created virtual file
*/
def this(path: JPath, content: Array[Byte]) = {
this(path.toString.replace(java.io.File.separatorChar, '/'), content)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
this(path.toString.replace(java.io.File.separatorChar, '/'), content)
this(jpath.getFileName().toString(), path)
this.content = content

wouldn't make sense? I think / is only used to get the last element

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.

2 participants