mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-08 01:28:31 -05:00
Reworks ExplorerNode base class
Adds TextExplorerNode for messages
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
'use strict';
|
||||
import { Command, Event, ExtensionContext, TreeItem } from 'vscode';
|
||||
import { GitService, GitUri } from '../gitService';
|
||||
import { Command, Event, TreeItem, TreeItemCollapsibleState } from 'vscode';
|
||||
import { GitUri } from '../gitService';
|
||||
|
||||
export declare type ResourceType = 'status' | 'branches' | 'repository' | 'branch-history' | 'file-history' | 'stash-history' | 'commit' | 'stash-commit' | 'commit-file';
|
||||
export declare type ResourceType = 'text' | 'status' | 'branches' | 'repository' | 'branch-history' | 'file-history' | 'stash-history' | 'commit' | 'stash-commit' | 'commit-file';
|
||||
|
||||
export abstract class ExplorerNode {
|
||||
|
||||
abstract readonly resourceType: ResourceType;
|
||||
|
||||
constructor(public readonly uri: GitUri, protected readonly context: ExtensionContext, protected readonly git: GitService) { }
|
||||
constructor(public readonly uri: GitUri) { }
|
||||
|
||||
abstract getChildren(): ExplorerNode[] | Promise<ExplorerNode[]>;
|
||||
abstract getTreeItem(): TreeItem | Promise<TreeItem>;
|
||||
@@ -20,4 +20,23 @@ export abstract class ExplorerNode {
|
||||
onDidChangeTreeData?: Event<ExplorerNode>;
|
||||
|
||||
refresh?(): void;
|
||||
}
|
||||
|
||||
export class TextExplorerNode extends ExplorerNode {
|
||||
|
||||
readonly resourceType: ResourceType = 'text';
|
||||
|
||||
constructor(private text: string) {
|
||||
super(new GitUri());
|
||||
}
|
||||
|
||||
getChildren(): ExplorerNode[] | Promise<ExplorerNode[]> {
|
||||
return [];
|
||||
}
|
||||
|
||||
getTreeItem(): TreeItem | Promise<TreeItem> {
|
||||
const item = new TreeItem(this.text, TreeItemCollapsibleState.None);
|
||||
item.contextValue = this.resourceType;
|
||||
return item;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user