本文整理汇总了TypeScript中vscode-languageserver-types.TextDocumentIdentifier类的典型用法代码示例。如果您正苦于以下问题:TypeScript TextDocumentIdentifier类的具体用法?TypeScript TextDocumentIdentifier怎么用?TypeScript TextDocumentIdentifier使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextDocumentIdentifier类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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```" }
});
});
示例2: query
async function query(position) {
return await languageServer.sendRequest("textDocument/rename", {
textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"),
position,
newName: "new_num"
});
}
示例3: it
it("updates text document", async () => {
let languageServer = await LanguageServer.startAndInitialize();
await languageServer.sendNotification("textDocument/didOpen", {
textDocument: Types.TextDocumentItem.create(
"file:///test-document.txt",
"txt",
0,
"Hello, World!"
)
});
await languageServer.sendNotification("textDocument/didChange", {
textDocument: Types.VersionedTextDocumentIdentifier.create(
"file:///test-document.txt",
1
),
contentChanges: [{ text: "Hello again!" }]
});
let result = await languageServer.sendRequest("debug/textDocument/get", {
textDocument: Types.TextDocumentIdentifier.create(
"file:///test-document.txt"
),
position: Types.Position.create(0, 0)
});
expect(result).toEqual("Hello again!");
await LanguageServer.exit(languageServer);
});
示例4: query
async function query(position) {
return await languageServer.sendRequest("textDocument/references", {
textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"),
position,
context: { includeDeclaration: false }
});
}
示例5: getDoc
async function getDoc(languageServer) {
let result = await languageServer.sendRequest("debug/textDocument/get", {
textDocument: Types.TextDocumentIdentifier.create(
"file:///test-document.txt"
),
position: Types.Position.create(0, 0)
});
return result;
}
示例6: getDocColorPresentation
export function getDocColorPresentation(fileName: string, color: Color, range: Range): ColorPresentation[] {
const fullPath = path.join(CASES_PATH, fileName);
const src: string = fs.readFileSync(fullPath).toString();
const doc = TextDocument.create(toVscodePath(fullPath), 'stylable', 1, src);
return getColorPresentation(newCssService, doc, {
textDocument: TextDocumentIdentifier.create(doc.uri),
color,
range
});
}
示例7: queryCompletion
async function queryCompletion(position) {
let result = await languageServer.sendRequest("textDocument/completion", {
textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"),
position
});
return result.items.map(item => {
return {
label: item.label,
sortText: item.sortText,
textEdit: item.textEdit,
};
});
}