File tree 2 files changed +24
-6
lines changed
main/kotlin/chapi/ast/goast
test/kotlin/chapi/ast/goast
2 files changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -118,8 +118,8 @@ class GoFullIdentListener(var fileName: String) : GoAstListener() {
118
118
return structTypeCtx.fieldDecl()
119
119
.map { field ->
120
120
CodeField (
121
- TypeType = field.type_().text,
122
- TypeValue = field.identifierList().text
121
+ TypeType = field.type_()? .text ? : " " ,
122
+ TypeValue = field.identifierList()? .text ? : " "
123
123
)
124
124
}.toTypedArray()
125
125
}
Original file line number Diff line number Diff line change 1
1
package chapi.ast.goast
2
2
3
- import chapi.domain.core.CodeCall
4
- import chapi.domain.core.CodeDataStruct
5
- import chapi.domain.core.CodeFunction
6
- import chapi.domain.core.CodeProperty
3
+ import chapi.domain.core.*
7
4
import kotlinx.serialization.encodeToString
8
5
import kotlinx.serialization.json.Json
6
+ import org.junit.jupiter.api.Disabled
9
7
import org.junit.jupiter.api.Test
8
+ import java.io.File
10
9
import kotlin.test.assertEquals
11
10
12
11
internal class GoAnalyserTest {
@@ -39,4 +38,23 @@ func main() {
39
38
)
40
39
assertEquals(Json .encodeToString(value), Json .encodeToString(expect))
41
40
}
41
+
42
+ @Test
43
+ @Disabled
44
+ fun analysisByDir () {
45
+ val dir = " /iam"
46
+ val codeContainer = GoAnalyser ().analysisByDir(dir)
47
+ println (codeContainer)
48
+ }
49
+ }
50
+
51
+ private fun GoAnalyser.analysisByDir (dir : String ): List <CodeContainer > {
52
+ val codeContainers = mutableListOf<CodeContainer >()
53
+ val files = File (dir).walkTopDown().filter { it.isFile && it.extension == " go" }.toList()
54
+ files.forEach {
55
+ println (it.absolutePath)
56
+ val codeContainer = analysis(it.readText(), it.name)
57
+ codeContainers.add(codeContainer)
58
+ }
59
+ return codeContainers
42
60
}
You can’t perform that action at this time.
0 commit comments