Skip to content

Commit

Permalink
refactors classes
Browse files Browse the repository at this point in the history
  • Loading branch information
isfopo committed Jul 14, 2024
1 parent 00a7030 commit 2d22bea
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 56 deletions.
53 changes: 3 additions & 50 deletions src/EnvironmentTreeviewProvider.ts
Original file line number Diff line number Diff line change
@@ -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<vscode.TreeItem>
Expand Down Expand Up @@ -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;
}
}
18 changes: 18 additions & 0 deletions src/classes/TreeItems/EnvironmentFileTreeItem.ts
Original file line number Diff line number Diff line change
@@ -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;
}
}
18 changes: 18 additions & 0 deletions src/classes/TreeItems/EnvironmentKeyValueTreeItem.ts
Original file line number Diff line number Diff line change
@@ -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;
}
}
14 changes: 14 additions & 0 deletions src/classes/TreeItems/EnvironmentWorkspaceFolderTreeItem.ts
Original file line number Diff line number Diff line change
@@ -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;
}
}
10 changes: 4 additions & 6 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -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();
Expand Down

0 comments on commit 2d22bea

Please sign in to comment.