|
6 | 6 | # If RUBY_DEBUG_PORT envval is provided (digits), open TCP/IP port. |
7 | 7 | # Otherwise, UNIX domain socket is used. |
8 | 8 | # |
| 9 | +require "awesome_print" |
| 10 | +require "pry" |
| 11 | +require "zeitwerk" |
| 12 | + |
| 13 | +# loader = Zeitwerk::Loader.for_gem(warn_on_extra_files: false) |
| 14 | + |
| 15 | +module DEBUGGER__ |
| 16 | + # Define these dummy constants so we silence errors like: |
| 17 | + # expected file lib/debug/local.rb to define constant DEBUGGER__::Local, but didn't (Zeitwerk::NameError) |
| 18 | + module Local; end |
| 19 | + module Server; end |
| 20 | + module ServerCdp; end |
| 21 | + module ServerDap; end |
| 22 | + module Version; end |
| 23 | + |
| 24 | + # List special cases where constants are defined in files where they wouldn't otherwise be found |
| 25 | + autoload(:CONFIG, "#{__dir__}/config.rb") |
| 26 | + autoload(:SESSION, "#{__dir__}/config.rb") |
| 27 | + # autoload(:NaiveString, "#{__dir__}/server_dap.rb") |
| 28 | + autoload(:SkipPathHelper, "#{__dir__}/thread_client.rb") |
| 29 | + autoload(:UI_Base, "#{__dir__}/session.rb") |
| 30 | +end |
| 31 | + |
| 32 | +loader = Zeitwerk::Loader.new |
| 33 | +loader.tag = File.basename(__FILE__, ".rb") |
| 34 | +loader.inflector = Zeitwerk::GemInflector.new(__FILE__) |
| 35 | +# loader.push_dir(__dir__) |
| 36 | + |
| 37 | +loader.ignore( |
| 38 | + "lib/debug/start.rb", |
| 39 | + "lib/debug/open.rb", |
| 40 | + "lib/debug/open_nonstop.rb", |
| 41 | + "lib/debug/prelude.rb", |
| 42 | + "lib/debug/dap_custom/traceInspector.rb" |
| 43 | +) |
| 44 | + |
| 45 | +# Configure a special-case for this mangled module name |
| 46 | +loader.push_dir(__dir__, namespace: DEBUGGER__) |
| 47 | +# loader.inflector.inflect( |
| 48 | +# "debug" => "DEBUGGER__" |
| 49 | +# ) |
| 50 | + |
| 51 | +loader.enable_reloading |
| 52 | +loader.setup |
| 53 | +loader.log! |
| 54 | +puts "zeitwerk configured" |
| 55 | + |
| 56 | +# ap({ roots: loader.send(:roots), ignored_paths: loader.send(:ignored_paths), all_paths: Zeitwerk::Loader.all_dirs }) |
| 57 | +# loader.eager_load |
| 58 | +# puts("loaded constants under DEBUGGER__:") |
| 59 | +# ap(DEBUGGER__.constants) |
| 60 | +# exit(0) |
9 | 61 |
|
10 | 62 | require_relative 'session' |
11 | 63 | return unless defined?(DEBUGGER__) |
|
0 commit comments