in src/main/kotlin/com/pestphp/pest/goto/PestDatasetUsagesGotoHandler.kt [17:47]
fun getDatasetUsages(literal: StringLiteralExpression): Array<PsiElement>? {
val function = literal.parent?.parent as? FunctionReferenceImpl ?: return null
if (!function.isPestDatasetFunction()) return null
val searchHelper = PsiSearchHelper.getInstance(literal.project)
val result = mutableListOf<PsiElement>()
val datasetName = literal.contents
val processor = Processor { psiFile: PsiFile ->
result.addAll(
PsiTreeUtil.findChildrenOfType(psiFile, StringLiteralExpression::class.java).filter {
it.contents == datasetName
}.mapNotNull {
it.parent?.parent as? MethodReference
}.filter {
it.isDatasetCall()
}
)
true
}
searchHelper.processAllFilesWithWordInLiterals(
datasetName,
GlobalSearchScope.allScope(literal.project),
processor,
)
return result.toTypedArray()
}