Skip to content

Commit

Permalink
fix: fix decl issue
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Jun 2, 2020
1 parent 8bd13ce commit 03ebe08
Showing 1 changed file with 29 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,8 @@ class TypeScriptFullIdentListener(private var node: TSIdentify) : TypeScriptAstL
this.buildConstructorMethod(childCtx as TypeScriptParser.ConstructorDeclarationContext)
currentNode.Functions += codeFunction
}
"PropertyMemberDeclarationContext" -> {
this.buildPropertyMember(childCtx as TypeScriptParser.PropertyMemberDeclarationContext)
}
else -> {
println("handleClassBodyElements -> childElementType : $childElementType")
}
}
}
}

private fun buildPropertyMember(originCtx: TypeScriptParser.PropertyMemberDeclarationContext) {
val childType = originCtx::class.java.simpleName

when (childType) {
"PropertyDeclarationExpressionContext" -> {
val ctx = originCtx as TypeScriptParser.PropertyDeclarationExpressionContext
val isField = ctx.propertyName() != null
if (isField) {
"PropertyDeclarationExpressionContext" -> {
val ctx = childCtx as TypeScriptParser.PropertyDeclarationExpressionContext
val codeField = CodeField(
TypeValue = ctx.propertyName().text
)
Expand All @@ -98,20 +82,35 @@ class TypeScriptFullIdentListener(private var node: TSIdentify) : TypeScriptAstL

currentNode.Fields += codeField
}
}
"MethodDeclarationExpressionContext" -> {
val ctx = originCtx as TypeScriptParser.MethodDeclarationExpressionContext
val codeFunction = CodeFunction(
Name = ctx.propertyName().text,
Position = buildPosition(ctx)
)
val callSignCtx = ctx.callSignature()

if (callSignCtx.typeAnnotation() != null) {
codeFunction.ReturnType = buildTypeAnnotation(callSignCtx.typeAnnotation())!!
"MethodDeclarationExpressionContext" -> {
val ctx = childCtx as TypeScriptParser.MethodDeclarationExpressionContext
val codeFunction = CodeFunction(
Name = ctx.propertyName().text,
Position = buildPosition(ctx)
)
val callSignCtx = ctx.callSignature()

if (callSignCtx.typeAnnotation() != null) {
codeFunction.ReturnType = buildTypeAnnotation(callSignCtx.typeAnnotation())!!
}

currentNode.Functions += codeFunction
}
else -> {
println("handleClassBodyElements -> childElementType : $childElementType")
}
}
}
}

private fun buildPropertyMember(originCtx: TypeScriptParser.PropertyMemberDeclarationContext) {
val childType = originCtx::class.java.simpleName.toString()

currentNode.Functions += codeFunction
print(childType)
when (childType) {

else -> {
println("handleClassBody -> buildPropertyMember")
}
}
}
Expand Down

0 comments on commit 03ebe08

Please # to comment.