diff --git a/chapi-ast-typescript/src/main/kotlin/chapi/ast/typescriptast/TypeScriptFullIdentListener.kt b/chapi-ast-typescript/src/main/kotlin/chapi/ast/typescriptast/TypeScriptFullIdentListener.kt index 9bfb69096e1fb8c3a8568f2b66a41f2c110f2d62..2b7b186b9debe4ea2ee1fd098bc6d026d806642f 100644 --- a/chapi-ast-typescript/src/main/kotlin/chapi/ast/typescriptast/TypeScriptFullIdentListener.kt +++ b/chapi-ast-typescript/src/main/kotlin/chapi/ast/typescriptast/TypeScriptFullIdentListener.kt @@ -65,20 +65,27 @@ class TypeScriptFullIdentListener(private var node: TSIdentify) : TypeScriptAstL if (name == "DecoratorListContext") { val decoratorList = leftChild as TypeScriptParser.DecoratorListContext for(decorator in decoratorList.decorator()) { - val annotation = CodeAnnotation() - val decoratorMemberExpression = decorator.decoratorMemberExpression() - if (decoratorMemberExpression != null) { - annotation.Name = decoratorMemberExpression.Identifier().text - } - if (decorator.decoratorCallExpression() != null) { - val member = decorator.decoratorCallExpression().decoratorMemberExpression() - annotation.Name = member.Identifier().text - } + val annotation = buildAnnotation(decorator) currentNode.Annotations += annotation } } } + private fun buildAnnotation(decorator: TypeScriptParser.DecoratorContext): CodeAnnotation { + val annotation = CodeAnnotation() + val memberExpression = decorator.decoratorMemberExpression() + val callExpression = decorator.decoratorCallExpression() + + if (memberExpression != null) { + annotation.Name = memberExpression.Identifier().text + } + if (callExpression != null) { + val member = callExpression.decoratorMemberExpression() + annotation.Name = member.Identifier().text + } + return annotation + } + private fun handleClassBodyElements(classTailCtx: TypeScriptParser.ClassTailContext?) { for (clzElementCtx in classTailCtx!!.classElement()) { val childCtx = clzElementCtx.getChild(0)