-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
627 additions
and
7 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/main/treeDataProviders/dependenciesTree/dependenciesRoot/nugetTree.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import * as Collections from 'typescript-collections'; | ||
import * as vscode from 'vscode'; | ||
import { ComponentDetails } from 'xray-client-js'; | ||
import { DependenciesTreeNode } from '../dependenciesTreeNode'; | ||
import { TreesManager } from '../../treesManager'; | ||
import { GeneralInfo } from '../../../types/generalInfo'; | ||
import { NugetUtils } from '../../../utils/nugetUtils'; | ||
|
||
export class NugetTreeNode extends DependenciesTreeNode { | ||
private static readonly COMPONENT_PREFIX: string = 'nuget://'; | ||
|
||
constructor( | ||
private _workspaceFolder: string, | ||
private _componentsToScan: Collections.Set<ComponentDetails>, | ||
private _treesManager: TreesManager, | ||
parent?: DependenciesTreeNode | ||
) { | ||
super(new GeneralInfo('', '', _workspaceFolder, ''), vscode.TreeItemCollapsibleState.Expanded, parent, ''); | ||
} | ||
|
||
public async refreshDependencies(quickScan: boolean, project: any) { | ||
this.generalInfo = new GeneralInfo(project.name, '', this._workspaceFolder, NugetUtils.PKG_TYPE); | ||
this.label = project.name; | ||
this.populateDependenciesTree(this, project.dependencies, quickScan); | ||
} | ||
|
||
private populateDependenciesTree(dependenciesTreeNode: DependenciesTreeNode, dependencies: any, quickScan: boolean) { | ||
if (!dependencies) { | ||
return; | ||
} | ||
for (let key in dependencies) { | ||
let dependency: any = dependencies[key]; | ||
let nameVersionTuple: string[] = this.getNameVersionTuple(dependency.dependency.id); | ||
let name: string = nameVersionTuple[0]; | ||
let version: string = nameVersionTuple[1]; | ||
if (version) { | ||
let childDependencies: any = dependency.directDependencies; | ||
let generalInfo: GeneralInfo = new GeneralInfo(name, version, '', NugetUtils.PKG_TYPE); | ||
let treeCollapsibleState: vscode.TreeItemCollapsibleState = | ||
childDependencies.length > 0 ? vscode.TreeItemCollapsibleState.Collapsed : vscode.TreeItemCollapsibleState.None; | ||
let child: DependenciesTreeNode = new DependenciesTreeNode(generalInfo, treeCollapsibleState, dependenciesTreeNode, ''); | ||
if (!quickScan || !this._treesManager.scanCacheManager.validateOrDelete(dependency.dependency.id)) { | ||
this._componentsToScan.add(new ComponentDetails(NugetTreeNode.COMPONENT_PREFIX + dependency.dependency.id)); | ||
} | ||
this.populateDependenciesTree(child, childDependencies, quickScan); | ||
} | ||
} | ||
} | ||
|
||
private getNameVersionTuple(value: string): string[] { | ||
let split: string[] = value.split(':'); | ||
return [split[0], split[1]]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.