本文整理汇总了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));
}