本文整理匯總了TypeScript中vscode-languageserver-types.VersionedTextDocumentIdentifier類的典型用法代碼示例。如果您正苦於以下問題:TypeScript VersionedTextDocumentIdentifier類的具體用法?TypeScript VersionedTextDocumentIdentifier怎麽用?TypeScript VersionedTextDocumentIdentifier使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了VersionedTextDocumentIdentifier類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: test
test('VersionedTextDocumentIdentifier', () => {
let uri = 'file:///folder/file.txt';
let identifier = VersionedTextDocumentIdentifier.create(uri, 9);
strictEqual(identifier.uri, uri);
strictEqual(identifier.version, 9);
ok(VersionedTextDocumentIdentifier.is(identifier));
});
示例2: it
it("updates in the middle of the line", async () => {
let languageServer = await LanguageServer.startAndInitialize();
await languageServer.sendNotification("textDocument/didOpen", {
textDocument: Types.TextDocumentItem.create(
"file:///test-document.txt",
"txt",
0,
"let x = 1;\n\nlet y = 2;"
)
});
expect(await getDoc(languageServer)).toEqual("let x = 1;\n\nlet y = 2;");
await languageServer.sendNotification("textDocument/didChange", {
textDocument: Types.VersionedTextDocumentIdentifier.create(
"file:///test-document.txt",
1
),
contentChanges: [
{
range: {
start: { line: 2, character: 5 },
end: { line: 2, character: 5 }
},
rangeLength: 0,
text: "1"
}
]
});
expect(await getDoc(languageServer)).toEqual("let x = 1;\n\nlet y1 = 2;");
await languageServer.sendNotification("textDocument/didChange", {
textDocument: Types.VersionedTextDocumentIdentifier.create(
"file:///test-document.txt",
1
),
contentChanges: [
{
range: {
start: { line: 2, character: 5 },
end: { line: 2, character: 6 }
},
rangeLength: 1,
text: ""
}
]
});
expect(await getDoc(languageServer)).toEqual("let x = 1;\n\nlet y = 2;");
await LanguageServer.exit(languageServer);
});
示例3: it
it('should return false for change to file not exists', async () => {
let uri = URI.file('/tmp/not_exists').toString()
let versioned = VersionedTextDocumentIdentifier.create(uri, null)
let edit = TextEdit.insert(Position.create(0, 0), 'bar')
let documentChanges = [TextDocumentEdit.create(versioned, [edit])]
let res = await workspace.applyEdit({ documentChanges })
expect(res).toBe(false)
})