当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Position.create方法代码示例

本文整理汇总了TypeScript中vscode-languageserver-types.Position.create方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Position.create方法的具体用法?TypeScript Position.create怎么用?TypeScript Position.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vscode-languageserver-types.Position的用法示例。


在下文中一共展示了Position.create方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: test

	test('WorkspaceEdit', () => {
		let workspaceChange = new WorkspaceChange();
		let uri = 'file:///abc.txt';
		let change1 = workspaceChange.getTextEditChange({uri: uri, version: 10});
		change1.insert(Position.create(0,1), 'insert');
		change1.replace(Range.create(0,1,2,3), 'replace');
		change1.delete(Range.create(0,1,2,3));
		let change2 = workspaceChange.getTextEditChange({ uri: 'file:///xyz.txt', version: 20 });
		change2.insert(Position.create(2,3), 'insert');

		let workspaceEdit = workspaceChange.edit;
		strictEqual(workspaceEdit.changes.length, 2);
		let edits = workspaceEdit.changes[0].edits;
		strictEqual(edits.length, 3);
		rangeEqual(edits[0].range, Range.create(0,1,0,1));
		strictEqual(edits[0].newText, 'insert');
		rangeEqual(edits[1].range, Range.create(0,1,2,3));
		strictEqual(edits[1].newText, 'replace');
		rangeEqual(edits[2].range, Range.create(0,1,2,3));
		strictEqual(edits[2].newText, '');

		edits = workspaceEdit.changes[1].edits;
		strictEqual(edits.length, 1);
		rangeEqual(edits[0].range, Range.create(2,3,2,3));
		strictEqual(edits[0].newText, 'insert');
	});
开发者ID:rlugojr,项目名称:vscode-languageserver-node,代码行数:26,代码来源:helpers.test.ts

示例2: test

	test('WorkspaceEdit', () => {
		let workspaceChange = new WorkspaceChange();
		let uri = 'file:///abc.txt';
		let change1 = workspaceChange.getTextEditChange(uri);
		change1.insert(Position.create(0,1), 'insert');
		change1.replace(Range.create(0,1,2,3), 'replace');
		change1.delete(Range.create(0,1,2,3));
		let change2 = workspaceChange.getTextEditChange('file:///xyz.txt');
		change2.insert(Position.create(2,3), 'insert');

		let workspaceEdit = workspaceChange.edit;
		let keys = Object.keys(workspaceEdit.changes);
		strictEqual(keys.length, 2);
		let edits = workspaceEdit.changes[uri];
		strictEqual(edits.length, 3);
		rangeEqual(edits[0].range, Range.create(0,1,0,1));
		strictEqual(edits[0].newText, 'insert');
		rangeEqual(edits[1].range, Range.create(0,1,2,3));
		strictEqual(edits[1].newText, 'replace');
		rangeEqual(edits[2].range, Range.create(0,1,2,3));
		strictEqual(edits[2].newText, '');

		edits = workspaceEdit.changes['file:///xyz.txt'];
		strictEqual(edits.length, 1);
		rangeEqual(edits[0].range, Range.create(2,3,2,3));
		strictEqual(edits[0].newText, 'insert');
	});
开发者ID:Blacklite,项目名称:vscode-languageserver-node,代码行数:27,代码来源:helpers.test.ts

示例3: _selectorCallSymbol

/**
 * Handler for selector call symbols
 * @param {Object} node
 * @param {String[]} text - text editor content splitted by lines
 * @return {SymbolInformation}
 */
function _selectorCallSymbol(node: StylusNode, text: string[]): SymbolInformation {
  const lineno = Number(node.lineno) - 1;
  const name = prepareName(text[lineno]);
  const column = Math.max(text[lineno].indexOf(name), 0);

  const posStart = Position.create(lineno, column);
  const posEnd = Position.create(lineno, column + name.length);

  return SymbolInformation.create(name, SymbolKind.Class, Range.create(posStart, posEnd));
}
开发者ID:cryptobuks,项目名称:tandem,代码行数:16,代码来源:symbols-finder.ts

示例4: test

	test('inserts', function (): any {
		let input = TextDocument.create('foo://bar/f', 'html', 0, '012345678901234567890123456789');
		assert.equal(applyEdits(input, [TextEdit.insert(Position.create(0, 0), 'Hello')]), 'Hello012345678901234567890123456789');
		assert.equal(applyEdits(input, [TextEdit.insert(Position.create(0, 1), 'Hello')]), '0Hello12345678901234567890123456789');
		assert.equal(applyEdits(input, [TextEdit.insert(Position.create(0, 1), 'Hello'), TextEdit.insert(Position.create(0, 1), 'World')]), '0HelloWorld12345678901234567890123456789');
		assert.equal(applyEdits(input, [TextEdit.insert(Position.create(0, 2), 'One'), TextEdit.insert(Position.create(0, 1), 'Hello'), TextEdit.insert(Position.create(0, 1), 'World'), TextEdit.insert(Position.create(0, 2), 'Two'), TextEdit.insert(Position.create(0, 2), 'Three')]), '0HelloWorld1OneTwoThree2345678901234567890123456789');
	});
开发者ID:sameer-coder,项目名称:vscode,代码行数:7,代码来源:utils.test.ts

示例5: _functionSymbol

/**
 * Handler for function
 * @param {Object} node
 * @param {String[]} text - text editor content splitted by lines
 * @return {SymbolInformation}
 */
function _functionSymbol(node: StylusNode, text: string[]): SymbolInformation {
  const name = node.name;
  const lineno = Number(node.val!.lineno) - 1;
  const column = Math.max(text[lineno].indexOf(name), 0);

  const posStart = Position.create(lineno, column);
  const posEnd = Position.create(lineno, column + name.length);
  const range = Range.create(posStart, posEnd);

  return SymbolInformation.create(name, SymbolKind.Function, range);
}
开发者ID:cryptobuks,项目名称:tandem,代码行数:17,代码来源:symbols-finder.ts

示例6: _selectorSymbol

/**
 * Handler for selectors
 * @param {Object} node
 * @param {String[]} text - text editor content splitted by lines
 * @return {SymbolInformation}
 */
function _selectorSymbol(node: StylusNode, text: string[]): SymbolInformation {
  const firstSegment = node.segments[0];
  const name = firstSegment.string
    ? node.segments.map(s => s.string).join('')
    : firstSegment.nodes!.map(s => s.name).join('');
  const lineno = Number(firstSegment.lineno) - 1;
  const column = node.column - 1;

  const posStart = Position.create(lineno, column);
  const posEnd = Position.create(lineno, column + name.length);
  const range = Range.create(posStart, posEnd);

  return SymbolInformation.create(name, SymbolKind.Class, range);
}
开发者ID:cryptobuks,项目名称:tandem,代码行数:20,代码来源:symbols-finder.ts

示例7: 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);
    });
开发者ID:the-lambda-church,项目名称:merlin,代码行数:29,代码来源:TextDocument.test.ts

示例8: it

  it("returns type inferred under cursor (markdown formatting)", 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,
        "let x = 1\n"
      )
    });

    let result = await languageServer.sendRequest("textDocument/hover", {
      textDocument: Types.TextDocumentIdentifier.create("file:///test.ml"),
      position: Types.Position.create(0, 4)
    });

    expect(result).toMatchObject({
      contents: { kind: "markdown", value: "```ocaml\nint\n```" },
      range: {end: {character: 5, line: 0}, start: {character: 4, line: 0}},
    });
  });
开发者ID:the-lambda-church,项目名称:merlin,代码行数:28,代码来源:textDocument-hover.test.ts

示例9: provideCompletionItems

export function provideCompletionItems(document: TextDocument, position: Position): CompletionList {
  const start = document.offsetAt(Position.create(position.line, 0));
  const end = document.offsetAt(position);
  const text = document.getText();
  const currentWord = text.slice(start, end).trim();
  const value = isValue(cssSchema, currentWord);

  let completions: CompletionItem[] = [];

  if (value) {
    const values = getValues(cssSchema, currentWord);
    const symbols = getAllSymbols(text, currentWord, position).filter(
      item => item.kind === CompletionItemKind.Variable || item.kind === CompletionItemKind.Function
    );
    completions = completions.concat(values, symbols, builtIn);
  } else {
    const atRules = getAtRules(cssSchema, currentWord);
    const properties = getProperties(cssSchema, currentWord, false);
    const symbols = getAllSymbols(text, currentWord, position).filter(
      item => item.kind !== CompletionItemKind.Variable
    );
    completions = completions.concat(properties, atRules, symbols);
  }
  return {
    isIncomplete: false,
    items: completions
  };
}
开发者ID:tiravata,项目名称:vetur,代码行数:28,代码来源:completion-item.ts


注:本文中的vscode-languageserver-types.Position.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。