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 ff7ae891..a9795d5a 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 @@ -963,6 +963,16 @@ class TypeScriptFullIdentListener(node: TSIdentify) : TypeScriptAstListener() { return args } + override fun enterExportDefaultDeclaration(ctx: TypeScriptParser.ExportDefaultDeclarationContext?) { + val singleExpr = ctx!!.singleExpression() + if (singleExpr != null) { + if (!singleExpr.text.contains("(")) { + currentNode.Exports += CodeExport(singleExpr.text) + defaultNode.Exports += CodeExport(singleExpr.text) + } + } + } + fun getNodeInfo(): CodeContainer { for (entry in nodeMap) { codeContainer.DataStructures += entry.value diff --git a/chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptAnalyserTest.kt b/chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptAnalyserTest.kt index ba75ae00..a38a2f6e 100644 --- a/chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptAnalyserTest.kt +++ b/chapi-ast-typescript/src/test/kotlin/chapi/ast/typescriptast/TypeScriptAnalyserTest.kt @@ -57,6 +57,7 @@ internal class TypeScriptAnalyserTest { val codeFile = TypeScriptAnalyser().analysis(content, "BadSmellThreshold.tsx") assertEquals(codeFile.DataStructures.size, 1) + assertEquals(codeFile.DataStructures[0].Exports[0].Name, "BadSmellThreshold") } @Test