tree-sitter - v0.25.1
    Preparing search index...

    Class Query

    Index

    Constructors

    • Create a new query from a string containing one or more S-expression patterns.

      The query is associated with a particular language, and can only be run on syntax nodes parsed with that language. References to Queries can be shared between multiple threads.

      Parameters

      • language: Language
      • source: string | Buffer<ArrayBufferLike>

      Returns Query

    Properties

    matchLimit: number

    The maximum number of in-progress matches for this cursor.

    Methods

    • Check if, on its last execution, this cursor exceeded its maximum number of in-progress matches.

      Returns boolean

      true if the cursor exceeded its match limit

    • Disable a certain capture within a query.

      This prevents the capture from being returned in matches, and also avoids any resource usage associated with recording the capture.

      Parameters

      • captureName: string

        The name of the capture to disable

      Returns void

    • Disable a certain pattern within a query.

      This prevents the pattern from matching, and also avoids any resource usage associated with the pattern.

      Parameters

      • patternIndex: number

        The index of the pattern to disable

      Returns void

    • Get the byte offset where the given pattern ends in the query's source.

      Parameters

      • patternIndex: number

        The index of the pattern to check

      Returns number

      The byte offset where the pattern ends

    • Check if a given step in a query is 'definite'.

      A query step is 'definite' if its parent pattern will be guaranteed to match successfully once it reaches the step.

      Parameters

      • byteOffset: number

        The byte offset of the step to check

      Returns boolean

    • Check if a given pattern within a query has a single root node.

      Parameters

      • patternIndex: number

        The index of the pattern to check

      Returns boolean

    • Check if a given pattern within a query has a single root node.

      Parameters

      • patternIndex: number

        The index of the pattern to check

      Returns boolean

    • Iterate over all of the matches in the order that they were found.

      Each match contains the index of the pattern that matched, and a list of captures. Because multiple patterns can match the same set of nodes, one match may contain captures that appear before some of the captures from a previous match.

      Parameters

      Returns QueryMatch[]

      An array of matches

    • Get the byte offset where the given pattern starts in the query's source.

      Parameters

      • patternIndex: number

        The index of the pattern to check

      Returns number

      The byte offset where the pattern starts