-
Notifications
You must be signed in to change notification settings - Fork 149
Expand file tree
/
Copy pathHostTaskNode.ts
More file actions
44 lines (37 loc) · 2.05 KB
/
HostTaskNode.ts
File metadata and controls
44 lines (37 loc) · 2.05 KB
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
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import { resolveAndNormalizeCwd, runningFuncTaskMap } from '../../funcCoreTools/funcHostTask';
import { buildHostTooltip, formatTimestamp, getScopeLabel } from './funcHostDebugUtils';
import { HostErrorNode } from './HostErrorNode';
export class HostTaskNode {
public readonly kind = 'hostTask' as const;
constructor(
public readonly workspaceFolder: vscode.WorkspaceFolder,
public readonly portNumber: string,
public readonly startTime: Date,
public readonly cwd?: string,
) { }
public getTreeItem(): vscode.TreeItem {
const task = runningFuncTaskMap.get(this.workspaceFolder, resolveAndNormalizeCwd(this.workspaceFolder, this.cwd));
const scopeLabel = getScopeLabel(this.workspaceFolder);
const label = `${scopeLabel} (${this.portNumber})`;
const tooltip = buildHostTooltip({ label, scopeLabel, portNumber: this.portNumber, startTime: this.startTime, cwd: this.cwd, pid: task?.processId });
const item = new vscode.TreeItem(label, vscode.TreeItemCollapsibleState.Expanded);
item.description = formatTimestamp(this.startTime);
item.tooltip = tooltip;
item.contextValue = 'azFunc.funcHostDebug.hostTask';
item.iconPath = new vscode.ThemeIcon('server-process');
return item;
}
public getChildren(): HostErrorNode[] {
const task = runningFuncTaskMap.get(this.workspaceFolder, resolveAndNormalizeCwd(this.workspaceFolder, this.cwd));
const errors = task?.errorLogs ?? [];
return errors
.slice()
.reverse()
.map((message) => new HostErrorNode(this.workspaceFolder, this.portNumber, message, this.cwd));
}
}