From ce2516dcab47003875d0bda1fef341fc867f8d40 Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Sun, 6 Mar 2022 21:28:07 +0800 Subject: [PATCH] feat(domain): add lsot commit --- .../src/main/kotlin/chapi/domain/core/CodeDataStruct.kt | 2 +- .../src/main/kotlin/chapi/domain/core/CodeFunction.kt | 5 +++++ .../src/test/kotlin/chapi/domain/core/CodeDataStructTest.kt | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/chapi-domain/src/main/kotlin/chapi/domain/core/CodeDataStruct.kt b/chapi-domain/src/main/kotlin/chapi/domain/core/CodeDataStruct.kt index b204ad58..f078f9d4 100644 --- a/chapi-domain/src/main/kotlin/chapi/domain/core/CodeDataStruct.kt +++ b/chapi-domain/src/main/kotlin/chapi/domain/core/CodeDataStruct.kt @@ -68,7 +68,7 @@ open class CodeDataStruct( return this.Package + "." + this.NodeName } - fun extension(): String { + fun fileExt(): String { return this.FilePath.substringAfterLast('.', "") } } diff --git a/chapi-domain/src/main/kotlin/chapi/domain/core/CodeFunction.kt b/chapi-domain/src/main/kotlin/chapi/domain/core/CodeFunction.kt index f2db4568..0e0b29af 100644 --- a/chapi-domain/src/main/kotlin/chapi/domain/core/CodeFunction.kt +++ b/chapi-domain/src/main/kotlin/chapi/domain/core/CodeFunction.kt @@ -9,6 +9,7 @@ import kotlinx.serialization.json.jsonObject @Serializable open class CodeFunction( var Name: String = "", + var FilePath: String = "", var Package: String = "", var ReturnType: String = "", var MultipleReturns: Array = arrayOf(), @@ -99,4 +100,8 @@ open class CodeFunction( this.LocalVariables = vars } + + fun fileExt(): String { + return this.FilePath.substringAfterLast('.', "") + } } diff --git a/chapi-domain/src/test/kotlin/chapi/domain/core/CodeDataStructTest.kt b/chapi-domain/src/test/kotlin/chapi/domain/core/CodeDataStructTest.kt index 30373028..a43db5c1 100644 --- a/chapi-domain/src/test/kotlin/chapi/domain/core/CodeDataStructTest.kt +++ b/chapi-domain/src/test/kotlin/chapi/domain/core/CodeDataStructTest.kt @@ -47,6 +47,6 @@ internal class CodeDataStructTest { @Test internal fun shouldGetFileExt() { val ds = CodeDataStruct(NodeName = "FunctionMap", FilePath = "src/main.java") - assertEquals("java", ds.extension()); + assertEquals("java", ds.fileExt()); } }