diff --git a/src/hooks.jl b/src/hooks.jl index 97189321..228f14b0 100644 --- a/src/hooks.jl +++ b/src/hooks.jl @@ -45,11 +45,8 @@ function _incomplete_tag(n::SyntaxNode, codelen) return :none end end - if kind(c) == K"error" && begin - cs = children(c) - length(cs) > 0 - end - for cc in cs + if kind(c) == K"error" && numchildren(c) > 0 + for cc in children(c) if kind(cc) == K"error" return :other end diff --git a/src/syntax_tree.jl b/src/syntax_tree.jl index 091a7564..a713ed35 100644 --- a/src/syntax_tree.jl +++ b/src/syntax_tree.jl @@ -223,10 +223,12 @@ function Base.copy(node::TreeNode) # copy the container but not the data (ie, deep copy the tree, shallow copy the data). copy(::Expr) is similar # copy "un-parents" the top-level `node` that you're copying newnode = typeof(node)(nothing, is_leaf(node) ? nothing : typeof(node)[], copy(node.data)) - for child in children(node) - newchild = copy(child) - newchild.parent = newnode - push!(newnode, newchild) + if !is_leaf(node) + for child in children(node) + newchild = copy(child) + newchild.parent = newnode + push!(newnode, newchild) + end end return newnode end