Skip to content

Commit 50fd2bc

Browse files
abgruszeckiromanowski
authored andcommitted
Scala3doc: update Dotty dependency to latest snapshot
1 parent 24e89e2 commit 50fd2bc

File tree

11 files changed

+44
-41
lines changed

11 files changed

+44
-41
lines changed

scala3doc/build.sbt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// re-expose subproject settings
22
val `example-project` = ExampleProject.`example-project`
33

4-
val dottyVersion = "0.27.0-RC1"
4+
val dottyVersion = "3.0.0-M1-bin-SNAPSHOT"
55
val dokkaVersion = "1.4.10.2"
66
val flexmarkVersion = "0.42.12"
77
val jacksonVersion = "2.9.8"
@@ -12,9 +12,8 @@ libraryDependencies ++= Seq(
1212
"org.jetbrains.dokka" % "dokka-test-api" % dokkaVersion % "test", // TODO move testing utils to dokka-site
1313
"com.virtuslab.dokka" % "dokka-site" % dokkaSiteVersion,
1414

15-
"ch.epfl.lamp" %% "dotty-tasty-inspector" % dottyVersion,
16-
"ch.epfl.lamp" %% "dotty-compiler" % dottyVersion,
17-
"ch.epfl.lamp" %% "dotty-library" % dottyVersion,
15+
"org.scala-lang" %% "scala3-tasty-inspector" % dottyVersion,
16+
"org.scala-lang" %% "scala3-compiler" % dottyVersion,
1817
"org.scala-sbt" % "io_2.13" % "1.3.4",
1918

2019
"com.vladsch.flexmark" % "flexmark-all" % flexmarkVersion,
@@ -27,7 +26,6 @@ libraryDependencies ++= Seq(
2726
resolvers += Resolver.jcenterRepo
2827
resolvers += Resolver.bintrayRepo("kotlin", "kotlin-dev")
2928
resolvers += Resolver.bintrayRepo("virtuslab", "dokka")
30-
resolvers += Resolver.mavenLocal
3129

3230
lazy val root = project
3331
.in(file("."))

scala3doc/src/main/scala/dotty/dokka/DottyDokkaConfig.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ case class DottyDokkaConfig(docConfiguration: DocConfiguration) extends DokkaCon
1919

2020
private object OurConfig extends DokkaConfiguration.PluginConfiguration:
2121
override def getFqPluginName = "ExternalDocsTooKey"
22-
override def getSerializationFormat: DokkaConfiguration$SerializationFormat = DokkaConfiguration$SerializationFormat.JSON
22+
override def getSerializationFormat: DokkaConfiguration$SerializationFormat =
23+
DokkaConfiguration$SerializationFormat.JSON.asInstanceOf[DokkaConfiguration$SerializationFormat]
2324
override def getValues: String = docConfiguration.args.docsRoot.getOrElse("")
2425

2526
override def getPluginsConfiguration: JList[DokkaConfiguration.PluginConfiguration] = List(OurConfig).asJava

scala3doc/src/main/scala/dotty/dokka/tasty/BasicSupport.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ trait BasicSupport:
2424
val params = annotTerm match
2525
case Apply(target, appliedWith) => {
2626
appliedWith.map {
27-
case Literal(Constant(value)) => Annotation.PrimitiveParameter(None, value match {
27+
case Literal(constant) => Annotation.PrimitiveParameter(None, constant.value match {
2828
case s: String => "\"" + s"$s" + "\""
2929
case other => other.toString()
3030
})
@@ -40,7 +40,7 @@ trait BasicSupport:
4040

4141

4242
extension (sym: reflect.Symbol):
43-
def documentation(using cxt: reflect.Context) = sym.comment match
43+
def documentation(using cxt: reflect.Context) = sym.documentation match
4444
case Some(comment) =>
4545
Map(sourceSet.getSourceSet -> parseComment(comment, sym.tree))
4646
case None =>

scala3doc/src/main/scala/dotty/dokka/tasty/ScalaDocSupport.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ trait ScaladocSupport { self: TastyParser =>
1313
import reflect._
1414

1515
def parseComment(
16-
commentNode: reflect.Comment,
16+
commentNode: reflect.Documentation,
1717
tree: reflect.Tree
1818
): dkkd.DocumentationNode = {
1919
val preparsed =

scala3doc/src/main/scala/dotty/dokka/tasty/SyntheticSupport.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ trait SyntheticsSupport:
3838
def getAllMembers: List[Symbol] = hackGetAllMembers(self.reflect)(s)
3939

4040
def isSyntheticField(c: Symbol) =
41-
c.flags.is(Flags.CaseAcessor) || c.flags.is(Flags.Object)
41+
c.flags.is(Flags.CaseAccessor) || c.flags.is(Flags.Object)
4242

4343
def isValidPos(pos: Position) =
4444
pos.exists && pos.start != pos.end
@@ -101,11 +101,11 @@ trait SyntheticsSupport:
101101
cSym.typeRef.appliedTo(cSym.typeParams.map(_.typeRef)).asInstanceOf[r.Type]
102102

103103
object MatchTypeCase:
104-
def unapply(tpe: Type): Option[(TypeOrBounds, TypeOrBounds)] =
104+
def unapply(tpe: Type): Option[(Type, Type)] =
105105
tpe match
106-
case AppliedType(t, Seq(from, to)) if t == MatchCaseType =>
106+
case AppliedType(t, Seq(from, to)) /*if t == MatchCaseType*/ =>
107107
Some((from, to))
108-
case TypeLambda(paramNames, paramTypes, AppliedType(t, Seq(from, to))) if t == MatchCaseType =>
108+
case TypeLambda(paramNames, paramTypes, AppliedType(t, Seq(from, to))) /*if t == MatchCaseType*/ =>
109109
Some((from, to))
110110
case _ =>
111111
None

scala3doc/src/main/scala/dotty/dokka/tasty/TastyParser.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ case class SbtDokkaTastyInspector(
8787

8888
override def run(implicit ctx: Context): Unit =
8989
val qctx = QuoteContextImpl()
90-
self.processCompilationUnit(qctx.tasty)(ctx.compilationUnit.tpdTree.asInstanceOf[qctx.tasty.Tree])
90+
self.processCompilationUnit(using qctx)(ctx.compilationUnit.tpdTree.asInstanceOf[qctx.tasty.Tree])
9191

9292
end TastyInspectorPhase
9393

@@ -100,8 +100,8 @@ trait DokkaBaseTastyInspector:
100100

101101
private val topLevels = Seq.newBuilder[Documentable]
102102

103-
def processCompilationUnit(reflect: Reflection)(root: reflect.Tree): Unit =
104-
val parser = new TastyParser(reflect, this, config)
103+
def processCompilationUnit(using ctx: quoted.QuoteContext)(root: ctx.reflect.Tree): Unit =
104+
val parser = new TastyParser(ctx.reflect, this, config)
105105
topLevels ++= parser.parseRootTree(root.asInstanceOf[parser.reflect.Tree])
106106

107107
def result(): List[DPackage] =

scala3doc/src/main/scala/dotty/dokka/tasty/TypesSupport.scala

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ trait TypesSupport:
1414
inner(tpeTree.tpe)
1515
case other => None
1616

17-
def inner(tpe: TypeOrBounds): Option[Symbol] = tpe match
17+
def inner(tpe: Type): Option[Symbol] = tpe match
1818
case ThisType(tpe) => inner(tpe)
1919
case AnnotatedType(tpe, _) => inner(tpe)
20-
case AppliedType(tpe, typeOrBoundsList) => inner(tpe)
20+
case AppliedType(tpe, _) => inner(tpe)
2121
case tp @ TermRef(qual, typeName) =>
2222
qual match
2323
case _: Type | _: NoPrefix => Some(tp.termSymbol)
@@ -45,8 +45,8 @@ trait TypesSupport:
4545

4646
new GenericTypeConstructor(tpeTree.symbol.dri, data.asJava, null)
4747

48-
given TypeOrBoundsSyntax as AnyRef:
49-
extension (tpe: TypeOrBounds):
48+
given TypeSyntax as AnyRef:
49+
extension (tpe: Type):
5050
def dokkaType(using ctx: reflect.Context): Bound =
5151
val data = inner(tpe)
5252
val dri = data.collect{
@@ -74,7 +74,7 @@ trait TypesSupport:
7474
tpeAnnotation.tpe.typeSymbol.toString == "class Repeated"
7575

7676
// TODO #23 add support for all types signatures that makes sense
77-
private def inner(tp: reflect.TypeOrBounds)(using cxt: reflect.Context): List[JProjection] =
77+
private def inner(tp: reflect.Type)(using cxt: reflect.Context): List[JProjection] =
7878
def noSupported(name: String): List[JProjection] =
7979
println(s"WARN: Unsupported type: $name: ${tp.show}")
8080
List(text(s"Unsupported[$name]"))
@@ -118,7 +118,7 @@ trait TypesSupport:
118118
.reduceLeftOption((acc: List[JProjection], elem: List[JProjection]) => acc ++ texts(", ") ++ elem).getOrElse(List())
119119
++ texts(")")
120120

121-
def parseRefinedElem(name: String, info: TypeOrBounds, polyTyped: List[JProjection] = Nil): List[JProjection] = ( info match {
121+
def parseRefinedElem(name: String, info: Type, polyTyped: List[JProjection] = Nil): List[JProjection] = ( info match {
122122
case m: MethodType => {
123123
val paramList = getParamList(m)
124124
texts(s"def $name") ++ polyTyped ++ paramList ++ texts(": ") ++ inner(m.resType)
@@ -137,7 +137,7 @@ trait TypesSupport:
137137
case other => noSupported(s"Not supported type in refinement $info")
138138
} ) ++ texts("; ")
139139

140-
def parsePolyFunction(info: TypeOrBounds): List[JProjection] = info match {
140+
def parsePolyFunction(info: Type): List[JProjection] = info match {
141141
case t: PolyType =>
142142
val paramBounds = getParamBounds(t)
143143
val method = t.resType.asInstanceOf[MethodType]
@@ -156,16 +156,16 @@ trait TypesSupport:
156156
prefix ++ texts("{ ") ++ refinedElems.flatMap(e => parseRefinedElem(e.name, e.info)) ++ texts(" }")
157157
}
158158
}
159-
case t @ AppliedType(tpe, typeOrBoundsList) =>
159+
case t @ AppliedType(tpe, typeList) =>
160160
import scala.internal.Chars._
161-
if !t.typeSymbol.name.forall(isIdentifierPart) && typeOrBoundsList.size == 2 then
162-
inner(typeOrBoundsList.head)
161+
if !t.typeSymbol.name.forall(isIdentifierPart) && typeList.size == 2 then
162+
inner(typeList.head)
163163
++ texts(" ")
164164
++ inner(tpe)
165165
++ texts(" ")
166-
++ inner(typeOrBoundsList.last)
166+
++ inner(typeList.last)
167167
else if t.isFunctionType then
168-
typeOrBoundsList match
168+
typeList match
169169
case Nil =>
170170
Nil
171171
case Seq(rtpe) =>
@@ -175,12 +175,12 @@ trait TypesSupport:
175175
case args =>
176176
texts("(") ++ commas(args.init.map(inner)) ++ texts(") => ") ++ inner(args.last)
177177
else if t.isTupleType then
178-
typeOrBoundsList match
178+
typeList match
179179
case Nil =>
180180
Nil
181181
case args =>
182182
texts("(") ++ commas(args.map(inner)) ++ texts(")")
183-
else inner(tpe) ++ texts("[") ++ commas(typeOrBoundsList.map(inner)) ++ texts("]")
183+
else inner(tpe) ++ texts("[") ++ commas(typeList.map(inner)) ++ texts("]")
184184

185185
case tp @ TypeRef(qual, typeName) =>
186186
qual match {

scala3doc/src/main/scala/dotty/dokka/tasty/comments/MarkdownConverter.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,14 @@ class MarkdownConverter(val repr: Repr) extends BaseConverter {
163163
case _ =>
164164
println(s"!!! DEFAULTING @ ${n.getNodeName}")
165165
emit(dkkd.P(
166-
List(
166+
List[dkkd.DocTag](
167167
dkkd.Span(
168168
List(dkk.text(s"!!! DEFAULTING @ ${n.getNodeName}")).asJava,
169169
kt.emptyMap,
170170
),
171171
dkk.text(MarkdownParser.renderToText(n))
172172
).asJava,
173-
kt.emptyMap
173+
kt.emptyMap[String, String]
174174
))
175175
}
176176

scala3doc/src/main/scala/dotty/dokka/tasty/comments/MemberLookup.scala

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,15 @@ trait MemberLookup {
104104
matched.map(hackResolveModule)
105105
}
106106

107-
owner.tree match {
108-
case tree: r.ClassDef =>
109-
findMatch(tree.body.iterator.collect { case t: r.Definition => t.symbol })
110-
case _ =>
111-
findMatch(hackMembersOf(owner))
112-
}
107+
if owner.isPackageDef then
108+
findMatch(hackMembersOf(owner))
109+
else
110+
owner.tree match {
111+
case tree: r.ClassDef =>
112+
findMatch(tree.body.iterator.collect { case t: r.Definition => t.symbol })
113+
case _ =>
114+
findMatch(hackMembersOf(owner))
115+
}
113116
}
114117

115118
private def downwardLookup(using r: Reflection)(query: List[String], owner: r.Symbol): Option[r.Symbol] =

scala3doc/src/test/scala/dotty/dokka/DottyTestRunner.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ abstract class DottyAbstractCoreTest extends AbstractCoreTest:
9898
// e.g. to remove '(0)' from object IAmACaseObject extends CaseImplementThis/*<-*/(0)/*->*/
9999
val CommentRegexp = """\/\*<-\*\/[^\/]+\/\*->\*\/"""
100100

101-
def (s: String).doesntStartWithAnyOfThese(c: Char*) = c.forall(char => !s.startsWith(char.toString))
101+
extension (s: String) def doesntStartWithAnyOfThese(c: Char*) = c.forall(char => !s.startsWith(char.toString))
102102
val lines = s.getLines().map(_.trim).toList
103103
.filter(_.doesntStartWithAnyOfThese('=',':','{','}'))
104104
.filterNot(_.trim.isEmpty)

0 commit comments

Comments
 (0)