import { ThemeIcon , Uri } from "vscode" ; import { Explorer } from "../constants" ; import { Jdtls } from "../java/jdtls" ; import { INodeData , NodeKind } from "../java/nodeData" ; import { DataNode } from "./dataNode" ; import { ExplorerNode } from "./explorerNode" ; import { NodeFactory } from "./nodeFactory" ; import { PackageRootNode } from "./packageRootNode" ; import { ProjectNode } from "./projectNode" ; export class ContainerNode extends DataNode { constructor ( nodeData , parent , private readonly _project ) { super ( nodeData , parent ) ; } public get projectBasePath ( ) { return this . _project . uri && Uri . parse ( this . _project . uri ) . fsPath ; } protected async loadData ( ) { return Jdtls . getPackageData ( { kind : NodeKind . Container , projectUri : this . _project . uri , path : this . path } ) ; } protected createChildNodeList ( ) { const result = [ ] ; if ( this . nodeData . children && this . nodeData . children . length ) { this . sort ( ) ; this . nodeData . children . forEach ( ( classpathNode ) => { result . push ( NodeFactory . createPackageRootNode ( classpathNode , this , this . _project ) ) ; } ) ; } return result ; } protected get contextValue ( ) : string { let contextValue = Explorer . ContextValueType . Container ; const containerType = getContainerType ( this . _nodeData . path ) ; if ( containerType ) { contextValue += `+${ containerType }` ; } return contextValue ; } protected get iconPath ( ) : ThemeIcon { return new ThemeIcon ( "folder-library" ) ; } } function getContainerType ( containerPath ) { if ( ! containerPath ) { return "" ; } else if ( containerPath . startsWith ( ContainerPath . JRE ) ) { return "jre" ; } else if ( containerPath . startsWith ( ContainerPath . Maven ) ) { return "maven" ; } else if ( containerPath . startsWith ( ContainerPath . Gradle ) ) { return "gradle" ; } else if ( containerPath . startsWith ( ContainerPath . ReferencedLibrary ) ) { return "referencedLibrary" ; } return "" ; } const enum ContainerPath { JRE = "org.eclipse.jdt.launching.JRE_CONTAINER" , Maven = "org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER" , Gradle = "org.eclipse.buildship.core.gradleclasspathcontainer" , ReferencedLibrary = "REFERENCED_LIBRARIES_PATH" }