-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #238 from eatkins/m3-fixes
M3 fixes
- Loading branch information
Showing
52 changed files
with
1,054 additions
and
330 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ matrix: | |
include: | ||
- scala: 2.12.8 | ||
env: | ||
CMD="mimaReportBinaryIssues scalafmtCheckAll test whitesourceCheckPolicies doc" | ||
CMD="mimaReportBinaryIssues scalafmtCheckAll headerCheck Test/headerCheck test whitesourceCheckPolicies doc" | ||
TRAVIS_SCALA_VERSION=2.12.8 | ||
[email protected] | ||
os: linux | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
/* | ||
* sbt IO | ||
* | ||
* Copyright 2011 - 2019, Lightbend, Inc. | ||
* Copyright 2008 - 2010, Mark Harrah | ||
* | ||
* Licensed under Apache License 2.0 | ||
* (http://www.apache.org/licenses/LICENSE-2.0). | ||
*/ | ||
|
||
package sbt.internal.nio | ||
|
||
import java.nio.file.Path | ||
|
||
import sbt.io._ | ||
import sbt.nio.file.Glob.FullFileGlob | ||
import sbt.nio.file.RelativeGlob.{ Matcher, NoPath } | ||
import sbt.nio.file.{ AnyPath, Glob, RecursiveGlob, RelativeGlob } | ||
|
||
private[sbt] object Globs { | ||
private[sbt] def apply(base: Path, recursive: Boolean, fileFilter: FileFilter): Glob = { | ||
fileFilterToRelativeGlob(fileFilter) match { | ||
case Some(relativeGlob) => | ||
Glob(base, if (recursive) RecursiveGlob / relativeGlob else relativeGlob) | ||
case None => | ||
FullFileGlob(base, recursive, fileFilter) | ||
} | ||
} | ||
private[sbt] def fileFilterToRelativeGlob(fileFilter: FileFilter): Option[RelativeGlob] = | ||
fileFilter match { | ||
case nameFilter: NameFilter => nameFilterToRelativeGlob(nameFilter) | ||
case af: AndFilter => | ||
if (af.left == NothingFilter || af.right == NothingFilter) Some(NoPath) | ||
else if (af.left == AllPassFilter) fileFilterToRelativeGlob(af.right) | ||
else if (af.right == AllPassFilter) fileFilterToRelativeGlob(af.left) | ||
else { | ||
(fileFilterToRelativeGlob(af.left), fileFilterToRelativeGlob(af.right)) match { | ||
case (no @ Some(NoPath), _) => no | ||
case (_, no @ Some(NoPath)) => no | ||
case (Some(AnyPath), right) => right | ||
case (left, Some(AnyPath)) => left | ||
case (Some(left: Matcher), Some(right: Matcher)) => Some(Matcher.and(left, right)) | ||
case _ => None | ||
} | ||
} | ||
case nf: NotFilter => | ||
nf.fileFilter match { | ||
case NothingFilter => Some(AnyPath) | ||
case AllPassFilter => Some(NoPath) | ||
case f => | ||
fileFilterToRelativeGlob(f).collect { | ||
case m: Matcher => Matcher.not(m) | ||
} | ||
} | ||
case of: OrFilter => | ||
if (of.left == AllPassFilter || of.right == AllPassFilter) Some(AnyPath) | ||
else if (of.left == NothingFilter) fileFilterToRelativeGlob(of.right) | ||
else if (of.right == NothingFilter) fileFilterToRelativeGlob(of.left) | ||
else { | ||
(fileFilterToRelativeGlob(of.left), fileFilterToRelativeGlob(of.right)) match { | ||
case (Some(NoPath), right) => right | ||
case (left, Some(NoPath)) => left | ||
case (any @ Some(AnyPath), _) => any | ||
case (_, any @ Some(AnyPath)) => any | ||
case (Some(left: Matcher), Some(right: Matcher)) => Some(Matcher.and(left, right)) | ||
case _ => None | ||
} | ||
} | ||
case AllPassFilter | HiddenFileFilter => Some(AnyPath) | ||
case NothingFilter => Some(NoPath) | ||
case _ => None | ||
} | ||
private[sbt] def nameFilterToRelativeGlob(nameFilter: NameFilter): Option[Matcher] = | ||
nameFilter match { | ||
case AllPassFilter => Some(AnyPath) | ||
case af: AndNameFilter => | ||
if (af.left == NothingFilter || af.right == NothingFilter) Some(NoPath) | ||
else if (af.left == AllPassFilter) nameFilterToRelativeGlob(af.right) | ||
else if (af.right == AllPassFilter) nameFilterToRelativeGlob(af.left) | ||
else | ||
(nameFilterToRelativeGlob(af.left), nameFilterToRelativeGlob(af.right)) match { | ||
case (Some(AnyPath), right) => right | ||
case (left, Some(AnyPath)) => left | ||
case (no @ Some(NoPath), _) => no | ||
case (_, no @ Some(NoPath)) => no | ||
case (Some(l), Some(r)) => Some(Matcher.and(l, r)) | ||
case _ => None | ||
} | ||
case ef: ExactFilter => Some(Matcher(ef.matchName)) | ||
case ef: ExtensionFilter => | ||
ef.extensions match { | ||
case extensions if extensions.length == 1 => Some(Matcher(s"*.${extensions.head}")) | ||
case extensions => Some(Matcher(s"*.${extensions.mkString("{", ",", "}")}")) | ||
} | ||
case NothingFilter => Some(NoPath) | ||
case nf: NotNameFilter => | ||
if (nf.fileFilter == NothingFilter) Some(AnyPath) | ||
else nameFilterToRelativeGlob(nf.fileFilter).map(Matcher.not) | ||
case of: OrNameFilter => | ||
if (of.left == AllPassFilter || of.right == AllPassFilter) Some(AnyPath) | ||
else if (of.left == NothingFilter) nameFilterToRelativeGlob(of.right) | ||
else if (of.right == NothingFilter) nameFilterToRelativeGlob(of.left) | ||
else | ||
(nameFilterToRelativeGlob(of.left), nameFilterToRelativeGlob(of.right)) match { | ||
case (any @ Some(AnyPath), _) => any | ||
case (_, any @ Some(AnyPath)) => any | ||
case (Some(NoPath), right) => right | ||
case (left, Some(NoPath)) => left | ||
case (Some(l), Some(r)) => Some(Matcher.or(l, r)) | ||
case _ => None | ||
} | ||
case pf: PatternFilter => Some(Matcher(s"${pf.parts.mkString("*")}")) | ||
case pf: PrefixFilter => Some(Matcher(s"${pf.prefix}*")) | ||
case sf: SimpleFilter => Some(Matcher(sf.acceptFunction)) | ||
case sf: SuffixFilter => Some(Matcher(s"*${sf.suffix}")) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.