This commit is contained in:
Eugene Yokota 2014-10-21 12:18:54 -04:00
commit 97584457fa
6 changed files with 96 additions and 71 deletions

View File

@ -95,6 +95,21 @@ private[sbt] case class SbtParser(file: File, lines: Seq[String]) extends Parsed
Seq(t)
}
// Check No val (a,b) = foo *or* val a,b = foo as these are problematic to range positions and the WHOLE architecture.
def isBadValDef(t: Tree): Boolean =
t match {
case (x @ (toolbox.u.ValDef(_, _, _, _) | toolbox.u.DefDef(_, _, _, _, _, _))) =>
val content = modifiedContent.substring(x.pos.start, x.pos.end)
val prettyPrint = x.toString
(!(content contains "=") && (prettyPrint contains "="))
case _ => false
}
parsedTrees.filter(isBadValDef).foreach { badTree =>
// Issue errors
val positionLine = badTree.pos.line
throw new MessageOnlyException(s"""[$fileName]:$positionLine: Pattern matching in val statements is not supported""".stripMargin)
}
val (imports, statements) = parsedTrees partition {
case _: Import => true
case _ => false

View File

@ -0,0 +1 @@
val a,b = project

View File

@ -1,72 +1,5 @@
val x = bar
name := "scala-stm"
organization := "org.scala-stm"
version := "0.8-SNAPSHOT"
scalaVersion := "2.11.2"
crossScalaVersions := Seq("2.11.2", "2.10.4", "2.9.3")
libraryDependencies += ("org.scalatest" %% "scalatest" % "[1.5,)" % "test")
libraryDependencies += ("junit" % "junit" % "4.5" % "test")
// skip exhaustive tests
testOptions += Tests.Argument("-l", "slow")
// test of TxnExecutor.transformDefault must be run by itself
parallelExecution in Test := false
////////////////////
// publishing
pomExtra :=
<url>http://nbronson.github.com/scala-stm/</url>
<licenses>
<license>
<name>BSD</name>
<url>https://github.com/nbronson/scala-stm/blob/master/LICENSE.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<connection>scm:git:git@github.com:nbronson/scala-stm.git</connection>
<url>git@github.com:nbronson/scala-stm.git</url>
</scm>
<developers>
<developer>
<id>nbronson</id>
<name>Nathan Bronson</name>
<email>ngbronson@gmail.com</email>
</developer>
</developers>
publishMavenStyle := true
publishTo <<= (version) { v: String =>
val base = "https://oss.sonatype.org/"
if (v.trim.endsWith("SNAPSHOT"))
Some("snapshots" at base + "content/repositories/snapshots/")
else
Some("releases" at base + "service/local/staging/deploy/maven2/")
}
// exclude scalatest from the Maven POM
pomPostProcess := { xi: scala.xml.Node =>
import scala.xml._
val badDeps = (xi \\ "dependency") filter {
x => (x \ "artifactId").text != "scala-library"
} toSet
def filt(root: Node): Node = root match {
case x: Elem => {
val ch = x.child filter { !badDeps(_) } map { filt(_) }
Elem(x.prefix, x.label, x.attributes, x.scope, ch: _*)
}
case x => x
}
filt(xi)
}
credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")
{
val a,b = project
}

View File

@ -0,0 +1,71 @@
name := "scala-stm"
organization := "org.scala-stm"
version := "0.8-SNAPSHOT"
scalaVersion := "2.11.2"
crossScalaVersions := Seq("2.11.2", "2.10.4", "2.9.3")
libraryDependencies += ("org.scalatest" %% "scalatest" % "[1.5,)" % "test")
libraryDependencies += ("junit" % "junit" % "4.5" % "test")
// skip exhaustive tests
testOptions += Tests.Argument("-l", "slow")
// test of TxnExecutor.transformDefault must be run by itself
parallelExecution in Test := false
////////////////////
// publishing
pomExtra :=
<url>http://nbronson.github.com/scala-stm/</url>
<licenses>
<license>
<name>BSD</name>
<url>https://github.com/nbronson/scala-stm/blob/master/LICENSE.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<connection>scm:git:git@github.com:nbronson/scala-stm.git</connection>
<url>git@github.com:nbronson/scala-stm.git</url>
</scm>
<developers>
<developer>
<id>nbronson</id>
<name>Nathan Bronson</name>
<email>ngbronson@gmail.com</email>
</developer>
</developers>
publishMavenStyle := true
publishTo <<= (version) { v: String =>
val base = "https://oss.sonatype.org/"
if (v.trim.endsWith("SNAPSHOT"))
Some("snapshots" at base + "content/repositories/snapshots/")
else
Some("releases" at base + "service/local/staging/deploy/maven2/")
}
// exclude scalatest from the Maven POM
pomPostProcess := { xi: scala.xml.Node =>
import scala.xml._
val badDeps = (xi \\ "dependency") filter {
x => (x \ "artifactId").text != "scala-library"
} toSet
def filt(root: Node): Node = root match {
case x: Elem => {
val ch = x.child filter { !badDeps(_) } map { filt(_) }
Elem(x.prefix, x.label, x.attributes, x.scope, ch: _*)
}
case x => x
}
filt(xi)
}
credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")

View File

@ -136,6 +136,7 @@ abstract class AbstractSplitExpressionsFilesTest(pathName: String) extends Speci
println(s"In file: $fileName, old splitter failed. ${ex.toString}")
case SplitterComparison(_, util.Failure(ex)) =>
println(s"In file: $fileName, new splitter failed. ${ex.toString}")
ex.printStackTrace()
case SplitterComparison(util.Success(resultOld), util.Success(resultNew)) =>
if (resultOld == resultNew) {
println(s"In file: $fileName, same results (imports, settings): $resultOld")

View File

@ -1,3 +1,5 @@
lazy val a,b = project
def now = System.currentTimeMillis
lazy val v = "1.0-" +
@ -10,3 +12,5 @@ val descr = "Description"
name := n
version := v