Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
domluna committed Sep 10, 2024
1 parent ba635d7 commit 9a0cf12
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 28 deletions.
8 changes: 1 addition & 7 deletions src/document.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,7 @@ function Document(text::AbstractString)
push!(format_skips, FormatSkip(v[1], line, v[2], last(r)))
end

return Document(
srcfile,
format_skips,
noindent_blocks,
comments,
ends_on_nl,
)
return Document(srcfile, format_skips, noindent_blocks, comments, ends_on_nl)
end

function has_noindent_block(d::Document, r::Tuple{Int,Int})
Expand Down
19 changes: 12 additions & 7 deletions src/fst.jl
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,9 @@ can_remove(fst::FST) = fst.nest_behavior !== AllowNestButDontRemove
Newline(; length = 0, nest_behavior = AllowNest) =
FST(NEWLINE, -1, -1, 0, length, "\n", nothing, nest_behavior, 0, -1, nothing)
Semicolon() = FST(SEMICOLON, -1, -1, 0, 1, ";", nothing, AllowNest, 0, -1, nothing)
TrailingComma() =
FST(TRAILINGCOMMA, -1, -1, 0, 0, "", nothing, AllowNest, 0, -1, nothing)
Whitespace(n) =
FST(WHITESPACE, -1, -1, 0, n, " "^n, nothing, AllowNest, 0, -1, nothing)
Placeholder(n) =
FST(PLACEHOLDER, -1, -1, 0, n, " "^n, nothing, AllowNest, 0, -1, nothing)
TrailingComma() = FST(TRAILINGCOMMA, -1, -1, 0, 0, "", nothing, AllowNest, 0, -1, nothing)
Whitespace(n) = FST(WHITESPACE, -1, -1, 0, n, " "^n, nothing, AllowNest, 0, -1, nothing)
Placeholder(n) = FST(PLACEHOLDER, -1, -1, 0, n, " "^n, nothing, AllowNest, 0, -1, nothing)
Notcode(startline, endline) =
FST(NOTCODE, startline, endline, 0, 0, "", nothing, AllowNest, 0, -1, nothing)
InlineComment(line) =
Expand Down Expand Up @@ -1150,7 +1147,15 @@ function add_node!(
if isnothing(t.metadata)
t.metadata = Metadata(K"begin", false, false, false, false, true, true)
else
t.metadata = Metadata(t.metadata.op_kind, t.metadata.op_dotted, t.metadata.is_standalone_shortcircuit, t.metadata.is_short_form_function, t.metadata.is_assignment, t.metadata.is_long_form_function, true)
t.metadata = Metadata(
t.metadata.op_kind,
t.metadata.op_dotted,
t.metadata.is_standalone_shortcircuit,
t.metadata.is_short_form_function,
t.metadata.is_assignment,
t.metadata.is_long_form_function,
true,
)
end
if is_iterable(t) && n_args(t) > 1
t.nest_behavior = AlwaysNest
Expand Down
21 changes: 7 additions & 14 deletions src/styles/default/pretty.jl
Original file line number Diff line number Diff line change
Expand Up @@ -504,19 +504,7 @@ function p_stringh(
for (i, l) in enumerate(lines)
ln = startline + i - 1
l = i == 1 ? l : l[sidx:end]
n = FST(
LITERAL,
ln,
ln,
sidx - 1,
length(l),
l,
nothing,
AllowNest,
0,
-1,
nothing,
)
n = FST(LITERAL, ln, ln, sidx - 1, length(l), l, nothing, AllowNest, 0, -1, nothing)
add_node!(t, n, s)
end

Expand All @@ -541,7 +529,12 @@ function p_globalrefdoc(ds::DefaultStyle, cst::JuliaSyntax.GreenNode, s::State;
args = children(cst)
for (i, c) in enumerate(args)
if i == 1
add_node!(t, pretty(style, c, s; kwargs..., from_docstring = true), s, max_padding = 0)
add_node!(
t,
pretty(style, c, s; kwargs..., from_docstring = true),
s,
max_padding = 0,
)
elseif i == length(args)
add_node!(t, pretty(style, c, s; kwargs...), s, max_padding = 0)
else
Expand Down

0 comments on commit 9a0cf12

Please sign in to comment.