Skip to content

Commit

Permalink
local refactorings: looks for the innermost scope
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk committed Oct 23, 2019
1 parent b8802f3 commit 9cea4e7
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/refactor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,13 @@ function current_scope(name, bindings, byteoffset)
for binding in bindings
isa(binding, LocalScope) || continue

scope = binding
if byteoffset in scope.span &&
any(bind -> bind isa LocalBinding && name == bind.name, scope.children)
return scope
else
let scope = current_scope(name, scope.children, byteoffset)
scope !== nothing && return scope
end
# first looks for innermost scope
childscope = current_scope(name, binding.children, byteoffset)
childscope !== nothing && return childscope

if byteoffset in binding.span &&
any(bind -> bind isa LocalBinding && name == bind.name, binding.children)
return binding
end
end

Expand Down

0 comments on commit 9cea4e7

Please sign in to comment.