Skip to content

Commit de78aff

Browse files
authored
Merge pull request #305 from SethTisue/misc-cleanups
misc cleanups, go (nearly) warning-free
2 parents 75dd089 + 19cca8f commit de78aff

File tree

6 files changed

+50
-25
lines changed

6 files changed

+50
-25
lines changed

build.sbt

+38-11
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,41 @@
1-
import sbtcrossproject.CrossPlugin.autoImport.crossProject
1+
lazy val root = project.in(file("."))
2+
.aggregate(parserCombinatorsJVM, parserCombinatorsJS, parserCombinatorsNative)
3+
.settings(
4+
publish / skip := true,
5+
)
26

37
lazy val parserCombinators = crossProject(JVMPlatform, JSPlatform, NativePlatform)
4-
.withoutSuffixFor(JVMPlatform).in(file("."))
5-
.settings(ScalaModulePlugin.scalaModuleSettings)
6-
.jvmSettings(ScalaModulePlugin.scalaModuleOsgiSettings)
8+
.in(file("."))
79
.settings(
10+
ScalaModulePlugin.scalaModuleSettings,
811
name := "scala-parser-combinators",
9-
scalaModuleMimaPreviousVersion := None,
12+
scalaModuleMimaPreviousVersion := None, // until we publish 1.2.0
1013

1114
apiMappings ++= scalaInstance.value.libraryJars.collect {
1215
case file if file.getName.startsWith("scala-library") && file.getName.endsWith(".jar") =>
1316
file -> url(s"http://www.scala-lang.org/api/${scalaVersion.value}/")
1417
}.toMap,
1518

16-
scalacOptions in (Compile, doc) ++= {
19+
// go nearly warning-free, but only on 2.13, it's too hard across all versions
20+
Compile / scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match {
21+
case Some((2, 13)) => Seq("-Werror",
22+
// ideally we'd do something about this. `^?` is the responsible method
23+
"-Wconf:site=scala.util.parsing.combinator.Parsers.*&cat=lint-multiarg-infix:i",
24+
// not sure what resolving this would look like? didn't think about it too hard
25+
"-Wconf:site=scala.util.parsing.combinator.lexical.StdLexical.*&cat=other-match-analysis:i",
26+
)
27+
case _ => Seq()
28+
}),
29+
Compile / doc / scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match {
30+
case Some((2, 13)) => Seq(
31+
// it isn't able to link to [[java.lang.NoSuchMethodError]]
32+
// scala-xml doesn't have this problem, I tried copying their apiMappings stuff
33+
// and that didn't help, I'm mystified why :-/
34+
"""-Wconf:msg=Could not find any member to link for*:i""",
35+
)
36+
case _ => Seq()
37+
}),
38+
Compile / doc / scalacOptions ++= {
1739
if (isDotty.value)
1840
Seq("-language:Scala2")
1941
else
@@ -22,15 +44,15 @@ lazy val parserCombinators = crossProject(JVMPlatform, JSPlatform, NativePlatfor
2244
"-doc-source-url",
2345
s"https://github.com/scala/scala-parser-combinators/tree/v${version.value}€{FILE_PATH}.scala",
2446
"-sourcepath",
25-
(baseDirectory in LocalRootProject).value.absolutePath,
47+
(LocalRootProject / baseDirectory).value.absolutePath,
2648
"-doc-title",
2749
"Scala Parser Combinators",
2850
"-doc-version",
2951
version.value
3052
)
3153
},
32-
unmanagedSourceDirectories in Compile ++= {
33-
(unmanagedSourceDirectories in Compile).value.map { dir =>
54+
Compile / unmanagedSourceDirectories ++= {
55+
(Compile / unmanagedSourceDirectories).value.map { dir =>
3456
CrossVersion.partialVersion(scalaVersion.value) match {
3557
case Some((2, 13)) => file(dir.getPath ++ "-2.13+")
3658
case Some((0, _)) => file(dir.getPath ++ "-2.13+")
@@ -40,22 +62,27 @@ lazy val parserCombinators = crossProject(JVMPlatform, JSPlatform, NativePlatfor
4062
}
4163
)
4264
.jvmSettings(
65+
ScalaModulePlugin.scalaModuleOsgiSettings,
4366
OsgiKeys.exportPackage := Seq(s"scala.util.parsing.*;version=${version.value}"),
4467
libraryDependencies += "junit" % "junit" % "4.13.1" % Test,
4568
libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % Test
4669
)
4770
.jsSettings(
4871
crossScalaVersions -= "0.27.0-RC1",
4972
// Scala.js cannot run forked tests
50-
fork in Test := false
73+
Test / fork := false
5174
)
5275
.jsConfigure(_.enablePlugins(ScalaJSJUnitPlugin))
5376
.nativeSettings(
54-
skip in compile := System.getProperty("java.version").startsWith("1.6") || !scalaVersion.value.startsWith("2.11"),
77+
compile / skip := System.getProperty("java.version").startsWith("1.6") || !scalaVersion.value.startsWith("2.11"),
5578
test := {},
5679
libraryDependencies := {
5780
if (!scalaVersion.value.startsWith("2.11"))
5881
libraryDependencies.value.filterNot(_.organization == "org.scala-native")
5982
else libraryDependencies.value
6083
}
6184
)
85+
86+
lazy val parserCombinatorsJVM = parserCombinators.jvm
87+
lazy val parserCombinatorsJS = parserCombinators.js
88+
lazy val parserCombinatorsNative = parserCombinators.native

build.sh

+8-8
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ set -e
1616
# - commit the changes and tag this new revision with an arbitrary suffix after a hash, e.g.,
1717
# `v1.2.3#dotty-0.27` (the suffix is ignored, the version will be `1.2.3`)
1818

19-
# For normal tags that are cross-built, we release on JDK 8 for Scala 2.x
19+
# We release on JDK 8 (for Scala 2.x and Dotty 0.x)
2020
isReleaseJob() {
21-
if [[ "$ADOPTOPENJDK" == "8" && "$TRAVIS_SCALA_VERSION" =~ ^2\.1[01234]\..*$ ]]; then
21+
if [[ "$ADOPTOPENJDK" == "8" ]]; then
2222
true
2323
else
2424
false
2525
fi
2626
}
2727

2828
if [[ "$SCALAJS_VERSION" != "" ]]; then
29-
projectPrefix="parserCombinatorsJS"
29+
projectPrefix="parserCombinatorsJS/"
3030
elif [[ "$SCALANATIVE_VERSION" != "" ]]; then
31-
projectPrefix="parserCombinatorsNative"
31+
projectPrefix="parserCombinatorsNative/"
3232
else
33-
projectPrefix="parserCombinators"
33+
projectPrefix="parserCombinatorsJVM/"
3434
fi
3535

3636
verPat="[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9-]+)?"
@@ -45,12 +45,12 @@ if [[ "$TRAVIS_TAG" =~ $tagPat ]]; then
4545
fi
4646

4747
# default is +publishSigned; we cross-build with travis jobs, not sbt's crossScalaVersions
48-
export CI_RELEASE="$projectPrefix/publishSigned"
49-
export CI_SNAPSHOT_RELEASE="$projectPrefix/publish"
48+
export CI_RELEASE="${projectPrefix}publishSigned"
49+
export CI_SNAPSHOT_RELEASE="${projectPrefix}publish"
5050

5151
# default is sonatypeBundleRelease, which closes and releases the staging repo
5252
# see https://github.com/xerial/sbt-sonatype#commands
5353
# for now, until we're confident in the new release scripts, just close the staging repo.
5454
export CI_SONATYPE_RELEASE="; sonatypePrepare; sonatypeBundleUpload; sonatypeClose"
5555

56-
sbt clean $projectPrefix/test $projectPrefix/publishLocal $releaseTask
56+
sbt clean ${projectPrefix}test ${projectPrefix}publishLocal $releaseTask

shared/src/main/scala/scala/util/parsing/combinator/JavaTokenParsers.scala

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ package scala
1414
package util.parsing.combinator
1515

1616
import scala.annotation.migration
17-
import scala.language.implicitConversions
1817

1918
/** `JavaTokenParsers` differs from [[scala.util.parsing.combinator.RegexParsers]]
2019
* by adding the following definitions:

shared/src/main/scala/scala/util/parsing/combinator/PackratParsers.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ trait PackratParsers extends Parsers {
6767
*/
6868
private[PackratParsers] val cache = mutable.HashMap.empty[(Parser[_], Position), MemoEntry[_]]
6969

70-
private[PackratParsers] def getFromCache[T](p: Parser[T]): Option[MemoEntry[T]] = {
71-
cache.get((p, pos)).asInstanceOf[Option[MemoEntry[T]]]
70+
private[PackratParsers] def getFromCache[T2](p: Parser[T2]): Option[MemoEntry[T2]] = {
71+
cache.get((p, pos)).asInstanceOf[Option[MemoEntry[T2]]]
7272
}
7373

74-
private[PackratParsers] def updateCacheAndGet[T](p: Parser[T], w: MemoEntry[T]): MemoEntry[T] = {
74+
private[PackratParsers] def updateCacheAndGet[T2](p: Parser[T2], w: MemoEntry[T2]): MemoEntry[T2] = {
7575
cache.put((p, pos),w)
7676
w
7777
}

shared/src/main/scala/scala/util/parsing/combinator/Parsers.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ trait Parsers {
238238
= withFilter(p)
239239

240240
def withFilter(p: T => Boolean): Parser[T]
241-
= Parser{ in => this(in) filterWithError(p, "Input doesn't match filter: "+_, in)}
241+
= Parser{ in => this(in).filterWithError(p, "Input doesn't match filter: "+_, in)}
242242

243243
// no filter yet, dealing with zero is tricky!
244244

shared/src/main/scala/scala/util/parsing/combinator/lexical/StdLexical.scala

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package lexical
1818
import token._
1919
import input.CharArrayReader.EofCh
2020
import scala.collection.mutable
21-
import scala.language.implicitConversions
2221

2322
/** This component provides a standard lexical parser for a simple,
2423
* [[http://scala-lang.org Scala]]-like language. It parses keywords and

0 commit comments

Comments
 (0)