本文整理汇总了TypeScript中vs/workbench/api/node/extHostTypes.TextEdit类的典型用法代码示例。如果您正苦于以下问题:TypeScript TextEdit类的具体用法?TypeScript TextEdit怎么用?TypeScript TextEdit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextEdit类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: 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
示例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, [['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
示例3: Position
let sub2 = participant.onWillSaveTextDocumentEvent(function (e) {
// the document state AFTER the first listener kicked in
assert.equal(document.version, 2);
assert.equal(document.getText(), 'barfoo');
e.waitUntil(TPromise.as([TextEdit.insert(new Position(0, 0), 'bar')]));
});
开发者ID:asotog,项目名称:vscode,代码行数:7,代码来源:extHostDocumentSaveParticipant.test.ts
示例4: Position
let sub = participant.getOnWillSaveTextDocumentEvent(nullExtensionDescription)(function (e) {
// concurrent change from somewhere
documents.$acceptModelChanged(resource.toString(), {
changes: [{
range: { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 },
rangeLength: undefined,
text: 'bar'
}],
eol: undefined,
versionId: 2
}, true);
e.waitUntil(TPromise.as([TextEdit.insert(new Position(0, 0), 'bar')]));
});
开发者ID:servicesgpr,项目名称:vscode,代码行数:15,代码来源:extHostDocumentSaveParticipant.test.ts
注:本文中的vs/workbench/api/node/extHostTypes.TextEdit类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论