diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-12-25 02:37:31 +0100 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2013-01-05 01:39:15 +0300 |
commit | 348c8fac9f897f9661f84e32949b8a4e0c99e93a (patch) | |
tree | 810b2d7d53451ceba5e43e1687a86cdedffd39f1 /src/reflect/scala/reflect/io | |
parent | ed4f4798df2ac104d9557de2241d8e89283b0662 (diff) | |
download | scala-348c8fac9f897f9661f84e32949b8a4e0c99e93a.tar.gz scala-348c8fac9f897f9661f84e32949b8a4e0c99e93a.tar.bz2 scala-348c8fac9f897f9661f84e32949b8a4e0c99e93a.zip |
adds c.introduceTopLevel
The first in the family of mutators for the global symbol table,
`introduceTopLevel` is capable of creating synthetic top-level
classes and modules.
The addition of nme.EMPTY_PACKAGE_NAME is necessary to let
programmers insert definitions into the empty package. That's explicitly
discouraged in the docs, but at times might come in handy.
This patch introduce workarounds to avoid incompatibilities with SBT.
First of all SBT doesn't like VirtualFiles having JFile set to null.
Secondly SBT gets confused when someone depends on synthetic files
added by c.introduceTopLevel.
Strictly speaking these problems require changes to SBT, and that will be
done later. However the main target of the patch is paradise/macros,
which needs to be useful immediately, therefore we apply workarounds.
Diffstat (limited to 'src/reflect/scala/reflect/io')
4 files changed, 9 insertions, 1 deletions
diff --git a/src/reflect/scala/reflect/io/AbstractFile.scala b/src/reflect/scala/reflect/io/AbstractFile.scala index 1a8d1c4f5e..bd6c186825 100644 --- a/src/reflect/scala/reflect/io/AbstractFile.scala +++ b/src/reflect/scala/reflect/io/AbstractFile.scala @@ -124,6 +124,9 @@ abstract class AbstractFile extends Iterable[AbstractFile] { /** Is this abstract file a directory? */ def isDirectory: Boolean + /** Does this abstract file correspond to something on-disk? */ + def isVirtual: Boolean = false + /** Returns the time that this abstract file was last modified. */ def lastModified: Long diff --git a/src/reflect/scala/reflect/io/NoAbstractFile.scala b/src/reflect/scala/reflect/io/NoAbstractFile.scala index 8c88d3abf6..2c59fd8aae 100644 --- a/src/reflect/scala/reflect/io/NoAbstractFile.scala +++ b/src/reflect/scala/reflect/io/NoAbstractFile.scala @@ -22,6 +22,7 @@ object NoAbstractFile extends AbstractFile { def file: JFile = null def input: InputStream = null def isDirectory: Boolean = false + override def isVirtual: Boolean = true def iterator: Iterator[AbstractFile] = Iterator.empty def lastModified: Long = 0L def lookupName(name: String, directory: Boolean): AbstractFile = null diff --git a/src/reflect/scala/reflect/io/VirtualDirectory.scala b/src/reflect/scala/reflect/io/VirtualDirectory.scala index 94cb52e9b5..589076d693 100644 --- a/src/reflect/scala/reflect/io/VirtualDirectory.scala +++ b/src/reflect/scala/reflect/io/VirtualDirectory.scala @@ -26,6 +26,7 @@ extends AbstractFile { def container = maybeContainer.get def isDirectory = true + override def isVirtual = true val lastModified: Long = System.currentTimeMillis override def file = null diff --git a/src/reflect/scala/reflect/io/VirtualFile.scala b/src/reflect/scala/reflect/io/VirtualFile.scala index 09b977bd45..0dfa7d5473 100644 --- a/src/reflect/scala/reflect/io/VirtualFile.scala +++ b/src/reflect/scala/reflect/io/VirtualFile.scala @@ -37,7 +37,7 @@ class VirtualFile(val name: String, override val path: String) extends AbstractF def absolute = this /** Returns null. */ - final def file: JFile = null + def file: JFile = null override def sizeOption: Option[Int] = Some(content.size) @@ -57,6 +57,9 @@ class VirtualFile(val name: String, override val path: String) extends AbstractF /** Is this abstract file a directory? */ def isDirectory: Boolean = false + /** @inheritdoc */ + override def isVirtual: Boolean = true + /** Returns the time that this abstract file was last modified. */ private var _lastModified: Long = 0 def lastModified: Long = _lastModified |