vscode#ReferenceContext TypeScript Examples

The following examples show how to use vscode#ReferenceContext. 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: spProviders.ts    From sourcepawn-vscode with MIT License 6 votes vote down vote up
public async provideReferences(
    document: TextDocument,
    position: Position,
    context: ReferenceContext,
    token: CancellationToken
  ): Promise<Location[]> {
    return referencesProvider(
      this.itemsRepository,
      position,
      document,
      context,
      token
    );
  }
Example #2
Source File: spReferencesProvider.ts    From sourcepawn-vscode with MIT License 6 votes vote down vote up
export function referencesProvider(
  itemsRepo: ItemsRepository,
  position: Position,
  document: TextDocument,
  context: ReferenceContext,
  token: CancellationToken
): Location[] {
  const items = itemsRepo.getItemFromPosition(document, position);
  if (items.length === 0) {
    return [];
  }

  const references = items
    .filter((e) => e.references !== undefined)
    .map((e) => e.references)
    .filter((e) => e !== undefined)
    .flat();

  if (context.includeDeclaration) {
    references.push(
      ...items.map((e) => locationFromRange(e.filePath, e.range))
    );
  }

  return references;
}