@@ -96,36 +96,36 @@ class TypeScriptFullIdentListener(node: TSIdentify) : TypeScriptAstListener() {
9696 ): CodeField {
9797 val key = it.getChild(0 ).text
9898 val singleExpression = it.singleExpression()
99- val field = CodeField (TypeKey = key, TypeValue = " " , Modifiers = modifiers)
10099
101- // val lastExpr = singleExpression.last()
102- // val field = CodeField(TypeKey = key, TypeValue = lastExpr.text, Modifiers = modifiers)
103- //
104- // when (lastExpr) {
105- // is TypeScriptParser.LiteralExpressionContext -> {
106- // if (lastExpr.literal().StringLiteral() != null) {
107- // field.TypeValue = unQuote(lastExpr.text)
108- // field.TypeType = "String"
109- // }
110- // }
111- //
112- // is IdentifierExpressionContext -> {
113- // singleExprToFieldCall(field, lastExpr.singleExpression(), lastExpr.identifierName().text)
114- // }
115- //
116- // is TypeScriptParser.YieldExpressionContext -> {
117- // if (lastExpr.yieldStatement().expressionSequence() != null) {
118- // val singeExprs = lastExpr.yieldStatement().expressionSequence().singleExpression()
119- // singeExprs.forEach { expr ->
120- // singleExprToFieldCall(field, expr, expr.text)
121- // }
122- // }
123- // }
124- //
125- // else -> {
126- // // println("variableToFields -> ${lastExpr.text} === ${lastExpr.javaClass.simpleName}")
127- // }
128- // }
100+ val lastExpr = singleExpression
101+ val field = CodeField (TypeKey = key, TypeValue = lastExpr.text, Modifiers = modifiers)
102+
103+ when (lastExpr) {
104+ is TypeScriptParser .LiteralExpressionContext -> {
105+ if (lastExpr.literal().StringLiteral () != null ) {
106+ field.TypeValue = unQuote(lastExpr.text)
107+ field.TypeType = " String"
108+ }
109+ }
110+
111+ is IdentifierExpressionContext -> {
112+ singleExprToFieldCall(field, lastExpr.singleExpression(), lastExpr.identifierName().text)
113+ }
114+
115+ is TypeScriptParser .YieldExpressionContext -> {
116+ if (lastExpr.yieldStatement().expressionSequence() != null ) {
117+ val singeExprs = lastExpr.yieldStatement().expressionSequence().singleExpression()
118+ singeExprs.forEach { expr ->
119+ singleExprToFieldCall(field, expr, expr.text)
120+ }
121+ }
122+ }
123+
124+ else -> {
125+ // println("variableToFields -> ${lastExpr.text} === ${lastExpr.javaClass.simpleName}")
126+ }
127+ }
128+
129129 return field
130130 }
131131
@@ -941,16 +941,13 @@ class TypeScriptFullIdentListener(node: TSIdentify) : TypeScriptAstListener() {
941941 CodeProperty (TypeValue = typeValue, TypeType = " " )
942942 }?.toTypedArray() ? : arrayOf()
943943
944- // override fun enterExportDefaultDeclaration(ctx: TypeScriptParser.ExportDefaultDeclarationContext?) {
945- // val singleExpr = ctx!!.singleExpression()
946- // if (singleExpr != null) {
947- // if (!singleExpr.text.contains("(")) {
948- // currentNode.Exports += CodeExport(singleExpr.text)
949- // defaultNode.Exports += CodeExport(singleExpr.text)
950- // }
951- // }
952- // }
953-
944+ override fun enterExportDefaultDeclaration (ctx : TypeScriptParser .ExportDefaultDeclarationContext ? ) {
945+ val name = ctx!! .identifierName()
946+ if (name != null ) {
947+ currentNode.Exports + = CodeExport (name.text)
948+ defaultNode.Exports + = CodeExport (name.text)
949+ }
950+ }
954951
955952 fun getNodeInfo (): CodeContainer {
956953 for (entry in nodeMap) {
0 commit comments