vscode-languageclient#TextDocumentPositionParams TypeScript Examples

The following examples show how to use vscode-languageclient#TextDocumentPositionParams. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: hoverProvider.ts    From vscode-stripe with MIT License 6 votes vote down vote up
async getContributedHoverCommands(
    params: TextDocumentPositionParams,
    token: CancellationToken,
  ): Promise<Command[]> {
    const contributedCommands: Command[] = [];
    for (const provideFn of hoverCommandRegistry) {
      try {
        if (token.isCancellationRequested) {
          break;
        }

        // eslint-disable-next-line no-await-in-loop
        const commands = (await provideFn(params, token)) || [];
        commands.forEach((command: Command) => {
          contributedCommands.push(command);
        });
      } catch (error) {
        return [];
      }
    }

    return contributedCommands;
  }
Example #2
Source File: hoverProvider.ts    From vscode-stripe with MIT License 6 votes vote down vote up
function createClientHoverProvider(languageClient: LanguageClient): JavaHoverProvider {
  const hoverProvider: JavaHoverProvider = new JavaHoverProvider(languageClient);
  registerHoverCommand(async (params: TextDocumentPositionParams, token: CancellationToken) => {
    const command = await provideHoverCommand(languageClient, params, token);
    return command;
  });

  return hoverProvider;
}
Example #3
Source File: hoverProvider.ts    From vscode-stripe with MIT License 6 votes vote down vote up
async function provideHoverCommand(
  languageClient: LanguageClient,
  params: TextDocumentPositionParams,
  token: CancellationToken,
): Promise<Command[] | undefined> {
  const response = await languageClient.sendRequest(
    FindLinks.type,
    {
      type: 'superImplementation',
      position: params,
    },
    token,
  );
  if (response && response.length) {
    const location = response[0];
    let tooltip;
    if (location.kind === 'method') {
      tooltip = `Go to super method '${location.displayName}'`;
    } else {
      tooltip = `Go to super implementation '${location.displayName}'`;
    }

    return [
      {
        title: 'Go to Super Implementation',
        command: javaCommands.NAVIGATE_TO_SUPER_IMPLEMENTATION_COMMAND,
        tooltip,
        arguments: [
          {
            uri: encodeBase64(location.uri),
            range: location.range,
          },
        ],
      },
    ];
  }
}