Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: public kwarg handling #392

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
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 @@
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)

Check warning on line 16 in src/bindings.jl

View check run for this annotation

Codecov / codecov/patch

src/bindings.jl#L16

Added line #L16 was not covered by tests
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 @@
mn === nothing && return true

if scopehasbinding(scope, mn)
if x.parent.head === :public
scope.names[mn].is_public = true

Check warning on line 73 in src/references.jl

View check run for this annotation

Codecov / codecov/patch

src/references.jl#L73

Added line #L73 was not covered by tests
end
setref!(x, scope.names[mn])
resolved = true
elseif scope.modules isa Dict && length(scope.modules) > 0
Expand Down
Loading