diff options
author | Paul Phillips <paulp@improving.org> | 2010-02-01 22:35:12 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-02-01 22:35:12 +0000 |
commit | b80125cb3fa7ab12b5921ee930c04e9d95384861 (patch) | |
tree | 2e3c09c8c62a7e13facef213d01e0d72009e432b /src/compiler/scala/tools/nsc/io/Path.scala | |
parent | 3282ac260cebe12a2d0dcb6bb7c0e479e0e20c6c (diff) | |
download | scala-b80125cb3fa7ab12b5921ee930c04e9d95384861.tar.gz scala-b80125cb3fa7ab12b5921ee930c04e9d95384861.tar.bz2 scala-b80125cb3fa7ab12b5921ee930c04e9d95384861.zip |
Quite a lot more work on completion.
completion is now avilable, with some caveats. Review by community.
Diffstat (limited to 'src/compiler/scala/tools/nsc/io/Path.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/io/Path.scala | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/compiler/scala/tools/nsc/io/Path.scala b/src/compiler/scala/tools/nsc/io/Path.scala index de1d129e00..b3f7ea5ab5 100644 --- a/src/compiler/scala/tools/nsc/io/Path.scala +++ b/src/compiler/scala/tools/nsc/io/Path.scala @@ -92,6 +92,7 @@ class Path private[io] (val jfile: JFile) def name: String = jfile.getName() def path: String = jfile.getPath() def normalize: Path = Path(jfile.getCanonicalPath()) + def isRootPath: Boolean = roots exists (_ isSame this) def resolve(other: Path) = if (other.isAbsolute || isEmpty) other else /(other) def relativize(other: Path) = { @@ -113,17 +114,19 @@ class Path private[io] (val jfile: JFile) /** * @return The path of the parent directory, or root if path is already root */ - def parent: Path = { - val p = path match { - case "" | "." => ".." - case _ if path endsWith ".." => path + separator + ".." // the only solution - case _ => jfile.getParent match { - case null if isAbsolute => path // it should be a root. BTW, don't need to worry about relative pathed root - case null => "." // a file ot dir under pwd - case x => x - } - } - new Directory(new JFile(p)) + def parent: Directory = path match { + case "" | "." => Directory("..") + case _ => + // the only solution <-- a comment which could have used elaboration + if (segments.nonEmpty && segments.last == "..") + (path / "..").toDirectory + else jfile.getParent match { + case null => + if (isAbsolute) toDirectory // it should be a root. BTW, don't need to worry about relative pathed root + else Directory(".") // a dir under pwd + case x => + Directory(x) + } } def parents: List[Path] = { val p = parent |