@@ -20,21 +20,28 @@ val UnresolvedLocationLink = "#"
2020trait Locations (using ctx : DocContext ):
2121 def members : Map [DRI , Member ]
2222
23+ var cache = new JHashMap [DRI , Seq [String ]]()
24+
2325 // TODO verify if location exisits
2426 def rawLocation (dri : DRI ): Seq [String ] =
25- dri match
26- case `docsDRI` => List (" docs" , " index" )
27- case `docsRootDRI` => List (" index" )
28- case `apiPageDRI` => List (" api" , " index" )
29- case dri if dri.isStaticFile =>
30- Paths .get(dri.location).iterator.asScala.map(_.toString).toList
31- case dri =>
32- val loc = dri.location
33- val fqn = loc.split(Array ('.' )).toList match
34- case List (" <empty>" ) => List (" index" )
35- case other => other
36-
37- Seq (" api" ) ++ fqn
27+ cache.get(dri) match
28+ case null =>
29+ val path = dri match
30+ case `docsDRI` => List (" docs" , " index" )
31+ case `docsRootDRI` => List (" index" )
32+ case `apiPageDRI` => List (" api" , " index" )
33+ case dri if dri.isStaticFile =>
34+ Paths .get(dri.location).iterator.asScala.map(_.toString).toList
35+ case dri =>
36+ val loc = dri.location
37+ val fqn = loc.split(Array ('.' )).toList match
38+ case List (" <empty>" ) => List (" index" )
39+ case other => other
40+
41+ Seq (" api" ) ++ fqn
42+ cache.put(dri, path)
43+ path
44+ case cached => cached
3845
3946 private def unknownPage (dri : DRI ): String =
4047 // TODO we should switch that to warning probably or has dedicated setting
@@ -93,17 +100,12 @@ trait Locations(using ctx: DocContext):
93100 }
94101
95102 // TODO #263: Add anchor support
96- def constructPathForScaladoc (dri : DRI ): String = {
97- val location = dri.location.replace(" ." ," /" )
98- val anchor = dri.anchor
99- docURL + location + extension
100- }
103+ def constructPathForScaladoc (dri : DRI ): String =
104+ docURL + dri.asFileLocation + extension
101105
102- def constructPathForScala3doc (dri : DRI ): String = {
103- val location = dri.location.replace(" ." ," /" )
104- val anchor = dri.anchor
105- docURL + location + extension
106- }
106+ // TODO Add tests for it!
107+ def constructPathForScala3doc (dri : DRI ): String =
108+ docURL + dri.asFileLocation + extension + " #" + dri.anchor
107109
108110 link.kind match {
109111 case DocumentationKind .Javadoc => constructPathForJavadoc(dri)
0 commit comments