summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2006-09-22 12:14:59 +0000
committermichelou <michelou@epfl.ch>2006-09-22 12:14:59 +0000
commitf5934f7970816ece828d1f453d3ea45dfe3bf896 (patch)
tree815c2dcee8ca502d6379813e17f0d7c384a158ca
parent04871d8ee1a9c12226d803adb0aee68866e9b497 (diff)
downloadscala-f5934f7970816ece828d1f453d3ea45dfe3bf896.tar.gz
scala-f5934f7970816ece828d1f453d3ea45dfe3bf896.tar.bz2
scala-f5934f7970816ece828d1f453d3ea45dfe3bf896.zip
removed leading/trailing tabs/blanks in nsc/io/...
removed leading/trailing tabs/blanks in nsc/io/*.scala
-rw-r--r--src/compiler/scala/tools/nsc/io/AbstractFile.scala58
-rw-r--r--src/compiler/scala/tools/nsc/io/PlainFile.scala59
-rw-r--r--src/compiler/scala/tools/nsc/io/VirtualFile.scala48
-rw-r--r--src/compiler/scala/tools/nsc/io/ZipArchive.scala102
4 files changed, 143 insertions, 124 deletions
diff --git a/src/compiler/scala/tools/nsc/io/AbstractFile.scala b/src/compiler/scala/tools/nsc/io/AbstractFile.scala
index c496aee84e..1faa3c2382 100644
--- a/src/compiler/scala/tools/nsc/io/AbstractFile.scala
+++ b/src/compiler/scala/tools/nsc/io/AbstractFile.scala
@@ -1,32 +1,30 @@
-/* ____ ____ ____ ____ ______ *\
-** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
-** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002-2006, LAMP/EPFL **
-** /_____/\____/\___/\____/____/ **
-\* */
-
+/* NSC -- new Scala compiler
+ * Copyright 2005-2006 LAMP/EPFL
+ * @author Martin Odersky
+ */
// $Id$
-package scala.tools.nsc.io;
+package scala.tools.nsc.io
-import java.io.File;
+import java.io.File
object AbstractFile {
/** Returns "getFile(new File(path))". */
- def getFile(path: String): AbstractFile = getFile(new File(path));
+ def getFile(path: String): AbstractFile = getFile(new File(path))
/**
* If the specified File exists and is a regular file, returns an
* abstract regular file backed by it. Otherwise, returns null.
*/
def getFile(file: File): AbstractFile =
- if (file.isFile() && file.exists()) new PlainFile(file) else null;
+ if (file.isFile() && file.exists()) new PlainFile(file) else null
/** Returns "getDirectory(new File(path))". */
- def getDirectory(path: String): AbstractFile = getDirectory(new File(path));
+ def getDirectory(path: String): AbstractFile = getDirectory(new File(path))
/**
* if the specified File exists and is either a directory or a
@@ -73,19 +71,19 @@ abstract class AbstractFile extends Object with Iterable[AbstractFile] {
// Public Methods
/** Returns the name of this abstract file. */
- def name: String;
+ def name: String
/** Returns the path of this abstract file. */
- def path: String;
+ def path: String
/** Returns the underlying File if any and null otherwise. */
- def file: File;
+ def file: File
/** Is this abstract file a directory? */
- def isDirectory: Boolean;
+ def isDirectory: Boolean
/** Returns the time that this abstract file was last modified. */
- def lastModified: Long;
+ def lastModified: Long
/** Reads the content of this abstract file into a byte array. */
//def getBytes: Array[Byte] = error("getBytes not supported by "+this.getClass())
@@ -94,7 +92,7 @@ abstract class AbstractFile extends Object with Iterable[AbstractFile] {
//def getChars: Array[Char] = error("getChars not supported by "+this.getClass())
/** Returns all abstract subfiles of this abstract directory. */
- def elements: Iterator[AbstractFile];
+ def elements: Iterator[AbstractFile]
/**
* Returns the abstract file in this abstract directory with the
@@ -102,7 +100,7 @@ abstract class AbstractFile extends Object with Iterable[AbstractFile] {
* argument "directory" tells whether to look for a directory or
* or a regular file.
*/
- def lookupName(name: String, directory: Boolean): AbstractFile;
+ def lookupName(name: String, directory: Boolean): AbstractFile
/**
* Returns the abstract file in this abstract directory with the
@@ -111,24 +109,24 @@ abstract class AbstractFile extends Object with Iterable[AbstractFile] {
* for a directory or a regular file.
*/
def lookupPath(path: String, directory: Boolean): AbstractFile = {
- val length = path.length();
- val separator = File.separatorChar;
- assert(0 < length && path.lastIndexOf(separator) < length - 1, path);
- var file = this;
- var start = 0;
+ val length = path.length()
+ val separator = File.separatorChar
+ assert(0 < length && path.lastIndexOf(separator) < length - 1, path)
+ var file = this
+ var start = 0
while (true) {
- val index = path.indexOf(separator, start);
- assert(index < 0 || start < index);
- val name = path.substring(start, if (index < 0) length else index);
- file = file.lookupName(name, if (index < 0) directory else true);
- if (file == null || index < 0) return file;
- start = index + 1;
+ val index = path.indexOf(separator, start)
+ assert(index < 0 || start < index)
+ val name = path.substring(start, if (index < 0) length else index)
+ file = file.lookupName(name, if (index < 0) directory else true)
+ if (file == null || index < 0) return file
+ start = index + 1
}
file
}
/** Returns the path of this abstract file. */
- override def toString() = path;
+ override def toString() = path
//########################################################################
}
diff --git a/src/compiler/scala/tools/nsc/io/PlainFile.scala b/src/compiler/scala/tools/nsc/io/PlainFile.scala
index eb1852666f..fcc2689592 100644
--- a/src/compiler/scala/tools/nsc/io/PlainFile.scala
+++ b/src/compiler/scala/tools/nsc/io/PlainFile.scala
@@ -1,16 +1,13 @@
-/* ____ ____ ____ ____ ______ *\
-** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
-** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002-2006, LAMP/EPFL **
-** /_____/\____/\___/\____/____/ **
-\* */
-
+/* NSC -- new Scala compiler
+ * Copyright 2005-2006 LAMP/EPFL
+ * @author Martin Odersky
+ */
// $Id$
-package scala.tools.nsc.io;
-
+package scala.tools.nsc.io
-import java.io.{File, FileInputStream, IOException};
+import java.io.{File, FileInputStream, IOException}
object PlainFile {
@@ -22,7 +19,7 @@ object PlainFile {
* by it. Otherwise, returns null.
*/
def fromFile(file: File): AbstractFile =
- if (file.exists()) new PlainFile(file) else null;
+ if (file.exists()) new PlainFile(file) else null
}
@@ -30,17 +27,17 @@ object PlainFile {
*/
class PlainFile(val file: File) extends AbstractFile {
- assert(file != null);
- assert(file.exists(), "non-existent file: " + file);
+ assert(file != null)
+ assert(file.exists(), "non-existent file: " + file)
//########################################################################
// Public Methods
/** Returns the name of this abstract file. */
- def name = file.getName();
+ def name = file.getName()
/** Returns the path of this abstract file. */
- def path = file.getPath();
+ def path = file.getPath()
override def hashCode(): Int =
@@ -58,33 +55,33 @@ class PlainFile(val file: File) extends AbstractFile {
}
/** Is this abstract file a directory? */
- def isDirectory: Boolean = file.isDirectory();
+ def isDirectory: Boolean = file.isDirectory()
/** Returns the time that this abstract file was last modified. */
- def lastModified: Long = file.lastModified();
+ def lastModified: Long = file.lastModified()
/** Reads the content of this abstract file into a byte array.
override def getBytes: Array[Byte] = {
assert(!isDirectory, "cannot read directory '" + this + "'");
- val in = new FileInputStream(file);
- var rest: Int = file.length().toInt;
- val buf: Array[Byte] = new Array[Byte](rest);
+ val in = new FileInputStream(file)
+ var rest: Int = file.length().toInt
+ val buf: Array[Byte] = new Array[Byte](rest)
while (rest > 0) {
val res = in.read(buf, buf.length - rest, rest);
if (res == -1)
throw new IOException("read error");
- rest = rest - res;
+ rest = rest - res
}
- in.close();
- return buf;
+ in.close()
+ buf
}
*/
/** Returns all abstract subfiles of this abstract directory. */
def elements: Iterator[AbstractFile] = {
- assert(isDirectory, "not a directory '" + this + "'");
- val names: Array[String] = file.list();
- if (names == null || names.length == 0) Iterator.empty;
+ assert(isDirectory, "not a directory '" + this + "'")
+ val names: Array[String] = file.list()
+ if (names == null || names.length == 0) Iterator.empty
else Iterator.fromArray(names).map { name: String => new File(file, name) }
.filter(.exists()).map(file => new PlainFile(file))
}
@@ -94,13 +91,17 @@ class PlainFile(val file: File) extends AbstractFile {
* specified name. If there is no such file, returns null. The
* argument "directory" tells whether to look for a directory or
* or a regular file.
+ *
+ * @param name ...
+ * @param directory ...
+ * @return ...
*/
def lookupName(name: String, directory: Boolean): AbstractFile = {
- //assert(isDirectory, "not a directory '" + this + "'");
- val child = new File(file, name);
+ //assert(isDirectory, "not a directory '" + this + "'")
+ val child = new File(file, name)
if (!child.exists() || (directory != child.isDirectory) ||
- directory == child.isFile()) null;
- else new PlainFile(child);
+ directory == child.isFile()) null
+ else new PlainFile(child)
}
//########################################################################
diff --git a/src/compiler/scala/tools/nsc/io/VirtualFile.scala b/src/compiler/scala/tools/nsc/io/VirtualFile.scala
index 9e453b66c6..e53387ac4f 100644
--- a/src/compiler/scala/tools/nsc/io/VirtualFile.scala
+++ b/src/compiler/scala/tools/nsc/io/VirtualFile.scala
@@ -1,21 +1,22 @@
-/* ____ ____ ____ ____ ______ *\
-** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
-** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002-2006, LAMP/EPFL **
-** /_____/\____/\___/\____/____/ **
-\* */
-
+/* NSC -- new Scala compiler
+ * Copyright 2005-2006 LAMP/EPFL
+ * @author Martin Odersky
+ */
// $Id$
-package scala.tools.nsc.io;
-
+package scala.tools.nsc.io
-import java.io.{File,IOException};
+import java.io.File
-/** This class implements an empty abstract regular file. */
+/** This class implements an empty abstract regular file.
+ *
+ * @author Philippe Altherr
+ * @version 1.0, 23/03/2004
+ */
class VirtualFile(val name: String, _path: String) extends AbstractFile {
- assert(name != null && path != null, name + " - " + path);
+ assert(name != null && path != null, name + " - " + path)
//########################################################################
// Public Constructors
@@ -23,27 +24,30 @@ class VirtualFile(val name: String, _path: String) extends AbstractFile {
/**
* Initializes this instance with the specified name and an
* identical path.
+ *
+ * @param name the name of the virtual file to be created
+ * @return the created virtual file
*/
- def this(name: String) = this(name, name);
+ def this(name: String) = this(name, name)
//########################################################################
// Public Methods
- def path = _path;
+ def path = _path
/** Returns null. */
- final def file: File = null;
+ final def file: File = null
/** Is this abstract file a directory? */
- def isDirectory: Boolean = false;
+ def isDirectory: Boolean = false
/** Returns the time that this abstract file was last modified. */
- def lastModified: Long = Long.MIN_VALUE;
+ def lastModified: Long = Long.MIN_VALUE
/** Returns all abstract subfiles of this abstract directory. */
def elements: Iterator[AbstractFile] = {
- assert(isDirectory, "not a directory '" + this + "'");
- Iterator.empty;
+ assert(isDirectory, "not a directory '" + this + "'")
+ Iterator.empty
}
/**
@@ -51,10 +55,14 @@ class VirtualFile(val name: String, _path: String) extends AbstractFile {
* specified name. If there is no such file, returns null. The
* argument "directory" tells whether to look for a directory or
* or a regular file.
+ *
+ * @param name ...
+ * @param directory ...
+ * @return ...
*/
def lookupName(name: String, directory: Boolean): AbstractFile = {
- assert(isDirectory, "not a directory '" + this + "'");
- null;
+ assert(isDirectory, "not a directory '" + this + "'")
+ null
}
//########################################################################
diff --git a/src/compiler/scala/tools/nsc/io/ZipArchive.scala b/src/compiler/scala/tools/nsc/io/ZipArchive.scala
index 99694b73fa..b0bbd91c1e 100644
--- a/src/compiler/scala/tools/nsc/io/ZipArchive.scala
+++ b/src/compiler/scala/tools/nsc/io/ZipArchive.scala
@@ -1,30 +1,41 @@
-/* ____ ____ ____ ____ ______ *\
-** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
-** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
-** /_____/\____/\___/\____/____/ **
-\* */
-
+/* NSC -- new Scala compiler
+ * Copyright 2005-2006 LAMP/EPFL
+ * @author Martin Odersky
+ */
// $Id$
-package scala.tools.nsc.io;
+package scala.tools.nsc.io
+import java.io.{File, IOException, InputStream}
+import java.util.Enumeration
+import java.util.zip.{ZipEntry, ZipFile}
-import java.io.{File, IOException, InputStream};
-import java.util.Enumeration;
-import java.util.zip.{ZipEntry, ZipFile};
import scala.collection.mutable.{Map, HashMap}
+/**
+ * @author Philippe Altherr
+ * @version 1.0, 23/03/2004
+ */
object ZipArchive {
//########################################################################
- /** Returns "fromFile(new File(path))". */
- def fromPath(path: String): AbstractFile = fromFile(new File(path));
+ /**
+ * ...
+ *
+ * @param path ...
+ * @return ...
+ */
+ def fromPath(path: String): AbstractFile = fromFile(new File(path))
/**
- * If the specified File exists and is a readable zip archive,
- * returns an abstract file backed by it. Otherwise, returns null.
+ * If the specified file <code>file</code> exists and is a readable
+ * zip archive, returns an abstract file backed by it. Otherwise,
+ * returns <code>null</code>.
+ *
+ * @param file ...
+ * @return ...
*/
def fromFile(file: File): AbstractFile =
try { new ZipArchive(file, new ZipFile(file)) }
@@ -32,6 +43,9 @@ object ZipArchive {
/**
* Returns an abstract directory backed by the specified archive.
+ *
+ * @param archive ...
+ * @return ...
*/
def fromArchive(archive: ZipFile): AbstractFile =
new ZipArchive(new File(archive.getName()), archive);
@@ -49,18 +63,18 @@ final class ZipArchive(file: File, val archive: ZipFile) extends PlainFile(file)
// Private Fields
/** The root directory or null if not yet initialized */
- private var root: DirEntry = _;
+ private var root: DirEntry = _
//########################################################################
// Public Methods
/** Returns true. */
- override def isDirectory = true;
+ override def isDirectory = true
/** Returns all abstract subfiles of this abstract directory. */
override def elements: Iterator[AbstractFile] = {
- if (root == null) load();
- root.elements;
+ if (root == null) load()
+ root.elements
}
/**
@@ -70,8 +84,8 @@ final class ZipArchive(file: File, val archive: ZipFile) extends PlainFile(file)
* or a regular file.
*/
override def lookupName(name: String, directory: Boolean): AbstractFile = {
- if (root == null) load();
- root.lookupName(name, directory);
+ if (root == null) load()
+ root.lookupName(name, directory)
}
//########################################################################
@@ -79,27 +93,27 @@ final class ZipArchive(file: File, val archive: ZipFile) extends PlainFile(file)
/** Loads the archive and creates the root directory. */
private def load(): Unit = {
- this.root = new DirEntry("<root>", "/");
+ this.root = new DirEntry("<root>", "/")
// A path to DirEntry map
- val dirs: Map[String,DirEntry] = new HashMap();
- dirs.update("/", root);
- val entries = archive.entries();
+ val dirs: Map[String,DirEntry] = new HashMap()
+ dirs.update("/", root)
+ val entries = archive.entries()
while (entries.hasMoreElements()) {
- val entry = entries.nextElement().asInstanceOf[ZipEntry];
- val path = entry.getName();
+ val entry = entries.nextElement().asInstanceOf[ZipEntry]
+ val path = entry.getName()
assert(entry.isDirectory() == path.endsWith("/"),
this.toString() + " - " + path);
if (entry.isDirectory()) {
- val dir: DirEntry = getDir(dirs, path);
- assert(dir.entry == null, this.toString() + " - " + path);
- dir.entry = entry;
+ val dir: DirEntry = getDir(dirs, path)
+ assert(dir.entry == null, this.toString() + " - " + path)
+ dir.entry = entry
} else {
- val index = path.lastIndexOf('/');
- val name = if (index < 0) path else path.substring(index + 1);
- val home = if (index < 0) "/" else path.substring(0, index + 1);
- val parent: DirEntry = getDir(dirs, home);
- assert(!parent.entries.contains(path), this.toString() + " - " + path);
- parent.entries.update(name, new FileEntry(name, path, entry));
+ val index = path.lastIndexOf('/')
+ val name = if (index < 0) path else path.substring(index + 1)
+ val home = if (index < 0) "/" else path.substring(0, index + 1)
+ val parent: DirEntry = getDir(dirs, home)
+ assert(!parent.entries.contains(path), this.toString() + " - " + path)
+ parent.entries.update(name, new FileEntry(name, path, entry))
}
}
}
@@ -130,10 +144,8 @@ final class ZipArchive(file: File, val archive: ZipFile) extends PlainFile(file)
/** Superclass of archive entries */
abstract class Entry(name: String, path: String)
- extends VirtualFile(name, path)
- {
-
- final override def path = ZipArchive.this.toString() + "(" + super.path + ")";
+ extends VirtualFile(name, path) {
+ final override def path = ZipArchive.this.toString() + "(" + super.path + ")"
final def getArchive = ZipArchive.this.archive
}
@@ -145,16 +157,16 @@ final class ZipArchive(file: File, val archive: ZipFile) extends PlainFile(file)
extends Entry(name, path)
{
- val entries: Map[String,Entry] = new HashMap();
+ val entries: Map[String,Entry] = new HashMap()
- var entry: ZipEntry = _;
+ var entry: ZipEntry = _
- override def isDirectory = true;
+ override def isDirectory = true
override def lastModified: Long =
- if (entry != null) entry.getTime() else super.lastModified;
+ if (entry != null) entry.getTime() else super.lastModified
- override def elements: Iterator[AbstractFile] = entries.values;
+ override def elements: Iterator[AbstractFile] = entries.values
override def lookupName(name: String, directory: Boolean): AbstractFile =
entries.get(if (directory) name + "/" else name) match {
@@ -171,7 +183,7 @@ final class ZipArchive(file: File, val archive: ZipFile) extends PlainFile(file)
extends Entry(name, path)
{
- override def lastModified: Long = entry.getTime();
+ override def lastModified: Long = entry.getTime()
/** in zip archives, we assume class files conform to Java spec by using UTF-8 * /
def getBytes: Array[Byte] = {