本文整理汇总了TypeScript中vscode-languageserver-types.TextDocumentItem类的典型用法代码示例。如果您正苦于以下问题:TypeScript TextDocumentItem类的具体用法?TypeScript TextDocumentItem怎么用?TypeScript TextDocumentItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextDocumentItem类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('TextDocumentItem', () => {
let uri = 'file:///folder/file.txt';
let item = TextDocumentItem.create(uri, 'pain-text', 9, 'content');
strictEqual(item.uri, uri);
strictEqual(item.languageId, 'pain-text');
strictEqual(item.version, 9);
strictEqual(item.text, 'content');
ok(TextDocumentItem.is(item));
});
示例2: it
it("updates in at the start 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: 1, character: 0 },
end: { line: 1, character: 0 }
},
rangeLength: 0,
text: "s"
}
]
});
expect(await getDoc(languageServer)).toEqual("let x = 1;\ns\nlet y = 2;");
languageServer = await LanguageServer.startAndInitialize();
});
示例3: it
it("returns type inferred under cursor with documentation", async () => {
languageServer = await LanguageServer.startAndInitialize({
textDocument: {
hover: {
dynamicRegistration: true,
contentFormat: ["markdown", "plaintext"]
}
}
});
await languageServer.sendNotification("textDocument/didOpen", {
textDocument: Types.TextDocumentItem.create(
"file:///test.ml",
"txt",
0,
"(** This function has a nice documentation *)\nlet id x = x\n"
)
});
let result = await languageServer.sendRequest("textDocument/hover", {
textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"),
position: Types.Position.create(1, 4)
});
expect(result).toMatchObject({
contents: {
kind: "markdown",
value: "```ocaml\n'a -> 'a\n(** This function has a nice documentation *)\n```" }
});
});
示例4: openDocument
async function openDocument(source) {
await languageServer.sendNotification("textDocument/didOpen", {
textDocument: Types.TextDocumentItem.create(
"file:///test.ml",
"txt",
0,
source
)
});
}