Coverage Summary for Class: ASTPrinterCommand (itmo.analyzer.ast)

Class Method, % Branch, % Line, % Instruction, %
ASTPrinterCommand 0% (0/2) 0% (0/6) 0% (0/17) 0% (0/138)
ASTPrinterCommand$run$1 0% (0/1) 0% (0/1) 0% (0/6)
ASTPrinterCommand$run$parseResult$2 0% (0/1) 0% (0/1) 0% (0/3)
Total 0% (0/4) 0% (0/6) 0% (0/19) 0% (0/147)


 package itmo.analyzer.ast
 
 import com.github.ajalt.clikt.core.CliktCommand
 import com.github.ajalt.clikt.parameters.arguments.argument
 import java.io.File
 
 class ASTPrinterCommand : CliktCommand(name = "ast", help = "Prints AST for given java file") {
 
     private val filePath by argument()
 
     override fun run() {
         val file = File(filePath)
         val absolutePath = file.absoluteFile.canonicalPath
         val parseResult by lazy { file.tryParseJavaCode() }
         when {
             !file.exists() -> {
                 println("File '$absolutePath' not exists")
             }
             file.isDirectory -> {
                 println("'$absolutePath' is a directory")
             }
             !parseResult.isSuccessful -> {
                 println("""
                     |Cannot parse '$absolutePath' as java file
                     |  ${parseResult.problems.joinToString("\n  |") { it.verboseMessage }}
                 """.trimMargin())
             }
             else -> {
                 println(parseResult.result.get().printAST())
             }
         }
 
     }
 }