in src/main/kotlin/com/pestphp/pest/goto/PestTestGoToSymbolContributor.kt [42:93]
override fun getItemsByName(
name: String,
pattern: String,
project: Project,
includeNonProjectItems: Boolean
): Array<NavigationItem> {
val index = FileBasedIndex.getInstance()
val psiManager = PsiManager.getInstance(project)
return index
.getAllKeys(key, project)
.flatMap { fileName ->
val hasName = index.getValues(
key,
fileName,
when {
includeNonProjectItems -> ProjectScope.getAllScope(project)
else -> ProjectScope.getProjectScope(project)
}
).flatten()
.contains(name)
if (!hasName) {
return@flatMap emptyList()
}
index.getContainingFiles(
key,
fileName,
when {
includeNonProjectItems -> ProjectScope.getAllScope(project)
else -> ProjectScope.getProjectScope(project)
}
)
}.mapNotNull { psiManager.findFile(it) }
.flatMap { it.getPestTests() }
.filter { it.getPestTestName().equals(name) }
.map { functionReference ->
val location = PhpPresentationUtil.getPresentablePathForFile(
functionReference.containingFile.virtualFile,
functionReference.project
)
val presentation = PresentationData(
functionReference.getPestTestName(),
location,
PestIcons.Logo,
null,
)
PestTestFunctionReference(functionReference, presentation)
}
.toTypedArray()
}