Home / File/ FindContextIdentifiers.ts — react Source File

FindContextIdentifiers.ts — react Source File

Architecture documentation for FindContextIdentifiers.ts, a typescript file in the react codebase. 7 imports, 1 dependents.

File typescript MIRInfrastructure HIR 7 imports 1 dependents 6 functions

Entity Profile

Dependency Diagram

graph LR
  a8683125_42ac_e9cd_3e85_739b8a5c0c4c["FindContextIdentifiers.ts"]
  e96f281e_f381_272d_2359_3e6a091c9a1d["CompilerError.ts"]
  a8683125_42ac_e9cd_3e85_739b8a5c0c4c --> e96f281e_f381_272d_2359_3e6a091c9a1d
  e51fd0d2_bb38_cc97_7763_efe37f300a47["CompilerError"]
  a8683125_42ac_e9cd_3e85_739b8a5c0c4c --> e51fd0d2_bb38_cc97_7763_efe37f300a47
  eb9d33f9_42c1_205c_93e6_8e1365a31839["utils.ts"]
  a8683125_42ac_e9cd_3e85_739b8a5c0c4c --> eb9d33f9_42c1_205c_93e6_8e1365a31839
  14f2e51a_d755_814e_2f56_72d3ed119459["getOrInsertDefault"]
  a8683125_42ac_e9cd_3e85_739b8a5c0c4c --> 14f2e51a_d755_814e_2f56_72d3ed119459
  18a78965_f593_105b_e5e8_07001321c2ec["HIR.ts"]
  a8683125_42ac_e9cd_3e85_739b8a5c0c4c --> 18a78965_f593_105b_e5e8_07001321c2ec
  ceff537f_04b5_ea96_fed3_19a0a7315bc6["traverse"]
  a8683125_42ac_e9cd_3e85_739b8a5c0c4c --> ceff537f_04b5_ea96_fed3_19a0a7315bc6
  52e3d8d7_abf4_7343_1f98_3f701ec04082["types"]
  a8683125_42ac_e9cd_3e85_739b8a5c0c4c --> 52e3d8d7_abf4_7343_1f98_3f701ec04082
  e3cfc07a_10c8_5dcd_e270_e8e14c29309b["Pipeline.ts"]
  e3cfc07a_10c8_5dcd_e270_e8e14c29309b --> a8683125_42ac_e9cd_3e85_739b8a5c0c4c
  style a8683125_42ac_e9cd_3e85_739b8a5c0c4c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

import type {NodePath} from '@babel/traverse';
import type * as t from '@babel/types';
import {CompilerError} from '../CompilerError';
import {getOrInsertDefault} from '../Utils/utils';
import {GeneratedSource} from './HIR';

type IdentifierInfo = {
  reassigned: boolean;
  reassignedByInnerFn: boolean;
  referencedByInnerFn: boolean;
};
const DEFAULT_IDENTIFIER_INFO: IdentifierInfo = {
  reassigned: false,
  reassignedByInnerFn: false,
  referencedByInnerFn: false,
};

type BabelFunction =
  | NodePath<t.FunctionDeclaration>
  | NodePath<t.FunctionExpression>
  | NodePath<t.ArrowFunctionExpression>
  | NodePath<t.ObjectMethod>;
type FindContextIdentifierState = {
  currentFn: Array<BabelFunction>;
  identifiers: Map<t.Identifier, IdentifierInfo>;
};

const withFunctionScope = {
  enter: function (
    path: BabelFunction,
    state: FindContextIdentifierState,
  ): void {
    state.currentFn.push(path);
  },
  exit: function (_: BabelFunction, state: FindContextIdentifierState): void {
    state.currentFn.pop();
  },
};

export function findContextIdentifiers(
  func: NodePath<t.Function>,
): Set<t.Identifier> {
  const state: FindContextIdentifierState = {
    currentFn: [],
    identifiers: new Map(),
  };

  func.traverse<FindContextIdentifierState>(
    {
      FunctionDeclaration: withFunctionScope,
      FunctionExpression: withFunctionScope,
      ArrowFunctionExpression: withFunctionScope,
      ObjectMethod: withFunctionScope,
// ... (170 more lines)

Subdomains

Frequently Asked Questions

What does FindContextIdentifiers.ts do?
FindContextIdentifiers.ts is a source file in the react codebase, written in typescript. It belongs to the MIRInfrastructure domain, HIR subdomain.
What functions are defined in FindContextIdentifiers.ts?
FindContextIdentifiers.ts defines 6 function(s): findContextIdentifiers, handleAssignment, handleIdentifier, nonNull, withFunctionScope.enter, withFunctionScope.exit.
What does FindContextIdentifiers.ts depend on?
FindContextIdentifiers.ts imports 7 module(s): CompilerError, CompilerError.ts, HIR.ts, getOrInsertDefault, traverse, types, utils.ts.
What files import FindContextIdentifiers.ts?
FindContextIdentifiers.ts is imported by 1 file(s): Pipeline.ts.
Where is FindContextIdentifiers.ts in the architecture?
FindContextIdentifiers.ts is located at compiler/packages/babel-plugin-react-compiler/src/HIR/FindContextIdentifiers.ts (domain: MIRInfrastructure, subdomain: HIR, directory: compiler/packages/babel-plugin-react-compiler/src/HIR).

Analyze Your Own Codebase

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

Try Supermodel Free