MCPcopy Index your code
hub / github.com/bazelbuild/bazel / docComments

Method docComments

src/main/java/net/starlark/java/syntax/Lexer.java:522–553  ·  view source on GitHub ↗

Scans a doc comment block. ON ENTRY: 'pos' is at newline (or EOF) terminating the doc comment's first line. ON EXIT: for a doc comment block, 'pos' is the index of the first following non-comment, non-whitespace character (or of EOF); for a trailing doc comment, 'pos' is unch

(Comment first, int firstStartPos, boolean isBlock)

Source from the content-addressed store, hash-verified

520 * </ul>
521 */
522 private void docComments(Comment first, int firstStartPos, boolean isBlock) {
523 int lastEndPos = pos;
524 ArrayList<Comment> docComments = new ArrayList<>();
525 docComments.add(first);
526 if (isBlock) {
527 int prevLine = first.getStartLocation().line();
528 while (peek(0) == '\n') {
529 checkIndentation = false;
530 computeIndentation();
531 if (peek(0) != '#' || peek(1) != ':') {
532 // Not a doc comment; terminate the doc comment block.
533 break;
534 }
535 int line = locs.getLocation(pos).line();
536 if (line != prevLine + 1) {
537 // We are at "#:", but computeIndentation() skipped one or more lines containing only
538 // whitespace and non-doc comments. Terminate the doc comment block.
539 break;
540 }
541 prevLine = line;
542 int startPos = pos;
543 scanToNewline();
544 Comment comment = addComment(startPos, pos);
545 lastEndPos = pos;
546 docComments.add(comment);
547 }
548 setToken(TokenKind.DOC_COMMENT_BLOCK, firstStartPos, lastEndPos);
549 } else {
550 setToken(TokenKind.DOC_COMMENT_TRAILING, firstStartPos, lastEndPos);
551 }
552 setValue(new DocComments(docComments));
553 }
554
555 private void scanToNewline() {
556 for (; pos < buffer.length; pos++) {

Callers 1

tokenizeMethod · 0.95

Calls 10

peekMethod · 0.95
computeIndentationMethod · 0.95
scanToNewlineMethod · 0.95
addCommentMethod · 0.95
setTokenMethod · 0.95
setValueMethod · 0.95
lineMethod · 0.80
getLocationMethod · 0.65
addMethod · 0.45
getStartLocationMethod · 0.45

Tested by

no test coverage detected