Phase 5: add rename and find usages

This commit is contained in:
hgranthorner
2026-08-04 15:54:31 -04:00
parent 4758bf12e2
commit 460fc969db
17 changed files with 293 additions and 25 deletions

View 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"
}