import { UI5SemanticModel , BaseUI5Node , UI5Prop , UI5Field , UI5Aggregation , UI5Association , } from "@ui5-language-assistant/semantic-model-types" ; import { MarkupContent } from "vscode-languageserver" ; import { getRootSymbolParent , ui5NodeToFQN , isRootSymbol , typeToString , getDeprecationMessage , convertJSDocToMarkdown , getLink , } from "@ui5-language-assistant/logic-utils" ; import { GENERATED_LIBRARY } from "@ui5-language-assistant/semantic-model" ; export function getNodeDocumentation ( node , model ) { let contents = "" ; const NL = "\n" ; const EMPTY_STRING = "" ; contents += node . since ? `Available since version ${ node . since }.` + NL : EMPTY_STRING ; if ( node . deprecatedInfo ?. isDeprecated ) { if ( contents !== "" ) { contents += NL ; } contents += getDeprecationMessage ( { since : node . deprecatedInfo . since , text : node . deprecatedInfo . text , } ) ; contents += NL ; } if ( node . experimentalInfo ?. isExperimental ) { if ( contents !== "" ) { contents += NL ; } contents += "Experimental" ; contents += node . experimentalInfo . since ? ` since version ${ node . experimentalInfo . since }` : EMPTY_STRING ; contents += "." ; contents += node . experimentalInfo . text ? ` ${ node . experimentalInfo . text }` : EMPTY_STRING ; contents += NL ; } if ( contents . length > 0 ) { contents += NL ; } contents += node . description ? node . description + NL : EMPTY_STRING ; const markdownContent = { kind : "markdown" , value : convertJSDocToMarkdown ( contents , model ) , } ; const symbolForDocumentation = getRootSymbolParent ( node ) ; if ( symbolForDocumentation !== undefined && symbolForDocumentation . library !== GENERATED_LIBRARY ) { const link = getLink ( model , ui5NodeToFQN ( symbolForDocumentation ) ) ; markdownContent . value += NL + `[More information](${ link })` + NL ; } return markdownContent ; } export function getNodeDetail ( node ) { if ( isRootSymbol ( node ) ) { return ui5NodeToFQN ( node ) ; } switch ( node . kind ) { case "UI5Prop" : return `(property) ${ node . name }: ${ typeToString ( ( node as UI5Prop ) . type ) }` ; case "UI5Field" : return `(field) ${ node . name }: ${ typeToString ( ( node as UI5Field ) . type ) }` ; case "UI5Aggregation" : return `(aggregation) ${ node . name }: ${ typeToString ( ( node as UI5Aggregation ) . type ) }` ; case "UI5Association" : return `(association) ${ node . name }: ${ typeToString ( ( node as UI5Association ) . type ) }` ; case "UI5Event" : return `(event) ${ node . name }` ; case "UI5EnumValue" : default : return node . name ; } }