當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript extHostTypes.WorkspaceEdit類代碼示例

本文整理匯總了TypeScript中vs/workbench/api/node/extHostTypes.WorkspaceEdit的典型用法代碼示例。如果您正苦於以下問題:TypeScript WorkspaceEdit類的具體用法?TypeScript WorkspaceEdit怎麽用?TypeScript WorkspaceEdit使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了WorkspaceEdit類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: test

	test('does not use version id if document is not available', () => {
		let edit = new extHostTypes.WorkspaceEdit();
		edit.replace(URI.parse('foo:bar2'), new extHostTypes.Range(0, 0, 0, 0), 'hello');
		return editors.applyWorkspaceEdit(edit).then((result) => {
			assert.equal(workspaceResourceEdits.length, 1);
			assert.ok(typeof workspaceResourceEdits[0].modelVersionId === 'undefined');
		});
	});
開發者ID:SeanKilleen,項目名稱:vscode,代碼行數:8,代碼來源:extHostTextEditors.test.ts

示例2: test

	test('WorkspaceEdit - two edits for one resource', function () {
		let edit = new types.WorkspaceEdit();
		let uri = URI.parse('foo:bar');
		edit.insert(uri, new types.Position(0, 0), 'Hello');
		edit.insert(uri, new types.Position(0, 0), 'Foo');

		assert.equal(edit._allEntries().length, 2);
		let [first, second] = edit._allEntries();
		assert.equal((first as [URI, types.TextEdit[]])[1][0].newText, 'Hello');
		assert.equal((second as [URI, types.TextEdit[]])[1][0].newText, 'Foo');
	});
開發者ID:liunian,項目名稱:vscode,代碼行數:11,代碼來源:extHostTypes.test.ts

示例3: 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.renameResource(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, 3);

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

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

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

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

		assert.equal(third[0].toString(), 'foo:b');
		assert.ok(!isFileChange(third));
		assert.ok(isTextChange(third) && third[1].length === 1);
	});
開發者ID:JarnoNijboer,項目名稱:vscode,代碼行數:33,代碼來源:extHostTypes.test.ts

示例4: test

	test('WorkspaceEdit', function() {

		let a = types.Uri.file('a.ts');
		let b = types.Uri.file('b.ts');

		let edit = new types.WorkspaceEdit();
		assert.ok(!edit.has(a));

		edit.set(a, [types.TextEdit.insert(new types.Position(0, 0), 'fff')]);
		assert.ok(edit.has(a));
		assert.equal(edit.size, 1);
		assertToJSON(edit, [[URI.parse('file:///a.ts').toJSON(), [{ range: [{ line: 0, character: 0 }, { line: 0, character: 0 }], newText: 'fff' }]]]);

		edit.insert(b, new types.Position(1, 1), 'fff');
		edit.delete(b, new types.Range(0, 0, 0, 0));
		assert.ok(edit.has(b));
		assert.equal(edit.size, 2);
		assertToJSON(edit, [
			[URI.parse('file:///a.ts').toJSON(), [{ range: [{ line: 0, character: 0 }, { line: 0, character: 0 }], newText: 'fff' }]],
			[URI.parse('file:///b.ts').toJSON(), [{ range: [{ line: 1, character: 1 }, { line: 1, character: 1 }], newText: 'fff' }, { range: [{ line: 0, character: 0 }, { line: 0, character: 0 }], newText: '' }]]
		]);

		edit.set(b, undefined);
		assert.ok(edit.has(b));
		assert.equal(edit.size, 2);

		edit.set(b, [types.TextEdit.insert(new types.Position(0, 0), 'ffff')]);
		assert.equal(edit.get(b).length, 1);

	});
開發者ID:13572293130,項目名稱:vscode,代碼行數:30,代碼來源:extHostTypes.test.ts

示例5: test

	test('WorkspaceEdit', function() {

		let a = types.Uri.file('a.ts');
		let b = types.Uri.file('b.ts');

		let edit = new types.WorkspaceEdit();
		assert.ok(!edit.has(a));

		edit.set(a, [types.TextEdit.insert(new types.Position(0, 0), 'fff')]);
		assert.ok(edit.has(a));
		assert.equal(edit.size, 1);
		assertToJSON(edit, [['file://a.ts', [{ range: [[0, 0], [0, 0]], newText: 'fff' }]]]);

		edit.insert(b, new types.Position(1, 1), 'fff');
		edit.delete(b, new types.Range(0, 0, 0, 0));
		assert.ok(edit.has(b));
		assert.equal(edit.size, 2);
		assertToJSON(edit, [
			['file://a.ts', [{ range: [[0, 0], [0, 0]], newText: 'fff' }]],
			['file://b.ts', [{ range: [[1, 1], [1, 1]], newText: 'fff' }, { range: [[0, 0], [0, 0]], newText: '' }]]
		]);

		edit.set(b, undefined);
		assert.ok(edit.has(b));
		assert.equal(edit.size, 2);

		edit.set(b, [types.TextEdit.insert(new types.Position(0, 0), 'ffff')]);
		assert.equal(edit.get(b).length, 1);

	});
開發者ID:sangohan,項目名稱:KodeStudio,代碼行數:30,代碼來源:extHostTypes.test.ts


注:本文中的vs/workbench/api/node/extHostTypes.WorkspaceEdit類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。