Skip to content

Commit

Permalink
Merge pull request #293 from JunoLab/avi/fix502
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk authored Feb 27, 2020
2 parents 26c67a3 + ad596a2 commit e5375dd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/static/bindings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,12 @@ function mark_binding!(x::EXPR, val = x)
mark_binding!(x.args[1], x)
elseif typof(x) === CSTParser.InvisBrackets
mark_binding!(CSTParser.rem_invis(x), val)
elseif typof(x) == CSTParser.UnaryOpCall &&
elseif typof(x) === CSTParser.UnaryOpCall &&
kindof(x.args[1]) === CSTParser.Tokens.DECLARATION
return x
elseif typof(x) === CSTParser.Ref
# https://github.com/JunoLab/Juno.jl/issues/502
return x
else# if typof(x) === IDENTIFIER || (typof(x) === BinaryOpCall && kindof(x.args[2]) === CSTParser.Tokens.DECLARATION)
x.meta = Binding(CSTParser.get_name(x), val)
end
Expand Down
4 changes: 4 additions & 0 deletions test/static/bindings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Adapted from https://github.com/julia-vscode/CSTParser.jl/blob/e4e32477a1e7b4d57
=#

using Atom: traverse_expr!, bindingof
using CSTParser
using CSTParser: typof

function collect_bindings(ex)
Expand Down Expand Up @@ -90,3 +91,6 @@ let cst = CSTParser.parse("function a::T * b::T end")
end

@test collect_bindings(CSTParser.parse("-(x::T) = x")) == ["-", "x"]

# https://github.com/JunoLab/Juno.jl/issues/502
@test isempty(collect_bindings(CSTParser.parse("ary[ind] = rand(Int)")))
3 changes: 3 additions & 0 deletions test/static/toplevel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ for t in ["f(call())", "f(call(), @macro)", "f(@macro)", "f(@macro, arg; kwarg =
@test length(items) === 1
@test items[1] isa Atom.ToplevelCall
end

# https://github.com/JunoLab/Juno.jl/issues/502
@test isempty(toplevelitems("ary[ind] = some"))

0 comments on commit e5375dd

Please sign in to comment.