本文整理汇总了TypeScript中vs/workbench/api/node/extHostTypes.WorkspaceEdit.insert方法的典型用法代码示例。如果您正苦于以下问题:TypeScript WorkspaceEdit.insert方法的具体用法?TypeScript WorkspaceEdit.insert怎么用?TypeScript WorkspaceEdit.insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vs/workbench/api/node/extHostTypes.WorkspaceEdit
的用法示例。
在下文中一共展示了WorkspaceEdit.insert方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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');
});
示例2: 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);
});
示例3: 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);
});