소스 검색

Adds view reference to all ViewNodes

Normalizes ctor parameters for ViewNodes
main
Eric Amodio 6 년 전
부모
커밋
5e30864af7
33개의 변경된 파일242개의 추가작업 그리고 227개의 파일을 삭제
  1. +7
    -7
      src/views/nodes/branchNode.ts
  2. +5
    -5
      src/views/nodes/branchOrTagFolderNode.ts
  3. +6
    -6
      src/views/nodes/branchesNode.ts
  4. +3
    -3
      src/views/nodes/commitFileNode.ts
  5. +5
    -5
      src/views/nodes/commitNode.ts
  6. +15
    -12
      src/views/nodes/common.ts
  7. +8
    -16
      src/views/nodes/fileHistoryNode.ts
  8. +16
    -8
      src/views/nodes/fileHistoryTrackerNode.ts
  9. +5
    -5
      src/views/nodes/folderNode.ts
  10. +1
    -1
      src/views/nodes/helpers.ts
  11. +9
    -17
      src/views/nodes/lineHistoryNode.ts
  12. +11
    -4
      src/views/nodes/lineHistoryTrackerNode.ts
  13. +9
    -9
      src/views/nodes/remoteNode.ts
  14. +8
    -6
      src/views/nodes/remotesNode.ts
  15. +6
    -6
      src/views/nodes/repositoriesNode.ts
  16. +12
    -12
      src/views/nodes/repositoryNode.ts
  17. +4
    -4
      src/views/nodes/resultsCommitNode.ts
  18. +6
    -6
      src/views/nodes/resultsCommitsNode.ts
  19. +6
    -6
      src/views/nodes/resultsComparisonNode.ts
  20. +4
    -4
      src/views/nodes/resultsFileNode.ts
  21. +6
    -6
      src/views/nodes/resultsFilesNode.ts
  22. +9
    -4
      src/views/nodes/resultsNode.ts
  23. +2
    -2
      src/views/nodes/stashFileNode.ts
  24. +4
    -4
      src/views/nodes/stashNode.ts
  25. +5
    -5
      src/views/nodes/stashesNode.ts
  26. +6
    -6
      src/views/nodes/statusFileNode.ts
  27. +7
    -7
      src/views/nodes/statusFilesNode.ts
  28. +8
    -8
      src/views/nodes/statusUpstreamNode.ts
  29. +7
    -7
      src/views/nodes/tagNode.ts
  30. +7
    -7
      src/views/nodes/tagsNode.ts
  31. +8
    -10
      src/views/nodes/viewNode.ts
  32. +4
    -4
      src/views/resultsView.ts
  33. +23
    -15
      src/views/viewBase.ts

+ 7
- 7
src/views/nodes/branchNode.ts 파일 보기

@ -11,20 +11,20 @@ import { MessageNode, ShowMoreNode } from './common';
import { insertDateMarkers } from './helpers';
import { PageableViewNode, ResourceType, ViewNode, ViewRefNode } from './viewNode';
export class BranchNode extends ViewRefNode implements PageableViewNode {
export class BranchNode extends ViewRefNode<RepositoriesView> implements PageableViewNode {
readonly supportsPaging: boolean = true;
maxCount: number | undefined;
private _children: ViewNode[] | undefined;
constructor(
public readonly branch: GitBranch,
uri: GitUri,
view: RepositoriesView,
parent: ViewNode,
public readonly view: RepositoriesView,
public readonly branch: GitBranch,
private readonly _markCurrent: boolean = true
) {
super(uri, parent);
super(uri, view, parent);
}
get id(): string {
@ -54,7 +54,7 @@ export class BranchNode extends ViewRefNode implements PageableViewNode {
maxCount: this.maxCount || this.view.config.defaultItemLimit,
ref: this.ref
});
if (log === undefined) return [new MessageNode(this, 'No commits could be found.')];
if (log === undefined) return [new MessageNode(this.view, this, 'No commits could be found.')];
const branches = await Container.git.getBranches(this.uri.repoPath);
// Get the sha length, since `git branch` can return variable length shas
@ -75,14 +75,14 @@ export class BranchNode extends ViewRefNode implements PageableViewNode {
...insertDateMarkers(
Iterables.map(
log.commits.values(),
c => new CommitNode(c, this, this.view, this.branch, getBranchTips)
c => new CommitNode(this.view, this, c, this.branch, getBranchTips)
),
this
)
];
if (log.truncated) {
children.push(new ShowMoreNode('Commits', this, this.view));
children.push(new ShowMoreNode(this.view, this, 'Commits'));
}
this._children = children;

+ 5
- 5
src/views/nodes/branchOrTagFolderNode.ts 파일 보기

@ -9,16 +9,16 @@ import { ResourceType, ViewNode } from './viewNode';
export class BranchOrTagFolderNode extends ViewNode {
constructor(
view: View,
parent: ViewNode,
public readonly type: 'branch' | 'remote-branch' | 'tag',
public readonly repoPath: string,
public readonly folderName: string,
public readonly relativePath: string | undefined,
public readonly root: Arrays.IHierarchicalItem<BranchNode | TagNode>,
parent: ViewNode,
public readonly view: View,
private readonly _expanded: boolean = false
) {
super(GitUri.fromRepoPath(repoPath), parent);
super(GitUri.fromRepoPath(repoPath), view, parent);
}
get id(): string {
@ -38,13 +38,13 @@ export class BranchOrTagFolderNode extends ViewNode {
folder.descendants.some(n => n instanceof BranchNode && n.current);
children.push(
new BranchOrTagFolderNode(
this.view,
this,
this.type,
this.repoPath,
folder.name,
folder.relativePath,
folder,
this,
this.view,
expanded
)
);

+ 6
- 6
src/views/nodes/branchesNode.ts 파일 보기

@ -9,16 +9,16 @@ import { BranchNode } from './branchNode';
import { BranchOrTagFolderNode } from './branchOrTagFolderNode';
import { ResourceType, ViewNode } from './viewNode';
export class BranchesNode extends ViewNode {
export class BranchesNode extends ViewNode<RepositoriesView> {
private _children: ViewNode[] | undefined;
constructor(
uri: GitUri,
public readonly repo: Repository,
view: RepositoriesView,
parent: ViewNode,
public readonly view: RepositoriesView
public readonly repo: Repository
) {
super(uri, parent);
super(uri, view, parent);
}
get id(): string {
@ -36,7 +36,7 @@ export class BranchesNode extends ViewNode {
const branchNodes = [
...Iterables.filterMap(
branches,
b => (b.remote ? undefined : new BranchNode(b, this.uri, this, this.view))
b => (b.remote ? undefined : new BranchNode(this.uri, this.view, this, b))
)
];
if (this.view.config.branches.layout === ViewBranchesLayout.List) return branchNodes;
@ -48,7 +48,7 @@ export class BranchesNode extends ViewNode {
this.view.config.files.compact
);
const root = new BranchOrTagFolderNode('branch', this.repo.path, '', undefined, hierarchy, this, this.view);
const root = new BranchOrTagFolderNode(this.view, this, 'branch', this.repo.path, '', undefined, hierarchy);
this._children = await root.getChildren();
}
return this._children;

+ 3
- 3
src/views/nodes/commitFileNode.ts 파일 보기

@ -29,14 +29,14 @@ export enum CommitFileNodeDisplayAs {
export class CommitFileNode extends ViewRefNode {
constructor(
view: View,
parent: ViewNode,
public readonly file: GitFile,
public commit: GitLogCommit,
parent: ViewNode,
public readonly view: View,
private readonly _displayAs: CommitFileNodeDisplayAs,
private readonly _selection?: Selection
) {
super(GitUri.fromFile(file, commit.repoPath, commit.sha), parent);
super(GitUri.fromFile(file, commit.repoPath, commit.sha), view, parent);
}
get priority(): number {

+ 5
- 5
src/views/nodes/commitNode.ts 파일 보기

@ -14,13 +14,13 @@ import { ResourceType, ViewNode, ViewRefNode } from './viewNode';
export class CommitNode extends ViewRefNode {
constructor(
public readonly commit: GitLogCommit,
view: View,
parent: ViewNode,
public readonly view: View,
public readonly commit: GitLogCommit,
public readonly branch?: GitBranch,
private readonly getBranchTips?: (sha: string) => string | undefined
) {
super(commit.toGitUri(), parent);
super(commit.toGitUri(), view, parent);
}
get ref(): string {
@ -32,7 +32,7 @@ export class CommitNode extends ViewRefNode {
let children: FileNode[] = [
...Iterables.map(
commit.files,
s => new CommitFileNode(s, commit.toFileCommit(s), this, this.view, CommitFileNodeDisplayAs.File)
s => new CommitFileNode(this.view, this, s, commit.toFileCommit(s), CommitFileNodeDisplayAs.File)
)
];
@ -44,7 +44,7 @@ export class CommitNode extends ViewRefNode {
this.view.config.files.compact
);
const root = new FolderNode(this.repoPath, '', undefined, hierarchy, this, this.view);
const root = new FolderNode(this.view, this, this.repoPath, '', hierarchy);
children = (await root.getChildren()) as FileNode[];
}
else {

+ 15
- 12
src/views/nodes/common.ts 파일 보기

@ -7,6 +7,7 @@ import { ResourceType, unknownGitUri, ViewNode } from './viewNode';
export class MessageNode extends ViewNode {
constructor(
view: View,
parent: ViewNode,
private readonly _message: string,
private readonly _tooltip?: string,
@ -19,7 +20,7 @@ export class MessageNode extends ViewNode {
}
| ThemeIcon
) {
super(unknownGitUri, parent);
super(unknownGitUri, view, parent);
}
getChildren(): ViewNode[] | Promise<ViewNode[]> {
@ -37,6 +38,7 @@ export class MessageNode extends ViewNode {
export class CommandMessageNode extends MessageNode {
constructor(
view: View,
parent: ViewNode,
private readonly _command: Command,
message: string,
@ -50,7 +52,7 @@ export class CommandMessageNode extends MessageNode {
}
| ThemeIcon
) {
super(parent, message, tooltip, iconPath);
super(view, parent, message, tooltip, iconPath);
}
getTreeItem(): TreeItem | Promise<TreeItem> {
@ -69,6 +71,7 @@ export class CommandMessageNode extends MessageNode {
export class UpdateableMessageNode extends ViewNode {
constructor(
view: View,
parent: ViewNode,
public readonly id: string,
private _message: string,
@ -82,7 +85,7 @@ export class UpdateableMessageNode extends ViewNode {
}
| ThemeIcon
) {
super(unknownGitUri, parent);
super(unknownGitUri, view, parent);
}
getChildren(): ViewNode[] | Promise<ViewNode[]> {
@ -134,11 +137,11 @@ export abstract class PagerNode extends ViewNode {
protected _args: RefreshNodeCommandArgs = {};
constructor(
protected readonly message: string,
protected readonly parent: ViewNode,
protected readonly view: View
view: View,
parent: ViewNode,
protected readonly message: string
) {
super(unknownGitUri, parent);
super(unknownGitUri, view, parent);
}
getChildren(): ViewNode[] | Promise<ViewNode[]> {
@ -160,19 +163,19 @@ export abstract class PagerNode extends ViewNode {
return {
title: 'Refresh',
command: this.view.getQualifiedCommand('refreshNode'),
arguments: [this.parent, this._args]
arguments: [this._parent, this._args]
} as Command;
}
}
export class ShowMoreNode extends PagerNode {
constructor(type: string, parent: ViewNode, view: View, maxCount: number = Container.config.advanced.maxListItems) {
constructor(view: View, parent: ViewNode, type: string, maxCount: number = Container.config.advanced.maxListItems) {
super(
view,
parent,
maxCount === 0
? `Show All ${type} ${GlyphChars.Space}${GlyphChars.Dash}${GlyphChars.Space} this may take a while`
: `Show More ${type}`,
parent,
view
: `Show More ${type}`
);
this._args.maxCount = maxCount;
}

+ 8
- 16
src/views/nodes/fileHistoryNode.ts 파일 보기

@ -1,6 +1,5 @@
'use strict';
import { Disposable, TreeItem, TreeItemCollapsibleState } from 'vscode';
import { GlyphChars } from '../../constants';
import { Container } from '../../container';
import {
GitCommitType,
@ -12,16 +11,16 @@ import {
RepositoryFileSystemChangeEvent
} from '../../git/gitService';
import { Logger } from '../../logger';
import { debug, gate, Iterables, log } from '../../system';
import { FileHistoryView } from '../fileHistoryView';
import { debug, Iterables } from '../../system';
import { View } from '../viewBase';
import { CommitFileNode, CommitFileNodeDisplayAs } from './commitFileNode';
import { MessageNode } from './common';
import { insertDateMarkers } from './helpers';
import { ResourceType, SubscribeableViewNode, ViewNode } from './viewNode';
export class FileHistoryNode extends SubscribeableViewNode<FileHistoryView> {
constructor(uri: GitUri, parent: ViewNode, view: FileHistoryView) {
super(uri, parent, view);
export class FileHistoryNode extends SubscribeableViewNode {
constructor(uri: GitUri, view: View, parent: ViewNode) {
super(uri, view, parent);
}
async getChildren(): Promise<ViewNode[]> {
@ -67,7 +66,7 @@ export class FileHistoryNode extends SubscribeableViewNode {
previousSha,
status.originalFileName || status.fileName
);
children.push(new CommitFileNode(status, commit, this, this.view, displayAs));
children.push(new CommitFileNode(this.view, this, status, commit, displayAs));
}
}
@ -79,14 +78,14 @@ export class FileHistoryNode extends SubscribeableViewNode {
...insertDateMarkers(
Iterables.map(
log.commits.values(),
c => new CommitFileNode(c.files[0], c, this, this.view, displayAs)
c => new CommitFileNode(this.view, this, c.files[0], c, displayAs)
),
this
)
);
}
if (children.length === 0) return [new MessageNode(this, 'No file history could be found.')];
if (children.length === 0) return [new MessageNode(this.view, this, 'No file history could be found.')];
return children;
}
@ -120,13 +119,6 @@ export class FileHistoryNode extends SubscribeableViewNode {
return item;
}
@gate()
@log()
changeBase(ref: string | undefined) {
this.uri.sha = ref;
return this.triggerChange();
}
@debug()
protected async subscribe() {
const repo = await Container.git.getRepository(this.uri);

+ 16
- 8
src/views/nodes/fileHistoryTrackerNode.ts 파일 보기

@ -13,11 +13,11 @@ import { FileHistoryNode } from './fileHistoryNode';
import { ResourceType, SubscribeableViewNode, unknownGitUri, ViewNode } from './viewNode';
export class FileHistoryTrackerNode extends SubscribeableViewNode<FileHistoryView> {
private _base: string | undefined;
private _baseRef: string | undefined;
private _child: FileHistoryNode | undefined;
constructor(view: FileHistoryView) {
super(unknownGitUri, undefined, view);
super(unknownGitUri, view);
}
dispose() {
@ -37,11 +37,18 @@ export class FileHistoryTrackerNode extends SubscribeableViewNode
async getChildren(): Promise<ViewNode[]> {
if (this._child === undefined) {
if (this.uri === unknownGitUri) {
return [new MessageNode(this, 'There are no editors open that can provide file history information.')];
return [
new MessageNode(
this.view,
this,
'There are no editors open that can provide file history information.'
)
];
}
const fileUri = new GitUri(this.uri, { ...this.uri, sha: this.uri.sha || this._base } as GitCommitish);
this._child = new FileHistoryNode(fileUri, this, this.view);
const uri = this.uri;
const fileUri = new GitUri(uri, { ...uri, sha: this._baseRef || uri.sha } as GitCommitish);
this._child = new FileHistoryNode(fileUri, this.view, this);
}
return [this._child];
@ -62,15 +69,16 @@ export class FileHistoryTrackerNode extends SubscribeableViewNode
const pick = await new BranchesAndTagsQuickPick(this.uri.repoPath!).show(
`Change the file history base to${GlyphChars.Ellipsis}`,
{
checked: this._base
checked: this._baseRef
}
);
if (pick === undefined || pick instanceof CommandQuickPickItem) return;
this._base = pick.current ? undefined : pick.name;
this._baseRef = pick.current ? undefined : pick.name;
if (this._child === undefined) return;
await this._child.changeBase(this._base);
this._uri = unknownGitUri;
await this.triggerChange();
}
@gate()

+ 5
- 5
src/views/nodes/folderNode.ts 파일 보기

@ -18,14 +18,14 @@ export class FolderNode extends ViewNode {
readonly priority: number = 1;
constructor(
view: View,
parent: ViewNode,
public readonly repoPath: string,
public readonly folderName: string,
public readonly relativePath: string | undefined,
public readonly root: Arrays.IHierarchicalItem<FileNode>,
parent: ViewNode,
public readonly view: View
public readonly relativePath?: string
) {
super(GitUri.fromRepoPath(repoPath), parent);
super(GitUri.fromRepoPath(repoPath), view, parent);
}
async getChildren(): Promise<(FolderNode | FileNode)[]> {
@ -43,7 +43,7 @@ export class FolderNode extends ViewNode {
for (const folder of Objects.values(this.root.children)) {
if (folder.value === undefined) {
children.push(
new FolderNode(this.repoPath, folder.name, folder.relativePath, folder, this, this.view)
new FolderNode(this.view, this, this.repoPath, folder.name, folder, folder.relativePath)
);
continue;
}

+ 1
- 1
src/views/nodes/helpers.ts 파일 보기

@ -45,7 +45,7 @@ export function* insertDateMarkers(
// Don't show the last marker as the first entry -- since it could be wildly far off
if (!first || index < markers.length - 1) {
yield new MessageNode(parent, marker);
yield new MessageNode(parent.view, parent, marker);
}
index++;

+ 9
- 17
src/views/nodes/lineHistoryNode.ts 파일 보기

@ -1,6 +1,5 @@
'use strict';
import { Disposable, Selection, TreeItem, TreeItemCollapsibleState } from 'vscode';
import { GlyphChars } from '../../constants';
import { Container } from '../../container';
import { GitCommitType, GitFile, GitLogCommit } from '../../git/git';
import {
@ -11,21 +10,21 @@ import {
RepositoryFileSystemChangeEvent
} from '../../git/gitService';
import { Logger } from '../../logger';
import { debug, gate, Iterables, log } from '../../system';
import { LineHistoryView } from '../lineHistoryView';
import { debug, Iterables } from '../../system';
import { View } from '../viewBase';
import { CommitFileNode, CommitFileNodeDisplayAs } from './commitFileNode';
import { MessageNode } from './common';
import { insertDateMarkers } from './helpers';
import { ResourceType, SubscribeableViewNode, ViewNode } from './viewNode';
export class LineHistoryNode extends SubscribeableViewNode<LineHistoryView> {
export class LineHistoryNode extends SubscribeableViewNode {
constructor(
uri: GitUri,
public readonly selection: Selection,
view: View,
parent: ViewNode,
view: LineHistoryView
public readonly selection: Selection
) {
super(uri, parent, view);
super(uri, view, parent);
}
async getChildren(): Promise<ViewNode[]> {
@ -44,7 +43,7 @@ export class LineHistoryNode extends SubscribeableViewNode {
...insertDateMarkers(
Iterables.filterMap(
log.commits.values(),
c => new CommitFileNode(c.files[0], c, this, this.view, displayAs, this.selection)
c => new CommitFileNode(this.view, this, c.files[0], c, displayAs, this.selection)
),
this
)
@ -86,11 +85,11 @@ export class LineHistoryNode extends SubscribeableViewNode {
blame.commit.originalFileName || blame.commit.fileName
);
children.splice(0, 0, new CommitFileNode(file, commit, this, this.view, displayAs, this.selection));
children.splice(0, 0, new CommitFileNode(this.view, this, file, commit, displayAs, this.selection));
}
}
if (children.length === 0) return [new MessageNode(this, 'No line history could be found.')];
if (children.length === 0) return [new MessageNode(this.view, this, 'No line history could be found.')];
return children;
}
@ -127,13 +126,6 @@ export class LineHistoryNode extends SubscribeableViewNode {
return item;
}
@gate()
@log()
changeBase(ref: string | undefined) {
this.uri.sha = ref;
return this.triggerChange();
}
@debug()
protected async subscribe() {
const repo = await Container.git.getRepository(this.uri);

+ 11
- 4
src/views/nodes/lineHistoryTrackerNode.ts 파일 보기

@ -18,7 +18,7 @@ export class LineHistoryTrackerNode extends SubscribeableViewNode
private _selection: Selection | undefined;
constructor(view: LineHistoryView) {
super(unknownGitUri, undefined, view);
super(unknownGitUri, view);
}
dispose() {
@ -38,11 +38,17 @@ export class LineHistoryTrackerNode extends SubscribeableViewNode
async getChildren(): Promise<ViewNode[]> {
if (this._child === undefined) {
if (this.uri === unknownGitUri) {
return [new MessageNode(this, 'There are no editors open that can provide line history information.')];
return [
new MessageNode(
this.view,
this,
'There are no editors open that can provide line history information.'
)
];
}
const fileUri = new GitUri(this.uri, { ...this.uri, sha: this.uri.sha || this._base } as GitCommitish);
this._child = new LineHistoryNode(fileUri, this._selection!, this, this.view);
this._child = new LineHistoryNode(fileUri, this.view, this, this._selection!);
}
return [this._child];
@ -71,7 +77,8 @@ export class LineHistoryTrackerNode extends SubscribeableViewNode
this._base = pick.current ? undefined : pick.name;
if (this._child === undefined) return;
await this._child.changeBase(this._base);
this._uri = unknownGitUri;
await this.triggerChange();
}
@gate()

+ 9
- 9
src/views/nodes/remoteNode.ts 파일 보기

@ -10,15 +10,15 @@ import { BranchNode } from './branchNode';
import { BranchOrTagFolderNode } from './branchOrTagFolderNode';
import { ResourceType, ViewNode } from './viewNode';
export class RemoteNode extends ViewNode {
export class RemoteNode extends ViewNode<RepositoriesView> {
constructor(
public readonly remote: GitRemote,
uri: GitUri,
public readonly repo: Repository,
view: RepositoriesView,
parent: ViewNode,
public readonly view: RepositoriesView
public readonly remote: GitRemote,
public readonly repo: Repository
) {
super(uri, parent);
super(uri, view, parent);
}
get id(): string {
@ -38,7 +38,7 @@ export class RemoteNode extends ViewNode {
b =>
!b.remote || !b.name.startsWith(this.remote.name)
? undefined
: new BranchNode(b, this.uri, this, this.view)
: new BranchNode(this.uri, this.view, this, b)
)
];
if (this.view.config.branches.layout === ViewBranchesLayout.List) return branchNodes;
@ -51,13 +51,13 @@ export class RemoteNode extends ViewNode {
);
const root = new BranchOrTagFolderNode(
this.view,
this,
'remote-branch',
this.repo.path,
'',
undefined,
hierarchy,
this,
this.view
hierarchy
);
const children = (await root.getChildren()) as (BranchOrTagFolderNode | BranchNode)[];

+ 8
- 6
src/views/nodes/remotesNode.ts 파일 보기

@ -8,14 +8,14 @@ import { MessageNode } from './common';
import { RemoteNode } from './remoteNode';
import { ResourceType, ViewNode } from './viewNode';
export class RemotesNode extends ViewNode {
export class RemotesNode extends ViewNode<RepositoriesView> {
constructor(
uri: GitUri,
public readonly repo: Repository,
view: RepositoriesView,
parent: ViewNode,
public readonly view: RepositoriesView
public readonly repo: Repository
) {
super(uri, parent);
super(uri, view, parent);
}
get id(): string {
@ -24,10 +24,12 @@ export class RemotesNode extends ViewNode {
async getChildren(): Promise<ViewNode[]> {
const remotes = await this.repo.getRemotes();
if (remotes === undefined || remotes.length === 0) return [new MessageNode(this, 'No remotes could be found')];
if (remotes === undefined || remotes.length === 0) {
return [new MessageNode(this.view, this, 'No remotes could be found')];
}
remotes.sort((a, b) => a.name.localeCompare(b.name));
return [...Iterables.map(remotes, r => new RemoteNode(r, this.uri, this.repo, this, this.view))];
return [...Iterables.map(remotes, r => new RemoteNode(this.uri, this.view, this, r, this.repo))];
}
getTreeItem(): TreeItem {

+ 6
- 6
src/views/nodes/repositoriesNode.ts 파일 보기

@ -14,7 +14,7 @@ export class RepositoriesNode extends SubscribeableViewNode {
private _children: (RepositoryNode | MessageNode)[] | undefined;
constructor(view: RepositoriesView) {
super(unknownGitUri, undefined, view);
super(unknownGitUri, view);
}
dispose() {
@ -33,13 +33,13 @@ export class RepositoriesNode extends SubscribeableViewNode {
async getChildren(): Promise<ViewNode[]> {
if (this._children === undefined) {
const repositories = await Container.git.getOrderedRepositories();
if (repositories.length === 0) return [new MessageNode(this, 'No repositories could be found.')];
if (repositories.length === 0) return [new MessageNode(this.view, this, 'No repositories could be found.')];
const children = [];
for (const repo of repositories) {
if (repo.closed) continue;
children.push(new RepositoryNode(GitUri.fromRepoPath(repo.path), repo, this, this.view));
children.push(new RepositoryNode(GitUri.fromRepoPath(repo.path), this.view, this, repo));
}
this._children = children;
@ -66,7 +66,7 @@ export class RepositoriesNode extends SubscribeableViewNode {
if (repositories.length === 0 && (this._children === undefined || this._children.length === 0)) return;
if (repositories.length === 0) {
this._children = [new MessageNode(this, 'No repositories could be found.')];
this._children = [new MessageNode(this.view, this, 'No repositories could be found.')];
return;
}
@ -79,7 +79,7 @@ export class RepositoriesNode extends SubscribeableViewNode {
void child.refresh();
}
else {
children.push(new RepositoryNode(GitUri.fromRepoPath(repo.path), repo, this, this.view));
children.push(new RepositoryNode(GitUri.fromRepoPath(repo.path), this.view, this, repo));
}
}
@ -133,7 +133,7 @@ export class RepositoriesNode extends SubscribeableViewNode {
parent = parent.getParent();
}
void this.view.reveal(node);
void this.view.reveal(node /*, { expand: true } */);
}
catch (ex) {
Logger.error(ex);

+ 12
- 12
src/views/nodes/repositoryNode.ts 파일 보기

@ -30,11 +30,11 @@ export class RepositoryNode extends SubscribeableViewNode {
constructor(
uri: GitUri,
public readonly repo: Repository,
view: RepositoriesView,
parent: ViewNode,
view: RepositoriesView
public readonly repo: Repository
) {
super(uri, parent, view);
super(uri, view, parent);
this._status = this.repo.getStatus();
}
@ -59,29 +59,29 @@ export class RepositoryNode extends SubscribeableViewNode {
status.state.behind,
status.detached
);
children.push(new BranchNode(branch, this.uri, this, this.view, false));
children.push(new BranchNode(this.uri, this.view, this, branch, false));
if (status.state.behind) {
children.push(new StatusUpstreamNode(status, 'behind', this, this.view));
children.push(new StatusUpstreamNode(this.view, this, status, 'behind'));
}
if (status.state.ahead) {
children.push(new StatusUpstreamNode(status, 'ahead', this, this.view));
children.push(new StatusUpstreamNode(this.view, this, status, 'ahead'));
}
if (status.state.ahead || (status.files.length !== 0 && this.includeWorkingTree)) {
const range = status.upstream ? `${status.upstream}..${branch.ref}` : undefined;
children.push(new StatusFilesNode(status, range, this, this.view));
children.push(new StatusFilesNode(this.view, this, status, range));
}
children.push(new MessageNode(this, GlyphChars.Dash.repeat(2), ''));
children.push(new MessageNode(this.view, this, GlyphChars.Dash.repeat(2), ''));
}
children.push(
new BranchesNode(this.uri, this.repo, this, this.view),
new RemotesNode(this.uri, this.repo, this, this.view),
new StashesNode(this.uri, this.repo, this, this.view),
new TagsNode(this.uri, this.repo, this, this.view)
new BranchesNode(this.uri, this.view, this, this.repo),
new RemotesNode(this.uri, this.view, this, this.repo),
new StashesNode(this.uri, this.view, this, this.repo),
new TagsNode(this.uri, this.view, this, this.repo)
);
this._children = children;
}

+ 4
- 4
src/views/nodes/resultsCommitNode.ts 파일 보기

@ -7,14 +7,14 @@ import { ResourceType, ViewNode } from './viewNode';
export class ResultsCommitNode extends ViewNode {
constructor(
public readonly commit: GitLogCommit,
public readonly view: ResultsView
view: ResultsView,
public readonly commit: GitLogCommit
) {
super(commit.toGitUri(), undefined);
super(commit.toGitUri(), view);
}
getChildren(): ViewNode[] {
return [new CommitNode(this.commit, this, this.view)];
return [new CommitNode(this.view, this, this.commit)];
}
getTreeItem(): TreeItem {

+ 6
- 6
src/views/nodes/resultsCommitsNode.ts 파일 보기

@ -2,7 +2,7 @@
import { TreeItem, TreeItemCollapsibleState } from 'vscode';
import { GitLog, GitUri } from '../../git/gitService';
import { Iterables } from '../../system';
import { ResultsView } from '../resultsView';
import { View } from '../viewBase';
import { CommitNode } from './commitNode';
import { ShowMoreNode } from './common';
import { PageableViewNode, ResourceType, ViewNode } from './viewNode';
@ -17,13 +17,13 @@ export class ResultsCommitsNode extends ViewNode implements PageableViewNode {
maxCount: number | undefined;
constructor(
view: View,
parent: ViewNode,
public readonly repoPath: string,
private readonly _commitsQuery: (maxCount: number | undefined) => Promise<CommitsQueryResults>,
parent: ViewNode | undefined,
public readonly view: ResultsView,
private readonly _contextValue: ResourceType = ResourceType.ResultsCommits
) {
super(GitUri.fromRepoPath(repoPath), parent);
super(GitUri.fromRepoPath(repoPath), view, parent);
}
async getChildren(): Promise<ViewNode[]> {
@ -31,11 +31,11 @@ export class ResultsCommitsNode extends ViewNode implements PageableViewNode {
if (log === undefined) return [];
const children: (CommitNode | ShowMoreNode)[] = [
...Iterables.map(log.commits.values(), c => new CommitNode(c, this, this.view))
...Iterables.map(log.commits.values(), c => new CommitNode(this.view, this, c))
];
if (log.truncated) {
children.push(new ShowMoreNode('Results', this, this.view));
children.push(new ShowMoreNode(this.view, this, 'Results'));
}
return children;

+ 6
- 6
src/views/nodes/resultsComparisonNode.ts 파일 보기

@ -4,19 +4,19 @@ import { GlyphChars } from '../../constants';
import { Container } from '../../container';
import { GitService, GitUri } from '../../git/gitService';
import { Strings } from '../../system';
import { ResultsView } from '../resultsView';
import { View } from '../viewBase';
import { CommitsQueryResults, ResultsCommitsNode } from './resultsCommitsNode';
import { ResultsFilesNode } from './resultsFilesNode';
import { NamedRef, ResourceType, ViewNode } from './viewNode';
export class ResultsComparisonNode extends ViewNode {
constructor(
view: View,
public readonly repoPath: string,
ref1: NamedRef,
ref2: NamedRef,
public readonly view: ResultsView
ref2: NamedRef
) {
super(GitUri.fromRepoPath(repoPath), undefined);
super(GitUri.fromRepoPath(repoPath), view);
this._ref1 = ref1;
this._ref2 = ref2;
@ -34,8 +34,8 @@ export class ResultsComparisonNode extends ViewNode {
async getChildren(): Promise<ViewNode[]> {
return [
new ResultsCommitsNode(this.uri.repoPath!, this.getCommitsQuery.bind(this), this, this.view),
new ResultsFilesNode(this.uri.repoPath!, this._ref1.ref, this._ref2.ref, this, this.view)
new ResultsCommitsNode(this.view, this, this.uri.repoPath!, this.getCommitsQuery.bind(this)),
new ResultsFilesNode(this.view, this, this.uri.repoPath!, this._ref1.ref, this._ref2.ref)
];
}

+ 4
- 4
src/views/nodes/resultsFileNode.ts 파일 보기

@ -9,14 +9,14 @@ import { ResourceType, ViewNode } from './viewNode';
export class ResultsFileNode extends ViewNode {
constructor(
view: View,
parent: ViewNode,
public readonly repoPath: string,
public readonly file: GitFile,
public readonly ref1: string,
public readonly ref2: string,
parent: ViewNode,
public readonly view: View
public readonly ref2: string
) {
super(GitUri.fromFile(file, repoPath, ref1 ? ref1 : ref2 ? ref2 : undefined), parent);
super(GitUri.fromFile(file, repoPath, ref1 ? ref1 : ref2 ? ref2 : undefined), view, parent);
}
getChildren(): ViewNode[] {

+ 6
- 6
src/views/nodes/resultsFilesNode.ts 파일 보기

@ -17,13 +17,13 @@ export interface FilesQueryResults {
export class ResultsFilesNode extends ViewNode {
constructor(
view: View,
parent: ViewNode,
public readonly repoPath: string,
private readonly _ref1: string,
private readonly _ref2: string,
parent: ViewNode,
public readonly view: View
private readonly _ref2: string
) {
super(GitUri.fromRepoPath(repoPath), parent);
super(GitUri.fromRepoPath(repoPath), view, parent);
}
async getChildren(): Promise<ViewNode[]> {
@ -31,7 +31,7 @@ export class ResultsFilesNode extends ViewNode {
if (diff === undefined) return [];
let children: FileNode[] = [
...Iterables.map(diff, s => new ResultsFileNode(this.repoPath, s, this._ref1, this._ref2, this, this.view))
...Iterables.map(diff, s => new ResultsFileNode(this.view, this, this.repoPath, s, this._ref1, this._ref2))
];
if (this.view.config.files.layout !== ViewFilesLayout.List) {
@ -42,7 +42,7 @@ export class ResultsFilesNode extends ViewNode {
this.view.config.files.compact
);
const root = new FolderNode(this.repoPath, '', undefined, hierarchy, this, this.view);
const root = new FolderNode(this.view, this, this.repoPath, '', hierarchy);
children = (await root.getChildren()) as FileNode[];
}
else {

+ 9
- 4
src/views/nodes/resultsNode.ts 파일 보기

@ -11,10 +11,8 @@ import { ResourceType, unknownGitUri, ViewNode } from './viewNode';
export class ResultsNode extends ViewNode {
private _children: (ViewNode | MessageNode)[] = [];
constructor(
public readonly view: ResultsView
) {
super(unknownGitUri, undefined);
constructor(view: ResultsView) {
super(unknownGitUri, view);
}
async getChildren(): Promise<ViewNode[]> {
@ -26,6 +24,7 @@ export class ResultsNode extends ViewNode {
return [
new CommandMessageNode(
this.view,
this,
{
...command,
@ -35,6 +34,7 @@ export class ResultsNode extends ViewNode {
'Click to search'
),
new CommandMessageNode(
this.view,
this,
{
...command,
@ -44,6 +44,7 @@ export class ResultsNode extends ViewNode {
'Click to search by message'
),
new CommandMessageNode(
this.view,
this,
{
...command,
@ -53,6 +54,7 @@ export class ResultsNode extends ViewNode {
'Click to search by author'
),
new CommandMessageNode(
this.view,
this,
{
...command,
@ -62,6 +64,7 @@ export class ResultsNode extends ViewNode {
'Click to search by commit id'
),
new CommandMessageNode(
this.view,
this,
{
...command,
@ -71,6 +74,7 @@ export class ResultsNode extends ViewNode {
'Click to search by files'
),
new CommandMessageNode(
this.view,
this,
{
...command,
@ -80,6 +84,7 @@ export class ResultsNode extends ViewNode {
'Click to search by changes'
),
new CommandMessageNode(
this.view,
this,
{
...command,

+ 2
- 2
src/views/nodes/stashFileNode.ts 파일 보기

@ -5,8 +5,8 @@ import { CommitFileNode, CommitFileNodeDisplayAs } from './commitFileNode';
import { ResourceType, ViewNode } from './viewNode';
export class StashFileNode extends CommitFileNode {
constructor(file: GitFile, commit: GitLogCommit, parent: ViewNode, view: View) {
super(file, commit, parent, view, CommitFileNodeDisplayAs.File);
constructor(view: View, parent: ViewNode, file: GitFile, commit: GitLogCommit) {
super(view, parent, file, commit, CommitFileNodeDisplayAs.File);
}
protected get resourceType(): ResourceType {

+ 4
- 4
src/views/nodes/stashNode.ts 파일 보기

@ -9,11 +9,11 @@ import { ResourceType, ViewNode, ViewRefNode } from './viewNode';
export class StashNode extends ViewRefNode {
constructor(
public readonly commit: GitStashCommit,
view: View,
parent: ViewNode,
public readonly view: View
public readonly commit: GitStashCommit
) {
super(commit.toGitUri(), parent);
super(commit.toGitUri(), view, parent);
}
get id(): string {
@ -41,7 +41,7 @@ export class StashNode extends ViewRefNode {
}
}
const children = files.map(s => new StashFileNode(s, this.commit.toFileCommit(s), this, this.view));
const children = files.map(s => new StashFileNode(this.view, this, s, this.commit.toFileCommit(s)));
children.sort((a, b) => a.label!.localeCompare(b.label!));
return children;
}

+ 5
- 5
src/views/nodes/stashesNode.ts 파일 보기

@ -11,11 +11,11 @@ import { ResourceType, ViewNode } from './viewNode';
export class StashesNode extends ViewNode {
constructor(
uri: GitUri,
public readonly repo: Repository,
view: View,
parent: ViewNode,
public readonly view: View
public readonly repo: Repository
) {
super(uri, parent);
super(uri, view, parent);
}
get id(): string {
@ -24,9 +24,9 @@ export class StashesNode extends ViewNode {
async getChildren(): Promise<ViewNode[]> {
const stash = await this.repo.getStashList();
if (stash === undefined) return [new MessageNode(this, 'No stashed changes.')];
if (stash === undefined) return [new MessageNode(this.view, this, 'No stashed changes.')];
return [...Iterables.map(stash.commits.values(), c => new StashNode(c, this, this.view))];
return [...Iterables.map(stash.commits.values(), c => new StashNode(this.view, this, c))];
}
getTreeItem(): TreeItem {

+ 6
- 6
src/views/nodes/statusFileNode.ts 파일 보기

@ -21,13 +21,13 @@ export class StatusFileNode extends ViewNode {
private readonly _hasUnstagedChanges: boolean = false;
constructor(
view: View,
parent: ViewNode,
public readonly repoPath: string,
public readonly file: GitFile,
public readonly commits: GitLogCommit[],
parent: ViewNode,
public readonly view: View
public readonly commits: GitLogCommit[]
) {
super(GitUri.fromFile(file, repoPath, 'HEAD'), parent);
super(GitUri.fromFile(file, repoPath, 'HEAD'), view, parent);
for (const c of this.commits) {
if (c.isStagedUncommitted) {
@ -45,10 +45,10 @@ export class StatusFileNode extends ViewNode {
return this.commits.map(
c =>
new CommitFileNode(
this.view,
this,
this.file,
c,
this,
this.view,
CommitFileNodeDisplayAs.CommitLabel |
(this.view.config.avatars
? CommitFileNodeDisplayAs.Gravatar

+ 7
- 7
src/views/nodes/statusFilesNode.ts 파일 보기

@ -19,16 +19,16 @@ import { FileNode, FolderNode } from './folderNode';
import { StatusFileNode } from './statusFileNode';
import { ResourceType, ViewNode } from './viewNode';
export class StatusFilesNode extends ViewNode {
export class StatusFilesNode extends ViewNode<RepositoriesView> {
readonly repoPath: string;
constructor(
public readonly status: GitStatus,
public readonly range: string | undefined,
view: RepositoriesView,
parent: ViewNode,
public readonly view: RepositoriesView
public readonly status: GitStatus,
public readonly range: string | undefined
) {
super(GitUri.fromRepoPath(status.repoPath), parent);
super(GitUri.fromRepoPath(status.repoPath), view, parent);
this.repoPath = status.repoPath;
}
@ -86,7 +86,7 @@ export class StatusFilesNode extends ViewNode {
...Iterables.map(
Objects.values(groups),
files =>
new StatusFileNode(repoPath, files[files.length - 1], files.map(s => s.commit), this, this.view)
new StatusFileNode(this.view, this, repoPath, files[files.length - 1], files.map(s => s.commit))
)
];
@ -98,7 +98,7 @@ export class StatusFilesNode extends ViewNode {
this.view.config.files.compact
);
const root = new FolderNode(repoPath, '', undefined, hierarchy, this, this.view);
const root = new FolderNode(this.view, this, repoPath, '', hierarchy);
children = (await root.getChildren()) as FileNode[];
}
else {

+ 8
- 8
src/views/nodes/statusUpstreamNode.ts 파일 보기

@ -3,7 +3,7 @@ import { TreeItem, TreeItemCollapsibleState } from 'vscode';
import { Container } from '../../container';
import { GitStatus, GitUri } from '../../git/gitService';
import { Iterables, Strings } from '../../system';
import { RepositoriesView } from '../repositoriesView';
import { View } from '../viewBase';
import { CommitNode } from './commitNode';
import { ShowMoreNode } from './common';
import { insertDateMarkers } from './helpers';
@ -15,12 +15,12 @@ export class StatusUpstreamNode extends ViewNode implements PageableViewNode {
maxCount: number | undefined;
constructor(
public readonly status: GitStatus,
public readonly direction: 'ahead' | 'behind',
view: View,
parent: RepositoryNode,
public readonly view: RepositoriesView
public readonly status: GitStatus,
public readonly direction: 'ahead' | 'behind'
) {
super(GitUri.fromRepoPath(status.repoPath), parent);
super(GitUri.fromRepoPath(status.repoPath), view, parent);
}
get id(): string {
@ -51,12 +51,12 @@ export class StatusUpstreamNode extends ViewNode implements PageableViewNode {
}
}
children = [...insertDateMarkers(Iterables.map(commits, c => new CommitNode(c, this, this.view)), this, 1)];
children = [...insertDateMarkers(Iterables.map(commits, c => new CommitNode(this.view, this, c)), this, 1)];
}
else {
children = [
...insertDateMarkers(
Iterables.map(log.commits.values(), c => new CommitNode(c, this, this.view)),
Iterables.map(log.commits.values(), c => new CommitNode(this.view, this, c)),
this,
1
)
@ -64,7 +64,7 @@ export class StatusUpstreamNode extends ViewNode implements PageableViewNode {
}
if (log.truncated) {
children.push(new ShowMoreNode('Commits', this, this.view));
children.push(new ShowMoreNode(this.view, this, 'Commits'));
}
return children;
}

+ 7
- 7
src/views/nodes/tagNode.ts 파일 보기

@ -10,17 +10,17 @@ import { MessageNode, ShowMoreNode } from './common';
import { insertDateMarkers } from './helpers';
import { PageableViewNode, ResourceType, ViewNode, ViewRefNode } from './viewNode';
export class TagNode extends ViewRefNode implements PageableViewNode {
export class TagNode extends ViewRefNode<RepositoriesView> implements PageableViewNode {
readonly supportsPaging: boolean = true;
maxCount: number | undefined;
constructor(
public readonly tag: GitTag,
uri: GitUri,
view: RepositoriesView,
parent: ViewNode,
public readonly view: RepositoriesView
public readonly tag: GitTag
) {
super(uri, parent);
super(uri, view, parent);
}
get id(): string {
@ -40,14 +40,14 @@ export class TagNode extends ViewRefNode implements PageableViewNode {
maxCount: this.maxCount || this.view.config.defaultItemLimit,
ref: this.tag.name
});
if (log === undefined) return [new MessageNode(this, 'No commits could be found.')];
if (log === undefined) return [new MessageNode(this.view, this, 'No commits could be found.')];
const children = [
...insertDateMarkers(Iterables.map(log.commits.values(), c => new CommitNode(c, this, this.view)), this)
...insertDateMarkers(Iterables.map(log.commits.values(), c => new CommitNode(this.view, this, c)), this)
];
if (log.truncated) {
children.push(new ShowMoreNode('Commits', this, this.view));
children.push(new ShowMoreNode(this.view, this, 'Commits'));
}
return children;
}

+ 7
- 7
src/views/nodes/tagsNode.ts 파일 보기

@ -10,14 +10,14 @@ import { MessageNode } from './common';
import { TagNode } from './tagNode';
import { ResourceType, ViewNode } from './viewNode';
export class TagsNode extends ViewNode {
export class TagsNode extends ViewNode<RepositoriesView> {
constructor(
uri: GitUri,
public readonly repo: Repository,
view: RepositoriesView,
parent: ViewNode,
public readonly view: RepositoriesView
public readonly repo: Repository
) {
super(uri, parent);
super(uri, view, parent);
}
get id(): string {
@ -26,10 +26,10 @@ export class TagsNode extends ViewNode {
async getChildren(): Promise<ViewNode[]> {
const tags = await this.repo.getTags();
if (tags.length === 0) return [new MessageNode(this, 'No tags could be found.')];
if (tags.length === 0) return [new MessageNode(this.view, this, 'No tags could be found.')];
tags.sort((a, b) => a.name.localeCompare(b.name));
const tagNodes = tags.map(t => new TagNode(t, this.uri, this, this.view));
const tagNodes = tags.map(t => new TagNode(this.uri, this.view, this, t));
if (this.view.config.branches.layout === ViewBranchesLayout.List) return tagNodes;
const hierarchy = Arrays.makeHierarchical(
@ -39,7 +39,7 @@ export class TagsNode extends ViewNode {
this.view.config.files.compact
);
const root = new BranchOrTagFolderNode('tag', this.repo.path, '', undefined, hierarchy, this, this.view);
const root = new BranchOrTagFolderNode(this.view, this, 'tag', this.repo.path, '', undefined, hierarchy);
const children = (await root.getChildren()) as (BranchOrTagFolderNode | TagNode)[];
return children;
}

+ 8
- 10
src/views/nodes/viewNode.ts 파일 보기

@ -59,10 +59,11 @@ export interface ViewNode {
}
@logName<ViewNode>((c, name) => `${name}${c.id ? `(${c.id})` : ''}`)
export abstract class ViewNode {
export abstract class ViewNode<TView extends View = View> {
constructor(
uri: GitUri,
protected readonly _parent: ViewNode | undefined
public readonly view: TView,
protected readonly _parent?: ViewNode
) {
this._uri = uri;
}
@ -93,7 +94,7 @@ export abstract class ViewNode {
refresh(reason?: RefreshReason): void | boolean | Promise<void> | Promise<boolean> {}
}
export abstract class ViewRefNode extends ViewNode {
export abstract class ViewRefNode<TView extends View = View> extends ViewNode<TView> {
abstract get ref(): string;
get repoPath(): string {
@ -118,16 +119,12 @@ export function supportsAutoRefresh(
return (view as any).onDidChangeAutoRefresh !== undefined;
}
export abstract class SubscribeableViewNode<TView extends View> extends ViewNode {
export abstract class SubscribeableViewNode<TView extends View = View> extends ViewNode<TView> {
protected _disposable: Disposable;
protected _subscription: Promise<Disposable | undefined> | undefined;
constructor(
uri: GitUri,
parent: ViewNode | undefined,
public readonly view: TView
) {
super(uri, parent);
constructor(uri: GitUri, view: TView, parent?: ViewNode) {
super(uri, view, parent);
const disposables = [
this.view.onDidChangeVisibility(this.onVisibilityChanged, this),
@ -165,6 +162,7 @@ export abstract class SubscribeableViewNode extends ViewNode
}
}
@gate()
@debug()
async triggerChange() {
return this.view.refreshNode(this);

+ 4
- 4
src/views/resultsView.ts 파일 보기

@ -112,16 +112,16 @@ export class ResultsView extends ViewBase {
}
addCommit(commit: GitLogCommit) {
return this.addResults(new ResultsCommitNode(commit, this));
return this.addResults(new ResultsCommitNode(this, commit));
}
addComparison(repoPath: string, ref1: string | NamedRef, ref2: string | NamedRef) {
return this.addResults(
new ResultsComparisonNode(
this,
repoPath,
typeof ref1 === 'string' ? { ref: ref1 } : ref1,
typeof ref2 === 'string' ? { ref: ref2 } : ref2,
this
typeof ref2 === 'string' ? { ref: ref2 } : ref2
)
);
}
@ -182,7 +182,7 @@ export class ResultsView extends ViewBase {
};
return this.addResults(
new ResultsCommitsNode(repoPath, getCommitsQuery, undefined, this, ResourceType.SearchResults)
new ResultsCommitsNode(this, this._root!, repoPath, getCommitsQuery, ResourceType.SearchResults)
);
}

+ 23
- 15
src/views/viewBase.ts 파일 보기

@ -16,7 +16,7 @@ import {
import { configuration } from '../configuration';
import { Container } from '../container';
import { Logger } from '../logger';
import { debug, Functions, log } from '../system';
import { debug, Functions, gate, log } from '../system';
import { FileHistoryView } from './fileHistoryView';
import { LineHistoryView } from './lineHistoryView';
import { ViewNode } from './nodes';
@ -26,7 +26,6 @@ import { ResultsView } from './resultsView';
import { RefreshNodeCommandArgs } from './viewCommands';
export enum RefreshReason {
Command = 'Command',
ConfigurationChanged = 'ConfigurationChanged',
VisibilityChanged = 'VisibilityChanged'
}
@ -37,7 +36,7 @@ export interface TreeViewNodeStateChangeEvent extends TreeViewExpansionEvent<
state: TreeItemCollapsibleState;
}
export abstract class ViewBase<TRoot extends ViewNode> implements TreeDataProvider<ViewNode>, Disposable {
export abstract class ViewBase<TRoot extends ViewNode<View>> implements TreeDataProvider<ViewNode>, Disposable {
protected _onDidChangeTreeData = new EventEmitter<ViewNode>();
public get onDidChangeTreeData(): Event<ViewNode> {
return this._onDidChangeTreeData.event;
@ -80,13 +79,14 @@ export abstract class ViewBase implements TreeDataProvid
protected abstract registerCommands(): void;
protected abstract onConfigurationChanged(e: ConfigurationChangeEvent): void;
protected initialize(container?: string) {
protected initialize(container?: string, options: { showCollapseAll?: boolean } = {}) {
if (this._disposable) {
this._disposable.dispose();
this._onDidChangeTreeData = new EventEmitter<ViewNode>();
}
this._tree = window.createTreeView(`${this.id}${container ? `:${container}` : ''}`, {
...options,
treeDataProvider: this
});
this._disposable = Disposable.from(
@ -97,14 +97,19 @@ export abstract class ViewBase implements TreeDataProvid
);
}
getChildren(node?: ViewNode): ViewNode[] | Promise<ViewNode[]> {
if (node !== undefined) return node.getChildren();
protected ensureRoot() {
if (this._root === undefined) {
this._root = this.getRoot();
}
return this._root.getChildren();
return this._root;
}
getChildren(node?: ViewNode): ViewNode[] | Promise<ViewNode[]> {
if (node !== undefined) return node.getChildren();
const root = this.ensureRoot();
return root.getChildren();
}
getParent(node: ViewNode): ViewNode | undefined {
@ -139,10 +144,6 @@ export abstract class ViewBase implements TreeDataProvid
@debug()
async refresh(reason?: RefreshReason) {
if (reason === undefined) {
reason = RefreshReason.Command;
}
if (this._root !== undefined) {
await this._root.refresh(reason);
}
@ -179,6 +180,7 @@ export abstract class ViewBase implements TreeDataProvid
options?: {
select?: boolean;
focus?: boolean;
// expand?: boolean | number;
}
) {
if (this._tree === undefined) return;
@ -192,9 +194,15 @@ export abstract class ViewBase implements TreeDataProvid
}
@log()
show() {
const location = this.location;
return commands.executeCommand(`${this.id}${location ? `:${location}` : ''}.focus`);
async show() {
try {
const location = this.location;
return await commands.executeCommand(`${this.id}${location ? `:${location}` : ''}.focus`);
}
catch (ex) {
Logger.error(ex);
return;
}
}
@debug({

불러오는 중...
취소
저장