Home / Function/ getComments() — react Function Reference

getComments() — react Function Reference

Architecture documentation for the getComments() function in getComments.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  fc9d352c_78b3_faf5_aa2a_54e0a99ad13b["getComments()"]
  e7807709_0c99_6e91_b50f_0f17e206f2f1["getComments.js"]
  fc9d352c_78b3_faf5_aa2a_54e0a99ad13b -->|defined in| e7807709_0c99_6e91_b50f_0f17e206f2f1
  style fc9d352c_78b3_faf5_aa2a_54e0a99ad13b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

scripts/babel/getComments.js lines 10–29

function getComments(path) {
  const allComments = path.hub.file.ast.comments;
  if (path.node.leadingComments) {
    // Babel AST includes comments.
    return path.node.leadingComments;
  }
  // In Hermes AST we need to find the comments by range.
  const comments = [];
  let line = path.node.loc.start.line;
  let i = allComments.length - 1;
  while (i >= 0 && allComments[i].loc.end.line >= line) {
    i--;
  }
  while (i >= 0 && allComments[i].loc.end.line === line - 1) {
    line = allComments[i].loc.start.line;
    comments.unshift(allComments[i]);
    i--;
  }
  return comments;
}

Domain

Subdomains

Frequently Asked Questions

What does getComments() do?
getComments() is a function in the react codebase, defined in scripts/babel/getComments.js.
Where is getComments() defined?
getComments() is defined in scripts/babel/getComments.js at line 10.

Analyze Your Own Codebase

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

Try Supermodel Free