3
3
*/
4
4
package dotty .tools .dotc .classpath
5
5
6
- import java .io .File // TODO rename to JFile for consistency
6
+ import java .io .{ File => JFile }
7
7
import java .net .{URI , URL }
8
8
import java .nio .file .{FileSystems , Files , SimpleFileVisitor }
9
9
import java .util .function .IntFunction
@@ -86,15 +86,15 @@ trait DirectoryLookup[FileEntryType <: ClassRepresentation] extends ClassPath {
86
86
}
87
87
88
88
trait JFileDirectoryLookup [FileEntryType <: ClassRepresentation ] extends DirectoryLookup [FileEntryType ] {
89
- type F = File
89
+ type F = JFile
90
90
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)
94
94
if (packageDir.exists && packageDir.isDirectory) Some (packageDir)
95
95
else None
96
96
}
97
- protected def listChildren (dir : File , filter : Option [File => Boolean ]): Array [File ] = {
97
+ protected def listChildren (dir : JFile , filter : Option [JFile => Boolean ]): Array [JFile ] = {
98
98
val listing = filter match {
99
99
case Some (f) => dir.listFiles(mkFileFilter(f))
100
100
case None => dir.listFiles()
@@ -112,15 +112,15 @@ trait JFileDirectoryLookup[FileEntryType <: ClassRepresentation] extends Directo
112
112
// Note this behaviour can be enabled in javac with `javac -XDsortfiles`, but that's only
113
113
// intended to improve determinism of the compiler for compiler hackers.
114
114
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)
117
117
})
118
118
listing
119
119
} else Array ()
120
120
}
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
124
124
125
125
assert(dir != null , " Directory file in DirectoryFileLookup cannot be null" )
126
126
@@ -205,12 +205,12 @@ final class JrtClassPath(fs: java.nio.file.FileSystem) extends ClassPath with No
205
205
dottedClassName.substring(0 , dottedClassName.lastIndexOf(" ." ))
206
206
}
207
207
208
- case class DirectoryClassPath (dir : File ) extends JFileDirectoryLookup [ClassFileEntryImpl ] with NoSourcePaths {
208
+ case class DirectoryClassPath (dir : JFile ) extends JFileDirectoryLookup [ClassFileEntryImpl ] with NoSourcePaths {
209
209
override def findClass (className : String ): Option [ClassRepresentation ] = findClassFile(className) map ClassFileEntryImpl
210
210
211
211
def findClassFile (className : String ): Option [AbstractFile ] = {
212
212
val relativePath = FileUtils .dirPath(className)
213
- val classFile = new File (s " $dir/ $relativePath.class " )
213
+ val classFile = new JFile (s " $dir/ $relativePath.class " )
214
214
if (classFile.exists) {
215
215
val wrappedClassFile = new dotty.tools.io.File (classFile.toPath)
216
216
val abstractClassFile = new PlainFile (wrappedClassFile)
@@ -219,23 +219,23 @@ case class DirectoryClassPath(dir: File) extends JFileDirectoryLookup[ClassFileE
219
219
}
220
220
221
221
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
223
223
224
224
private [dotty] def classes (inPackage : String ): Seq [ClassFileEntry ] = files(inPackage)
225
225
}
226
226
227
- case class DirectorySourcePath (dir : File ) extends JFileDirectoryLookup [SourceFileEntryImpl ] with NoClassPaths {
227
+ case class DirectorySourcePath (dir : JFile ) extends JFileDirectoryLookup [SourceFileEntryImpl ] with NoClassPaths {
228
228
def asSourcePathString : String = asClassPathString
229
229
230
230
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)
232
232
233
233
override def findClass (className : String ): Option [ClassRepresentation ] = findSourceFile(className) map SourceFileEntryImpl
234
234
235
235
private def findSourceFile (className : String ): Option [AbstractFile ] = {
236
236
val relativePath = FileUtils .dirPath(className)
237
237
val sourceFile = Stream (" scala" , " java" )
238
- .map(ext => new File (s " $dir/ $relativePath. $ext" ))
238
+ .map(ext => new JFile (s " $dir/ $relativePath. $ext" ))
239
239
.collectFirst { case file if file.exists() => file }
240
240
241
241
sourceFile.map { file =>
0 commit comments