override fun getItemsByName()

in src/com/intellij/idea/plugin/hybris/system/type/searcheverywhere/TypeSearchEverywhereContributor.kt [107:141]


        override fun getItemsByName(name: String?, pattern: String?, project: Project?, includeNonProjectItems: Boolean): Array<NavigationItem> {
            if (project == null || name == null || pattern == null) return emptyArray()

            val types = TSMetaModelAccess.getInstance(project).getAll()
                .filter { it.name?.lowercase()?.contains(pattern.lowercase()) == true }
                .flatMap { it.retrieveAllDoms() }
                .mapNotNull {
                    when (it) {
                        is CollectionType -> it.code.xmlAttributeValue
                        is EnumType -> it.code.xmlAttributeValue
                        is MapType -> it.code.xmlAttributeValue
                        is Relation -> it.code.xmlAttributeValue
                        is ItemType -> it.code.xmlAttributeValue
                        else -> null
                    }
                }
                .mapNotNull { it as? NavigationItem }
                .toTypedArray()

            val beans = BSMetaModelAccess.getInstance(project).getAllBeans()
                .filter { it.name?.lowercase()?.contains(pattern.lowercase()) == true }
                .flatMap { it.retrieveAllDoms() }
                .mapNotNull { it.clazz.xmlAttributeValue }
                .mapNotNull { it as? NavigationItem }
                .toTypedArray()

            val enums = BSMetaModelAccess.getInstance(project).getAllEnums()
                .filter { it.name?.lowercase()?.contains(pattern.lowercase()) == true }
                .flatMap { it.retrieveAllDoms() }
                .mapNotNull { it.clazz.xmlAttributeValue }
                .mapNotNull { it as? NavigationItem }
                .toTypedArray()

            return types + beans + enums
        }