MCPcopy Index your code
hub / github.com/facebook/react / getComments

Function getComments

scripts/babel/getComments.js:10–29  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

8'use strict';
9
10function getComments(path) {
11 const allComments = path.hub.file.ast.comments;
12 if (path.node.leadingComments) {
13 // Babel AST includes comments.
14 return path.node.leadingComments;
15 }
16 // In Hermes AST we need to find the comments by range.
17 const comments = [];
18 let line = path.node.loc.start.line;
19 let i = allComments.length - 1;
20 while (i >= 0 && allComments[i].loc.end.line >= line) {
21 i--;
22 }
23 while (i >= 0 && allComments[i].loc.end.line === line - 1) {
24 line = allComments[i].loc.start.line;
25 comments.unshift(allComments[i]);
26 i--;
27 }
28 return comments;
29}
30
31module.exports = getComments;

Callers 2

ExpressionStatementFunction · 0.85
ExpressionStatementFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected