Skip to content

Commit

Permalink
Fixes for 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
christopher-dG committed Apr 14, 2020
1 parent 73d9e9e commit 8b29ec6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion src/interactive.jl
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,25 @@ function interactive_pairs(::Type{T}) where T <: TemplateOrPlugin

# Use pushfirst! here so that users can override field types if they wish.
foreach(pair -> pushfirst!(pairs, pair), extra_customizable(T))
unique!(first, pairs)
uniqueby!(first, pairs)
sort!(pairs; by=first)

return pairs
end

# Compute all the concrete subtypes of T.
concretes(T::Type) = isconcretetype(T) ? Any[T] : vcat(map(concretes, subtypes(T))...)

if VERSION >= v"1.1"
const uniqueby! = unique!
else
function uniqueby!(f, xs)
seen = Set()
todelete = Int[]
foreach(enumerate(map(f, xs))) do (i, out)
out in seen && push!(todelete, i)
push!(seen, out)
end
return deleteat!(xs, todelete)
end
end
2 changes: 1 addition & 1 deletion test/interactive.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ notnothingtype(::Type{Union{T, Nothing}}) where T = T
@testset "Interactive mode" begin
@testset "convert_input has all required methods" begin
Fs = mapreduce(union!, PT.concretes(PT.Plugin); init=Set()) do T
map(notnothingtype, fieldtypes(T))
map(notnothingtype, map(n -> fieldtype(T, n), fieldnames(T)))
end
foreach(Fs) do F
@test hasmethod(PT.convert_input, Tuple{Type{Template}, Type{F}, AbstractString})
Expand Down

0 comments on commit 8b29ec6

Please sign in to comment.