diff --git a/src/views/nodes/UncommittedFilesNode.ts b/src/views/nodes/UncommittedFilesNode.ts index 072d750..59a8810 100644 --- a/src/views/nodes/UncommittedFilesNode.ts +++ b/src/views/nodes/UncommittedFilesNode.ts @@ -10,15 +10,14 @@ import type { GitStatus, GitStatusFile } from '../../git/models/status'; import { groupBy, makeHierarchical } from '../../system/array'; import { flatMap } from '../../system/iterable'; import { joinPaths, normalizePath } from '../../system/path'; -import type { RepositoriesView } from '../repositoriesView'; -import type { WorktreesView } from '../worktreesView'; +import type { ViewsWithWorkingTree } from '../viewBase'; import type { FileNode } from './folderNode'; import { FolderNode } from './folderNode'; import { RepositoryNode } from './repositoryNode'; import { UncommittedFileNode } from './UncommittedFileNode'; import { ContextValues, ViewNode } from './viewNode'; -export class UncommittedFilesNode extends ViewNode { +export class UncommittedFilesNode extends ViewNode { static key = ':uncommitted-files'; static getId(repoPath: string): string { return `${RepositoryNode.getId(repoPath)}${this.key}`; @@ -27,8 +26,8 @@ export class UncommittedFilesNode extends ViewNode | undefined; }; -export class BranchNode - extends ViewRefNode - implements PageableViewNode -{ +export class BranchNode extends ViewRefNode implements PageableViewNode { static key = ':branch'; static getId(repoPath: string, name: string, root: boolean): string { return `${RepositoryNode.getId(repoPath)}${this.key}(${name})${root ? ':root' : ''}`; @@ -62,8 +57,8 @@ export class BranchNode constructor( uri: GitUri, - view: BranchesView | CommitsView | RemotesView | RepositoriesView, - parent: ViewNode, + view: ViewsWithBranches, + public override parent: ViewNode, public readonly branch: GitBranch, // Specifies that the node is shown as a root public readonly root: boolean, diff --git a/src/views/nodes/branchOrTagFolderNode.ts b/src/views/nodes/branchOrTagFolderNode.ts index 5360379..467481b 100644 --- a/src/views/nodes/branchOrTagFolderNode.ts +++ b/src/views/nodes/branchOrTagFolderNode.ts @@ -16,7 +16,7 @@ export class BranchOrTagFolderNode extends ViewNode { constructor( view: View, - parent: ViewNode, + protected override readonly parent: ViewNode, public readonly type: 'branch' | 'remote-branch' | 'tag', public readonly repoPath: string, public readonly folderName: string, @@ -48,7 +48,7 @@ export class BranchOrTagFolderNode extends ViewNode { children.push( new BranchOrTagFolderNode( this.view, - this.folderName ? this : this.parent!, + this.folderName ? this : this.parent, this.type, this.repoPath, folder.name, @@ -62,7 +62,7 @@ export class BranchOrTagFolderNode extends ViewNode { } // Make sure to set the parent - (folder.value as any).parent = this.folderName ? this : this.parent!; + folder.value.parent = this.folderName ? this : this.parent; children.push(folder.value); } diff --git a/src/views/nodes/branchTrackingStatusFilesNode.ts b/src/views/nodes/branchTrackingStatusFilesNode.ts index 816582e..4ebf368 100644 --- a/src/views/nodes/branchTrackingStatusFilesNode.ts +++ b/src/views/nodes/branchTrackingStatusFilesNode.ts @@ -26,7 +26,7 @@ export class BranchTrackingStatusFilesNode extends ViewNode { constructor( view: ViewsWithCommits, - parent: ViewNode, + protected override readonly parent: ViewNode, public readonly branch: GitBranch, public readonly status: Required, public readonly direction: 'ahead' | 'behind', diff --git a/src/views/nodes/branchTrackingStatusNode.ts b/src/views/nodes/branchTrackingStatusNode.ts index 7a4ab05..5a6cb3d 100644 --- a/src/views/nodes/branchTrackingStatusNode.ts +++ b/src/views/nodes/branchTrackingStatusNode.ts @@ -45,7 +45,7 @@ export class BranchTrackingStatusNode extends ViewNode impleme constructor( view: ViewsWithCommits, - parent: ViewNode, + protected override readonly parent: ViewNode, public readonly branch: GitBranch, public readonly status: BranchTrackingStatus, public readonly upstreamType: 'ahead' | 'behind' | 'same' | 'none', diff --git a/src/views/nodes/branchesNode.ts b/src/views/nodes/branchesNode.ts index fd16073..49e2ec4 100644 --- a/src/views/nodes/branchesNode.ts +++ b/src/views/nodes/branchesNode.ts @@ -5,15 +5,15 @@ import type { Repository } from '../../git/models/repository'; import { makeHierarchical } from '../../system/array'; import { gate } from '../../system/decorators/gate'; import { debug } from '../../system/decorators/log'; -import type { BranchesView } from '../branchesView'; import { RepositoriesView } from '../repositoriesView'; +import type { ViewsWithBranchesNode } from '../viewBase'; import { BranchNode } from './branchNode'; import { BranchOrTagFolderNode } from './branchOrTagFolderNode'; import { MessageNode } from './common'; import { RepositoryNode } from './repositoryNode'; import { ContextValues, ViewNode } from './viewNode'; -export class BranchesNode extends ViewNode { +export class BranchesNode extends ViewNode { static key = ':branches'; static getId(repoPath: string): string { return `${RepositoryNode.getId(repoPath)}${this.key}`; @@ -23,8 +23,8 @@ export class BranchesNode extends ViewNode { constructor( uri: GitUri, - view: BranchesView | RepositoriesView, - parent: ViewNode, + view: ViewsWithBranchesNode, + protected override readonly parent: ViewNode, public readonly repo: Repository, ) { super(uri, view, parent); diff --git a/src/views/nodes/commitFileNode.ts b/src/views/nodes/commitFileNode.ts index 7de3b18..f07c8c4 100644 --- a/src/views/nodes/commitFileNode.ts +++ b/src/views/nodes/commitFileNode.ts @@ -10,13 +10,12 @@ import type { GitFile } from '../../git/models/file'; import { getGitFileStatusIcon } from '../../git/models/file'; import type { GitRevisionReference } from '../../git/models/reference'; import { joinPaths, relativeDir } from '../../system/path'; -import type { StashesView } from '../stashesView'; -import type { ViewsWithCommits } from '../viewBase'; +import type { ViewsWithCommits, ViewsWithStashes } from '../viewBase'; import type { ViewNode } from './viewNode'; import { ContextValues, ViewRefFileNode } from './viewNode'; export class CommitFileNode< - TView extends ViewsWithCommits | StashesView = ViewsWithCommits | StashesView, + TView extends ViewsWithCommits | ViewsWithStashes = ViewsWithCommits, > extends ViewRefFileNode { static key = ':file'; static getId(parent: ViewNode, path: string): string { diff --git a/src/views/nodes/commitNode.ts b/src/views/nodes/commitNode.ts index 3ebe4c7..005c816 100644 --- a/src/views/nodes/commitNode.ts +++ b/src/views/nodes/commitNode.ts @@ -42,7 +42,7 @@ export class CommitNode extends ViewRefNode { +export class CompareBranchNode extends ViewNode { static key = ':compare-branch'; static getId(repoPath: string, name: string, root: boolean): string { return `${RepositoryNode.getId(repoPath)}${this.key}(${name})${root ? ':root' : ''}`; @@ -33,8 +31,8 @@ export class CompareBranchNode extends ViewNode { constructor( view: SearchAndCompareView, - parent: ViewNode, + protected override readonly parent: ViewNode, public readonly repoPath: string, private _ref: StoredNamedRef, private _compareWith: StoredNamedRef, diff --git a/src/views/nodes/contributorNode.ts b/src/views/nodes/contributorNode.ts index 163d8a0..73797a7 100644 --- a/src/views/nodes/contributorNode.ts +++ b/src/views/nodes/contributorNode.ts @@ -10,8 +10,7 @@ import { debug } from '../../system/decorators/log'; import { map } from '../../system/iterable'; import { pluralize } from '../../system/string'; import type { ContactPresence } from '../../vsls/vsls'; -import type { ContributorsView } from '../contributorsView'; -import type { RepositoriesView } from '../repositoriesView'; +import type { ViewsWithContributors } from '../viewBase'; import { CommitNode } from './commitNode'; import { LoadMoreNode, MessageNode } from './common'; import { insertDateMarkers } from './helpers'; @@ -19,7 +18,7 @@ import { RepositoryNode } from './repositoryNode'; import type { PageableViewNode } from './viewNode'; import { ContextValues, ViewNode } from './viewNode'; -export class ContributorNode extends ViewNode implements PageableViewNode { +export class ContributorNode extends ViewNode implements PageableViewNode { static key = ':contributor'; static getId( repoPath: string, @@ -32,8 +31,8 @@ export class ContributorNode extends ViewNode { +export class ContributorsNode extends ViewNode { static key = ':contributors'; static getId(repoPath: string): string { return `${RepositoryNode.getId(repoPath)}${this.key}`; @@ -25,8 +24,8 @@ export class ContributorsNode extends ViewNode impl constructor( uri: GitUri, view: FileHistoryView, - parent: ViewNode, + protected override readonly parent: ViewNode, private readonly folder: boolean, private readonly branch: GitBranch | undefined, ) { diff --git a/src/views/nodes/lineHistoryNode.ts b/src/views/nodes/lineHistoryNode.ts index 32fd034..d19224a 100644 --- a/src/views/nodes/lineHistoryNode.ts +++ b/src/views/nodes/lineHistoryNode.ts @@ -39,7 +39,7 @@ export class LineHistoryNode constructor( uri: GitUri, view: FileHistoryView | LineHistoryView, - parent: ViewNode, + protected override readonly parent: ViewNode, private readonly branch: GitBranch | undefined, public readonly selection: Selection, private readonly editorContents: string | undefined, diff --git a/src/views/nodes/mergeConflictCurrentChangesNode.ts b/src/views/nodes/mergeConflictCurrentChangesNode.ts index 61b41b9..1fa5db2 100644 --- a/src/views/nodes/mergeConflictCurrentChangesNode.ts +++ b/src/views/nodes/mergeConflictCurrentChangesNode.ts @@ -18,7 +18,7 @@ import { ContextValues, ViewNode } from './viewNode'; export class MergeConflictCurrentChangesNode extends ViewNode { constructor( view: ViewsWithCommits | FileHistoryView | LineHistoryView, - parent: ViewNode, + protected override readonly parent: ViewNode, private readonly status: GitMergeStatus | GitRebaseStatus, private readonly file: GitFile, ) { diff --git a/src/views/nodes/mergeConflictIncomingChangesNode.ts b/src/views/nodes/mergeConflictIncomingChangesNode.ts index 9df2910..78aebb0 100644 --- a/src/views/nodes/mergeConflictIncomingChangesNode.ts +++ b/src/views/nodes/mergeConflictIncomingChangesNode.ts @@ -18,7 +18,7 @@ import { ContextValues, ViewNode } from './viewNode'; export class MergeConflictIncomingChangesNode extends ViewNode { constructor( view: ViewsWithCommits | FileHistoryView | LineHistoryView, - parent: ViewNode, + protected override readonly parent: ViewNode, private readonly status: GitMergeStatus | GitRebaseStatus, private readonly file: GitFile, ) { diff --git a/src/views/nodes/mergeStatusNode.ts b/src/views/nodes/mergeStatusNode.ts index 289a347..e475a18 100644 --- a/src/views/nodes/mergeStatusNode.ts +++ b/src/views/nodes/mergeStatusNode.ts @@ -24,7 +24,7 @@ export class MergeStatusNode extends ViewNode { constructor( view: ViewsWithCommits, - parent: ViewNode, + protected override readonly parent: ViewNode, public readonly branch: GitBranch, public readonly mergeStatus: GitMergeStatus, public readonly status: GitStatus | undefined, diff --git a/src/views/nodes/rebaseStatusNode.ts b/src/views/nodes/rebaseStatusNode.ts index c8c4fa8..2d28bf2 100644 --- a/src/views/nodes/rebaseStatusNode.ts +++ b/src/views/nodes/rebaseStatusNode.ts @@ -34,7 +34,7 @@ export class RebaseStatusNode extends ViewNode { constructor( view: ViewsWithCommits, - parent: ViewNode, + protected override readonly parent: ViewNode, public readonly branch: GitBranch, public readonly rebaseStatus: GitRebaseStatus, public readonly status: GitStatus | undefined, diff --git a/src/views/nodes/remoteNode.ts b/src/views/nodes/remoteNode.ts index 2c84dc5..428acdc 100644 --- a/src/views/nodes/remoteNode.ts +++ b/src/views/nodes/remoteNode.ts @@ -7,15 +7,14 @@ import { getRemoteUpstreamDescription } from '../../git/models/remote'; import type { Repository } from '../../git/models/repository'; import { makeHierarchical } from '../../system/array'; import { log } from '../../system/decorators/log'; -import type { RemotesView } from '../remotesView'; -import type { RepositoriesView } from '../repositoriesView'; +import type { ViewsWithRemotes } from '../viewBase'; import { BranchNode } from './branchNode'; import { BranchOrTagFolderNode } from './branchOrTagFolderNode'; import { MessageNode } from './common'; import { RepositoryNode } from './repositoryNode'; import { ContextValues, ViewNode } from './viewNode'; -export class RemoteNode extends ViewNode { +export class RemoteNode extends ViewNode { static key = ':remote'; static getId(repoPath: string, name: string, id: string): string { return `${RepositoryNode.getId(repoPath)}${this.key}(${name}|${id})`; @@ -23,8 +22,8 @@ export class RemoteNode extends ViewNode { constructor( uri: GitUri, - view: RemotesView | RepositoriesView, - parent: ViewNode, + view: ViewsWithRemotes, + protected override readonly parent: ViewNode, public readonly remote: GitRemote, public readonly repo: Repository, ) { diff --git a/src/views/nodes/remotesNode.ts b/src/views/nodes/remotesNode.ts index ad39c3a..481bd1e 100644 --- a/src/views/nodes/remotesNode.ts +++ b/src/views/nodes/remotesNode.ts @@ -3,14 +3,13 @@ import type { GitUri } from '../../git/gitUri'; import type { Repository } from '../../git/models/repository'; import { gate } from '../../system/decorators/gate'; import { debug } from '../../system/decorators/log'; -import type { RemotesView } from '../remotesView'; -import type { RepositoriesView } from '../repositoriesView'; +import type { ViewsWithRemotesNode } from '../viewBase'; import { MessageNode } from './common'; import { RemoteNode } from './remoteNode'; import { RepositoryNode } from './repositoryNode'; import { ContextValues, ViewNode } from './viewNode'; -export class RemotesNode extends ViewNode { +export class RemotesNode extends ViewNode { static key = ':remotes'; static getId(repoPath: string): string { return `${RepositoryNode.getId(repoPath)}${this.key}`; @@ -18,7 +17,7 @@ export class RemotesNode extends ViewNode { private _children: ViewNode[] | undefined; - constructor(uri: GitUri, view: RemotesView | RepositoriesView, parent: ViewNode, public readonly repo: Repository) { + constructor(uri: GitUri, view: ViewsWithRemotesNode, parent: ViewNode, public readonly repo: Repository) { super(uri, view, parent); } diff --git a/src/views/nodes/repositoriesNode.ts b/src/views/nodes/repositoriesNode.ts index ed8524e..edd8be4 100644 --- a/src/views/nodes/repositoriesNode.ts +++ b/src/views/nodes/repositoriesNode.ts @@ -6,16 +6,16 @@ import { gate } from '../../system/decorators/gate'; import { debug } from '../../system/decorators/log'; import { debounce, szudzikPairing } from '../../system/function'; import { Logger } from '../../system/logger'; -import type { RepositoriesView } from '../repositoriesView'; +import type { ViewsWithRepositoriesNode } from '../viewBase'; import { MessageNode } from './common'; import { RepositoryNode } from './repositoryNode'; import type { ViewNode } from './viewNode'; import { ContextValues, SubscribeableViewNode } from './viewNode'; -export class RepositoriesNode extends SubscribeableViewNode { +export class RepositoriesNode extends SubscribeableViewNode { private _children: (RepositoryNode | MessageNode)[] | undefined; - constructor(view: RepositoriesView) { + constructor(view: ViewsWithRepositoriesNode) { super(unknownGitUri, view); } diff --git a/src/views/nodes/repositoryNode.ts b/src/views/nodes/repositoryNode.ts index 11ad062..9773765 100644 --- a/src/views/nodes/repositoryNode.ts +++ b/src/views/nodes/repositoryNode.ts @@ -12,7 +12,7 @@ import { gate } from '../../system/decorators/gate'; import { debug, log } from '../../system/decorators/log'; import { disposableInterval } from '../../system/function'; import { pad } from '../../system/string'; -import type { RepositoriesView } from '../repositoriesView'; +import type { ViewsWithRepositories } from '../viewBase'; import { BranchesNode } from './branchesNode'; import { BranchNode } from './branchNode'; import { BranchTrackingStatusNode } from './branchTrackingStatusNode'; @@ -30,7 +30,7 @@ import type { ViewNode } from './viewNode'; import { ContextValues, SubscribeableViewNode } from './viewNode'; import { WorktreesNode } from './worktreesNode'; -export class RepositoryNode extends SubscribeableViewNode { +export class RepositoryNode extends SubscribeableViewNode { static key = ':repository'; static getId(repoPath: string): string { return `gitlens${this.key}(${repoPath})`; @@ -39,7 +39,7 @@ export class RepositoryNode extends SubscribeableViewNode { private _children: ViewNode[] | undefined; private _status: Promise; - constructor(uri: GitUri, view: RepositoriesView, parent: ViewNode, public readonly repo: Repository) { + constructor(uri: GitUri, view: ViewsWithRepositories, parent: ViewNode, public readonly repo: Repository) { super(uri, view, parent); this._status = this.repo.getStatus(); diff --git a/src/views/nodes/searchResultsNode.ts b/src/views/nodes/searchResultsNode.ts index 4ad00f1..aed25dc 100644 --- a/src/views/nodes/searchResultsNode.ts +++ b/src/views/nodes/searchResultsNode.ts @@ -40,7 +40,7 @@ export class SearchResultsNode extends ViewNode implements private _instanceId: number; constructor( view: SearchAndCompareView, - parent: ViewNode, + protected override readonly parent: ViewNode, public readonly repoPath: string, search: SearchQuery, private _labels: { diff --git a/src/views/nodes/stashFileNode.ts b/src/views/nodes/stashFileNode.ts index 7ca36fe..dd2a9c2 100644 --- a/src/views/nodes/stashFileNode.ts +++ b/src/views/nodes/stashFileNode.ts @@ -1,14 +1,13 @@ import type { GitStashCommit } from '../../git/models/commit'; import type { GitFile } from '../../git/models/file'; -import type { StashesView } from '../stashesView'; -import type { ViewsWithCommits } from '../viewBase'; +import type { ViewsWithStashes } from '../viewBase'; import { CommitFileNode } from './commitFileNode'; import type { ViewNode } from './viewNode'; import { ContextValues } from './viewNode'; -export class StashFileNode extends CommitFileNode { +export class StashFileNode extends CommitFileNode { // eslint-disable-next-line @typescript-eslint/no-useless-constructor - constructor(view: ViewsWithCommits | StashesView, parent: ViewNode, file: GitFile, commit: GitStashCommit) { + constructor(view: ViewsWithStashes, parent: ViewNode, file: GitFile, commit: GitStashCommit) { super(view, parent, file, commit); } diff --git a/src/views/nodes/stashNode.ts b/src/views/nodes/stashNode.ts index 8121a39..51a78a7 100644 --- a/src/views/nodes/stashNode.ts +++ b/src/views/nodes/stashNode.ts @@ -7,9 +7,7 @@ import { makeHierarchical } from '../../system/array'; import { configuration } from '../../system/configuration'; import { joinPaths, normalizePath } from '../../system/path'; import { sortCompare } from '../../system/string'; -import type { RepositoriesView } from '../repositoriesView'; -import type { StashesView } from '../stashesView'; -import type { ViewsWithCommits } from '../viewBase'; +import type { ViewsWithStashes } from '../viewBase'; import type { FileNode } from './folderNode'; import { FolderNode } from './folderNode'; import { RepositoryNode } from './repositoryNode'; @@ -17,14 +15,14 @@ import { StashFileNode } from './stashFileNode'; import type { ViewNode } from './viewNode'; import { ContextValues, ViewRefNode } from './viewNode'; -export class StashNode extends ViewRefNode { +export class StashNode extends ViewRefNode { static key = ':stash'; static getId(repoPath: string, ref: string): string { return `${RepositoryNode.getId(repoPath)}${this.key}(${ref})`; } constructor( - view: ViewsWithCommits | StashesView | RepositoriesView, + view: ViewsWithStashes, parent: ViewNode, public readonly commit: GitStashCommit, private readonly options?: { icon?: boolean }, diff --git a/src/views/nodes/stashesNode.ts b/src/views/nodes/stashesNode.ts index 2c40ae1..de41191 100644 --- a/src/views/nodes/stashesNode.ts +++ b/src/views/nodes/stashesNode.ts @@ -4,14 +4,13 @@ import type { Repository } from '../../git/models/repository'; import { gate } from '../../system/decorators/gate'; import { debug } from '../../system/decorators/log'; import { map } from '../../system/iterable'; -import type { RepositoriesView } from '../repositoriesView'; -import type { StashesView } from '../stashesView'; +import type { ViewsWithStashesNode } from '../viewBase'; import { MessageNode } from './common'; import { RepositoryNode } from './repositoryNode'; import { StashNode } from './stashNode'; import { ContextValues, ViewNode } from './viewNode'; -export class StashesNode extends ViewNode { +export class StashesNode extends ViewNode { static key = ':stashes'; static getId(repoPath: string): string { return `${RepositoryNode.getId(repoPath)}${this.key}`; @@ -19,7 +18,7 @@ export class StashesNode extends ViewNode { private _children: ViewNode[] | undefined; - constructor(uri: GitUri, view: StashesView | RepositoriesView, parent: ViewNode, public readonly repo: Repository) { + constructor(uri: GitUri, view: ViewsWithStashesNode, parent: ViewNode, public readonly repo: Repository) { super(uri, view, parent); } diff --git a/src/views/nodes/statusFilesNode.ts b/src/views/nodes/statusFilesNode.ts index 81487d2..80ec55a 100644 --- a/src/views/nodes/statusFilesNode.ts +++ b/src/views/nodes/statusFilesNode.ts @@ -10,7 +10,7 @@ import { groupBy, makeHierarchical } from '../../system/array'; import { filter, flatMap, map } from '../../system/iterable'; import { joinPaths, normalizePath } from '../../system/path'; import { pluralize, sortCompare } from '../../system/string'; -import type { RepositoriesView } from '../repositoriesView'; +import type { ViewsWithWorkingTree } from '../viewBase'; import { WorktreesView } from '../worktreesView'; import type { FileNode } from './folderNode'; import { FolderNode } from './folderNode'; @@ -18,7 +18,7 @@ import { RepositoryNode } from './repositoryNode'; import { StatusFileNode } from './statusFileNode'; import { ContextValues, ViewNode } from './viewNode'; -export class StatusFilesNode extends ViewNode { +export class StatusFilesNode extends ViewNode { static key = ':status-files'; static getId(repoPath: string): string { return `${RepositoryNode.getId(repoPath)}${this.key}`; @@ -27,8 +27,8 @@ export class StatusFilesNode extends ViewNode readonly repoPath: string; constructor( - view: RepositoriesView | WorktreesView, - parent: ViewNode, + view: ViewsWithWorkingTree, + protected override readonly parent: ViewNode, public readonly status: | GitStatus | { diff --git a/src/views/nodes/tagNode.ts b/src/views/nodes/tagNode.ts index cf764a3..40cc4c3 100644 --- a/src/views/nodes/tagNode.ts +++ b/src/views/nodes/tagNode.ts @@ -11,8 +11,7 @@ import { gate } from '../../system/decorators/gate'; import { debug } from '../../system/decorators/log'; import { map } from '../../system/iterable'; import { pad } from '../../system/string'; -import type { RepositoriesView } from '../repositoriesView'; -import type { TagsView } from '../tagsView'; +import type { ViewsWithTags } from '../viewBase'; import { CommitNode } from './commitNode'; import { LoadMoreNode, MessageNode } from './common'; import { insertDateMarkers } from './helpers'; @@ -20,13 +19,13 @@ import { RepositoryNode } from './repositoryNode'; import type { PageableViewNode, ViewNode } from './viewNode'; import { ContextValues, ViewRefNode } from './viewNode'; -export class TagNode extends ViewRefNode implements PageableViewNode { +export class TagNode extends ViewRefNode implements PageableViewNode { static key = ':tag'; static getId(repoPath: string, name: string): string { return `${RepositoryNode.getId(repoPath)}${this.key}(${name})`; } - constructor(uri: GitUri, view: TagsView | RepositoriesView, parent: ViewNode, public readonly tag: GitTag) { + constructor(uri: GitUri, view: ViewsWithTags, public override parent: ViewNode, public readonly tag: GitTag) { super(uri, view, parent); } diff --git a/src/views/nodes/tagsNode.ts b/src/views/nodes/tagsNode.ts index c640e41..c92f96e 100644 --- a/src/views/nodes/tagsNode.ts +++ b/src/views/nodes/tagsNode.ts @@ -5,15 +5,14 @@ import type { Repository } from '../../git/models/repository'; import { makeHierarchical } from '../../system/array'; import { gate } from '../../system/decorators/gate'; import { debug } from '../../system/decorators/log'; -import type { RepositoriesView } from '../repositoriesView'; -import type { TagsView } from '../tagsView'; +import type { ViewsWithTagsNode } from '../viewBase'; import { BranchOrTagFolderNode } from './branchOrTagFolderNode'; import { MessageNode } from './common'; import { RepositoryNode } from './repositoryNode'; import { TagNode } from './tagNode'; import { ContextValues, ViewNode } from './viewNode'; -export class TagsNode extends ViewNode { +export class TagsNode extends ViewNode { static key = ':tags'; static getId(repoPath: string): string { return `${RepositoryNode.getId(repoPath)}${this.key}`; @@ -21,7 +20,12 @@ export class TagsNode extends ViewNode { private _children: ViewNode[] | undefined; - constructor(uri: GitUri, view: TagsView | RepositoriesView, parent: ViewNode, public readonly repo: Repository) { + constructor( + uri: GitUri, + view: ViewsWithTagsNode, + protected override readonly parent: ViewNode, + public readonly repo: Repository, + ) { super(uri, view, parent); } diff --git a/src/views/nodes/viewNode.ts b/src/views/nodes/viewNode.ts index 6e5588e..45279df 100644 --- a/src/views/nodes/viewNode.ts +++ b/src/views/nodes/viewNode.ts @@ -194,6 +194,10 @@ export abstract class ViewRefNode< TReference extends GitReference = GitReference, State extends object = any, > extends ViewNode { + constructor(uri: GitUri, view: TView, protected override readonly parent: ViewNode) { + super(uri, view, parent); + } + abstract get ref(): TReference; get repoPath(): string { @@ -397,7 +401,7 @@ export abstract class RepositoryFolderNode< constructor( uri: GitUri, view: TView, - parent: ViewNode, + protected override readonly parent: ViewNode, public readonly repo: Repository, splatted: boolean, private readonly options?: { showBranchAndLastFetched?: boolean }, diff --git a/src/views/nodes/worktreeNode.ts b/src/views/nodes/worktreeNode.ts index 22699df..819cd75 100644 --- a/src/views/nodes/worktreeNode.ts +++ b/src/views/nodes/worktreeNode.ts @@ -15,8 +15,7 @@ import { map } from '../../system/iterable'; import type { Deferred } from '../../system/promise'; import { defer, getSettledValue } from '../../system/promise'; import { pad } from '../../system/string'; -import type { RepositoriesView } from '../repositoriesView'; -import type { WorktreesView } from '../worktreesView'; +import type { ViewsWithWorktrees } from '../viewBase'; import { CommitNode } from './commitNode'; import { LoadMoreNode, MessageNode } from './common'; import { CompareBranchNode } from './compareBranchNode'; @@ -31,7 +30,7 @@ type State = { pendingPullRequest: Promise | undefined; }; -export class WorktreeNode extends ViewNode { +export class WorktreeNode extends ViewNode { static key = ':worktree'; static getId(repoPath: string, uri: Uri): string { return `${RepositoryNode.getId(repoPath)}${this.key}(${uri.path})`; @@ -41,8 +40,8 @@ export class WorktreeNode extends ViewNode { +export class WorktreesNode extends ViewNode { static key = ':worktrees'; static getId(repoPath: string): string { return `${RepositoryNode.getId(repoPath)}${this.key}`; @@ -22,8 +21,8 @@ export class WorktreesNode extends ViewNode { constructor( uri: GitUri, - view: WorktreesView | RepositoriesView, - parent: ViewNode, + view: ViewsWithWorktreesNode, + protected override readonly parent: ViewNode, public readonly repo: Repository, ) { super(uri, view, parent); diff --git a/src/views/viewBase.ts b/src/views/viewBase.ts index a793085..454764d 100644 --- a/src/views/viewBase.ts +++ b/src/views/viewBase.ts @@ -63,8 +63,24 @@ export type View = | StashesView | TagsView | WorktreesView; + +export type ViewsWithBranches = BranchesView | CommitsView | RemotesView | RepositoriesView; +export type ViewsWithBranchesNode = BranchesView | RepositoriesView; export type ViewsWithCommits = Exclude; -export type ViewsWithRepositoryFolders = Exclude; +export type ViewsWithContributors = ContributorsView | RepositoriesView; +export type ViewsWithContributorsNode = ContributorsView | RepositoriesView; +export type ViewsWithRemotes = RemotesView | RepositoriesView; +export type ViewsWithRemotesNode = RemotesView | RepositoriesView; +export type ViewsWithRepositories = RepositoriesView; +export type ViewsWithRepositoriesNode = RepositoriesView; +export type ViewsWithRepositoryFolders = Exclude; +export type ViewsWithStashes = StashesView | ViewsWithCommits; +export type ViewsWithStashesNode = RepositoriesView | StashesView; +export type ViewsWithTags = RepositoriesView | TagsView; +export type ViewsWithTagsNode = RepositoriesView | TagsView; +export type ViewsWithWorkingTree = RepositoriesView | WorktreesView; +export type ViewsWithWorktrees = RepositoriesView | WorktreesView; +export type ViewsWithWorktreesNode = RepositoriesView | WorktreesView; export interface TreeViewNodeCollapsibleStateChangeEvent extends TreeViewExpansionEvent { state: TreeItemCollapsibleState;