@@ -47,28 +47,26 @@ trait DirectoryLookup[FileEntryType <: ClassRepresentation] extends ClassPath {
4747 protected def createFileEntry (file : AbstractFile ): FileEntryType
4848 protected def isMatchingFile (f : F ): Boolean
4949
50- private def getDirectory (forPackage : String ): Option [F ] = {
51- if (forPackage == ClassPath . RootPackage ) {
50+ private def getDirectory (forPackage : PackageName ): Option [F ] = {
51+ if (forPackage.isRoot ) {
5252 Some (dir)
5353 } else {
54- val packageDirName = FileUtils .dirPath(forPackage)
55- getSubDir(packageDirName)
54+ getSubDir(forPackage.dirPathTrailingSlash)
5655 }
5756 }
58- override private [nsc] def hasPackage (pkg : String ) = getDirectory(pkg).isDefined
57+ override private [nsc] def hasPackage (pkg : PackageName ) = getDirectory(pkg).isDefined
5958
60- private [nsc] def packages (inPackage : String ): Seq [PackageEntry ] = {
59+ private [nsc] def packages (inPackage : PackageName ): Seq [PackageEntry ] = {
6160 val dirForPackage = getDirectory(inPackage)
6261
6362 val nestedDirs : Array [F ] = dirForPackage match {
6463 case None => emptyFiles
6564 case Some (directory) => listChildren(directory, Some (isPackage))
6665 }
67- val prefix = PackageNameUtils .packagePrefix(inPackage)
68- nestedDirs.map(f => PackageEntryImpl (prefix + getName(f)))
66+ nestedDirs.map(f => PackageEntryImpl (inPackage.entryName(getName(f))))
6967 }
7068
71- protected def files (inPackage : String ): Seq [FileEntryType ] = {
69+ protected def files (inPackage : PackageName ): Seq [FileEntryType ] = {
7270 val dirForPackage = getDirectory(inPackage)
7371 val files : Array [F ] = dirForPackage match {
7472 case None => emptyFiles
@@ -77,18 +75,17 @@ trait DirectoryLookup[FileEntryType <: ClassRepresentation] extends ClassPath {
7775 files.map(f => createFileEntry(toAbstractFile(f)))
7876 }
7977
80- private [nsc] def list (inPackage : String ): ClassPathEntries = {
78+ private [nsc] def list (inPackage : PackageName ): ClassPathEntries = {
8179 val dirForPackage = getDirectory(inPackage)
8280 val files : Array [F ] = dirForPackage match {
8381 case None => emptyFiles
8482 case Some (directory) => listChildren(directory)
8583 }
86- val packagePrefix = PackageNameUtils .packagePrefix(inPackage)
8784 val packageBuf = collection.mutable.ArrayBuffer .empty[PackageEntry ]
8885 val fileBuf = collection.mutable.ArrayBuffer .empty[FileEntryType ]
8986 for (file <- files) {
9087 if (isPackage(file))
91- packageBuf += PackageEntryImpl (packagePrefix + getName(file))
88+ packageBuf += PackageEntryImpl (inPackage.entryName( getName(file) ))
9289 else if (isMatchingFile(file))
9390 fileBuf += createFileEntry(toAbstractFile(file))
9491 }
@@ -196,21 +193,21 @@ final class JrtClassPath(fs: java.nio.file.FileSystem) extends ClassPath with No
196193 }
197194
198195 /** Empty string represents root package */
199- override private [nsc] def hasPackage (pkg : String ) = packageToModuleBases.contains(pkg)
200- override private [nsc] def packages (inPackage : String ): Seq [PackageEntry ] = {
201- packageToModuleBases.keysIterator.filter(pack => packageContains(inPackage, pack)).map(PackageEntryImpl (_)).toVector
196+ override private [nsc] def hasPackage (pkg : PackageName ) = packageToModuleBases.contains(pkg.dottedString )
197+ override private [nsc] def packages (inPackage : PackageName ): Seq [PackageEntry ] = {
198+ packageToModuleBases.keysIterator.filter(pack => packageContains(inPackage.dottedString , pack)).map(PackageEntryImpl (_)).toVector
202199 }
203- private [nsc] def classes (inPackage : String ): Seq [ClassFileEntry ] = {
204- if (inPackage == " " ) Nil
200+ private [nsc] def classes (inPackage : PackageName ): Seq [ClassFileEntry ] = {
201+ if (inPackage.isRoot ) Nil
205202 else {
206- packageToModuleBases.getOrElse(inPackage, Nil ).flatMap(x =>
207- Files .list(x.resolve(inPackage.replace( '.' , '/' ) )).iterator().asScala.filter(_.getFileName.toString.endsWith(" .class" ))).map(x =>
203+ packageToModuleBases.getOrElse(inPackage.dottedString , Nil ).flatMap(x =>
204+ Files .list(x.resolve(inPackage.dirPathTrailingSlash )).iterator().asScala.filter(_.getFileName.toString.endsWith(" .class" ))).map(x =>
208205 ClassFileEntryImpl (new PlainNioFile (x))).toVector
209206 }
210207 }
211208
212- override private [nsc] def list (inPackage : String ): ClassPathEntries =
213- if (inPackage == " " ) ClassPathEntries (packages(inPackage), Nil )
209+ override private [nsc] def list (inPackage : PackageName ): ClassPathEntries =
210+ if (inPackage.isRoot ) ClassPathEntries (packages(inPackage), Nil )
214211 else ClassPathEntries (packages(inPackage), classes(inPackage))
215212
216213 def asURLs : Seq [URL ] = Seq (new URL (" jrt:/" ))
@@ -262,21 +259,21 @@ final class CtSymClassPath(ctSym: java.nio.file.Path, release: Int) extends Clas
262259 }
263260
264261 /** Empty string represents root package */
265- override private [nsc] def hasPackage (pkg : String ) = packageIndex.contains(pkg)
266- override private [nsc] def packages (inPackage : String ): Seq [PackageEntry ] = {
267- packageIndex.keysIterator.filter(pack => packageContains(inPackage, pack)).map(PackageEntryImpl (_)).toVector
262+ override private [nsc] def hasPackage (pkg : PackageName ) = packageIndex.contains(pkg.dottedString )
263+ override private [nsc] def packages (inPackage : PackageName ): Seq [PackageEntry ] = {
264+ packageIndex.keysIterator.filter(pack => packageContains(inPackage.dottedString , pack)).map(PackageEntryImpl (_)).toVector
268265 }
269- private [nsc] def classes (inPackage : String ): Seq [ClassFileEntry ] = {
270- if (inPackage == " " ) Nil
266+ private [nsc] def classes (inPackage : PackageName ): Seq [ClassFileEntry ] = {
267+ if (inPackage.isRoot ) Nil
271268 else {
272- val sigFiles = packageIndex.getOrElse(inPackage, Nil ).iterator.flatMap(p =>
269+ val sigFiles = packageIndex.getOrElse(inPackage.dottedString , Nil ).iterator.flatMap(p =>
273270 Files .list(p).iterator().asScala.filter(_.getFileName.toString.endsWith(" .sig" )))
274271 sigFiles.map(f => ClassFileEntryImpl (new PlainNioFile (f))).toVector
275272 }
276273 }
277274
278- override private [nsc] def list (inPackage : String ): ClassPathEntries =
279- if (inPackage == " " ) ClassPathEntries (packages(inPackage), Nil )
275+ override private [nsc] def list (inPackage : PackageName ): ClassPathEntries =
276+ if (inPackage.isRoot ) ClassPathEntries (packages(inPackage), Nil )
280277 else ClassPathEntries (packages(inPackage), classes(inPackage))
281278
282279 def asURLs : Seq [URL ] = Nil
@@ -310,7 +307,7 @@ case class DirectoryClassPath(dir: File) extends JFileDirectoryLookup[ClassFileE
310307 protected def createFileEntry (file : AbstractFile ): ClassFileEntryImpl = ClassFileEntryImpl (file)
311308 protected def isMatchingFile (f : File ): Boolean = f.isClass
312309
313- private [nsc] def classes (inPackage : String ): Seq [ClassFileEntry ] = files(inPackage)
310+ private [nsc] def classes (inPackage : PackageName ): Seq [ClassFileEntry ] = files(inPackage)
314311}
315312
316313case class DirectorySourcePath (dir : File ) extends JFileDirectoryLookup [SourceFileEntryImpl ] with NoClassPaths {
@@ -334,5 +331,5 @@ case class DirectorySourcePath(dir: File) extends JFileDirectoryLookup[SourceFil
334331 }
335332 }
336333
337- private [nsc] def sources (inPackage : String ): Seq [SourceFileEntry ] = files(inPackage)
334+ private [nsc] def sources (inPackage : PackageName ): Seq [SourceFileEntry ] = files(inPackage)
338335}
0 commit comments