forked from microsoft/vscode-java-dependency
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackageNode.ts
More file actions
72 lines (65 loc) · 2.88 KB
/
Copy pathpackageNode.ts
File metadata and controls
72 lines (65 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
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 { FolderNode } from "./folderNode";
import { PrimaryTypeNode } from "./PrimaryTypeNode";
import { ProjectNode } from "./projectNode";
export class PackageNode extends DataNode {
constructor(nodeData: INodeData, parent: DataNode, protected _project: ProjectNode, protected _rootNode: DataNode) {
super(nodeData, parent);
}
public isSourcePackage(): boolean {
const parentData = <IPackageRootNodeData> this._rootNode.nodeData;
return parentData.entryKind === PackageRootKind.K_SOURCE || parentData.kind === NodeKind.Project;
}
protected async loadData(): Promise<INodeData[]> {
return Jdtls.getPackageData({
kind: NodeKind.Package,
projectUri: this._project.nodeData.uri,
path: this.nodeData.name,
handlerIdentifier: this.nodeData.handlerIdentifier,
});
}
protected createChildNodeList(): ExplorerNode[] {
const result: ExplorerNode[] = [];
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));
}
} else if (nodeData.kind === NodeKind.Folder) {
result.push(new FolderNode(nodeData, this, this._project, 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: string = 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;
}
}