Skip to content

Commit 1d7eac4

Browse files
Adapts code to the new repo
1 parent e9b08aa commit 1d7eac4

File tree

6 files changed

+29
-39
lines changed

6 files changed

+29
-39
lines changed

compiler/src/main/scala/org/scalaexercises/exercises/compiler/SourceTextExtraction.scala

+6-16
Original file line numberDiff line numberDiff line change
@@ -147,25 +147,25 @@ object SourceTextExtraction {
147147
// visitMethodExpr as trailing params on each recursive call
148148
@tailrec def traversal(trees: List[(Path[g.type], Int, Tree)], acc: A): A = trees match {
149149
case Nil => acc
150-
case (path, order, tree) :: rs =>
150+
case (path, _, tree) :: rs =>
151151
tree match {
152152

153-
case DocDef(comment, moduleDef @ ModuleDef(mods, _, impl)) =>
153+
case DocDef(comment, moduleDef @ ModuleDef(_, _, impl)) =>
154154
val nextPath = moduleDef.name :: path
155155
traversal(
156156
impl.body.zipWithIndex.map { case (body, index) => (nextPath, index, body) } ::: rs,
157157
visitDocComment(nextPath.reverse, comment, acc)
158158
)
159159

160160
// TODO: is this needed?
161-
case DocDef(comment, classDef @ ClassDef(mods, _, Nil, impl)) =>
161+
case DocDef(comment, classDef @ ClassDef(_, _, Nil, impl)) =>
162162
val nextPath = classDef.name :: path
163163
traversal(
164164
impl.body.zipWithIndex.map { case (body, index) => (nextPath, index, body) } ::: rs,
165165
visitDocComment(nextPath.reverse, comment, acc)
166166
)
167167

168-
case DocDef(comment, q"def $tname(...$paramss): $tpt = $expr") =>
168+
case DocDef(comment, q"def $tname(...$_): $_ = $expr") =>
169169
val nextPath = tname :: path
170170
val nextPathReversed = nextPath.reverse
171171
traversal(
@@ -177,31 +177,21 @@ object SourceTextExtraction {
177177
)
178178
)
179179

180-
case moduleDef @ ModuleDef(mods, _, impl) =>
180+
case moduleDef @ ModuleDef(_, _, impl) =>
181181
val nextPath = moduleDef.name :: path
182182
traversal(
183183
impl.body.zipWithIndex.map { case (body, index) => (nextPath, index, body) } ::: rs,
184184
acc
185185
)
186186

187187
// TODO: is this needed?
188-
case classDef @ ClassDef(mods, _, Nil, impl) =>
188+
case classDef @ ClassDef(_, _, Nil, impl) =>
189189
val nextPath = classDef.name :: path
190190
traversal(
191191
impl.body.zipWithIndex.map { case (body, index) => (nextPath, index, body) } ::: rs,
192192
acc
193193
)
194194

195-
/*
196-
// TODO: can this be removed?
197-
case q"def $tname(...$paramss): $tpt = $expr" =>
198-
val nextPath = tname :: path
199-
traversal(
200-
(nextPath, 0, expr) :: rs,
201-
acc
202-
)
203-
*/
204-
205195
case q"package $ref { ..$topstats }" =>
206196
val nextPath =
207197
if (ref.name == termNames.EMPTY_PACKAGE_NAME) path

compiler/src/main/scala/org/scalaexercises/exercises/compiler/comments.scala

+13-13
Original file line numberDiff line numberDiff line change
@@ -315,20 +315,20 @@ private[compiler] object CommentRendering {
315315
}
316316

317317
private[this] def renderInline(inl: Inline): NodeSeq = inl match {
318-
case Chain(items) => items flatMap renderInline
319-
case Italic(in) => <i>{renderInline(in)}</i>
320-
case Bold(in) => <b>{renderInline(in)}</b>
321-
case Underline(in) => <u>{renderInline(in)}</u>
322-
case Superscript(in) => <sup>{renderInline(in)}</sup>
323-
case Subscript(in) => <sub>{renderInline(in)}</sub>
324-
case Link(raw, title) => <a href={raw} target="_blank">{renderInline(title)}</a>
325-
case Monospace(in) => <code>{renderInline(in)}</code>
326-
case Text(text) => scala.xml.Text(text)
327-
case Summary(in) => renderInline(in)
328-
case HtmlTag(tag) => scala.xml.Unparsed(tag)
329-
case EntityLink(target, link) => renderLink(target, link, hasLinks = true)
318+
case Chain(items) => items flatMap renderInline
319+
case Italic(in) => <i>{renderInline(in)}</i>
320+
case Bold(in) => <b>{renderInline(in)}</b>
321+
case Underline(in) => <u>{renderInline(in)}</u>
322+
case Superscript(in) => <sup>{renderInline(in)}</sup>
323+
case Subscript(in) => <sub>{renderInline(in)}</sub>
324+
case Link(raw, title) => <a href={raw} target="_blank">{renderInline(title)}</a>
325+
case Monospace(in) => <code>{renderInline(in)}</code>
326+
case Text(text) => scala.xml.Text(text)
327+
case Summary(in) => renderInline(in)
328+
case HtmlTag(tag) => scala.xml.Unparsed(tag)
329+
case EntityLink(target, _) => renderLink(target)
330330
}
331331

332-
private[this] def renderLink(text: Inline, link: LinkTo, hasLinks: Boolean) = renderInline(text)
332+
private[this] def renderLink(text: Inline) = renderInline(text)
333333

334334
}

sbt-exercise/src/main/scala/org/scalaexercises/exercises/sbtexercise/ExerciseCompilerPlugin.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ object ExerciseCompilerPlugin extends AutoPlugin {
112112
* back to `src/main/[scala|test|...]`.
113113
*/
114114
private def reconfigureSub(key: SettingKey[File]): Def.Initialize[File] =
115-
Def.setting { (ThisScope.copy(config = Global.config) / key).value / "main" }
115+
Def.setting((ThisScope.copy(config = Global.config) / key).value / "main")
116116

117117
// for most of the work below, a captured error is an error message and/or a
118118
// throwable value

sbt-exercise/src/sbt-test/sbt-exercise/basic/build.sbt

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ val pluginVersion = System.getProperty("plugin.version")
55
lazy val content = (project in file("content"))
66
.enablePlugins(ExerciseCompilerPlugin)
77
.settings(
8-
scalaVersion := "2.13.1",
8+
scalaVersion := "2.12.11",
99
resolvers ++= Seq(
1010
Resolver.sonatypeRepo("snapshots"),
1111
Resolver.defaultLocal
1212
),
1313
libraryDependencies ++= Seq(
14-
"org.scala-exercises" %% "runtime" % pluginVersion changing (),
14+
"org.scala-exercises" %% "runtime" % "0.6.0",
1515
"org.scala-exercises" %% "exercise-compiler" % pluginVersion changing (),
1616
"org.scala-exercises" %% "definitions" % pluginVersion changing ()
1717
)
@@ -20,13 +20,13 @@ lazy val content = (project in file("content"))
2020
lazy val contentInPackages = (project in file("contentinpackages"))
2121
.enablePlugins(ExerciseCompilerPlugin)
2222
.settings(
23-
scalaVersion := "2.13.1",
23+
scalaVersion := "2.12.11",
2424
resolvers ++= Seq(
2525
Resolver.sonatypeRepo("snapshots"),
2626
Resolver.defaultLocal
2727
),
2828
libraryDependencies ++= Seq(
29-
"org.scala-exercises" %% "runtime" % pluginVersion changing (),
29+
"org.scala-exercises" %% "runtime" % "0.6.0",
3030
"org.scala-exercises" %% "exercise-compiler" % pluginVersion changing (),
3131
"org.scala-exercises" %% "definitions" % pluginVersion changing ()
3232
)
@@ -35,7 +35,7 @@ lazy val contentInPackages = (project in file("contentinpackages"))
3535
lazy val check = (project in file("check"))
3636
.dependsOn(content, contentInPackages)
3737
.settings(
38-
scalaVersion := "2.13.1",
38+
scalaVersion := "2.12.11",
3939
resolvers ++= Seq(
4040
Resolver.sonatypeRepo("snapshots"),
4141
Resolver.defaultLocal
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# check that the exercise plugin works on a minimal project
22

3-
-$ exists content/target/scala-2.13/src_managed/main/org/scalaexercises/content/
3+
-$ exists content/target/scala-2.12/src_managed/main/org/scalaexercises/content/
44

55
> project content
66
> package
77

8-
-$ exists contentinpackages/target/scala-2.13/src_managed/main/org/scalaexercises/contentinpackages/
8+
-$ exists contentinpackages/target/scala-2.12/src_managed/main/org/scalaexercises/contentinpackages/
99

1010
> project contentInPackages
1111
> package
1212

13-
$ exists content/target/scala-2.13/src_managed/main/org/scalaexercises/content/
13+
$ exists content/target/scala-2.12/src_managed/main/org/scalaexercises/content/
1414

1515
> project check
1616
> run

sbt-exercise/src/sbt-test/sbt-exercise/scalariform/build.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ val pluginVersion = System.getProperty("plugin.version")
22

33
lazy val root = (project in file("."))
44
.settings(
5-
scalaVersion := "2.13.1",
5+
scalaVersion := "2.12.11",
66
resolvers ++= Seq(
77
Resolver.sonatypeRepo("snapshots"),
88
Resolver.defaultLocal

0 commit comments

Comments
 (0)