mirror of
https://github.com/sbt/sbt.git
synced 2026-08-22 06:07:24 +02:00
Fixes #1530. Fixes NPE by using IO.listFiles
This commit is contained in:
+2
-1
@@ -47,6 +47,7 @@
|
|||||||
[1516]: https://github.com/sbt/sbt/pull/1516
|
[1516]: https://github.com/sbt/sbt/pull/1516
|
||||||
[1465]: https://github.com/sbt/sbt/issues/1465
|
[1465]: https://github.com/sbt/sbt/issues/1465
|
||||||
[1524]: https://github.com/sbt/sbt/issues/1524
|
[1524]: https://github.com/sbt/sbt/issues/1524
|
||||||
|
[1530]: https://github.com/sbt/sbt/issues/1530
|
||||||
|
|
||||||
[@dansanduleac]: https://github.com/dansanduleac
|
[@dansanduleac]: https://github.com/dansanduleac
|
||||||
[@2m]: https://github.com/2m
|
[@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 `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 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 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
|
### Maven Central Repository defaults to HTTPS
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package sbt.complete
|
package sbt.complete
|
||||||
|
|
||||||
import java.io.File
|
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
|
* 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)
|
override def withAddedPrefix(addedPrefix: String): FileExamples = new FileExamples(base, prefix + addedPrefix)
|
||||||
|
|
||||||
protected def files(directory: File): Stream[String] = {
|
protected def files(directory: File): Stream[String] = {
|
||||||
val childPaths = directory.listFiles().toStream
|
val childPaths = IO.listFiles(directory).toStream
|
||||||
val prefixedDirectChildPaths = childPaths.map(relativize(base, _).get).filter(_ startsWith prefix)
|
val prefixedDirectChildPaths = childPaths map { IO.relativize(base, _).get } filter { _ startsWith prefix }
|
||||||
val dirsToRecurseInto = childPaths.filter(_.isDirectory).map(relativize(base, _).get).filter(dirStartsWithPrefix)
|
val dirsToRecurseInto = childPaths filter { _.isDirectory } map { IO.relativize(base, _).get } filter { dirStartsWithPrefix }
|
||||||
prefixedDirectChildPaths append dirsToRecurseInto.flatMap(dir => files(new File(base, dir)))
|
prefixedDirectChildPaths append dirsToRecurseInto.flatMap(dir => files(new File(base, dir)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -80,8 +80,7 @@ class FileExamplesTest extends Specification {
|
|||||||
(childDirectories ++ nestedDirectories).map(_.mkdirs())
|
(childDirectories ++ nestedDirectories).map(_.mkdirs())
|
||||||
(childFiles ++ nestedFiles).map(_.createNewFile())
|
(childFiles ++ nestedFiles).map(_.createNewFile())
|
||||||
|
|
||||||
// NOTE: Creating a new file here because `tempDir.listFiles()` returned an empty list.
|
baseDir = tempDir
|
||||||
baseDir = new File(tempDir.getCanonicalPath)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private def toChildFiles(baseDir: File, files: List[String]): List[File] = files.map(new File(baseDir, _))
|
private def toChildFiles(baseDir: File, files: List[String]): List[File] = files.map(new File(baseDir, _))
|
||||||
|
|||||||
Reference in New Issue
Block a user