diff --git a/tasty-inspector/src/scala/tasty/inspector/TastyInspector.scala b/tasty-inspector/src/scala/tasty/inspector/TastyInspector.scala index ad171d12a8da..e5ccd9c661dc 100644 --- a/tasty-inspector/src/scala/tasty/inspector/TastyInspector.scala +++ b/tasty-inspector/src/scala/tasty/inspector/TastyInspector.scala @@ -22,6 +22,8 @@ object TastyInspector: /** Load and process TASTy files using TASTy reflect * * @param tastyFiles List of paths of `.tasty` files + * + * @return boolean value indicating whether the process succeeded */ def inspectTastyFiles(tastyFiles: List[String])(inspector: Inspector): Boolean = inspectAllTastyFiles(tastyFiles, Nil, Nil)(inspector) @@ -29,6 +31,8 @@ object TastyInspector: /** Load and process TASTy files in a `jar` file using TASTy reflect * * @param jars Path of `.jar` file + * + * @return boolean value indicating whether the process succeeded */ def inspectTastyFilesInJar(jar: String)(inspector: Inspector): Boolean = inspectAllTastyFiles(Nil, List(jar), Nil)(inspector) @@ -38,6 +42,8 @@ object TastyInspector: * @param tastyFiles List of paths of `.tasty` files * @param jars List of path of `.jar` files * @param dependenciesClasspath Classpath with extra dependencies needed to load class in the `.tasty` files + * + * @return boolean value indicating whether the process succeeded */ def inspectAllTastyFiles(tastyFiles: List[String], jars: List[String], dependenciesClasspath: List[String])(inspector: Inspector): Boolean = def checkFile(fileName: String, ext: String): Unit = @@ -49,7 +55,7 @@ object TastyInspector: tastyFiles.foreach(checkFile(_, "tasty")) jars.foreach(checkFile(_, "jar")) val files = tastyFiles ::: jars - files.nonEmpty && inspectFiles(dependenciesClasspath, files)(inspector) + inspectFiles(dependenciesClasspath, files)(inspector) private def inspectorDriver(inspector: Inspector) = class InspectorDriver extends Driver: @@ -100,11 +106,11 @@ object TastyInspector: private def inspectFiles(classpath: List[String], classes: List[String])(inspector: Inspector): Boolean = - if (classes.isEmpty) - throw new IllegalArgumentException("Parameter classes should no be empty") - - val reporter = inspectorDriver(inspector).process(inspectorArgs(classpath, classes)) - reporter.hasErrors + classes match + case Nil => false + case _ => + val reporter = inspectorDriver(inspector).process(inspectorArgs(classpath, classes)) + !reporter.hasErrors end inspectFiles