Home / Function/ simplifyIdentifiersRemoveRefSuffix() — react Function Reference

simplifyIdentifiersRemoveRefSuffix() — react Function Reference

Architecture documentation for the simplifyIdentifiersRemoveRefSuffix() function in minimize.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  7aa71470_4175_bdff_c893_620816842e47["simplifyIdentifiersRemoveRefSuffix()"]
  9c061da8_dbf8_4168_823d_991654a3c55d["minimize.ts"]
  7aa71470_4175_bdff_c893_620816842e47 -->|defined in| 9c061da8_dbf8_4168_823d_991654a3c55d
  a7ee1f5a_4bf8_7201_de45_83f6328fc3fa["collectUniqueIdentifierNames()"]
  7aa71470_4175_bdff_c893_620816842e47 -->|calls| a7ee1f5a_4bf8_7201_de45_83f6328fc3fa
  7a9af496_ef6a_d9e8_8eaf_1f386f49e4b3["cloneAst()"]
  7aa71470_4175_bdff_c893_620816842e47 -->|calls| 7a9af496_ef6a_d9e8_8eaf_1f386f49e4b3
  b99ea007_79df_8b89_65e1_348b6793732f["renameAllIdentifiers()"]
  7aa71470_4175_bdff_c893_620816842e47 -->|calls| b99ea007_79df_8b89_65e1_348b6793732f
  style 7aa71470_4175_bdff_c893_620816842e47 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/snap/src/minimize.ts lines 1933–1954

function* simplifyIdentifiersRemoveRefSuffix(ast: t.File): Generator<t.File> {
  const names = collectUniqueIdentifierNames(ast);

  for (const name of names) {
    // Check if name ends with "Ref" and has more characters before it
    if (name.length > 3 && name.endsWith('Ref')) {
      const newName = name.slice(0, -3);
      // Skip if the new name would conflict with an existing identifier
      if (names.has(newName)) {
        continue;
      }
      // Skip if new name would be empty or just whitespace
      if (newName.length === 0) {
        continue;
      }
      const cloned = cloneAst(ast);
      if (renameAllIdentifiers(cloned, name, newName)) {
        yield cloned;
      }
    }
  }
}

Domain

Subdomains

Frequently Asked Questions

What does simplifyIdentifiersRemoveRefSuffix() do?
simplifyIdentifiersRemoveRefSuffix() is a function in the react codebase, defined in compiler/packages/snap/src/minimize.ts.
Where is simplifyIdentifiersRemoveRefSuffix() defined?
simplifyIdentifiersRemoveRefSuffix() is defined in compiler/packages/snap/src/minimize.ts at line 1933.
What does simplifyIdentifiersRemoveRefSuffix() call?
simplifyIdentifiersRemoveRefSuffix() calls 3 function(s): cloneAst, collectUniqueIdentifierNames, renameAllIdentifiers.

Analyze Your Own Codebase

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

Try Supermodel Free