Skip to content

Commit 6e43703

Browse files
committed
refactor: use dots to clear method chain and args
1 parent 8b75eeb commit 6e43703

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

compiler/src/dotty/tools/io/ClassPath.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ object ClassPath {
106106
dir.list.filter(x => filt(x.name) && (x.isDirectory || isJarOrZip(x))).map(_.path).toList
107107

108108
if (pattern == "*") lsDir(Directory("."))
109-
else if (pattern endsWith wildSuffix) lsDir(Directory(pattern dropRight 2))
110-
else if (pattern contains '*') {
109+
else if (pattern.endsWith(wildSuffix)) lsDir(Directory(pattern dropRight 2))
110+
else if (pattern.contains('*')) {
111111
try {
112112
val regexp = ("^" + pattern.replace("""\*""", """.*""") + "$").r
113113
lsDir(Directory(pattern).parent, regexp.findFirstIn(_).isDefined)
@@ -118,17 +118,17 @@ object ClassPath {
118118
}
119119

120120
/** Split classpath using platform-dependent path separator */
121-
def split(path: String): List[String] = (path split pathSeparator).toList.filterNot(_ == "").distinct
121+
def split(path: String): List[String] = path.split(pathSeparator).toList.filterNot(_ == "").distinct
122122

123123
/** Join classpath using platform-dependent path separator */
124-
def join(paths: String*): String = paths filterNot (_ == "") mkString pathSeparator
124+
def join(paths: String*): String = paths.filterNot(_ == "").mkString(pathSeparator)
125125

126126
/** Split the classpath, apply a transformation function, and reassemble it. */
127127
def map(cp: String, f: String => String): String = join(split(cp) map f: _*)
128128

129129
/** Expand path and possibly expanding stars */
130130
def expandPath(path: String, expandStar: Boolean = true): List[String] =
131-
if (expandStar) split(path) flatMap expandS
131+
if (expandStar) split(path).flatMap(expandS)
132132
else split(path)
133133

134134
/** Expand dir out to contents, a la extdir */

compiler/src/dotty/tools/io/Jar.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ class Jar(file: File) {
4646
lazy val jarFile: JarFile = new JarFile(file.jpath.toFile)
4747
lazy val manifest: Option[Manifest] = withJarInput(s => Option(s.getManifest))
4848

49-
def mainClass: Option[String] = manifest map (f => f(Name.MAIN_CLASS))
49+
def mainClass: Option[String] = manifest.map(_(Name.MAIN_CLASS))
5050
/** The manifest-defined classpath String if available. */
5151
def classPathString: Option[String] =
52-
for (m <- manifest ; cp <- m.attrs get Name.CLASS_PATH) yield cp
52+
for (m <- manifest ; cp <- m.attrs.get(Name.CLASS_PATH)) yield cp
5353
def classPathElements: List[String] = classPathString match {
54-
case Some(s) => s split "\\s+" toList
54+
case Some(s) => s.split("\\s+").toList
5555
case _ => Nil
5656
}
5757

compiler/src/dotty/tools/io/Path.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ object Path {
4444
else name.substring(i + 1).toLowerCase
4545
}
4646

47-
def onlyDirs(xs: Iterator[Path]): Iterator[Directory] = xs filter (_.isDirectory) map (_.toDirectory)
48-
def onlyDirs(xs: List[Path]): List[Directory] = xs filter (_.isDirectory) map (_.toDirectory)
49-
def onlyFiles(xs: Iterator[Path]): Iterator[File] = xs filter (_.isFile) map (_.toFile)
47+
def onlyDirs(xs: Iterator[Path]): Iterator[Directory] = xs.filter(_.isDirectory).map(_.toDirectory)
48+
def onlyDirs(xs: List[Path]): List[Directory] = xs.filter(_.isDirectory).map(_.toDirectory)
49+
def onlyFiles(xs: Iterator[Path]): Iterator[File] = xs.filter(_.isFile).map(_.toFile)
5050

5151
def roots: List[Path] = FileSystems.getDefault.getRootDirectories.iterator().asScala.map(Path.apply).toList
5252

@@ -103,7 +103,7 @@ class Path private[io] (val jpath: JPath) {
103103
*/
104104
def walkFilter(cond: Path => Boolean): Iterator[Path] =
105105
if (isFile) toFile walkFilter cond
106-
else if (isDirectory) toDirectory walkFilter cond
106+
else if (isDirectory) toDirectory.walkFilter(cond)
107107
else Iterator.empty
108108

109109
/** Equivalent to walkFilter(_ => true).

compiler/src/dotty/tools/io/PlainFile.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import java.io.{InputStream, OutputStream}
1111
/** ''Note: This library is considered experimental and should not be used unless you know what you are doing.'' */
1212
class PlainDirectory(givenPath: Directory) extends PlainFile(givenPath) {
1313
override def isDirectory: Boolean = true
14-
override def iterator(): Iterator[PlainFile] = givenPath.list filter (_.exists) map (x => new PlainFile(x))
14+
override def iterator(): Iterator[PlainFile] = givenPath.list.filter(_.exists).map(new PlainFile(_))
1515
override def delete(): Unit = givenPath.deleteRecursively()
1616
}
1717

0 commit comments

Comments
 (0)