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


TypeScript vscode-languageserver-types.Position类代码示例

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


在下文中一共展示了Position类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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

示例10: test

 test('getChangedPosition #3', () => {
   let pos = Position.create(0, 1)
   let r = Range.create(addPosition(pos, 0, -1), pos)
   let edit = TextEdit.replace(r, 'a\nb\n')
   let res = getChangedPosition(pos, edit)
   expect(res).toEqual({ line: 2, character: -1 })
 })
开发者ID:illarionvk,项目名称:dotfiles,代码行数:7,代码来源:position.test.ts

示例11: it

  it("completes with invalid prefix is buggy", async () => {
    openDocument(outdent`
      let f = LL.
    `);

    let items = await queryCompletion(Types.Position.create(0, 11));
    expect(items).toMatchObject([]);
  });
开发者ID:the-lambda-church,项目名称:merlin,代码行数:8,代码来源:textDocument-completion.test.ts

示例12: 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

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

示例14: async

 provideCompletionItems: async (
   _document: TextDocument,
   _position: Position,
   _token: CancellationToken,
   _context: CompletionContext
 ): Promise<CompletionItem[]> => {
   return [{
     label: 'foo',
     filterText: 'foo',
     additionalTextEdits: [TextEdit.insert(Position.create(0, 0), 'a\nbar')]
   }]
 }
开发者ID:illarionvk,项目名称:dotfiles,代码行数:12,代码来源:completion.test.ts

示例15: getValueAndRange

function getValueAndRange(document: TextDocument, currRange: Range): { value: string; range: Range } {
  let value = document.getText();
  let range = currRange;

  if (currRange) {
    const startOffset = document.offsetAt(currRange.start);
    const endOffset = document.offsetAt(currRange.end);
    value = value.substring(startOffset, endOffset);
  } else {
    range = Range.create(Position.create(0, 0), document.positionAt(value.length));
  }
  return { value, range };
}
开发者ID:cryptobuks,项目名称:tandem,代码行数:13,代码来源:index.ts


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