Phase 5: add rename and find usages
This commit is contained in:
37
src/test/kotlin/dev/hgh/jai/findusages/JaiFindUsagesTest.kt
Normal file
37
src/test/kotlin/dev/hgh/jai/findusages/JaiFindUsagesTest.kt
Normal file
@@ -0,0 +1,37 @@
|
||||
package dev.hgh.jai.findusages
|
||||
|
||||
import com.intellij.psi.search.searches.ReferencesSearch
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import com.intellij.testFramework.fixtures.BasePlatformTestCase
|
||||
import dev.hgh.jai.psi.JaiDeclName
|
||||
|
||||
class JaiFindUsagesTest : BasePlatformTestCase() {
|
||||
fun testFindUsagesActionFindsProcedureReference() {
|
||||
val usages = myFixture.testFindUsages("Declaration.jai", "Usage.jai")
|
||||
|
||||
assertEquals(1, usages.size)
|
||||
}
|
||||
|
||||
fun testFindsProcedureReferencesFromDeclaration() {
|
||||
val source =
|
||||
myFixture.addFileToProject(
|
||||
"find-usages.jai",
|
||||
"""
|
||||
helper :: () {}
|
||||
first :: () { helper(); }
|
||||
second :: () { helper(); }
|
||||
""".trimIndent(),
|
||||
)
|
||||
val declaration =
|
||||
PsiTreeUtil
|
||||
.findChildrenOfType(source, JaiDeclName::class.java)
|
||||
.single { it.text == "helper" }
|
||||
|
||||
val usages = ReferencesSearch.search(declaration).findAll()
|
||||
|
||||
assertEquals(2, usages.size)
|
||||
assertTrue(usages.all { it.element.text == "helper" })
|
||||
}
|
||||
|
||||
override fun getTestDataPath(): String = "src/test/testData/findusages"
|
||||
}
|
||||
Reference in New Issue
Block a user