当前位置: 首页>>代码示例>>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;未经允许,请勿转载。