import { ThemeIcon } from "vscode" ; import { Explorer } from "../constants" ; import { Jdtls } from "../java/jdtls" ; import { INodeData , NodeKind } from "../java/nodeData" ; import { IPackageRootNodeData , PackageRootKind } from "../java/packageRootNodeData" ; import { isTest } from "../utility" ; import { DataNode } from "./dataNode" ; import { ExplorerNode } from "./explorerNode" ; import { FileNode } from "./fileNode" ; import { PrimaryTypeNode } from "./PrimaryTypeNode" ; export class PackageNode extends DataNode { constructor ( nodeData , parent , protected _project , protected _rootNode ) { super ( nodeData , parent ) ; } protected async loadData ( ) { return Jdtls . getPackageData ( { kind : NodeKind . Package , projectUri : this . _project . nodeData . uri , path : this . nodeData . name , handlerIdentifier : this . nodeData . handlerIdentifier , } ) ; } protected createChildNodeList ( ) { const result = [ ] ; if ( this . nodeData . children && this . nodeData . children . length ) { this . sort ( ) ; this . nodeData . children . forEach ( ( nodeData ) => { if ( nodeData . kind === NodeKind . File ) { result . push ( new FileNode ( nodeData , this ) ) ; } else if ( nodeData . kind === NodeKind . PrimaryType ) { if ( nodeData . metaData && nodeData . metaData [ PrimaryTypeNode . K_TYPE_KIND ] ) { result . push ( new PrimaryTypeNode ( nodeData , this , this . _rootNode ) ) ; } } } ) ; } return result ; } protected get iconPath ( ) : ThemeIcon { return new ThemeIcon ( "symbol-package" ) ; } protected get contextValue ( ) : string | undefined { const parentData = < IPackageRootNodeData > this . _rootNode . nodeData ; let contextValue = Explorer . ContextValueType . Package ; if ( parentData . entryKind === PackageRootKind . K_SOURCE || parentData . kind === NodeKind . Project ) { contextValue += "+source" ; } else if ( parentData . entryKind === PackageRootKind . K_BINARY ) { contextValue += "+binary" ; } if ( isTest ( parentData ) ) { contextValue += "+test" ; } return contextValue ; } }