in src/handlers/setDependencyVersionHandler.ts [15:64]
export async function setDependencyVersionHandler(selectedItem?: any): Promise<void> {
let pomPath: string;
let effectiveVersion: string;
if (selectedItem && selectedItem.pomPath) { // codeAction
pomPath = selectedItem.pomPath;
effectiveVersion = selectedItem.effectiveVersion;
} else if (selectedItem && selectedItem instanceof Dependency) {
pomPath = selectedItem.projectPomPath;
effectiveVersion = selectedItem.omittedStatus?.effectiveVersion ?? selectedItem.version;
} else {
throw new UserError("No dependency node specified.");
}
if (!await fse.pathExists(pomPath)) {
throw new UserError("Specified POM file does not exist on file system.");
}
const gid: string = selectedItem.groupId;
const aid: string = selectedItem.artifactId;
const versions: string[] = getAllVersionsInTree(pomPath, gid, aid);
const OPTION_SEARCH_MAVEN_CENTRAL: string = "Search Maven Central Repository...";
versions.push(OPTION_SEARCH_MAVEN_CENTRAL);
let selectedVersion: string | undefined = await vscode.window.showQuickPick(
versions.map(version => ({ value: version, label: version !== OPTION_SEARCH_MAVEN_CENTRAL ? `$(package) ${version}` : version, description: version === effectiveVersion ? "effective" : undefined })),
{
placeHolder: `Select a version for ${gid}:${aid}...`,
ignoreFocusOut: true
}
).then(version => version ? version.value : undefined);
if (selectedVersion === undefined) {
return;
}
if (selectedVersion === OPTION_SEARCH_MAVEN_CENTRAL) {
const selectedVersionFromMavenCentral: string | undefined = await vscode.window.showQuickPick<vscode.QuickPickItem & { value: string }>(
getVersions(gid, aid).then(artifacts => artifacts.map(artifact => ({ value: artifact.v, label: `$(package) ${artifact.v}`, description: artifact.v === effectiveVersion ? "effective" : undefined }))),
{
placeHolder: `Select a version for ${gid}:${aid}...`,
ignoreFocusOut: true
}
).then(artifact => artifact ? artifact.value : undefined);
if (selectedVersionFromMavenCentral === undefined) {
return;
}
selectedVersion = selectedVersionFromMavenCentral;
}
if (selectedVersion !== effectiveVersion) {
await setDependencyVersion(pomPath, gid, aid, selectedVersion);
}
}