import * as vscode from "vscode" ; import { setUserError } from "vscode-extension-telemetry-wrapper" ; import { MavenProject } from "../explorer/model/MavenProject" ; import { rawDependencyTree } from "../utils/mavenUtils" ; import { dependenciesContentUri } from "../utils/uiUtils" ; export async function showDependenciesHandler ( project ) { const uri = dependenciesContentUri ( project . pomPath ) ; await vscode . window . showTextDocument ( uri ) ; } export async function getDependencyTree ( pomPathOrMavenProject ) { let pomPath ; let name ; if ( typeof pomPathOrMavenProject === "object" && pomPathOrMavenProject instanceof MavenProject ) { const mavenProject = pomPathOrMavenProject ; pomPath = mavenProject . pomPath ; name = mavenProject . name ; } else if ( typeof pomPathOrMavenProject === "string" ) { pomPath = pomPathOrMavenProject ; name = pomPath ; } else { return undefined ; } return await vscode . window . withProgress ( { location : vscode . ProgressLocation . Window , cancellable : false } , async ( p , _token ) => new Promise < string | undefined > ( async ( resolve , reject ) : Promise < void > => { p . report ( { message : `Generating Dependency Tree: ${ name }` } ) ; try { const rawData = await rawDependencyTree ( pomPath ) ; resolve ( rawData ) ; return ; } catch ( error ) { setUserError ( error ) ; reject ( error ) ; return ; } } ) ) ; }