-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Don't give public but unexported symbols as repl completions in an unqualified context #51345
Conversation
…qualified context
|
||
@testset "public but non-exported symbols only complete qualified (#51331)" begin | ||
c, r, res = test_complete("ispub") | ||
@test res |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is res
actually testing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's something about the type of completion, perhaps weather or not it is ever sensible to display the completion inline. For example, IICU, we never display argument hints inline.
julia> completions("summ", 4)
(REPL.REPLCompletions.Completion[REPL.REPLCompletions.ModuleCompletion(Base, "summary"), REPL.REPLCompletions.ModuleCompletion(Base, "summarysize")], 1:4, true)
julia> completions("summary(", 8)
(REPL.REPLCompletions.Completion[REPL.REPLCompletions.MethodCompletion(Tuple{typeof(summary), Base.JuliaSyntax.SyntaxHead}, summary(head::Base.JuliaSyntax.SyntaxHead) @ Base.JuliaSyntax ~/.julia/dev/julia/base/JuliaSyntax/src/parse_stream.jl:98), REPL.REPLCompletions.MethodCompletion(Tuple{typeof(summary), Base.JuliaSyntax.GreenNode}, summary(node::Base.JuliaSyntax.GreenNode) @ Base.JuliaSyntax ~/.julia/dev/julia/base/JuliaSyntax/src/green_tree.jl:39), REPL.REPLCompletions.MethodCompletion(Tuple{typeof(summary), IO, Function}, summary(io::IO, f::Function) @ Base show.jl:3111), REPL.REPLCompletions.MethodCompletion(Tuple{typeof(summary), IO, AbstractDict}, summary(io::IO, t::AbstractDict) @ Base abstractdict.jl:33), REPL.REPLCompletions.MethodCompletion(Tuple{typeof(summary), IO, T} where T<:Union{Base.KeySet, Base.ValueIterator}, summary(io::IO, iter::T) where T<:Union{KeySet, ValueIterator} @ Base abstractdict.jl:51), REPL.REPLCompletions.MethodCompletion(Tuple{typeof(summary), IO, AbstractString}, summary(io::IO, s::AbstractString) @ Base strings/basic.jl:234), REPL.REPLCompletions.MethodCompletion(Tuple{typeof(summary), IO, AbstractSet}, summary(io::IO, t::AbstractSet) @ Base show.jl:214), REPL.REPLCompletions.MethodCompletion(Tuple{typeof(summary), IO, AbstractArray}, summary(io::IO, a::AbstractArray) @ Base show.jl:3099), REPL.REPLCompletions.MethodCompletion(Tuple{typeof(summary), IO, Any}, summary(io::IO, x) @ Base show.jl:3081), REPL.REPLCompletions.MethodCompletion(Tuple{typeof(summary), Any}, summary(x) @ Base show.jl:3082)], 1:7, false)
julia> summary(
summary(head::Base.JuliaSyntax.SyntaxHead) @ Base.JuliaSyntax ~/.julia/dev/julia/base/JuliaSyntax/src/parse_stream.jl:98
summary(node::Base.JuliaSyntax.GreenNode) @ Base.JuliaSyntax ~/.julia/dev/julia/base/JuliaSyntax/src/green_tree.jl:39
summary(io::IO, f::Function) @ Base show.jl:3111
summary(io::IO, t::AbstractDict) @ Base abstractdict.jl:33
summary(io::IO, iter::T) where T<:Union{KeySet, ValueIterator} @ Base abstractdict.jl:51
summary(io::IO, s::AbstractString) @ Base strings/basic.jl:234
summary(io::IO, t::AbstractSet) @ Base show.jl:214
summary(io::IO, a::AbstractArray) @ Base show.jl:3099
summary(io::IO, x) @ Base show.jl:3081
summary(x) @ Base show.jl:3082
julia> summary(
ssyms = names(mod, all = all, imported = imported) | ||
all || filter!(Base.Fix1(Base.isexported, mod), ssyms) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about making this an option on names
. Seems useful?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We considered that for a bit here, but I ended up thinking that the predicates we use to filter the names are awfully complicated and hard to understand and accurately document as is:
Lines 955 to 959 in ebe1a37
int hidden = jl_symbol_name(asname)[0]=='#'; | |
if ((b->publicp || | |
(imported && b->imported) || | |
(jl_atomic_load_relaxed(&b->owner) == b && !b->imported && (all || m == jl_main_module))) && | |
(all || (!b->deprecated && !hidden))) { |
and that it would be better to give users access to a full list of names and a set of predicates to filter with themselves. This arises from the belief that complex configuration is better expressed with code than keywords.
(I'm merging this bugfix now, but that does not close this discussion, feel free to open a feature request issue)
* Backport several changes from `REPL.REPLCompletions` - JuliaLang/julia#51502 - JuliaLang/julia#51345 * make field_completion_eligible true for 1.6 Base._which was added in JuliaLang/julia@7b19e09 * Update FuzzyCompletions.jl
Fix #52551. This PR ensures that a `SomeModule.?(...#TAB` completion can only suggests method `foo` such that `SomeModule.foo` exists (by checking `isdefined(SomeModule, :foo)`). This is equivalent, I believe, to the initial implementation of #38791, less the bug. Now that we have #51345, we may want to relax the above condition somewhat to include public names present in modules loaded into `SomeModule`, so that, for instance, a direct completion of `?(` would include `@assume_effects`. This could be good for method exploration because even though typing `@assume_effects` with no qualification in `Main` will error, the error now includes the helpful message ``` Hint: a global variable of this name also exists in Base. ``` But that can wait for a later PR anyway, this one is just the bugfix. The bug mentioned at #52551 (comment) dates from the initial #38791 so this could be backported as far back as v1.8. --------- Co-authored-by: Shuhei Kadowaki <[email protected]>
Fix #52551. This PR ensures that a `SomeModule.?(...#TAB` completion can only suggests method `foo` such that `SomeModule.foo` exists (by checking `isdefined(SomeModule, :foo)`). This is equivalent, I believe, to the initial implementation of #38791, less the bug. Now that we have #51345, we may want to relax the above condition somewhat to include public names present in modules loaded into `SomeModule`, so that, for instance, a direct completion of `?(` would include `@assume_effects`. This could be good for method exploration because even though typing `@assume_effects` with no qualification in `Main` will error, the error now includes the helpful message ``` Hint: a global variable of this name also exists in Base. ``` But that can wait for a later PR anyway, this one is just the bugfix. The bug mentioned at #52551 (comment) dates from the initial #38791 so this could be backported as far back as v1.8. --------- Co-authored-by: Shuhei Kadowaki <[email protected]> (cherry picked from commit a987f56)
Fixes #51331
Bug introduced by #50105