Skip to content

Commit

Permalink
Merge pull request #6 from dstarcev/master
Browse files Browse the repository at this point in the history
Fix NoUnusedImportsRule failing on escaped imports
  • Loading branch information
shyiko authored Aug 5, 2016
2 parents 9efa4c9 + 28d2eb2 commit 5ab8b34
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class NoUnusedImportsRule : Rule {
node.visit { node ->
if (node.elementType == KtStubElementTypes.REFERENCE_EXPRESSION) {
if (node.psi.getNonStrictParentOfType(KtImportDirective::class.java) == null) {
ref.add(node.text)
ref.add(node.text.trim('`'))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,20 @@ class NoUnusedImportsRuleTest {
import p2.B
import p.C
import p.a.*
import escaped.`when`
import escaped.`foo`
fun main() {
println(a())
C.call(B())
`when`()
}
""".trimIndent()
)).isEqualTo(listOf(
LintError(2, 1, "rule-id", "Unused import"),
LintError(3, 1, "rule-id", "Unused import"),
LintError(4, 1, "rule-id", "Unused import")
LintError(4, 1, "rule-id", "Unused import"),
LintError(9, 1, "rule-id", "Unused import")
))
}

Expand All @@ -41,23 +45,28 @@ class NoUnusedImportsRuleTest {
import p.B as B12
import p2.B as B2
import p.C
import escaped.`when`
import escaped.`foo`
fun main() {
println(a())
C.call()
fn(B2.NAME)
`when`()
}
""".trimIndent()
)).isEqualTo(
"""
import p.a
import p2.B as B2
import p.C
import escaped.`when`
fun main() {
println(a())
C.call()
fn(B2.NAME)
`when`()
}
""".trimIndent()
)
Expand Down

0 comments on commit 5ab8b34

Please # to comment.