@@ -255,11 +255,11 @@ class TypeScriptFullIdentListener(node: TSIdentify) : TypeScriptAstListener() {
255255 return codeFunction
256256 }
257257
258- // private fun buildImplements(typeList: TypeScriptParser.ClassOrInterfaceTypeListContext?): Array<String> {
259- // return typeList?.typeReference ()?.map { typeRefCtx ->
260- // typeRefCtx.typeName().text
261- // }?.toTypedArray() ?: arrayOf()
262- // }
258+ private fun buildImplements (typeList : TypeScriptParser .ClassOrInterfaceTypeListContext ? ): Array <String > {
259+ return typeList?.parameterizedTypeRef ()?.map { typeRefCtx ->
260+ typeRefCtx.typeName().text
261+ }?.toTypedArray() ? : arrayOf()
262+ }
263263
264264 override fun exitClassDeclaration (ctx : TypeScriptParser .ClassDeclarationContext ? ) {
265265 hasEnterClass = false
@@ -278,15 +278,14 @@ class TypeScriptFullIdentListener(node: TSIdentify) : TypeScriptAstListener() {
278278 Position = buildPosition(ctx)
279279 )
280280
281- // if (ctx.interfaceExtendsClause() != null) {
282- // val elements = buildImplements(ctx.interfaceExtendsClause().classOrInterfaceTypeList())
283- // currentNode.Extend = elements[0]
284- // }
285- //
286- // val objectTypeCtx = ctx.objectType()
287- // if (objectTypeCtx.typeBody() != null) {
288- // this.buildInterfaceBody(objectTypeCtx.typeBody().typeMemberList())
289- // }
281+ if (ctx.interfaceExtendsClause() != null ) {
282+ val elements = buildImplements(ctx.interfaceExtendsClause().classOrInterfaceTypeList())
283+ currentNode.Extend = elements[0 ]
284+ }
285+
286+ if (ctx.interfaceBody() != null ) {
287+ this .buildInterfaceBody(ctx.interfaceBody().interfaceMemberList())
288+ }
290289
291290 nodeMap[nodeName] = currentNode
292291 }
@@ -296,7 +295,7 @@ class TypeScriptFullIdentListener(node: TSIdentify) : TypeScriptAstListener() {
296295 }
297296
298297 private fun buildInterfaceBody (typeMemberList : TypeScriptParser .InterfaceMemberListContext ) {
299- typeMemberList? .interfaceMember()?.forEach { memberContext ->
298+ typeMemberList.interfaceMember()?.forEach { memberContext ->
300299 when (val memberChild = memberContext.getChild(0 )) {
301300 is TypeScriptParser .PropertySignatureContext -> {
302301 buildInterfacePropertySignature(memberChild)
@@ -783,22 +782,27 @@ class TypeScriptFullIdentListener(node: TSIdentify) : TypeScriptAstListener() {
783782 callSignCtx : TypeScriptParser .CallSignatureContext ,
784783 currentFunc : CodeFunction
785784 ) {
786- // if (callSignCtx.parameterList() != null) {
787- // val parameters = buildMethodParameters(callSignCtx.parameterList())
788- // currentFunc.Parameters = parameters
789- // }
790- //
791- // if (callSignCtx.typeAnnotation () != null) {
792- // val returnType = buildReturnTypeByType (callSignCtx.typeAnnotation() )
793- // currentFunc.MultipleReturns += returnType
794- // }
785+ if (callSignCtx.parameterList() != null ) {
786+ val parameters = buildMethodParameters(callSignCtx.parameterList())
787+ currentFunc.Parameters = parameters
788+ }
789+
790+ if (callSignCtx.typeRef () != null ) {
791+ val returnType = buildReturnTypeByTypeRef (callSignCtx.typeRef() !! )
792+ currentFunc.MultipleReturns + = returnType
793+ }
795794 }
796795
797796 private fun buildReturnTypeByType (typeAnnotationContext : TypeScriptParser .TypeAnnotationContext ? ): CodeProperty =
798797 CodeProperty (
799798 TypeType = buildTypeAnnotation(typeAnnotationContext) ? : " " , TypeValue = " "
800799 )
801800
801+ private fun buildReturnTypeByTypeRef (typeRefContext : TypeScriptParser .TypeRefContext ): CodeProperty =
802+ CodeProperty (
803+ TypeType = processRef(typeRefContext) ? : " " , TypeValue = " "
804+ )
805+
802806 override fun enterExpressionStatement (ctx : TypeScriptParser .ExpressionStatementContext ? ) {
803807 if (ctx?.expressionSequence() == null ) return
804808
0 commit comments