Skip to content

Commit 2e8d590

Browse files
authored
build_tree: clarify accepted keyword arguments (#571)
Currently `build_tree` accepts extra `kwargs...` which causes actually invalid `kwargs...` to be silently ignored. This is particularly confusing since they can be mixed up with `_parse!` keyword arguments. This change clarifies which keyword arguments `build_tree` accepts and makes it explicitly error when invalid keyword arguments are passed.
1 parent 63bee39 commit 2e8d590

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

src/integration/expr.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,10 @@ end
643643
return retexpr
644644
end
645645

646-
function build_tree(::Type{Expr}, stream::ParseStream; filename=nothing, first_line=1, kws...)
646+
function build_tree(::Type{Expr}, stream::ParseStream;
647+
filename=nothing, first_line=1,
648+
# unused, but required since `_parse` is written generic
649+
keep_parens=false)
647650
source = SourceFile(stream, filename=filename, first_line=first_line)
648651
return build_tree(Expr, stream, source)
649652
end

src/porcelain/green_node.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ function GreenNode(cursor::GreenTreeCursor)
132132
end
133133
end
134134

135-
function build_tree(T::Type{GreenNode}, stream::ParseStream; kws...)
135+
function build_tree(::Type{GreenNode}, stream::ParseStream;
136+
# unused, but required since `_parse` is written generic
137+
filename=nothing, first_line=1, keep_parens=false)
136138
cursor = GreenTreeCursor(stream)
137139
if has_toplevel_siblings(cursor)
138140
# There are multiple toplevel nodes, e.g. because we're using this

src/porcelain/syntax_tree.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ end
302302
Base.copy(data::SyntaxData) = SyntaxData(data.source, data.raw, data.byte_end, data.val)
303303

304304
function build_tree(::Type{SyntaxNode}, stream::ParseStream;
305-
filename=nothing, first_line=1, keep_parens=false, kws...)
305+
filename=nothing, first_line=1, keep_parens=false)
306306
source = SourceFile(stream, filename=filename, first_line=first_line)
307307
cursor = RedTreeCursor(stream)
308308
if has_toplevel_siblings(cursor)

0 commit comments

Comments
 (0)