Home / File/ getComments.js — react Source File

getComments.js — react Source File

Architecture documentation for getComments.js, a javascript file in the react codebase.

Entity Profile

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.
 */

'use strict';

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;
}

module.exports = getComments;

Domain

Subdomains

Functions

Frequently Asked Questions

What does getComments.js do?
getComments.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Entrypoint subdomain.
What functions are defined in getComments.js?
getComments.js defines 1 function(s): getComments.
Where is getComments.js in the architecture?
getComments.js is located at scripts/babel/getComments.js (domain: BabelCompiler, subdomain: Entrypoint, directory: scripts/babel).

Analyze Your Own Codebase

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

Try Supermodel Free