Skip to content

Commit b86d1a5

Browse files
committed
1 parent b862724 commit b86d1a5

File tree

3 files changed

+49
-4
lines changed

3 files changed

+49
-4
lines changed

src/completions.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,16 @@ end
108108
end
109109
end
110110

111+
@static if isdefined(LineEdit, :Modifiers)
112+
if !force
113+
# Filter out methods where all arguments are `Any`
114+
filter!(cs) do c
115+
isa(c, MethodCompletion) || return true
116+
sig = Base.unwrap_unionall(c.method.sig)::DataType
117+
return !all(T -> T === Any || T === Vararg{Any}, sig.parameters[2:end])
118+
end
119+
end
120+
end
111121
cs = cs[1:min(end, MAX_COMPLETIONS - length(comps))]
112122
REPLCompletions.afterusing(line, Int(first(replace))) && filter!(ispkgcomp, cs) # need `Int` for correct dispatch on x86
113123
append!(comps, completion.(Ref(mod), cs, prefix))
@@ -157,6 +167,16 @@ end
157167
end
158168
end
159169

170+
@static if isdefined(LineEdit, :Modifiers)
171+
if !force
172+
# Filter out methods where all arguments are `Any`
173+
filter!(cs) do c
174+
isa(c, MethodCompletion) || return true
175+
sig = Base.unwrap_unionall(c.method.sig)::DataType
176+
return !all(T -> T === Any || T === Vararg{Any}, sig.parameters[2:end])
177+
end
178+
end
179+
end
160180
cs = cs[1:min(end, MAX_COMPLETIONS - length(comps))]
161181
REPLCompletions.afterusing(line, Int(first(replace))) && filter!(ispkgcomp, cs) # need `Int` for correct dispatch on x86
162182
append!(comps, completion.(Ref(mod), cs, prefix))

src/modules.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,10 @@ handle("module") do data
293293

294294
# NOTE: special case `Core.Compiler`
295295
if occursin(basepath("compiler"), path)
296+
irshow = path == basepath("compiler/ssair/show.jl")
296297
return (
297-
main = "Core",
298-
sub = "Compiler",
298+
main = irshow ? "Base" : "Core",
299+
sub = irshow ? "IRShow" : "Compiler",
299300
inactive = false,
300301
subInactive = false,
301302
)

src/repl.jl

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,17 +310,41 @@ end
310310
# NOTE: shouldn't conflict with identifiers exported by FuzzyCompletions
311311
using REPL: REPLCompletions
312312

313+
@static if isdefined(LineEdit, :Modifiers)
314+
315+
mutable struct JunoREPLCompletionProvider <: REPL.CompletionProvider
316+
mod::Module
317+
modifiers::LineEdit.Modifiers
318+
end
319+
JunoREPLCompletionProvider(mod::Module) = JunoREPLCompletionProvider(mod, LineEdit.Modifiers())
320+
LineEdit.setmodifiers!(c::JunoREPLCompletionProvider, m::LineEdit.Modifiers) = c.modifiers = m
321+
322+
else # @static if isdefined(LineEdit, :Modifiers)
323+
313324
struct JunoREPLCompletionProvider <: REPL.CompletionProvider
314325
mod::Module
315326
end
316327

328+
end # @static if isdefined(LineEdit, :Modifiers)
329+
317330
function LineEdit.complete_line(c::JunoREPLCompletionProvider, s)
318331
partial = REPL.beforecursor(s.input_buffer)
319332
full = LineEdit.input_string(s)
320333

321334
# module-aware repl backend completions
322-
comps, range, should_complete = REPLCompletions.completions(full, lastindex(partial), c.mod)
323-
ret = map(REPLCompletions.completion_text, comps) |> unique!
335+
ret, range, should_complete = REPLCompletions.completions(full, lastindex(partial), c.mod)
336+
@static if isdefined(LineEdit, :Modifiers)
337+
if !c.modifiers.shift
338+
# Filter out methods where all arguments are `Any`
339+
filter!(ret) do c
340+
isa(c, REPLCompletions.MethodCompletion) || return true
341+
sig = Base.unwrap_unionall(c.method.sig)::DataType
342+
return !all(T -> T === Any || T === Vararg{Any}, sig.parameters[2:end])
343+
end
344+
end
345+
c.modifiers = LineEdit.Modifiers()
346+
end
347+
ret = unique!(map(REPLCompletions.completion_text, ret))
324348

325349
return ret, partial[range], should_complete
326350
end

0 commit comments

Comments
 (0)