From 0377898c0c132da381813b08c65b1c2332dfbc46 Mon Sep 17 00:00:00 2001 From: Michael Hatherly Date: Fri, 6 Oct 2023 10:36:32 +0100 Subject: [PATCH] Add `PrecompileTools` workloads --- Project.toml | 4 ++-- ext/InteractiveErrorsJuliaFormatterExt.jl | 7 +++++++ ext/InteractiveErrorsOhMyREPLExt.jl | 7 +++++++ src/InteractiveErrors.jl | 10 +++++++++- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index a69235f..f288c65 100644 --- a/Project.toml +++ b/Project.toml @@ -4,11 +4,11 @@ authors = ["Michael Hatherly "] 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" @@ -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] diff --git a/ext/InteractiveErrorsJuliaFormatterExt.jl b/ext/InteractiveErrorsJuliaFormatterExt.jl index 443b070..5e4ac40 100644 --- a/ext/InteractiveErrorsJuliaFormatterExt.jl +++ b/ext/InteractiveErrorsJuliaFormatterExt.jl @@ -2,6 +2,7 @@ module InteractiveErrorsJuliaFormatterExt import JuliaFormatter import InteractiveErrors +import PrecompileTools InteractiveErrors.has_juliaformatter() = true @@ -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 diff --git a/ext/InteractiveErrorsOhMyREPLExt.jl b/ext/InteractiveErrorsOhMyREPLExt.jl index ba64587..093be0b 100644 --- a/ext/InteractiveErrorsOhMyREPLExt.jl +++ b/ext/InteractiveErrorsOhMyREPLExt.jl @@ -2,6 +2,7 @@ module InteractiveErrorsOhMyREPLExt import OhMyREPL import InteractiveErrors +import PrecompileTools InteractiveErrors.has_ohmyrepl() = true @@ -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 diff --git a/src/InteractiveErrors.jl b/src/InteractiveErrors.jl index 91ee633..f91043f 100644 --- a/src/InteractiveErrors.jl +++ b/src/InteractiveErrors.jl @@ -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! @@ -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