-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup parts of the VirtualFile-related code
* Rename VirtualFileWrap/XsbtPlainFile/XsbtVirtualFile to AbstractZincFile/ZincPlainFile/ZincVirtualFil; * Default FileConverter#toVirtualFile(VirtualFileRef): VirtualFile * Rework BasicVirtualDirectory & BasicMemoryFile to avoid needless Option and BasicVirtualDirectory boxing, & use structural sharing; * Cleanup some of VirtualFile's docs.
- Loading branch information
Showing
16 changed files
with
128 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
internal/compiler-bridge/src/main/scala/xsbt/AbstractZincFile.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Zinc - The incremental compiler for Scala. | ||
* Copyright Lightbend, Inc. and Mark Harrah | ||
* | ||
* Licensed under Apache License 2.0 | ||
* (http://www.apache.org/licenses/LICENSE-2.0). | ||
* | ||
* See the NOTICE file distributed with this work for | ||
* additional information regarding copyright ownership. | ||
*/ | ||
|
||
package xsbt | ||
|
||
import xsbti.{ PathBasedFile, VirtualFile } | ||
import scala.reflect.io.Streamable | ||
|
||
private trait AbstractZincFile extends scala.reflect.io.AbstractFile { | ||
def underlying: VirtualFile | ||
} | ||
|
||
private final class ZincPlainFile private[xsbt] (val underlying: PathBasedFile) | ||
extends scala.reflect.io.PlainFile(scala.reflect.io.Path(underlying.toPath.toFile)) | ||
with AbstractZincFile | ||
|
||
private final class ZincVirtualFile private[xsbt] (val underlying: VirtualFile) | ||
extends scala.reflect.io.VirtualFile(underlying.name, underlying.id) | ||
with AbstractZincFile { | ||
Streamable.closing(output)(_.write(Streamable.bytes(underlying.input))) // fill in the content | ||
} | ||
|
||
private object AbstractZincFile { | ||
def apply(virtualFile: VirtualFile): AbstractZincFile = virtualFile match { | ||
case file: PathBasedFile => new ZincPlainFile(file) | ||
case _ => new ZincVirtualFile(virtualFile) | ||
} | ||
|
||
def unapply(file: scala.reflect.io.AbstractFile): Option[VirtualFile] = file match { | ||
case wrapper: AbstractZincFile => Some(wrapper.underlying) | ||
case _ => None | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 0 additions & 54 deletions
54
internal/compiler-bridge/src/main/scala/xsbt/VirtualFileWrap.scala
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.