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)
| 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++) { |
no test coverage detected