Skip to content

Commit

Permalink
Update the tasty inspector returned value
Browse files Browse the repository at this point in the history
  • Loading branch information
BarkingBad committed Aug 17, 2021
1 parent 86c9a7e commit fd600bb
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions tasty-inspector/src/scala/tasty/inspector/TastyInspector.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@ 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)

/** 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)
Expand All @@ -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 =
Expand All @@ -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:
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit fd600bb

Please sign in to comment.