fn renderExtraNewlineToken(r: *Render, token_index: Ast.TokenIndex) Error!void OutOfMemoryRan out of memory allocating call stack frames to complete rendering.
WriteFailedTransitive failure from
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098fn renderExtraNewlineToken(r: *Render, token_index: Ast.TokenIndex) Error!void {
const tree = r.tree;
const ais = r.ais;
const token_start = tree.tokenStart(token_index);
if (token_start == 0) return;
const prev_token_end = if (token_index == 0)
0
else
tree.tokenStart(token_index - 1) + tokenSliceForRender(tree, token_index - 1).len;
// If there is a immediately preceding comment or doc_comment,
// skip it because required extra newline has already been rendered.
if (mem.find(u8, tree.source[prev_token_end..token_start], "//") != null) return;
if (tree.isTokenPrecededByTags(token_index, &.{.doc_comment})) return;
// Iterate backwards to the end of the previous token, stopping if a
// non-whitespace character is encountered or two newlines have been found.
var i = token_start - 1;
var newlines: u2 = 0;
while (std.ascii.isWhitespace(tree.source[i])) : (i -= 1) {
if (tree.source[i] == '\n') newlines += 1;
if (newlines == 2) return ais.insertNewline();
if (i == prev_token_end) break;
}
}
Check if there is an empty line immediately before the given token. If so, render it.