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


TypeScript VersionedTextDocumentIdentifier.create方法代碼示例

本文整理匯總了TypeScript中vscode-languageserver-types.VersionedTextDocumentIdentifier.create方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript VersionedTextDocumentIdentifier.create方法的具體用法?TypeScript VersionedTextDocumentIdentifier.create怎麽用?TypeScript VersionedTextDocumentIdentifier.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在vscode-languageserver-types.VersionedTextDocumentIdentifier的用法示例。


在下文中一共展示了VersionedTextDocumentIdentifier.create方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

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

示例2: 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));
	});
開發者ID:Blacklite,項目名稱:vscode-languageserver-node,代碼行數:7,代碼來源:helpers.test.ts

示例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)
 })
開發者ID:illarionvk,項目名稱:dotfiles,代碼行數:8,代碼來源:workspace.test.ts


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