From 715a5655ef288a79e7112ccd28e79de374ff1b4d Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Thu, 17 Oct 2013 15:00:48 -0400 Subject: [PATCH] Deprecate some methods replaced by PathFinder.pair --- src/sphinx/Detailed-Topics/Mapping-Files.rst | 14 +++++++------- src/sphinx/Name-Index.rst | 2 +- util/io/src/main/scala/sbt/Path.scala | 2 ++ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/sphinx/Detailed-Topics/Mapping-Files.rst b/src/sphinx/Detailed-Topics/Mapping-Files.rst index 1acec432d..7597612c9 100644 --- a/src/sphinx/Detailed-Topics/Mapping-Files.rst +++ b/src/sphinx/Detailed-Topics/Mapping-Files.rst @@ -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` 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>`_ API for details, but essentially this method accepts a function `File => Option[String]` or `File => Option[File]` that is used to @@ -37,7 +37,7 @@ For example: import Path.relativeTo val files: Seq[File] = file("/a/b/C.scala") :: 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 assert( mappings == expected ) @@ -59,7 +59,7 @@ For example, the following demonstrates building a import Path.rebase val files: Seq[File] = file("/a/b/C.scala") :: 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 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 baseDirectories: Seq[File] = file("/a") :: Nil 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 assert( mappings == expected ) @@ -89,7 +89,7 @@ directory. For example: import Path.flat 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 assert( mappings == expected ) @@ -101,7 +101,7 @@ To build a `Seq[(File, File)]` using `flat`: import Path.flat val files: Seq[File] = file("/a/b/C.scala") :: Nil 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 assert( mappings == expected ) @@ -119,7 +119,7 @@ fall back to flattening: import Path.relativeTo val files: Seq[File] = file("/a/b/C.scala") :: file("/zzz/D.scala") :: 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 assert( mappings == expected ) diff --git a/src/sphinx/Name-Index.rst b/src/sphinx/Name-Index.rst index 467b7323e..67b95f71e 100644 --- a/src/sphinx/Name-Index.rst +++ b/src/sphinx/Name-Index.rst @@ -130,7 +130,7 @@ and :doc:`/Detailed-Topics/Paths` for the full documentation. as collections (like `Seq`) and `Parser <../api/sbt/complete/Parser.html>`_ (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`. - `get` forces a `PathFinder <../api/sbt/PathFinder.html>`_ (a call-by-name data structure) to a strict `Seq[File]` diff --git a/util/io/src/main/scala/sbt/Path.scala b/util/io/src/main/scala/sbt/Path.scala index 10635e38f..479fc5eb4 100644 --- a/util/io/src/main/scala/sbt/Path.scala +++ b/util/io/src/main/scala/sbt/Path.scala @@ -113,6 +113,7 @@ sealed abstract class PathFinder * of paths selected by this finder.*/ final def \ (literal: String): PathFinder = this / literal + @deprecated("Use pair.", "0.13.1") def x_![T](mapper: File => Option[T]): 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. @@ -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. * 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.*/ + @deprecated("Use pair.", "0.13.1") def x[T](mapper: File => Option[T], errorIfNone: Boolean = true): Seq[(File,T)] = { val apply = if(errorIfNone) mapper | fail else mapper