mirror of https://github.com/sbt/sbt.git
Deprecate some methods replaced by PathFinder.pair
This commit is contained in:
parent
4506c8b877
commit
715a5655ef
|
|
@ -14,7 +14,7 @@ that can be useful for constructing the `Seq[(File, String)]` or
|
||||||
|
|
||||||
A common way of making this sequence is to start with a `PathFinder`
|
A common way of making this sequence is to start with a `PathFinder`
|
||||||
or `Seq[File]` (which is implicitly convertible to `PathFinder`) and
|
or `Seq[File]` (which is implicitly convertible to `PathFinder`) and
|
||||||
then call the `x` method. See the
|
then call the `pair` method. See the
|
||||||
`PathFinder <../../api/sbt/PathFinder.html>`_
|
`PathFinder <../../api/sbt/PathFinder.html>`_
|
||||||
API for details, but essentially this method accepts a function
|
API for details, but essentially this method accepts a function
|
||||||
`File => Option[String]` or `File => Option[File]` that is used to
|
`File => Option[String]` or `File => Option[File]` that is used to
|
||||||
|
|
@ -37,7 +37,7 @@ For example:
|
||||||
import Path.relativeTo
|
import Path.relativeTo
|
||||||
val files: Seq[File] = file("/a/b/C.scala") :: Nil
|
val files: Seq[File] = file("/a/b/C.scala") :: Nil
|
||||||
val baseDirectories: Seq[File] = file("/a") :: Nil
|
val baseDirectories: Seq[File] = file("/a") :: Nil
|
||||||
val mappings: Seq[(File,String)] = files x relativeTo(baseDirectories)
|
val mappings: Seq[(File,String)] = files pair relativeTo(baseDirectories)
|
||||||
|
|
||||||
val expected = (file("/a/b/C.scala") -> "b/C.scala") :: Nil
|
val expected = (file("/a/b/C.scala") -> "b/C.scala") :: Nil
|
||||||
assert( mappings == expected )
|
assert( mappings == expected )
|
||||||
|
|
@ -59,7 +59,7 @@ For example, the following demonstrates building a
|
||||||
import Path.rebase
|
import Path.rebase
|
||||||
val files: Seq[File] = file("/a/b/C.scala") :: Nil
|
val files: Seq[File] = file("/a/b/C.scala") :: Nil
|
||||||
val baseDirectories: Seq[File] = file("/a") :: Nil
|
val baseDirectories: Seq[File] = file("/a") :: Nil
|
||||||
val mappings: Seq[(File,String)] = files x rebase(baseDirectories, "pre/")
|
val mappings: Seq[(File,String)] = files pair rebase(baseDirectories, "pre/")
|
||||||
|
|
||||||
val expected = (file("/a/b/C.scala") -> "pre/b/C.scala" ) :: Nil
|
val expected = (file("/a/b/C.scala") -> "pre/b/C.scala" ) :: Nil
|
||||||
assert( mappings == expected )
|
assert( mappings == expected )
|
||||||
|
|
@ -72,7 +72,7 @@ Or, to build a `Seq[(File, File)]`:
|
||||||
val files: Seq[File] = file("/a/b/C.scala") :: Nil
|
val files: Seq[File] = file("/a/b/C.scala") :: Nil
|
||||||
val baseDirectories: Seq[File] = file("/a") :: Nil
|
val baseDirectories: Seq[File] = file("/a") :: Nil
|
||||||
val newBase: File = file("/new/base")
|
val newBase: File = file("/new/base")
|
||||||
val mappings: Seq[(File,File)] = files x rebase(baseDirectories, newBase)
|
val mappings: Seq[(File,File)] = files pair rebase(baseDirectories, newBase)
|
||||||
|
|
||||||
val expected = (file("/a/b/C.scala") -> file("/new/base/b/C.scala") ) :: Nil
|
val expected = (file("/a/b/C.scala") -> file("/new/base/b/C.scala") ) :: Nil
|
||||||
assert( mappings == expected )
|
assert( mappings == expected )
|
||||||
|
|
@ -89,7 +89,7 @@ directory. For example:
|
||||||
|
|
||||||
import Path.flat
|
import Path.flat
|
||||||
val files: Seq[File] = file("/a/b/C.scala") :: Nil
|
val files: Seq[File] = file("/a/b/C.scala") :: Nil
|
||||||
val mappings: Seq[(File,String)] = files x flat
|
val mappings: Seq[(File,String)] = files pair flat
|
||||||
|
|
||||||
val expected = (file("/a/b/C.scala") -> "C.scala" ) :: Nil
|
val expected = (file("/a/b/C.scala") -> "C.scala" ) :: Nil
|
||||||
assert( mappings == expected )
|
assert( mappings == expected )
|
||||||
|
|
@ -101,7 +101,7 @@ To build a `Seq[(File, File)]` using `flat`:
|
||||||
import Path.flat
|
import Path.flat
|
||||||
val files: Seq[File] = file("/a/b/C.scala") :: Nil
|
val files: Seq[File] = file("/a/b/C.scala") :: Nil
|
||||||
val newBase: File = file("/new/base")
|
val newBase: File = file("/new/base")
|
||||||
val mappings: Seq[(File,File)] = files x flat(newBase)
|
val mappings: Seq[(File,File)] = files pair flat(newBase)
|
||||||
|
|
||||||
val expected = (file("/a/b/C.scala") -> file("/new/base/C.scala") ) :: Nil
|
val expected = (file("/a/b/C.scala") -> file("/new/base/C.scala") ) :: Nil
|
||||||
assert( mappings == expected )
|
assert( mappings == expected )
|
||||||
|
|
@ -119,7 +119,7 @@ fall back to flattening:
|
||||||
import Path.relativeTo
|
import Path.relativeTo
|
||||||
val files: Seq[File] = file("/a/b/C.scala") :: file("/zzz/D.scala") :: Nil
|
val files: Seq[File] = file("/a/b/C.scala") :: file("/zzz/D.scala") :: Nil
|
||||||
val baseDirectories: Seq[File] = file("/a") :: Nil
|
val baseDirectories: Seq[File] = file("/a") :: Nil
|
||||||
val mappings: Seq[(File,String)] = files x ( relativeTo(baseDirectories) | flat )
|
val mappings: Seq[(File,String)] = files pair ( relativeTo(baseDirectories) | flat )
|
||||||
|
|
||||||
val expected = (file("/a/b/C.scala") -> "b/C.scala") ) :: (file("/zzz/D.scala") -> "D.scala") ) :: Nil
|
val expected = (file("/a/b/C.scala") -> "b/C.scala") ) :: (file("/zzz/D.scala") -> "D.scala") ) :: Nil
|
||||||
assert( mappings == expected )
|
assert( mappings == expected )
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ and :doc:`/Detailed-Topics/Paths` for the full documentation.
|
||||||
as collections (like `Seq`) and
|
as collections (like `Seq`) and
|
||||||
`Parser <../api/sbt/complete/Parser.html>`_
|
`Parser <../api/sbt/complete/Parser.html>`_
|
||||||
(see :doc:`/Detailed-Topics/Parsing-Input`).
|
(see :doc:`/Detailed-Topics/Parsing-Input`).
|
||||||
- `x` Used to construct mappings from a `File` to another `File`
|
- `pair` Used to construct mappings from a `File` to another `File`
|
||||||
or to a `String`. See :doc:`/Detailed-Topics/Mapping-Files`.
|
or to a `String`. See :doc:`/Detailed-Topics/Mapping-Files`.
|
||||||
- `get` forces a `PathFinder <../api/sbt/PathFinder.html>`_
|
- `get` forces a `PathFinder <../api/sbt/PathFinder.html>`_
|
||||||
(a call-by-name data structure) to a strict `Seq[File]`
|
(a call-by-name data structure) to a strict `Seq[File]`
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,7 @@ sealed abstract class PathFinder
|
||||||
* of paths selected by this finder.*/
|
* of paths selected by this finder.*/
|
||||||
final def \ (literal: String): PathFinder = this / literal
|
final def \ (literal: String): PathFinder = this / literal
|
||||||
|
|
||||||
|
@deprecated("Use pair.", "0.13.1")
|
||||||
def x_: Traversable[(File,T)] = x(mapper, false)
|
def x_: Traversable[(File,T)] = x(mapper, false)
|
||||||
|
|
||||||
/** Applies `mapper` to each path selected by this PathFinder and returns the path paired with the non-empty result.
|
/** Applies `mapper` to each path selected by this PathFinder and returns the path paired with the non-empty result.
|
||||||
|
|
@ -124,6 +125,7 @@ sealed abstract class PathFinder
|
||||||
/** Applies `mapper` to each path selected by this PathFinder and returns the path paired with the non-empty result.
|
/** Applies `mapper` to each path selected by this PathFinder and returns the path paired with the non-empty result.
|
||||||
* If the result is empty (None) and `errorIfNone` is true, an exception is thrown.
|
* If the result is empty (None) and `errorIfNone` is true, an exception is thrown.
|
||||||
* If `errorIfNone` is false, the path is dropped from the returned Traversable.*/
|
* If `errorIfNone` is false, the path is dropped from the returned Traversable.*/
|
||||||
|
@deprecated("Use pair.", "0.13.1")
|
||||||
def x[T](mapper: File => Option[T], errorIfNone: Boolean = true): Seq[(File,T)] =
|
def x[T](mapper: File => Option[T], errorIfNone: Boolean = true): Seq[(File,T)] =
|
||||||
{
|
{
|
||||||
val apply = if(errorIfNone) mapper | fail else mapper
|
val apply = if(errorIfNone) mapper | fail else mapper
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue