-
Notifications
You must be signed in to change notification settings - Fork 47k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transform updates to support Flow this annotation syntax #25918
Changes from all commits
80f2e10
c29471e
c9cedd6
e599d98
0d8af33
475e622
006863c
32262ad
795490d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,8 @@ | |
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @noflow | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These files contain flow syntax but are not flow checked. |
||
*/ | ||
|
||
// Provided by www | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* 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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the new syntax as a test case that all systems now seem to be handling it