import { values , pickBy , includes , flatMap } from "lodash" ; import { UI5Class , UI5Interface , UI5SemanticModel , } from "@ui5-language-assistant/semantic-model-types" ; import { getSuperClasses } from "./get-super-class" ; export function findClassesMatchingType ( { type , model , } ) { const matchingClasses = pickBy ( model . classes , ( _ ) => classIsOfType ( _ , type ) ) ; return values ( matchingClasses ) ; } export function classIsOfType ( clazz , type ) { const clazzAndSuperClasses = getSuperClasses ( clazz ) . concat ( [ clazz ] ) ; const superInterfaces = flatMap ( clazzAndSuperClasses , ( _ ) => _ . implements ) ; return ( includes ( clazzAndSuperClasses , type ) || includes ( superInterfaces , type ) ) ; }