Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/StaticLint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function (state::Toplevel)(x::EXPR)
if state.modified_exprs !== nothing && x in state.modified_exprs
state.in_modified_expr = true
end
if CSTParser.defines_function(x) || CSTParser.defines_macro(x) || headof(x) === :export
if CSTParser.defines_function(x) || CSTParser.defines_macro(x) || headof(x) === :export || headof(x) === :public
if state.in_modified_expr
push!(state.delayed, x)
else
Expand Down Expand Up @@ -115,6 +115,7 @@ function (state::Delayed)(x::EXPR)
mark_globals(x, state)
handle_macro(x, state)
s0 = scopes(x, state)

resolve_ref(x, state)

old = flag!(state, x)
Expand Down
10 changes: 6 additions & 4 deletions src/bindings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@ mutable struct Binding
val::Union{Binding,EXPR,SymbolServer.SymStore,Nothing}
type::Union{Binding,SymbolServer.SymStore,Nothing}
refs::Vector{Any}
is_public::Bool
end
Binding(x::EXPR) = Binding(CSTParser.get_name(x), x, nothing, [])
Binding(x::EXPR) = Binding(CSTParser.get_name(x), x, nothing, [], false)
Binding(name, val, type, refs) = Binding(name, val, type, refs, false)

function Base.show(io::IO, b::Binding)
printstyled(io, " Binding(", to_codeobject(b.name),
b.type === nothing ? "" : ":: ",
b.refs isa Vector ? "($(length(b.refs)) refs))" : ")", color=:blue)
b.is_public ? "ᵖ" : "",
b.type === nothing ? "" : "::($(b.type))",
b.refs isa Vector ? " ($(length(b.refs)) refs))" : ")", color=:blue)
end


hasbinding(x::EXPR) = hasmeta(x) && hasbinding(x.meta)
bindingof(x) = nothing
bindingof(x::EXPR) = bindingof(x.meta)
Expand Down
3 changes: 3 additions & 0 deletions src/references.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ function resolve_ref(x::EXPR, scope::Scope, state::State)::Bool
mn === nothing && return true

if scopehasbinding(scope, mn)
if x.parent.head === :public
scope.names[mn].is_public = true
end
setref!(x, scope.names[mn])
resolved = true
elseif scope.modules isa Dict && length(scope.modules) > 0
Expand Down