> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lsproxy.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Finds occurrences of an identifier by name in a file

> Given a file path and identifier name, returns:
- Without position: All matching identifiers in the file
- With position: The exact identifier with that name at that position, or 3 closest identifiers with that name

Example finding all occurrences of "user_name":
```
let user_name = "John";  // First occurrence
println!("{}", user_name); // Second occurrence
```

When a position is provided, it searches for an exact match at that location.
If no exact match exists, returns the 3 identifiers closest to the position
based on line and character distance, prioritizing lines.



## OpenAPI

````yaml openapi.json post /symbol/find-identifier
openapi: 3.1.0
info:
  title: lsproxy
  description: ''
  license:
    name: Apache-2.0
    url: https://www.apache.org/licenses/LICENSE-2.0
  version: 0.2.1
servers:
  - url: http://localhost:4444/v1
    description: API server v1
security:
  - bearer_auth: []
tags:
  - name: lsproxy-api
    description: LSP Proxy API
paths:
  /symbol/find-identifier:
    post:
      tags:
        - symbol
      summary: Finds occurrences of an identifier by name in a file
      description: >-
        Given a file path and identifier name, returns:

        - Without position: All matching identifiers in the file

        - With position: The exact identifier with that name at that position,
        or 3 closest identifiers with that name


        Example finding all occurrences of "user_name":

        ```

        let user_name = "John";  // First occurrence

        println!("{}", user_name); // Second occurrence

        ```


        When a position is provided, it searches for an exact match at that
        location.

        If no exact match exists, returns the 3 identifiers closest to the
        position

        based on line and character distance, prioritizing lines.
      operationId: find_identifier
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FindIdentifierRequest'
        required: true
      responses:
        '200':
          description: Identifier retrieved successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IdentifierResponse'
        '400':
          description: Bad request
        '500':
          description: Internal server error
components:
  schemas:
    FindIdentifierRequest:
      type: object
      required:
        - name
        - path
      properties:
        name:
          type: string
          description: The name of the identifier to search for.
          example: User
        path:
          type: string
          description: The path to the file to search for identifiers.
          example: src/main.py
        position:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Position'
              description: The position hint to search for identifiers. If not provided.
    IdentifierResponse:
      type: object
      required:
        - identifiers
      properties:
        identifiers:
          type: array
          items:
            $ref: '#/components/schemas/Identifier'
    Position:
      type: object
      description: A position within a text document, using 0-based indexing
      required:
        - line
        - character
      properties:
        character:
          type: integer
          format: int32
          description: 0-indexed character index within the line.
          example: 5
          minimum: 0
        line:
          type: integer
          format: int32
          description: 0-indexed line number.
          example: 10
          minimum: 0
    Identifier:
      type: object
      required:
        - name
        - file_range
      properties:
        file_range:
          $ref: '#/components/schemas/FileRange'
        kind:
          type:
            - string
            - 'null'
        name:
          type: string
    FileRange:
      type: object
      description: A range within a specific file, defined by start and end positions
      required:
        - path
        - range
      properties:
        path:
          type: string
          description: The path to the file.
          example: src/main.py
        range:
          $ref: '#/components/schemas/Range'
          description: The range within the file
    Range:
      type: object
      required:
        - start
        - end
      properties:
        end:
          $ref: '#/components/schemas/Position'
          description: The end position of the range.
        start:
          $ref: '#/components/schemas/Position'
          description: The start position of the range.
  securitySchemes:
    bearer_auth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````