import { findLinks as JSONFindLinks } from 'vscode-json-languageservice/lib/umd/services/jsonLinks' ; import { DocumentLink } from 'vscode-languageserver' ; import { TextDocument } from 'vscode-languageserver-textdocument' ; import { Telemetry } from '../../languageserver/telemetry' ; import { yamlDocumentsCache } from '../parser/yaml-documents' ; import { convertErrorToTelemetryMsg } from '../utils/objects' ; export class YamlLinks { constructor ( private readonly telemetry ) { } findLinks ( document ) { try { const doc = yamlDocumentsCache . getYamlDocument ( document ) ; const linkPromises = [ ] ; for ( const yamlDoc of doc . documents ) { linkPromises . push ( JSONFindLinks ( document , yamlDoc ) ) ; } return Promise . all ( linkPromises ) . then ( ( yamlLinkArray ) => [ ] . concat ( ... yamlLinkArray ) ) ; } catch ( err ) { this . telemetry . sendError ( 'yaml.documentLink.error' , { error : convertErrorToTelemetryMsg ( err ) } ) ; } } }