protected def generatedCaseClasses()

in src/main/scala/com/spotify/scio/AnnotationTypeInjector.scala [132:153]


  protected def generatedCaseClasses(source: String, c: ScClass) = {
    // For some reason sometimes [[getVirtualFile]] returns null, use Option. I don't know why.
    val fileName =
      Option(c.asInstanceOf[PsiElement].getContainingFile.getVirtualFile)
        // wrap VirtualFile to java.io.File to use OS file separator
        .map(vf => new File(vf.getCanonicalPath).getCanonicalPath)

    val file = for {
      psiElementPath <- fileName
      hash <- Some(hash(source, psiElementPath))
      cf <- classFile(c, hash)
    } yield cf

    file.fold(Seq.empty[String]) { f =>
      import scala.jdk.CollectionConverters._
      Files
        .readLines(f, Charset.defaultCharset())
        .asScala
        .filter(_.contains("case class"))
        .toSeq
    }
  }