當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript vscode-languageserver-types.TextDocumentItem類代碼示例

本文整理匯總了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));
	});
開發者ID:Blacklite,項目名稱:vscode-languageserver-node,代碼行數:9,代碼來源:helpers.test.ts

示例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();
  });
開發者ID:the-lambda-church,項目名稱:merlin,代碼行數:34,代碼來源:TextDocument.test.ts

示例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```" }
    });
  });
開發者ID:the-lambda-church,項目名稱:merlin,代碼行數:29,代碼來源:textDocument-hover.test.ts

示例4: openDocument

 async function openDocument(source) {
   await languageServer.sendNotification("textDocument/didOpen", {
     textDocument: Types.TextDocumentItem.create(
       "file:///test.ml",
       "txt",
       0,
       source
     )
   });
 }
開發者ID:the-lambda-church,項目名稱:merlin,代碼行數:10,代碼來源:textDocument-typeDefinition.test.ts


注:本文中的vscode-languageserver-types.TextDocumentItem類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。