Skip to content

Commit 3c7e613

Browse files
12wrigjacopybara-github
authored andcommitted
Restructure and add comments to the parseJSDocInfoFrom method so that it is easier to understand when valid JSDocInfo is being returned.
PiperOrigin-RevId: 714094933
1 parent 91bda23 commit 3c7e613

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/com/google/javascript/jscomp/parsing/IRFactory.java

+10-7
Original file line numberDiff line numberDiff line change
@@ -718,14 +718,17 @@ private Comment getJSDocCommentAt(SourcePosition pos) {
718718
}
719719

720720
private @Nullable JSDocInfo parseJSDocInfoFrom(Comment comment) {
721-
if (comment != null) {
722-
JsDocInfoParser jsDocParser = createJsDocInfoParser(comment);
723-
parsedComments.add(comment);
724-
if (!handlePossibleFileOverviewJsDoc(jsDocParser)) {
725-
return jsDocParser.retrieveAndResetParsedJSDocInfo();
726-
}
721+
if (comment == null) {
722+
return null;
727723
}
728-
return null;
724+
JsDocInfoParser jsDocParser = createJsDocInfoParser(comment);
725+
parsedComments.add(comment);
726+
if (handlePossibleFileOverviewJsDoc(jsDocParser)) {
727+
// Returning null here means that the comment was treated as a fileoverview comment, and
728+
// JSDocInfo should not then be attached to a specific node, so we return null;
729+
return null;
730+
}
731+
return jsDocParser.retrieveAndResetParsedJSDocInfo();
729732
}
730733

731734
private @Nullable JSDocInfo parseJSDocInfoOnTree(ParseTree tree) {

0 commit comments

Comments
 (0)