1
- // Copy of tasty-inspector/src/scala/tasty/inspector/TastyInspector.scala
1
+ // Renamed copy of tasty-inspector/src/scala/tasty/inspector/TastyInspector.scala
2
2
// FIXME remove this copy of the file
3
+ // Since copying, an inspectAllTastyFilesInContext method was added for scaladoc only
4
+ // to fix regressions introduced by the switch from old to a new TastyInspector
3
5
4
6
package scala .tasty .inspector
5
7
@@ -21,7 +23,7 @@ import dotty.tools.dotc.report
21
23
22
24
import java .io .File .pathSeparator
23
25
24
- object TastyInspector :
26
+ object ScaladocInternalTastyInspector :
25
27
26
28
/** Load and process TASTy files using TASTy reflect
27
29
*
@@ -41,6 +43,32 @@ object TastyInspector:
41
43
def inspectTastyFilesInJar (jar : String )(inspector : Inspector ): Boolean =
42
44
inspectAllTastyFiles(Nil , List (jar), Nil )(inspector)
43
45
46
+ private def checkFiles (tastyFiles : List [String ], jars : List [String ]): Unit =
47
+ def checkFile (fileName : String , ext : String ): Unit =
48
+ val file = dotty.tools.io.Path (fileName)
49
+ if ! file.ext.toLowerCase.equalsIgnoreCase(ext) then
50
+ throw new IllegalArgumentException (s " File extension is not `. $ext`: $file" )
51
+ else if ! file.exists then
52
+ throw new IllegalArgumentException (s " File not found: ${file.toAbsolute}" )
53
+ tastyFiles.foreach(checkFile(_, " tasty" ))
54
+ jars.foreach(checkFile(_, " jar" ))
55
+
56
+ /**
57
+ * Added for Scaladoc-only.
58
+ * Meant to fix regressions introduces by the switch from old to new TastyInspector:
59
+ * https://github.com/scala/scala3/issues/18231
60
+ * https://github.com/scala/scala3/issues/20476
61
+ * Stable TastyInspector API does not support passing compiler context.
62
+ */
63
+ def inspectAllTastyFilesInContext (tastyFiles : List [String ], jars : List [String ], dependenciesClasspath : List [String ])(inspector : Inspector )(using Context ): Boolean =
64
+ checkFiles(tastyFiles, jars)
65
+ val classes = tastyFiles ::: jars
66
+ classes match
67
+ case Nil => true
68
+ case _ =>
69
+ val reporter = inspectorDriver(inspector).process(inspectorArgs(dependenciesClasspath, classes), summon[Context ])
70
+ ! reporter.hasErrors
71
+
44
72
/** Load and process TASTy files using TASTy reflect
45
73
*
46
74
* @param tastyFiles List of paths of `.tasty` files
@@ -50,14 +78,7 @@ object TastyInspector:
50
78
* @return boolean value indicating whether the process succeeded
51
79
*/
52
80
def inspectAllTastyFiles (tastyFiles : List [String ], jars : List [String ], dependenciesClasspath : List [String ])(inspector : Inspector ): Boolean =
53
- def checkFile (fileName : String , ext : String ): Unit =
54
- val file = dotty.tools.io.Path (fileName)
55
- if ! file.ext.toLowerCase.equalsIgnoreCase(ext) then
56
- throw new IllegalArgumentException (s " File extension is not `. $ext`: $file" )
57
- else if ! file.exists then
58
- throw new IllegalArgumentException (s " File not found: ${file.toAbsolute}" )
59
- tastyFiles.foreach(checkFile(_, " tasty" ))
60
- jars.foreach(checkFile(_, " jar" ))
81
+ checkFiles(tastyFiles, jars)
61
82
val files = tastyFiles ::: jars
62
83
inspectFiles(dependenciesClasspath, files)(inspector)
63
84
@@ -124,4 +145,4 @@ object TastyInspector:
124
145
end inspectFiles
125
146
126
147
127
- end TastyInspector
148
+ end ScaladocInternalTastyInspector
0 commit comments