Skip to content

Commit

Permalink
Fixes SI-6305 scala.tools.nsc.io split between jars.
Browse files Browse the repository at this point in the history
* migrates scala.tools.nsc.io portions into scala.reflect.io
* marks all classes in scala.reflect.io experimental/internal
* rewires src/reflect to use new io locations
* creates forwarders in scala.tools.nsci.io package object.
  • Loading branch information
jsuereth committed Sep 18, 2012
1 parent a9f95dc commit c6dde6a
Show file tree
Hide file tree
Showing 17 changed files with 77 additions and 27 deletions.
17 changes: 17 additions & 0 deletions src/compiler/scala/tools/nsc/io/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,23 @@ import java.util.jar.{ Attributes }
import scala.language.implicitConversions

package object io {
// Forwarders from scala.reflect.io
type AbstractFile = scala.reflect.io.AbstractFile
val AbstractFile = scala.reflect.io.AbstractFile
type Directory = scala.reflect.io.Directory
val Directory = scala.reflect.io.Directory
type File = scala.reflect.io.File
val File = scala.reflect.io.File
type Path = scala.reflect.io.Path
val Path = scala.reflect.io.Path
type PlainFile = scala.reflect.io.PlainFile
val PlainFile = scala.reflect.io.PlainFile
val Streamable = scala.reflect.io.Streamable
type VirtualDirectory = scala.reflect.io.VirtualDirectory
type VirtualFile = scala.reflect.io.VirtualFile
val ZipArchive = scala.reflect.io.ZipArchive
type ZipArchive = scala.reflect.io.ZipArchive

implicit def postfixOps = scala.language.postfixOps // make all postfix ops in this package compile without warning

type JManifest = java.util.jar.Manifest
Expand Down
2 changes: 1 addition & 1 deletion src/reflect/scala/reflect/api/Symbols.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ trait Symbols extends base.Symbols { self: Universe =>
/** Source file if this symbol is created during this compilation run,
* or a class file if this symbol is loaded from a *.class or *.jar.
*/
def associatedFile: scala.tools.nsc.io.AbstractFile
def associatedFile: scala.reflect.io.AbstractFile

/** A list of annotations attached to this Symbol.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/reflect/scala/reflect/internal/Symbols.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import util.Statistics
import Flags._
import base.Attachments
import scala.annotation.tailrec
import scala.tools.nsc.io.AbstractFile
import scala.reflect.io.AbstractFile

trait Symbols extends api.Symbols { self: SymbolTable =>
import definitions._
Expand Down
2 changes: 1 addition & 1 deletion src/reflect/scala/reflect/internal/util/SourceFile.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

package scala.reflect.internal.util

import scala.tools.nsc.io.{ AbstractFile, VirtualFile }
import scala.reflect.io.{ AbstractFile, VirtualFile }
import scala.collection.mutable.ArrayBuffer
import scala.annotation.tailrec
import java.util.regex.Pattern
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/


package scala.tools.nsc
package scala.reflect
package io

import java.io.{ FileOutputStream, IOException, InputStream, OutputStream, BufferedOutputStream }
Expand All @@ -13,6 +13,10 @@ import java.net.URL
import scala.collection.mutable.ArrayBuffer

/**
* An abstraction over files for use in the reflection/compiler libraries.
*
* ''Note: This library is considered experimental and should not be used unless you know what you are doing.''
*
* @author Philippe Altherr
* @version 1.0, 23/03/2004
*/
Expand Down Expand Up @@ -81,6 +85,8 @@ object AbstractFile {
* all other cases, the class <code>SourceFile</code> is used, which honors
* <code>global.settings.encoding.value</code>.
* </p>
*
* ''Note: This library is considered experimental and should not be used unless you know what you are doing.''
*/
abstract class AbstractFile extends Iterable[AbstractFile] {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
** |/ **
\* */

package scala.tools.nsc
package scala.reflect
package io

import java.io.{ File => JFile }

/**
* ''Note: This library is considered experimental and should not be used unless you know what you are doing.''
*/
object Directory {
import scala.util.Properties.{ tmpDir, userHome, userDir }

Expand All @@ -34,6 +36,8 @@ import Path._
*
* @author Paul Phillips
* @since 2.8
*
* ''Note: This is library is considered experimental and should not be used unless you know what you are doing.''
*/
class Directory(jfile: JFile) extends Path(jfile) {
override def toAbsolute: Directory = if (isAbsolute) this else super.toAbsolute.toDirectory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
\* */


package scala.tools.nsc
package scala.reflect
package io

import java.io.{
Expand All @@ -17,7 +17,9 @@ import java.io.{ File => JFile }
import java.nio.channels.{ Channel, FileChannel }
import scala.io.Codec
import scala.language.{reflectiveCalls, implicitConversions}

/**
* ''Note: This library is considered experimental and should not be used unless you know what you are doing.''
*/
object File {
def pathSeparator = java.io.File.pathSeparator
def separator = java.io.File.separator
Expand Down Expand Up @@ -74,6 +76,8 @@ import Path._
*
* @author Paul Phillips
* @since 2.8
*
* ''Note: This is library is considered experimental and should not be used unless you know what you are doing.''
*/
class File(jfile: JFile)(implicit constructorCodec: Codec) extends Path(jfile) with Streamable.Chars {
override val creationCodec = constructorCodec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
\* */


package scala.tools.nsc
package scala.reflect
package io

/** ''Note: This library is considered experimental and should not be used unless you know what you are doing.'' */
case class FileOperationException(msg: String) extends RuntimeException(msg)
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
* @author Paul Phillips
*/

package scala.tools.nsc
package scala.reflect
package io

import java.io.InputStream
import java.io.{ File => JFile }

/** A distinguished object so you can avoid both null
* and Option.
*
* ''Note: This library is considered experimental and should not be used unless you know what you are doing.''
*/
object NoAbstractFile extends AbstractFile {
def absolute: AbstractFile = this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @author Paul Phillips
*/

package scala.tools.nsc
package scala.reflect
package io

import java.io.{
Expand All @@ -27,8 +27,9 @@ import scala.language.implicitConversions
*
* @author Paul Phillips
* @since 2.8
*
* ''Note: This library is considered experimental and should not be used unless you know what you are doing.''
*/

object Path {
def isExtensionJarOrZip(jfile: JFile): Boolean = isExtensionJarOrZip(jfile.getName)
def isExtensionJarOrZip(name: String): Boolean = {
Expand Down Expand Up @@ -83,6 +84,8 @@ import Path._

/** The Path constructor is private so we can enforce some
* semantics regarding how a Path might relate to the world.
*
* ''Note: This library is considered experimental and should not be used unless you know what you are doing.''
*/
class Path private[io] (val jfile: JFile) {
val separator = java.io.File.separatorChar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
*/


package scala.tools.nsc
package scala.reflect
package io

import java.io.{ FileInputStream, FileOutputStream, IOException }
import PartialFunction._

/** ''Note: This library is considered experimental and should not be used unless you know what you are doing.'' */
object PlainFile {
/**
* If the specified File exists, returns an abstract file backed
Expand All @@ -20,14 +20,16 @@ object PlainFile {
else if (file.isFile) new PlainFile(file)
else null
}

/** ''Note: This library is considered experimental and should not be used unless you know what you are doing.'' */
class PlainDirectory(givenPath: Directory) extends PlainFile(givenPath) {
override def isDirectory = true
override def iterator = givenPath.list filter (_.exists) map (x => new PlainFile(x))
override def delete(): Unit = givenPath.deleteRecursively()
}

/** This class implements an abstract file backed by a File.
*
* ''Note: This library is considered experimental and should not be used unless you know what you are doing.''
*/
class PlainFile(val givenPath: Path) extends AbstractFile {
assert(path ne null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @author Paul Phillips
*/

package scala.tools.nsc
package scala.reflect
package io

import java.net.{ URI, URL }
Expand All @@ -17,12 +17,15 @@ import Path.fail
*
* @author Paul Phillips
* @since 2.8
*
* ''Note: This library is considered experimental and should not be used unless you know what you are doing.''
*/

object Streamable {
/** Traits which can be viewed as a sequence of bytes. Source types
* which know their length should override def length: Long for more
* efficient method implementations.
*
* ''Note: This library is considered experimental and should not be used unless you know what you are doing.''
*/
trait Bytes {
def inputStream(): InputStream
Expand Down Expand Up @@ -66,6 +69,8 @@ object Streamable {
}

/** For objects which can be viewed as Chars.
*
* ''Note: This library is considered experimental and should not be used unless you know what you are doing.''
*/
trait Chars extends Bytes {
/** Calls to methods requiring byte<->char transformations should be offered
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright 2005-2012 LAMP/EPFL
*/

package scala.tools.nsc
package scala.reflect
package io

import scala.collection.mutable
Expand All @@ -11,6 +11,8 @@ import scala.collection.mutable
* An in-memory directory.
*
* @author Lex Spoon
*
* ''Note: This library is considered experimental and should not be used unless you know what you are doing.''
*/
class VirtualDirectory(val name: String, maybeContainer: Option[VirtualDirectory])
extends AbstractFile {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/


package scala.tools.nsc
package scala.reflect
package io

import java.io.{ ByteArrayInputStream, ByteArrayOutputStream, InputStream, OutputStream }
Expand All @@ -14,6 +14,8 @@ import java.io.{ File => JFile }
*
* @author Philippe Altherr
* @version 1.0, 23/03/2004
*
* ''Note: This library is considered experimental and should not be used unless you know what you are doing.''
*/
class VirtualFile(val name: String, override val path: String) extends AbstractFile {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @author Paul Phillips
*/

package scala.tools.nsc
package scala.reflect
package io

import java.net.URL
Expand All @@ -20,6 +20,8 @@ import scala.annotation.tailrec
* @author Philippe Altherr (original version)
* @author Paul Phillips (this one)
* @version 2.0,
*
* ''Note: This library is considered experimental and should not be used unless you know what you are doing.''
*/
object ZipArchive {
def fromPath(path: String): FileZipArchive = fromFile(new JFile(path))
Expand Down Expand Up @@ -57,7 +59,7 @@ object ZipArchive {
}
}
import ZipArchive._

/** ''Note: This library is considered experimental and should not be used unless you know what you are doing.'' */
abstract class ZipArchive(override val file: JFile) extends AbstractFile with Equals {
self =>

Expand All @@ -78,13 +80,14 @@ abstract class ZipArchive(override val file: JFile) extends AbstractFile with Eq
}
}
def deepIterator = walkIterator(iterator)

/** ''Note: This library is considered experimental and should not be used unless you know what you are doing.'' */
sealed abstract class Entry(path: String) extends VirtualFile(baseName(path), path) {
// have to keep this name for compat with sbt's compiler-interface
def getArchive: ZipFile = null
override def underlyingSource = Some(self)
override def toString = self.path + "(" + path + ")"
}
/** ''Note: This library is considered experimental and should not be used unless you know what you are doing.'' */
class DirEntry(path: String) extends Entry(path) {
val entries = mutable.HashMap[String, Entry]()

Expand Down Expand Up @@ -120,7 +123,7 @@ abstract class ZipArchive(override val file: JFile) extends AbstractFile with Eq
else ensureDir(dirs, dirName(entry.getName), null)
}
}

/** ''Note: This library is considered experimental and should not be used unless you know what you are doing.'' */
final class FileZipArchive(file: JFile) extends ZipArchive(file) {
def iterator: Iterator[Entry] = {
val zipFile = new ZipFile(file)
Expand Down Expand Up @@ -161,7 +164,7 @@ final class FileZipArchive(file: JFile) extends ZipArchive(file) {
case _ => false
}
}

/** ''Note: This library is considered experimental and should not be used unless you know what you are doing.'' */
final class URLZipArchive(val url: URL) extends ZipArchive(null) {
def iterator: Iterator[Entry] = {
val root = new DirEntry("/")
Expand Down
2 changes: 1 addition & 1 deletion src/reflect/scala/reflect/runtime/ReflectionUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ object ReflectionUtils {
case cl: java.net.URLClassLoader =>
(cl.getURLs mkString ",")
case cl if cl != null && isAbstractFileClassLoader(cl.getClass) =>
cl.asInstanceOf[{val root: scala.tools.nsc.io.AbstractFile}].root.canonicalPath
cl.asInstanceOf[{val root: scala.reflect.io.AbstractFile}].root.canonicalPath
case null =>
inferBootClasspath
case _ =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package scala.reflect
package runtime

import scala.tools.nsc.io.AbstractFile
import scala.reflect.io.AbstractFile

trait SynchronizedSymbols extends internal.Symbols { self: SymbolTable =>

Expand Down

0 comments on commit c6dde6a

Please sign in to comment.