import * as vscode from "vscode" ; import { mavenExplorerProvider } from "../explorer/mavenExplorerProvider" ; import { Dependency } from "../explorer/model/Dependency" ; import { ITreeItem } from "../explorer/model/ITreeItem" ; import { MavenProject } from "../explorer/model/MavenProject" ; import { Queue } from "../taskExecutor" ; export async function goToEffectiveHandler ( view , node ? ) { if ( node === undefined || node . omittedStatus === undefined ) { throw new Error ( "No conflict dependency node specified." ) ; } const fullArtifactName = [ node . groupId , node . artifactId , node . omittedStatus . effectiveVersion , node . scope ] . join ( ":" ) ; const pomPath = node . projectPomPath ; const project = mavenExplorerProvider . getMavenProject ( pomPath ) ; if ( project === undefined ) { throw new Error ( "Failed to find maven projects." ) ; } const dependencyNodes = project . dependencyNodes ; const treeItem = await searchFirstEffective ( dependencyNodes , fullArtifactName ) ; if ( treeItem === undefined ) { throw new Error ( "Failed to find dependency." ) ; } view . reveal ( treeItem , { focus : true } ) ; } async function searchFirstEffective ( dependencyNodes , fullArtifactName ) { let targetItem ; const queue = new Queue ( ) ; for ( const child of dependencyNodes ) { queue . push ( child ) ; } while ( queue . empty ( ) === false ) { const node = queue . pop ( ) ; if ( node === undefined ) { throw new Error ( "Failed to find dependency." ) ; } if ( node . fullArtifactName === fullArtifactName ) { targetItem = node ; break ; } const children = node . children ; for ( const child of children ) { queue . push ( child ) ; } } return targetItem ; }