import { isEmpty , has } from "lodash" ; import { BaseUI5Node , UI5SemanticModel , } from "@ui5-language-assistant/semantic-model-types" ; export function newMap < T > ( ) { return Object . create ( null ) ; } export function getParentFqn ( fqn , name ) { if ( ! isEmpty ( fqn ) && fqn . endsWith ( "." + name ) ) { return fqn . substring ( 0 , fqn . length - ( name . length + 1 ) ) ; } return undefined ; } export function error ( message , throwError ) { if ( throwError ) { throw new Error ( message ) ; } else { console . error ( message ) ; } } export function findValueInMaps < T > ( key , ... maps ) { for ( const mapElement of maps ) { if ( has ( mapElement , key ) ) { return mapElement [ key ] ; } } return undefined ; } export function getSymbolMaps ( model ) { return [ model . classes , model . enums , model . namespaces , model . interfaces , model . typedefs , model . functions , ] ; } export function findSymbol ( model , fqn ) { return findValueInMaps < BaseUI5Node > ( fqn , ... getSymbolMaps ( model ) ) ; } export function forEachSymbol ( model , iteratee ) { const typeMaps = getSymbolMaps ( model ) ; main : for ( const mapElement of typeMaps ) { for ( const key in mapElement ) { const keepIterating = iteratee ( mapElement [ key ] , key ) ; if ( keepIterating === false ) { break main ; } } } } param value param property export function hasProperty < T > ( value , property ) { return has ( value , property ) ; }