Skip to content

Commit

Permalink
Add PrecompileTools workloads (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelHatherly authored Oct 6, 2023
1 parent c5f103f commit 1f2cefc
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ authors = ["Michael Hatherly <[email protected]>"]
version = "0.1.6"

[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
FoldingTrees = "1eca21be-9b9b-4ed8-839a-6d8ae26b1781"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
IterTools = "c8e1da08-722c-5040-9ed9-7db0dc04731e"
PackageExtensionCompat = "65ce6f38-6b18-4e1d-a461-8949797d7930"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"

Expand All @@ -27,10 +27,10 @@ InteractiveErrorsJuliaFormatterExt = "JuliaFormatter"
InteractiveErrorsOhMyREPLExt = "OhMyREPL"

[compat]
AbstractTrees = "0.3, 0.4"
FoldingTrees = "1.1"
IterTools = "1"
PackageExtensionCompat = "1"
PrecompileTools = "1"
julia = "1.6"

[extras]
Expand Down
7 changes: 7 additions & 0 deletions ext/InteractiveErrorsJuliaFormatterExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module InteractiveErrorsJuliaFormatterExt

import JuliaFormatter
import InteractiveErrors
import PrecompileTools

InteractiveErrors.has_juliaformatter() = true

Expand All @@ -14,4 +15,10 @@ function InteractiveErrors.format_julia_source(source::String)
end
end

PrecompileTools.@compile_workload begin
InteractiveErrors.format_julia_source(
read(joinpath(@__DIR__, "..", "src", "InteractiveErrors.jl"), String),
)
end

end
7 changes: 7 additions & 0 deletions ext/InteractiveErrorsOhMyREPLExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module InteractiveErrorsOhMyREPLExt

import OhMyREPL
import InteractiveErrors
import PrecompileTools

InteractiveErrors.has_ohmyrepl() = true

Expand All @@ -19,4 +20,10 @@ function InteractiveErrors.highlight(source::String)
return String(take!(io))
end

PrecompileTools.@compile_workload begin
InteractiveErrors.highlight(
read(joinpath(@__DIR__, "..", "src", "InteractiveErrors.jl"), String),
)
end

end
10 changes: 9 additions & 1 deletion src/InteractiveErrors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using FoldingTrees

using REPL, REPL.TerminalMenus, InteractiveUtils, IterTools

import PackageExtensionCompat
import PackageExtensionCompat, PrecompileTools

export toggle, current_theme, set_theme!, reset_theme!, adjust_theme!

Expand Down Expand Up @@ -391,4 +391,12 @@ function __init__()
PackageExtensionCompat.@require_extensions
end

PrecompileTools.@compile_workload begin
try
div(1, 0)
catch error
explore(IOBuffer(), CapturedError(error, catch_backtrace()); interactive = false)
end
end

end # module

0 comments on commit 1f2cefc

Please sign in to comment.