-
-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathdub-view.ts
51 lines (48 loc) · 1.68 KB
/
dub-view.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import * as vscode from "vscode"
import * as path from "path"
import { extensionContext } from "./extension";
export interface DubDependencyInfo {
name: string;
failed?: boolean;
version: string;
path: string;
description: string;
homepage: string;
authors: string[];
copyright: string;
license: string;
subPackages: string[];
hasDependencies: boolean;
root: boolean;
}
export class DubDependency extends vscode.TreeItem {
constructor(info: DubDependencyInfo, command?: vscode.Command, icon?: string);
constructor(info: string, command?: vscode.Command, icon?: string);
constructor(info: DubDependencyInfo | string, command?: vscode.Command, icon?: string) {
super(typeof info == "string" ? info : info.name + ": " + info.version + (info.failed ? " (failed loading)" : ""),
typeof info == "string" ? vscode.TreeItemCollapsibleState.None : vscode.TreeItemCollapsibleState.Collapsed);
if (typeof info == "object") {
this.info = info;
this.iconPath = {
light: vscode.Uri.joinPath(extensionContext.extensionUri, "images", "dependency-light.svg"),
dark: vscode.Uri.joinPath(extensionContext.extensionUri, "images", "dependency-dark.svg")
};
this.command = {
command: "code-d.viewDubPackage",
title: "Open README",
tooltip: "Open README",
arguments: [info.path, info.name]
};
this.contextValue = info.root ? "root" : "dependency";
}
if (command)
this.command = command;
if (icon)
this.iconPath = {
light: vscode.Uri.joinPath(extensionContext.extensionUri, "images", icon + "-light.svg"),
dark: vscode.Uri.joinPath(extensionContext.extensionUri, "images", icon + "-dark.svg")
};
}
info?: DubDependencyInfo;
command?: vscode.Command;
}