From 5fb6cf36dadb6c512bf93c5b8ab3b88277653400 Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Fri, 5 Jan 2024 21:20:19 +0800 Subject: [PATCH] fix: fix build issue --- build.gradle.kts | 2 ++ .../src/test/kotlin/chapi/ast/goast/GoAnalyserTest.kt | 11 ++++------- .../kotlin/chapi/ast/javaast/JavaFullIdentListener.kt | 7 +++---- chapi-domain/build.gradle.kts | 2 +- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index ab010352..7e034db1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,6 +4,8 @@ plugins { val kotlinVersion = "1.9.0" kotlin("jvm") version kotlinVersion apply false + kotlin("plugin.serialization") version "1.6.10" + id("java-library") id("maven-publish") publishing diff --git a/chapi-ast-go/src/test/kotlin/chapi/ast/goast/GoAnalyserTest.kt b/chapi-ast-go/src/test/kotlin/chapi/ast/goast/GoAnalyserTest.kt index cbc6d6a0..43aca399 100644 --- a/chapi-ast-go/src/test/kotlin/chapi/ast/goast/GoAnalyserTest.kt +++ b/chapi-ast-go/src/test/kotlin/chapi/ast/goast/GoAnalyserTest.kt @@ -127,16 +127,13 @@ func installController(g *gin.Engine) *gin.Engine { @Disabled fun analysisByDir() { val dir = "/Users/phodal/test/iam" - val codeContainer = GoAnalyser().analysisByDir(dir) + val files = File(dir).walkTopDown().filter { it.isFile && it.extension == "go" }.toList() + val codeContainer = files.map { + GoAnalyser().analysis(it.readText(), it.name) + }.toList() // write to file val json = Json.encodeToString(codeContainer) File("iam.json").writeText(json) } } -private fun GoAnalyser.analysisByDir(dir: String): List { - val files = File(dir).walkTopDown().filter { it.isFile && it.extension == "go" }.toList() - return files.map { - analysis(it.readText(), it.name) - }.toList() -} diff --git a/chapi-ast-java/src/main/kotlin/chapi/ast/javaast/JavaFullIdentListener.kt b/chapi-ast-java/src/main/kotlin/chapi/ast/javaast/JavaFullIdentListener.kt index 4b9c0909..95d85923 100644 --- a/chapi-ast-java/src/main/kotlin/chapi/ast/javaast/JavaFullIdentListener.kt +++ b/chapi-ast-java/src/main/kotlin/chapi/ast/javaast/JavaFullIdentListener.kt @@ -5,7 +5,6 @@ import chapi.domain.core.* import chapi.infra.Stack import org.antlr.v4.runtime.ParserRuleContext import org.antlr.v4.runtime.tree.ParseTree -import kotlin.reflect.typeOf data class TargetTypePackage(val targetType: String, val packageName: String) data class JavaTargetType(var targetType: String = "", var callType: CallType = CallType.FUNCTION) @@ -307,9 +306,9 @@ open class JavaFullIdentListener(fileName: String, val classes: List) : var methodName = callee var targetTypeStr = targetType - val targetType = this.warpTargetFullType(targetTypeStr) - var callType = targetType.callType - val fullType = targetType.targetType + val wrapTargetType = this.warpTargetFullType(targetTypeStr) + var callType = wrapTargetType.callType + val fullType = wrapTargetType.targetType if (targetTypeStr == "super" || callee == "super") { callType = CallType.SUPER diff --git a/chapi-domain/build.gradle.kts b/chapi-domain/build.gradle.kts index 65cee46c..5b6bbf4b 100644 --- a/chapi-domain/build.gradle.kts +++ b/chapi-domain/build.gradle.kts @@ -10,7 +10,7 @@ dependencies { implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2") implementation(kotlin("stdlib-jdk8")) implementation(kotlin("reflect")) - // Kotlin reflection. + testImplementation(kotlin("test")) // JUnit 5