mirror of https://github.com/sbt/sbt.git
Merge pull request #1533 from sbt/fix/1530
Fixes #1530. Fixes NPE by using IO.listFiles
This commit is contained in:
commit
32990f3570
|
|
@ -47,6 +47,7 @@
|
|||
[1516]: https://github.com/sbt/sbt/pull/1516
|
||||
[1465]: https://github.com/sbt/sbt/issues/1465
|
||||
[1524]: https://github.com/sbt/sbt/issues/1524
|
||||
[1530]: https://github.com/sbt/sbt/issues/1530
|
||||
|
||||
[@dansanduleac]: https://github.com/dansanduleac
|
||||
[@2m]: https://github.com/2m
|
||||
|
|
@ -108,7 +109,7 @@
|
|||
- Fixes `build.sbt` errors causing `ArrayIndexOutOfBoundsException` due to invalid source in position. [#1181][1181] by [@eed3si9n][@eed3si9n]
|
||||
- Fixes config-classes leak in loading build files. [#1524][1524] by [@jsuereth][@jsuereth]
|
||||
- Fixes name-conflicts in hashed settings class files. [#1465][1465] by [@jsuereth][@jsuereth]
|
||||
|
||||
- Fixes `NullPointerError` in tab completion by `FileExamples`. [#1530][1530] by [@eed3si9n][@eed3si9n]
|
||||
|
||||
### Maven Central Repository defaults to HTTPS
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package sbt.complete
|
||||
|
||||
import java.io.File
|
||||
import sbt.IO._
|
||||
import sbt.IO
|
||||
|
||||
/**
|
||||
* These sources of examples are used in parsers for user input completion. An example of such a source is the
|
||||
|
|
@ -48,9 +48,9 @@ class FileExamples(base: File, prefix: String = "") extends ExampleSource {
|
|||
override def withAddedPrefix(addedPrefix: String): FileExamples = new FileExamples(base, prefix + addedPrefix)
|
||||
|
||||
protected def files(directory: File): Stream[String] = {
|
||||
val childPaths = directory.listFiles().toStream
|
||||
val prefixedDirectChildPaths = childPaths.map(relativize(base, _).get).filter(_ startsWith prefix)
|
||||
val dirsToRecurseInto = childPaths.filter(_.isDirectory).map(relativize(base, _).get).filter(dirStartsWithPrefix)
|
||||
val childPaths = IO.listFiles(directory).toStream
|
||||
val prefixedDirectChildPaths = childPaths map { IO.relativize(base, _).get } filter { _ startsWith prefix }
|
||||
val dirsToRecurseInto = childPaths filter { _.isDirectory } map { IO.relativize(base, _).get } filter { dirStartsWithPrefix }
|
||||
prefixedDirectChildPaths append dirsToRecurseInto.flatMap(dir => files(new File(base, dir)))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -80,8 +80,7 @@ class FileExamplesTest extends Specification {
|
|||
(childDirectories ++ nestedDirectories).map(_.mkdirs())
|
||||
(childFiles ++ nestedFiles).map(_.createNewFile())
|
||||
|
||||
// NOTE: Creating a new file here because `tempDir.listFiles()` returned an empty list.
|
||||
baseDir = new File(tempDir.getCanonicalPath)
|
||||
baseDir = tempDir
|
||||
}
|
||||
|
||||
private def toChildFiles(baseDir: File, files: List[String]): List[File] = files.map(new File(baseDir, _))
|
||||
|
|
|
|||
Loading…
Reference in New Issue