Skip to content

Commit d5df465

Browse files
committed
Cleaned Type matching
1 parent 4e38e23 commit d5df465

File tree

4 files changed

+46
-52
lines changed

4 files changed

+46
-52
lines changed

tastydoc/src/dotty/tastydoc/TastyTypeConverter.scala

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ trait TastyTypeConverter {
5959
if(link == "/scala"){
6060
if(label.matches("Function[1-9]") || label.matches("Function[1-9][0-9]")){
6161
val argsAndReturn = typeOrBoundsList.map(convertTypeOrBoundsToReference(reflect)(_))
62-
FunctionReference(argsAndReturn.take(argsAndReturn.size - 1), argsAndReturn.last, false) //TODO: Implict
62+
FunctionReference(argsAndReturn.take(argsAndReturn.size - 1), argsAndReturn.last, false)
6363
}else if(label.matches("Tuple[1-9]") || label.matches("Tuple[1-9][0-9]")){
6464
TupleReference(typeOrBoundsList.map(convertTypeOrBoundsToReference(reflect)(_)))
6565
}else{
@@ -70,10 +70,10 @@ trait TastyTypeConverter {
7070
}
7171
case _ => throw Exception("Match error in AppliedType. This should not happen, please open an issue. " + tp)
7272
}
73-
case reflect.Type.IsTypeRef(reflect.Type.TypeRef(typeName, qual)) => //TODO Verify all these typeOrBounds handling
73+
case reflect.Type.IsTypeRef(reflect.Type.TypeRef(typeName, qual)) =>
7474
convertTypeOrBoundsToReference(reflect)(qual) match {
75-
case TypeReference(label, link, xs, _) => TypeReference(typeName, link + "/" + label, xs, true) //TODO check hasOwnFile
76-
case EmptyReference => TypeReference(typeName, "", Nil, true) //TODO check hasOwnFile
75+
case TypeReference(label, link, xs, _) => TypeReference(typeName, link + "/" + label, xs, true)
76+
case EmptyReference => TypeReference(typeName, "", Nil, true)
7777
case _ => throw Exception("Match error in TypeRef. This should not happen, please open an issue. " + convertTypeOrBoundsToReference(reflect)(qual))
7878
}
7979
case reflect.Type.IsTermRef(reflect.Type.TermRef(typeName, qual)) =>
@@ -83,26 +83,20 @@ trait TastyTypeConverter {
8383
case _ => throw Exception("Match error in TermRef. This should not happen, please open an issue. " + convertTypeOrBoundsToReference(reflect)(qual))
8484
}
8585
case reflect.Type.IsSymRef(reflect.Type.SymRef(symbol, typeOrBounds)) => symbol match {
86-
case reflect.IsClassDefSymbol(_) =>
86+
case reflect.IsClassDefSymbol(_) => //Need to be split because these types have their own file
8787
convertTypeOrBoundsToReference(reflect)(typeOrBounds) match {
8888
case TypeReference(label, link, xs, _) => TypeReference(symbol.name, link + "/" + label, xs, true)
8989
case EmptyReference if symbol.name == "<root>" | symbol.name == "_root_" => EmptyReference
9090
case EmptyReference => TypeReference(symbol.name, "", Nil, true)
9191
case _ => throw Exception("Match error in SymRef/TypeOrBounds/ClassDef. This should not happen, please open an issue. " + convertTypeOrBoundsToReference(reflect)(typeOrBounds))
9292
}
93-
case reflect.IsPackageDefSymbol(_) | reflect.IsTypeDefSymbol(_) | reflect.IsValDefSymbol(_) =>
93+
case reflect.IsTermSymbol(_) | reflect.IsTypeDefSymbol(_) =>
9494
convertTypeOrBoundsToReference(reflect)(typeOrBounds) match {
9595
case TypeReference(label, link, xs, _) => TypeReference(symbol.name, link + "/" + label, xs)
9696
case EmptyReference if symbol.name == "<root>" | symbol.name == "_root_" => EmptyReference
9797
case EmptyReference => TypeReference(symbol.name, "", Nil)
9898
case _ => throw Exception("Match error in SymRef/TypeOrBounds/Other. This should not happen, please open an issue. " + convertTypeOrBoundsToReference(reflect)(typeOrBounds))
9999
}
100-
case reflect.IsTermSymbol(_) => convertTypeOrBoundsToReference(reflect)(typeOrBounds) match {
101-
case TypeReference(label, link, xs, _) => TypeReference(symbol.name, link + "/" + label, xs)
102-
case EmptyReference if symbol.name == "<root>" | symbol.name == "_root_" => EmptyReference
103-
case EmptyReference => TypeReference(symbol.name, "", Nil)
104-
case _ => throw Exception("Match error in SymRef/TypeOrBounds/Term. This should not happen, please open an issue. " + convertTypeOrBoundsToReference(reflect)(typeOrBounds))
105-
}
106100
case _ => throw Exception("Match error in SymRef. This should not happen, please open an issue. " + symbol)
107101
}
108102
case _ => throw Exception("No match for type in conversion to Reference. This should not happen, please open an issue. " + tp)

tastydoc/src/dotty/tastydoc/references.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ object references {
99
final case class FunctionReference(args: List[Reference], returnValue: Reference, isImplicit: Boolean) extends Reference
1010
final case class TupleReference(args: List[Reference]) extends Reference
1111
final case class BoundsReference(low: Reference, high: Reference) extends Reference
12-
final case class NamedReference(name: String, ref: Reference, isRepeated: Boolean = false) extends Reference //TODO isRepeated
12+
final case class NamedReference(name: String, ref: Reference, isRepeated: Boolean = false) extends Reference
1313
final case class ByNameReference(ref: Reference) extends Reference
1414
final case class ConstantReference(label: String) extends Reference
1515
final case class CompanionReference(label: String, path: String, kind: String) extends Reference

tastydoc/src/dotty/tastydoc/representations.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ object representations extends TastyExtractor {
223223
def innerLogic(representation: Representation): Unit = representation match {
224224
case r: ClassRepresentation =>
225225
r.parents.foreach{_ match {
226-
case ref@TypeReference(label, path, _, _) => mutablePackagesMap.get(path.tail.replaceAll("\\/", "\\.")) match {
226+
case ref@TypeReference(label, path, _, _) => mutablePackagesMap.get(path.replaceFirst("/", "").replaceAll("/", ".")) match {
227227
case Some(p) =>
228228
p.members.filter(_.name == label).foreach{_ match {
229229
case parent: ClassRepresentation => parent.knownSubclasses = TypeReference(r.name, r.path.mkString("/", "/", ""), Nil, true) :: parent.knownSubclasses

tastydoc/test/dotty/tastydoc/Tests.scala

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -36,42 +36,42 @@ class Tests {
3636
"example.UserDocLinkingClass"
3737
))
3838
}
39-
// @Test def testDotty(): Unit = {
40-
// Main.main(Array(
41-
// "--classpath",
42-
// "tastydoc/dotty-0.16.0-RC3/lib",
43-
// "--syntax",
44-
// "wiki",
45-
// "--packagestolink",
46-
// "dotty.*",
47-
// "scala.annotation.*",
48-
// "scala.compiletime.*",
49-
// "scala.implicits.*",
50-
// "scala.internal.*",
51-
// "scala.quoted.*",
52-
// "scala.reflect.*",
53-
// "scala.runtime.*",
54-
// "scala.tasty.*",
55-
// "scala.testing.*",
56-
// "scalaShadowing.*",
57-
// //Individual files
58-
// "scala.\\$times\\$colon*",
59-
// "scala.Conversion*",
60-
// "scala.Enum*",
61-
// "scala.Eql*",
62-
// "scala.forceInline*",
63-
// "scala.FunctionXXL*",
64-
// "scala.IArray*",
65-
// "scala.NonEmptyTuple*",
66-
// "scala.Product0*",
67-
// "scala.Selectable*",
68-
// "scala.Tuple*",
69-
// "scala.TupleXXL*",
70-
// "scala.ValueOf*",
71-
// "-d",
72-
// "dotty",
73-
// "scala",
74-
// "scalaShadowing"
75-
// ))
76-
// }
39+
@Test def testDotty(): Unit = {
40+
Main.main(Array(
41+
"--classpath",
42+
"tastydoc/dotty-0.16.0-RC3/lib",
43+
"--syntax",
44+
"wiki",
45+
"--packagestolink",
46+
"dotty.*",
47+
"scala.annotation.*",
48+
"scala.compiletime.*",
49+
"scala.implicits.*",
50+
"scala.internal.*",
51+
"scala.quoted.*",
52+
"scala.reflect.*",
53+
"scala.runtime.*",
54+
"scala.tasty.*",
55+
"scala.testing.*",
56+
"scalaShadowing.*",
57+
//Individual files
58+
"scala.\\$times\\$colon*",
59+
"scala.Conversion*",
60+
"scala.Enum*",
61+
"scala.Eql*",
62+
"scala.forceInline*",
63+
"scala.FunctionXXL*",
64+
"scala.IArray*",
65+
"scala.NonEmptyTuple*",
66+
"scala.Product0*",
67+
"scala.Selectable*",
68+
"scala.Tuple*",
69+
"scala.TupleXXL*",
70+
"scala.ValueOf*",
71+
"-d",
72+
"dotty",
73+
"scala",
74+
"scalaShadowing"
75+
))
76+
}
7777
}

0 commit comments

Comments
 (0)