Skip to content

Commit 6d3e244

Browse files
committed
avoid deprecated ligatures
1 parent 0d2c422 commit 6d3e244

File tree

7 files changed

+129
-129
lines changed

7 files changed

+129
-129
lines changed

plugin/src/main/scala/com/typesafe/genjavadoc/AST.scala

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package com.typesafe.genjavadoc
22

33
import scala.annotation.tailrec
44

5-
trait AST { this: TransformCake
5+
trait AST { this: TransformCake =>
66

77
import global._
88

@@ -18,11 +18,11 @@ trait AST { this: TransformCake ⇒
1818
sym: Symbol,
1919
name: String,
2020
access: String,
21-
pattern: (String, String) String,
21+
pattern: (String, String) => String,
2222
module: Boolean,
2323
comment: Seq[String],
2424
pckg: String,
25-
filepattern: String String,
25+
filepattern: String => String,
2626
members: Vector[Templ],
2727
interface: Boolean,
2828
static: Boolean,
@@ -49,14 +49,14 @@ trait AST { this: TransformCake ⇒
4949
object ClassInfo {
5050
def apply(c: ImplDef, comment: Seq[String], topLevel: Boolean): ClassInfo = {
5151
c match {
52-
case ClassDef(mods, _, tparams, impl)
52+
case ClassDef(mods, _, tparams, impl) =>
5353
val name = c.name.toString
5454
val acc = access(mods, topLevel)
5555
val fl = flags(mods)
5656
val kind = if (mods.isInterface || mods.isTrait) "interface" else "class"
5757
val tp = c.symbol.owner.thisType.memberInfo(c.symbol) match {
58-
case p @ PolyType(params, _) js(c.symbol, p)
59-
case _ ""
58+
case p @ PolyType(params, _) => js(c.symbol, p)
59+
case _ => ""
6060
}
6161
val parent = {
6262
val p = impl.parents.head
@@ -65,13 +65,13 @@ trait AST { this: TransformCake ⇒
6565
s" extends ${js(c.symbol, p.tpe)}"
6666
}
6767
}
68-
val intf = impl.parents.tail map (i js(c.symbol, i.tpe)) mkString (", ")
68+
val intf = impl.parents.tail map (i => js(c.symbol, i.tpe)) mkString (", ")
6969
val interfaces = if (!intf.isEmpty) (if (mods.isInterface || mods.isTrait) " extends " else " implements ") + intf else ""
70-
val sig = (n: String, a: String) s"$a $fl $kind $n$tp$parent$interfaces"
70+
val sig = (n: String, a: String) => s"$a $fl $kind $n$tp$parent$interfaces"
7171
val packageName = c.symbol.enclosingPackage.fullName('/')
7272
val file =
7373
if (packageName == "<empty>") (n: String) => s"$n.java"
74-
else (n: String) s"$packageName/$n.java"
74+
else (n: String) => s"$packageName/$n.java"
7575
val pckg = c.symbol.enclosingPackage.fullName
7676
ClassInfo(c.symbol, name, acc, sig, mods.hasModuleFlag, comment, pckg, file, Vector.empty, kind == "interface", false, true)
7777
}
@@ -93,7 +93,7 @@ trait AST { this: TransformCake ⇒
9393
}
9494
}
9595

96-
case class MethodInfo(access: String, pattern: String String, ret: String, name: String, comment: Seq[String]) extends Templ {
96+
case class MethodInfo(access: String, pattern: String => String, ret: String, name: String, comment: Seq[String]) extends Templ {
9797
def sig = pattern(s"$ret $name")
9898
}
9999
object MethodInfo {
@@ -104,13 +104,13 @@ trait AST { this: TransformCake ⇒
104104
("", d.symbol.enclClass.name.toString)
105105
} else (js(d.symbol, d.tpt.tpe), d.name.toString)
106106
val tp = d.symbol.owner.thisType.memberInfo(d.symbol) match {
107-
case p @ PolyType(params, _) js(d.symbol, p)
108-
case _ ""
107+
case p @ PolyType(params, _) => js(d.symbol, p)
108+
case _ => ""
109109
}
110110
@tailrec def rec(l: List[ValDef], acc: Vector[String] = Vector.empty): Seq[String] = l match {
111-
case x :: Nil if hasVararg acc :+ s"${js(d.symbol, x.tpt.tpe, voidOK = false).dropRight(2)}... ${mangleMethodName(x)}"
112-
case x :: xs rec(xs, acc :+ s"${js(d.symbol, x.tpt.tpe, voidOK = false)} ${mangleMethodName(x)}")
113-
case Nil acc
111+
case x :: Nil if hasVararg => acc :+ s"${js(d.symbol, x.tpt.tpe, voidOK = false).dropRight(2)}... ${mangleMethodName(x)}"
112+
case x :: xs => rec(xs, acc :+ s"${js(d.symbol, x.tpt.tpe, voidOK = false)} ${mangleMethodName(x)}")
113+
case Nil => acc
114114
}
115115
val args = rec(d.vparamss.head) mkString ("(", ", ", ")")
116116

@@ -123,7 +123,7 @@ trait AST { this: TransformCake ⇒
123123
val throws = if (throwsAnnotations.isEmpty) "" else "throws " + throwsAnnotations.mkString(", ")
124124

125125
val impl = if (d.mods.isDeferred || interface) ";" else "{ throw new RuntimeException(); }"
126-
val pattern = (n: String) s"$acc $tp $n $args $throws $impl"
126+
val pattern = (n: String) => s"$acc $tp $n $args $throws $impl"
127127
def hasParam(n: String) = comment.find(_.contains(s"@param $n")).isDefined
128128

129129
val commentWithParams =
@@ -154,7 +154,7 @@ trait AST { this: TransformCake ⇒
154154
}
155155
val d = DefDef(sym, EmptyTree)
156156
val m = MethodInfo(d, false, Nil, varargs, None)
157-
m.copy(pattern = n "static " + m.pattern(n))
157+
m.copy(pattern = n => "static " + m.pattern(n))
158158
}
159159
}
160160

plugin/src/main/scala/com/typesafe/genjavadoc/BaseComments.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package com.typesafe.genjavadoc
33
import scala.collection.immutable.TreeMap
44
import scala.annotation.tailrec
55

6-
trait BaseComments { this: TransformCake
6+
trait BaseComments { this: TransformCake =>
77
import global._
88

99
def unit: CompilationUnit
@@ -29,23 +29,23 @@ trait BaseComments { this: TransformCake ⇒
2929
def apply(pos: Position, text: String) = {
3030
val ll = text.replaceAll("\n[ \t]*", "\n ").split("\n")
3131
.map {
32-
case See(prefix, link)
32+
case See(prefix, link) =>
3333
if (HttpLink.findFirstIn(link).isDefined)
3434
s"""$prefix<a href="$link"/>"""
3535
else
3636
s"$prefix$link"
37-
case x x
37+
case x => x
3838
}
39-
.map(line replacements.foldLeft(line) { case (l, (from, to)) l.replace(from, to) })
39+
.map(line => replacements.foldLeft(line) { case (l, (from, to)) => l.replace(from, to) })
4040
val (_, _, _, l2) = ll.foldLeft((false, false, true, List.empty[String])) {
4141
// insert <p> line upon transition to empty, collapse contiguous empty lines
42-
case ((pre, code, empty, lines), line @ EmptyLine())
42+
case ((pre, code, empty, lines), line @ EmptyLine()) =>
4343
val nl =
4444
if (pre || line.contains("/**") || line.contains("*/")) line :: lines
4545
else if (!pre && !empty) " * <p>" :: (lines.head + (if (code) "</code>" else "")) :: lines.tail
4646
else lines
4747
(pre, false, true, nl)
48-
case ((pre, code, empty, lines), line)
48+
case ((pre, code, empty, lines), line) =>
4949
val (nc, nl) = if (pre) (code, line) else codeLine(code, line)
5050
val np = if (line contains "<pre>") true else if (line contains "</pre>") false else pre
5151
val nl2 = if (pre && np) preLine(nl) else nl
@@ -62,12 +62,12 @@ trait BaseComments { this: TransformCake ⇒
6262
}
6363
private def replace(str: String, from: String, to: String): String = {
6464
str.indexOf(from) match {
65-
case -1 str
66-
case n str.substring(0, n) + to + str.substring(n + from.length)
65+
case -1 => str
66+
case n => str.substring(0, n) + to + str.substring(n + from.length)
6767
}
6868
}
6969
private def htmlEntity(str: String): String = {
70-
str flatMap (ch if (ch > 127) f"&#x${ch}%04x;" else "" + ch)
70+
str flatMap (ch => if (ch > 127) f"&#x${ch}%04x;" else "" + ch)
7171
}
7272
}
7373

@@ -88,7 +88,7 @@ trait BaseComments { this: TransformCake ⇒
8888

8989
def between(p1: Position, p2: Position) = unit.source.content.slice(p1.start, p2.start).filterNot(_ == '\n').mkString
9090

91-
object Scaladoc extends (Comment Boolean) {
91+
object Scaladoc extends (Comment => Boolean) {
9292
def apply(c: Comment): Boolean = c.text.head.startsWith("/**")
9393
}
9494

plugin/src/main/scala/com/typesafe/genjavadoc/BasicTransform.scala

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package com.typesafe.genjavadoc
22

33
import scala.reflect.internal.Flags
44

5-
trait BasicTransform { this: TransformCake
5+
trait BasicTransform { this: TransformCake =>
66
import global._
77

88
private def skippedName(name: String): Boolean = {
@@ -17,7 +17,7 @@ trait BasicTransform { this: TransformCake ⇒
1717

1818
def newTransformUnit(unit: CompilationUnit): Unit = {
1919
superTransformUnit(unit)
20-
for (c flattenObjects(classes.flatMap(liftInnerClassesWithSameName).flatMap(withoutPrivates))) {
20+
for (c <- flattenObjects(classes.flatMap(liftInnerClassesWithSameName).flatMap(withoutPrivates))) {
2121
val out = file(c.file)
2222
try {
2323
if (c.pckg != "<empty>") out.println(s"package ${c.pckg};")
@@ -30,7 +30,7 @@ trait BasicTransform { this: TransformCake ⇒
3030

3131
private var visited: List[Tree] = Nil
3232
private var keep = true
33-
private def noKeep(code: Tree): Tree = {
33+
private def noKeep(code: => Tree): Tree = {
3434
val old = keep
3535
keep = false
3636
try code finally keep = old
@@ -52,12 +52,12 @@ trait BasicTransform { this: TransformCake ⇒
5252
pos = max(tp, prevTemplateMaxPos)
5353
if (old.precedes(pos)) {
5454
(positions.from(old) intersect positions.to(pos)).toSeq.map(comments).filter(Scaladoc).lastOption match {
55-
case Some(c) c.text // :+ s"// found in '${between(old, pos)}'"
56-
case None
55+
case Some(c) => c.text // :+ s"// found in '${between(old, pos)}'"
56+
case None =>
5757
// s"// empty '${between(old, pos)}' (${pos.lineContent}:${pos.column})" ::
5858
Nil
5959
}
60-
} else Seq("// not preceding") ++ visited.reverse.map(t "// " + global.showRaw(t))
60+
} else Seq("// not preceding") ++ visited.reverse.map(t => "// " + global.showRaw(t))
6161
} else Seq("// no position")
6262
advancePos(tp)
6363
endPos foreach { p =>
@@ -78,18 +78,18 @@ trait BasicTransform { this: TransformCake ⇒
7878

7979
def endPos(t: Tree) = {
8080
val traverser = new CollectTreeTraverser({
81-
case t if t.pos.isDefined t.pos
81+
case t if t.pos.isDefined => t.pos
8282
})
8383
traverser.traverse(t)
8484
if (traverser.results.isEmpty) None else Some(traverser.results.max)
8585
}
8686

8787
tree match {
88-
case c: ClassDef if keep
88+
case c: ClassDef if keep =>
8989
withClass(c, commentText(c.pos, None)) {
9090
superTransform(tree)
9191
}
92-
case d: DefDef if keep
92+
case d: DefDef if keep =>
9393
val text =
9494
if (d.mods.hasModuleFlag) { // accessor for an object
9595
// the accessor occurs out of order; we must not advance the position
@@ -110,11 +110,11 @@ trait BasicTransform { this: TransformCake ⇒
110110
addMethod(d, text)
111111
}
112112
tree
113-
case _: ValDef { track(tree) }
114-
case _: PackageDef { track(tree); superTransform(tree) }
115-
case _: Template { track(tree); superTransform(tree) }
116-
case _: TypeTree { track(tree) }
117-
case _ { track(tree); noKeep(superTransform(tree)) }
113+
case _: ValDef => { track(tree) }
114+
case _: PackageDef => { track(tree); superTransform(tree) }
115+
case _: Template => { track(tree); superTransform(tree) }
116+
case _: TypeTree => { track(tree) }
117+
case _ => { track(tree); noKeep(superTransform(tree)) }
118118
}
119119
}
120120

@@ -124,7 +124,7 @@ trait BasicTransform { this: TransformCake ⇒
124124
// the current class, any level
125125
private var clazz: Option[ClassInfo] = None
126126

127-
private def withClass(c: ImplDef, comment: Seq[String])(block: Tree): Tree = {
127+
private def withClass(c: ImplDef, comment: Seq[String])(block: => Tree): Tree = {
128128
val deprecation = deprecationInfo(c)
129129
val commentWithDeprecation = deprecation match {
130130
case Some(deprec) => deprec.appendToComment(comment)
@@ -136,10 +136,10 @@ trait BasicTransform { this: TransformCake ⇒
136136
val ret = block
137137
clazz =
138138
old match {
139-
case None
139+
case None =>
140140
classes :+= clazz.get
141141
None
142-
case Some(oc)
142+
case Some(oc) =>
143143
Some(oc.addMember(clazz.get))
144144
}
145145
pos = templateMaxPos
@@ -148,11 +148,11 @@ trait BasicTransform { this: TransformCake ⇒
148148
}
149149

150150
private def addMethod(d: DefDef, comment: Seq[String]): Unit = {
151-
clazz = clazz map (c c.addMember(MethodInfo(d, c.interface, comment, hasVararg = false, deprecation = deprecationInfo(d))))
151+
clazz = clazz map (c => c.addMember(MethodInfo(d, c.interface, comment, hasVararg = false, deprecation = deprecationInfo(d))))
152152
}
153153

154154
private def addVarargsMethod(d: DefDef, comment: Seq[String]): Unit = {
155-
clazz = clazz map (c c.addMember(MethodInfo(d, c.interface, comment, hasVararg = true, deprecation = deprecationInfo(d))))
155+
clazz = clazz map (c => c.addMember(MethodInfo(d, c.interface, comment, hasVararg = true, deprecation = deprecationInfo(d))))
156156
}
157157

158158
private def deprecationInfo(d: DefDef): Option[DeprecationInfo] = deprecationInfo(d.symbol)

0 commit comments

Comments
 (0)