Skip to content

Commit 7fefe01

Browse files
committed
Rename java.io.File to JFile for consistency
1 parent 195c109 commit 7fefe01

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

compiler/src/dotty/tools/dotc/classpath/DirectoryClassPath.scala

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
package dotty.tools.dotc.classpath
55

6-
import java.io.File // TODO rename to JFile for consistency
6+
import java.io.{File => JFile}
77
import java.net.{URI, URL}
88
import java.nio.file.{FileSystems, Files, SimpleFileVisitor}
99
import java.util.function.IntFunction
@@ -86,15 +86,15 @@ trait DirectoryLookup[FileEntryType <: ClassRepresentation] extends ClassPath {
8686
}
8787

8888
trait JFileDirectoryLookup[FileEntryType <: ClassRepresentation] extends DirectoryLookup[FileEntryType] {
89-
type F = File
89+
type F = JFile
9090

91-
protected def emptyFiles: Array[File] = Array.empty
92-
protected def getSubDir(packageDirName: String): Option[File] = {
93-
val packageDir = new File(dir, packageDirName)
91+
protected def emptyFiles: Array[JFile] = Array.empty
92+
protected def getSubDir(packageDirName: String): Option[JFile] = {
93+
val packageDir = new JFile(dir, packageDirName)
9494
if (packageDir.exists && packageDir.isDirectory) Some(packageDir)
9595
else None
9696
}
97-
protected def listChildren(dir: File, filter: Option[File => Boolean]): Array[File] = {
97+
protected def listChildren(dir: JFile, filter: Option[JFile => Boolean]): Array[JFile] = {
9898
val listing = filter match {
9999
case Some(f) => dir.listFiles(mkFileFilter(f))
100100
case None => dir.listFiles()
@@ -112,15 +112,15 @@ trait JFileDirectoryLookup[FileEntryType <: ClassRepresentation] extends Directo
112112
// Note this behaviour can be enabled in javac with `javac -XDsortfiles`, but that's only
113113
// intended to improve determinism of the compiler for compiler hackers.
114114
java.util.Arrays.sort(listing,
115-
new java.util.Comparator[File] {
116-
def compare(o1: File, o2: File) = o1.getName.compareTo(o2.getName)
115+
new java.util.Comparator[JFile] {
116+
def compare(o1: JFile, o2: JFile) = o1.getName.compareTo(o2.getName)
117117
})
118118
listing
119119
} else Array()
120120
}
121-
protected def getName(f: File): String = f.getName
122-
protected def toAbstractFile(f: File): AbstractFile = new PlainFile(new dotty.tools.io.File(f.toPath))
123-
protected def isPackage(f: File): Boolean = f.isPackage
121+
protected def getName(f: JFile): String = f.getName
122+
protected def toAbstractFile(f: JFile): AbstractFile = new PlainFile(new dotty.tools.io.File(f.toPath))
123+
protected def isPackage(f: JFile): Boolean = f.isPackage
124124

125125
assert(dir != null, "Directory file in DirectoryFileLookup cannot be null")
126126

@@ -205,12 +205,12 @@ final class JrtClassPath(fs: java.nio.file.FileSystem) extends ClassPath with No
205205
dottedClassName.substring(0, dottedClassName.lastIndexOf("."))
206206
}
207207

208-
case class DirectoryClassPath(dir: File) extends JFileDirectoryLookup[ClassFileEntryImpl] with NoSourcePaths {
208+
case class DirectoryClassPath(dir: JFile) extends JFileDirectoryLookup[ClassFileEntryImpl] with NoSourcePaths {
209209
override def findClass(className: String): Option[ClassRepresentation] = findClassFile(className) map ClassFileEntryImpl
210210

211211
def findClassFile(className: String): Option[AbstractFile] = {
212212
val relativePath = FileUtils.dirPath(className)
213-
val classFile = new File(s"$dir/$relativePath.class")
213+
val classFile = new JFile(s"$dir/$relativePath.class")
214214
if (classFile.exists) {
215215
val wrappedClassFile = new dotty.tools.io.File(classFile.toPath)
216216
val abstractClassFile = new PlainFile(wrappedClassFile)
@@ -219,23 +219,23 @@ case class DirectoryClassPath(dir: File) extends JFileDirectoryLookup[ClassFileE
219219
}
220220

221221
protected def createFileEntry(file: AbstractFile): ClassFileEntryImpl = ClassFileEntryImpl(file)
222-
protected def isMatchingFile(f: File): Boolean = f.isClass
222+
protected def isMatchingFile(f: JFile): Boolean = f.isClass
223223

224224
private[dotty] def classes(inPackage: String): Seq[ClassFileEntry] = files(inPackage)
225225
}
226226

227-
case class DirectorySourcePath(dir: File) extends JFileDirectoryLookup[SourceFileEntryImpl] with NoClassPaths {
227+
case class DirectorySourcePath(dir: JFile) extends JFileDirectoryLookup[SourceFileEntryImpl] with NoClassPaths {
228228
def asSourcePathString: String = asClassPathString
229229

230230
protected def createFileEntry(file: AbstractFile): SourceFileEntryImpl = SourceFileEntryImpl(file)
231-
protected def isMatchingFile(f: File): Boolean = endsScalaOrJava(f.getName)
231+
protected def isMatchingFile(f: JFile): Boolean = endsScalaOrJava(f.getName)
232232

233233
override def findClass(className: String): Option[ClassRepresentation] = findSourceFile(className) map SourceFileEntryImpl
234234

235235
private def findSourceFile(className: String): Option[AbstractFile] = {
236236
val relativePath = FileUtils.dirPath(className)
237237
val sourceFile = Stream("scala", "java")
238-
.map(ext => new File(s"$dir/$relativePath.$ext"))
238+
.map(ext => new JFile(s"$dir/$relativePath.$ext"))
239239
.collectFirst { case file if file.exists() => file }
240240

241241
sourceFile.map { file =>

0 commit comments

Comments
 (0)