Home / Function/ isContainedInJsx() — supabase Function Reference

isContainedInJsx() — supabase Function Reference

Architecture documentation for the isContainedInJsx() function in CodeSample.ts from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  61a11eae_9925_0e46_4d24_ff81c9154e78["isContainedInJsx()"]
  b135dfcb_3344_a04b_5125_18abca69f9f7["_createElidedLine()"]
  b135dfcb_3344_a04b_5125_18abca69f9f7 -->|calls| 61a11eae_9925_0e46_4d24_ff81c9154e78
  style 61a11eae_9925_0e46_4d24_ff81c9154e78 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/docs/features/directives/CodeSample.ts lines 445–499

function isContainedInJsx(tree: acorn.Node, line: number) {
  const acornNodeContainsLine = (node: acorn.Node, line) =>
    node.loc?.start?.line != null &&
    node.loc?.end?.line != null &&
    node.loc.start.line <= line &&
    node.loc.end.line >= line
  if (!acornNodeContainsLine(tree, line)) {
    return false
  }

  let candidateNarrowestContainingNode = tree

  function getNarrowestContainingNode(node: acorn.Node, line: number) {
    for (const key of Object.keys(node)) {
      const value = node[key]
      if (!value || typeof value !== 'object') {
        continue
      }

      if (!Array.isArray(value)) {
        if (acornNodeContainsLine(value, line)) {
          candidateNarrowestContainingNode = value
          getNarrowestContainingNode(value, line)
        }
      } else {
        for (const child of value) {
          if (!acornNodeContainsLine(child, line)) {
            continue
          } else {
            if (
              (child.loc?.start?.line != null &&
                candidateNarrowestContainingNode.loc?.start?.line != null &&
                child.loc.start.line > candidateNarrowestContainingNode.loc.start.line) ||
              (child.loc?.end?.line != null &&
                candidateNarrowestContainingNode.loc?.end?.line != null &&
                child.loc.end.line < candidateNarrowestContainingNode.loc.end.line) ||
              (child.loc?.start?.column != null &&
                candidateNarrowestContainingNode.loc?.start?.column != null &&
                child.loc.start.column > candidateNarrowestContainingNode.loc.start.column) ||
              (child.loc?.end?.column != null &&
                candidateNarrowestContainingNode.loc?.end?.column != null &&
                child.loc.end.column < candidateNarrowestContainingNode.loc.end.column)
            ) {
              candidateNarrowestContainingNode = child
              getNarrowestContainingNode(child, line)
            }
          }
        }
      }
    }
  }

  getNarrowestContainingNode(tree, line)
  return candidateNarrowestContainingNode.type.startsWith('JSX')
}

Subdomains

Frequently Asked Questions

What does isContainedInJsx() do?
isContainedInJsx() is a function in the supabase codebase.
What calls isContainedInJsx()?
isContainedInJsx() is called by 1 function(s): _createElidedLine.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free