Skip to content

Commit

Permalink
feat(typescript): add exports to name support
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Apr 9, 2022
1 parent 2bdd161 commit ec6fafb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ec6fafb

Please # to comment.