Skip to content

Commit

Permalink
fix: <java> #20,incorrect TypeValue and TypeKey (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
wuwen5 authored Aug 24, 2022
1 parent 9766ba0 commit 51eaa28
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -531,10 +531,12 @@ open class JavaFullIdentListener(fileName: String, val classes: Array<String>) :
}

val typeTypeText = typeCtx.identifier(0).text
val typeValue = declCtx.variableDeclaratorId().identifier().text
fieldsMap[typeValue] = typeTypeText
val typeKey = declCtx.variableDeclaratorId().identifier().text
val typeValue = declCtx.variableInitializer()?.text ?: ""

fieldsMap[typeKey] = typeTypeText

val field = CodeField(typeTypeText, typeValue, Modifiers = arrayOf(), Annotations = this.currentAnnotations)
val field = CodeField(typeTypeText, typeValue, typeKey, Modifiers = arrayOf(), Annotations = this.currentAnnotations)
fields += field

buildFieldCall(typeTypeText, ctx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ package hello;
public class JavaCallApp {
private JavaDaoParser daoParser;
private String name = "abc";
public daoCall() {
daoParser.Call();
Expand All @@ -123,9 +124,13 @@ public class JavaCallApp {
val codeFile = JavaAnalyser().identFullInfo(code, "")
println(codeFile.DataStructures[0].Fields.size)

assertEquals(codeFile.DataStructures[0].Fields.size, 1)
assertEquals(codeFile.DataStructures[0].Fields.size, 2)
assertEquals(codeFile.DataStructures[0].Fields[0].TypeType, "JavaDaoParser")
assertEquals(codeFile.DataStructures[0].Fields[0].TypeValue, "daoParser")
assertEquals(codeFile.DataStructures[0].Fields[0].TypeKey, "daoParser")

assertEquals(codeFile.DataStructures[0].Fields[1].TypeType, "String")
assertEquals(codeFile.DataStructures[0].Fields[1].TypeKey, "name")
assertEquals(codeFile.DataStructures[0].Fields[1].TypeValue, "\"abc\"")
}

@Test
Expand Down

0 comments on commit 51eaa28

Please sign in to comment.