diff --git a/src/EnvironmentTreeviewProvider.ts b/src/EnvironmentTreeviewProvider.ts index cfda710..2a49e7b 100644 --- a/src/EnvironmentTreeviewProvider.ts +++ b/src/EnvironmentTreeviewProvider.ts @@ -1,6 +1,8 @@ import * as vscode from "vscode"; import { parseEnvironmentContent, replace } from "./helpers/parse"; -import type { EnvironmentContent, EnvironmentKeyValue } from "./types"; +import { EnvironmentWorkspaceFolderTreeItem } from "./classes/TreeItems/EnvironmentWorkspaceFolderTreeItem"; +import { EnvironmentKeyValueTreeItem } from "./classes/TreeItems/EnvironmentKeyValueTreeItem"; +import { EnvironmentFileTreeItem } from "./classes/TreeItems/EnvironmentFileTreeItem"; export class EnvironmentTreeviewProvider implements vscode.TreeDataProvider @@ -197,52 +199,3 @@ export class EnvironmentTreeviewProvider ); } } - -export enum EnvironmentValueType { - string = "string", - bool = "bool", -} - -export class EnvironmentWorkspaceFolderTreeItem extends vscode.TreeItem { - constructor( - public readonly folder: vscode.WorkspaceFolder, - public readonly collapsibleState: vscode.TreeItemCollapsibleState = vscode - .TreeItemCollapsibleState.Collapsed - ) { - super(folder.name, collapsibleState); - this.contextValue = "workspaceFolder"; - this.tooltip = this.folder.uri.fsPath; - this.iconPath = vscode.ThemeIcon.Folder; - } -} - -export class EnvironmentKeyValueTreeItem extends vscode.TreeItem { - constructor( - public readonly key: string, - public readonly value: EnvironmentKeyValue, - public readonly parent: EnvironmentFileTreeItem, - public readonly collapsibleState: vscode.TreeItemCollapsibleState = vscode - .TreeItemCollapsibleState.None - ) { - super(key, collapsibleState); - this.contextValue = `keyValue-${this.value.type}`; - this.tooltip = this.value.value; - this.description = this.value.value; - } -} - -export class EnvironmentFileTreeItem extends vscode.TreeItem { - constructor( - public readonly name: string, - public readonly uri: vscode.Uri, - public readonly content: EnvironmentContent, - public readonly collapsibleState: vscode.TreeItemCollapsibleState = vscode - .TreeItemCollapsibleState.Collapsed - ) { - super(name, collapsibleState); - this.contextValue = "file"; - this.uri = uri; - this.tooltip = this.uri.fsPath; - this.iconPath = vscode.ThemeIcon.File; - } -} diff --git a/src/classes/TreeItems/EnvironmentFileTreeItem.ts b/src/classes/TreeItems/EnvironmentFileTreeItem.ts new file mode 100644 index 0000000..9053c96 --- /dev/null +++ b/src/classes/TreeItems/EnvironmentFileTreeItem.ts @@ -0,0 +1,18 @@ +import * as vscode from "vscode"; +import type { EnvironmentContent } from "../../types"; + +export class EnvironmentFileTreeItem extends vscode.TreeItem { + constructor( + public readonly name: string, + public readonly uri: vscode.Uri, + public readonly content: EnvironmentContent, + public readonly collapsibleState: vscode.TreeItemCollapsibleState = vscode + .TreeItemCollapsibleState.Collapsed + ) { + super(name, collapsibleState); + this.contextValue = "file"; + this.uri = uri; + this.tooltip = this.uri.fsPath; + this.iconPath = vscode.ThemeIcon.File; + } +} diff --git a/src/classes/TreeItems/EnvironmentKeyValueTreeItem.ts b/src/classes/TreeItems/EnvironmentKeyValueTreeItem.ts new file mode 100644 index 0000000..c202886 --- /dev/null +++ b/src/classes/TreeItems/EnvironmentKeyValueTreeItem.ts @@ -0,0 +1,18 @@ +import * as vscode from "vscode"; +import type { EnvironmentKeyValue } from "../../types"; +import { EnvironmentFileTreeItem } from "./EnvironmentFileTreeItem"; + +export class EnvironmentKeyValueTreeItem extends vscode.TreeItem { + constructor( + public readonly key: string, + public readonly value: EnvironmentKeyValue, + public readonly parent: EnvironmentFileTreeItem, + public readonly collapsibleState: vscode.TreeItemCollapsibleState = vscode + .TreeItemCollapsibleState.None + ) { + super(key, collapsibleState); + this.contextValue = `keyValue-${this.value.type}`; + this.tooltip = this.value.value; + this.description = this.value.value; + } +} diff --git a/src/classes/TreeItems/EnvironmentWorkspaceFolderTreeItem.ts b/src/classes/TreeItems/EnvironmentWorkspaceFolderTreeItem.ts new file mode 100644 index 0000000..b296f67 --- /dev/null +++ b/src/classes/TreeItems/EnvironmentWorkspaceFolderTreeItem.ts @@ -0,0 +1,14 @@ +import * as vscode from "vscode"; + +export class EnvironmentWorkspaceFolderTreeItem extends vscode.TreeItem { + constructor( + public readonly folder: vscode.WorkspaceFolder, + public readonly collapsibleState: vscode.TreeItemCollapsibleState = vscode + .TreeItemCollapsibleState.Collapsed + ) { + super(folder.name, collapsibleState); + this.contextValue = "workspaceFolder"; + this.tooltip = this.folder.uri.fsPath; + this.iconPath = vscode.ThemeIcon.Folder; + } +} diff --git a/src/extension.ts b/src/extension.ts index d3e1e1b..02f95ca 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,10 +1,8 @@ import * as vscode from "vscode"; -import { - EnvironmentFileTreeItem, - EnvironmentKeyValueTreeItem, - EnvironmentTreeviewProvider, - EnvironmentWorkspaceFolderTreeItem, -} from "./EnvironmentTreeviewProvider"; +import { EnvironmentTreeviewProvider } from "./EnvironmentTreeviewProvider"; +import { EnvironmentWorkspaceFolderTreeItem } from "./classes/TreeItems/EnvironmentWorkspaceFolderTreeItem"; +import { EnvironmentFileTreeItem } from "./classes/TreeItems/EnvironmentFileTreeItem"; +import { EnvironmentKeyValueTreeItem } from "./classes/TreeItems/EnvironmentKeyValueTreeItem"; export function activate(context: vscode.ExtensionContext) { const treeDataProvider = new EnvironmentTreeviewProvider(context).register();