本文整理匯總了TypeScript中vscode.workspace.textDocuments.forEach方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript workspace.textDocuments.forEach方法的具體用法?TypeScript workspace.textDocuments.forEach怎麽用?TypeScript workspace.textDocuments.forEach使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vscode.workspace.textDocuments
的用法示例。
在下文中一共展示了workspace.textDocuments.forEach方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: if
workspace.onDidChangeConfiguration(() => {
workspace.textDocuments.forEach(document => {
if (document.uri.scheme === ConstVariable.markdownScheme) {
dfmPreviewProcessor.updateContent(document.uri);
} else if (document.uri.scheme === ConstVariable.tokenTreeScheme) {
tokenTreeProcessor.updateContent(document.uri);
}
});
});
示例2: activate
export function activate(context: ExtensionContext) {
let module = context.asAbsolutePath(path.join('server', 'out', 'server.js'));
let outputChannel: OutputChannel = Window.createOutputChannel('lsp-multi-server-example');
function didOpenTextDocument(document: TextDocument): void {
// We are only interested in language mode text
if (document.languageId !== 'plaintext' || (document.uri.scheme !== 'file' && document.uri.scheme !== 'untitled')) {
return;
}
let uri = document.uri;
// Untitled files go to a default client.
if (uri.scheme === 'untitled' && !defaultClient) {
let debugOptions = { execArgv: ["--nolazy", "--inspect=6010"] };
let serverOptions = {
run: { module, transport: TransportKind.ipc },
debug: { module, transport: TransportKind.ipc, options: debugOptions}
};
let clientOptions: LanguageClientOptions = {
documentSelector: [
{ scheme: 'untitled', language: 'plaintext' }
],
diagnosticCollectionName: 'lsp-multi-server-example',
outputChannel: outputChannel
}
defaultClient = new LanguageClient('lsp-multi-server-example', 'LSP Multi Server Example', serverOptions, clientOptions);
defaultClient.start();
return;
}
let folder = Workspace.getWorkspaceFolder(uri);
// Files outside a folder can't be handled. This might depend on the language.
// Single file languages like JSON might handle files outside the workspace folders.
if (!folder) {
return;
}
// If we have nested workspace folders we only start a server on the outer most workspace folder.
folder = getOuterMostWorkspaceFolder(folder);
if (!clients.has(folder.uri.toString())) {
let debugOptions = { execArgv: ["--nolazy", `--inspect=${6011 + clients.size}`] };
let serverOptions = {
run: { module, transport: TransportKind.ipc },
debug: { module, transport: TransportKind.ipc, options: debugOptions}
};
let clientOptions: LanguageClientOptions = {
documentSelector: [
{ scheme: 'file', language: 'plaintext', pattern: `${folder.uri.fsPath}/**/*` }
],
diagnosticCollectionName: 'lsp-multi-server-example',
workspaceFolder: folder,
outputChannel: outputChannel
}
let client = new LanguageClient('lsp-multi-server-example', 'LSP Multi Server Example', serverOptions, clientOptions);
client.start();
clients.set(folder.uri.toString(), client);
}
}
Workspace.onDidOpenTextDocument(didOpenTextDocument);
Workspace.textDocuments.forEach(didOpenTextDocument);
Workspace.onDidChangeWorkspaceFolders((event) => {
for (let folder of event.removed) {
let client = clients.get(folder.uri.toString());
if (client) {
clients.delete(folder.uri.toString());
client.stop();
}
}
});
}
示例3: checkVariablesInAllTextDocuments
public checkVariablesInAllTextDocuments() {
workspace.textDocuments.forEach(this.checkVariables, this);
}
示例4: _rebuildConfigMap
private _rebuildConfigMap(): void {
this._documentToConfigMap = {};
workspace.textDocuments.forEach(document => this._onDidOpenDocument(document));
}