forked from microsoft/vscode-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworkspaceApis.ts
More file actions
112 lines (91 loc) · 3.84 KB
/
workspaceApis.ts
File metadata and controls
112 lines (91 loc) · 3.84 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import * as vscode from 'vscode';
import { Resource } from '../types';
export function getWorkspaceFolders(): readonly vscode.WorkspaceFolder[] | undefined {
return vscode.workspace.workspaceFolders;
}
export function getWorkspaceFolder(uri: Resource): vscode.WorkspaceFolder | undefined {
return uri ? vscode.workspace.getWorkspaceFolder(uri) : undefined;
}
export function getWorkspaceFolderPaths(): string[] {
return vscode.workspace.workspaceFolders?.map((w) => w.uri.fsPath) ?? [];
}
export function getConfiguration(
section?: string,
scope?: vscode.ConfigurationScope | null,
): vscode.WorkspaceConfiguration {
return vscode.workspace.getConfiguration(section, scope);
}
export function applyEdit(edit: vscode.WorkspaceEdit): Thenable<boolean> {
return vscode.workspace.applyEdit(edit);
}
export function findFiles(
include: vscode.GlobPattern,
exclude?: vscode.GlobPattern | null,
maxResults?: number,
token?: vscode.CancellationToken,
): Thenable<vscode.Uri[]> {
return vscode.workspace.findFiles(include, exclude, maxResults, token);
}
export function onDidCloseTextDocument(handler: (e: vscode.TextDocument) => void): vscode.Disposable {
return vscode.workspace.onDidCloseTextDocument(handler);
}
export function onDidSaveTextDocument(handler: (e: vscode.TextDocument) => void): vscode.Disposable {
return vscode.workspace.onDidSaveTextDocument(handler);
}
export function getOpenTextDocuments(): readonly vscode.TextDocument[] {
return vscode.workspace.textDocuments;
}
export function onDidOpenTextDocument(handler: (doc: vscode.TextDocument) => void): vscode.Disposable {
return vscode.workspace.onDidOpenTextDocument(handler);
}
export function onDidChangeTextDocument(handler: (e: vscode.TextDocumentChangeEvent) => void): vscode.Disposable {
return vscode.workspace.onDidChangeTextDocument(handler);
}
export function onDidChangeConfiguration(handler: (e: vscode.ConfigurationChangeEvent) => void): vscode.Disposable {
return vscode.workspace.onDidChangeConfiguration(handler);
}
export function createFileSystemWatcher(
globPattern: vscode.GlobPattern,
ignoreCreateEvents?: boolean,
ignoreChangeEvents?: boolean,
ignoreDeleteEvents?: boolean,
): vscode.FileSystemWatcher {
return vscode.workspace.createFileSystemWatcher(
globPattern,
ignoreCreateEvents,
ignoreChangeEvents,
ignoreDeleteEvents,
);
}
export function onDidChangeWorkspaceFolders(
handler: (e: vscode.WorkspaceFoldersChangeEvent) => void,
): vscode.Disposable {
return vscode.workspace.onDidChangeWorkspaceFolders(handler);
}
export function isVirtualWorkspace(): boolean {
const isVirtualWorkspace =
vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.every((f) => f.uri.scheme !== 'file');
return !!isVirtualWorkspace;
}
export function isTrusted(): boolean {
return vscode.workspace.isTrusted;
}
export function onDidGrantWorkspaceTrust(handler: () => void): vscode.Disposable {
return vscode.workspace.onDidGrantWorkspaceTrust(handler);
}
export function createDirectory(uri: vscode.Uri): Thenable<void> {
return vscode.workspace.fs.createDirectory(uri);
}
export function openNotebookDocument(uri: vscode.Uri): Thenable<vscode.NotebookDocument>;
export function openNotebookDocument(
notebookType: string,
content?: vscode.NotebookData,
): Thenable<vscode.NotebookDocument>;
export function openNotebookDocument(notebook: any, content?: vscode.NotebookData): Thenable<vscode.NotebookDocument> {
return vscode.workspace.openNotebookDocument(notebook, content);
}
export function copy(source: vscode.Uri, dest: vscode.Uri, options?: { overwrite?: boolean }): Thenable<void> {
return vscode.workspace.fs.copy(source, dest, options);
}