当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript workspace.textDocuments.forEach方法代码示例

本文整理汇总了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);
         }
     });
 });
开发者ID:928PJY,项目名称:docfx,代码行数:9,代码来源:extension.ts

示例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();
			}
		}
	});
}
开发者ID:voodoos,项目名称:vscode-extension-samples,代码行数:71,代码来源:extension.ts

示例3: checkVariablesInAllTextDocuments

 public checkVariablesInAllTextDocuments() {
     workspace.textDocuments.forEach(this.checkVariables, this);
 }
开发者ID:Huachao,项目名称:vscode-restclient,代码行数:3,代码来源:variableDiagnosticsProvider.ts

示例4: _rebuildConfigMap

 private _rebuildConfigMap(): void {
     this._documentToConfigMap = {};
     workspace.textDocuments.forEach(document => this._onDidOpenDocument(document));
 }
开发者ID:asgardsinc,项目名称:vscode-editorconfig,代码行数:4,代码来源:editorConfigMain.ts


注:本文中的vscode.workspace.textDocuments.forEach方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。