Skip to content

Commit

Permalink
feat: <ts> add sepcific symbol support
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Feb 10, 2020
1 parent 6126c4d commit 31238fc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ class TypeScriptFullIdentListener(private var node: TSIdentify) : TypeScriptPars
}
}

if (ctx.Dollar() != null) {
codeImport.UsageName += ctx.Dollar().text
}

if (ctx.Lodash() != null) {
codeImport.UsageName += ctx.Lodash().text
}

codeFile.Imports += codeImport
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,20 @@ import "./module.js";
assertEquals(codeFile.Imports.size, 1)
assertEquals(codeFile.Imports[0].Source, "./module.js")
}

@Test
internal fun shouldIdentifySpecificSymbol() {
var code = """
import $ from "jquery";
import _ from "lodash";
"""

val codeFile = TypeScriptAnalyser().analysis(code, "")
assertEquals(codeFile.Imports.size, 2)
assertEquals(codeFile.Imports[0].Source, "jquery")
assertEquals(codeFile.Imports[0].UsageName[0], "$")
assertEquals(codeFile.Imports[1].Source, "lodash")
assertEquals(codeFile.Imports[1].UsageName[0], "_")
}
}

0 comments on commit 31238fc

Please sign in to comment.