import * as Collections from 'typescript-collections' ; import * as vscode from 'vscode' ; import { ComponentDetails } from 'jfrog-client-js' ; import { DependenciesTreeNode } from '../dependenciesTreeNode' ; import { TreesManager } from '../../treesManager' ; import { GeneralInfo } from '../../../types/generalInfo' ; import { NugetUtils } from '../../../utils/nugetUtils' ; import { RootNode } from './rootTree' ; export class NugetTreeNode extends RootNode { private static readonly COMPONENT_PREFIX : string = 'nuget://' ; constructor ( workspaceFolder , private _componentsToScan , private _treesManager , parent ? ) { super ( workspaceFolder , parent , '' ) ; } public refreshDependencies ( quickScan , project ) { this . generalInfo = new GeneralInfo ( project . name , '' , [ 'None' ] , this . workspaceFolder , NugetUtils . PKG_TYPE ) ; this . label = project . name ; this . populateDependenciesTree ( this , project . dependencies , quickScan ) ; } private populateDependenciesTree ( dependenciesTreeNode , dependencies , quickScan ) { if ( ! dependencies ) { return ; } for ( let key in dependencies ) { let dependency = dependencies [ key ] ; let id = dependency . id ; let version = dependency . version ; let childDependencies = dependency . dependencies ; if ( id && version && childDependencies ) { let generalInfo = new GeneralInfo ( id , version , [ 'None' ] , '' , NugetUtils . PKG_TYPE ) ; let treeCollapsibleState = childDependencies . length > 0 ? vscode . TreeItemCollapsibleState . Collapsed : vscode . TreeItemCollapsibleState . None ; let child = new DependenciesTreeNode ( generalInfo , treeCollapsibleState , dependenciesTreeNode , '' ) ; let combined = id + ':' + version ; if ( ! quickScan || ! this . _treesManager . scanCacheManager . isValid ( combined ) ) { this . _componentsToScan . add ( new ComponentDetails ( NugetTreeNode . COMPONENT_PREFIX + combined ) ) ; } this . populateDependenciesTree ( child , childDependencies , quickScan ) ; } } } }