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


TypeScript WorkspaceEdit.renameFile方法代码示例

本文整理汇总了TypeScript中vs/workbench/api/common/extHostTypes.WorkspaceEdit.renameFile方法的典型用法代码示例。如果您正苦于以下问题:TypeScript WorkspaceEdit.renameFile方法的具体用法?TypeScript WorkspaceEdit.renameFile怎么用?TypeScript WorkspaceEdit.renameFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vs/workbench/api/common/extHostTypes.WorkspaceEdit的用法示例。


在下文中一共展示了WorkspaceEdit.renameFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: test

	test('WorkspaceEdit - keep order of text and file changes', function () {

		const edit = new types.WorkspaceEdit();
		edit.replace(URI.parse('foo:a'), new types.Range(1, 1, 1, 1), 'foo');
		edit.renameFile(URI.parse('foo:a'), URI.parse('foo:b'));
		edit.replace(URI.parse('foo:a'), new types.Range(2, 1, 2, 1), 'bar');
		edit.replace(URI.parse('foo:b'), new types.Range(3, 1, 3, 1), 'bazz');

		const all = edit._allEntries();
		assert.equal(all.length, 4);

		function isFileChange(thing: [URI, types.TextEdit[]] | [URI?, URI?, { overwrite?: boolean }?]): thing is [URI?, URI?, { overwrite?: boolean }?] {
			const [f, s] = thing;
			return URI.isUri(f) && URI.isUri(s);
		}

		function isTextChange(thing: [URI, types.TextEdit[]] | [URI?, URI?, { overwrite?: boolean }?]): thing is [URI, types.TextEdit[]] {
			const [f, s] = thing;
			return URI.isUri(f) && Array.isArray(s);
		}

		const [first, second, third, fourth] = all;
		assert.equal(first[0]!.toString(), 'foo:a');
		assert.ok(!isFileChange(first));
		assert.ok(isTextChange(first) && first[1].length === 1);

		assert.equal(second[0]!.toString(), 'foo:a');
		assert.ok(isFileChange(second));

		assert.equal(third[0]!.toString(), 'foo:a');
		assert.ok(isTextChange(third) && third[1].length === 1);

		assert.equal(fourth[0]!.toString(), 'foo:b');
		assert.ok(!isFileChange(fourth));
		assert.ok(isTextChange(fourth) && fourth[1].length === 1);
	});
开发者ID:eamodio,项目名称:vscode,代码行数:36,代码来源:extHostTypes.test.ts


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