Module: MilkTea::DAP::Server::ServerBreakpoints

Included in:
MilkTea::DAP::Server
Defined in:
lib/milk_tea/dap/server/breakpoints.rb

Instance Method Summary collapse

Instance Method Details

#sync_breakpoints_to_backendObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/milk_tea/dap/server/breakpoints.rb', line 7

def sync_breakpoints_to_backend
  return if @breakpoints_synced_to_backend

  @session.each_breakpoint_source do |source_path, breakpoints|
    response = backend_request("setBreakpoints", {
      "source" => { "path" => source_path },
      "breakpoints" => breakpoints.map { |bp| filter_breakpoint_for_backend(bp) }
    })
    next unless response["success"]

    backend_bps = response.dig("body", "breakpoints") || []
    breakpoints.each_with_index do |local_bp, i|
      backend_bp = backend_bps[i]
      next unless backend_bp

      local_line = local_bp[:line] || local_bp["line"]
      local_verified = local_bp[:verified]
      backend_line = backend_bp["line"] || backend_bp[:line]
      backend_verified = backend_bp["verified"] || backend_bp[:verified]
      next if local_line == backend_line && local_verified == backend_verified

      write_event("breakpoint", {
        reason: "changed",
        breakpoint: {
          id: local_bp[:id] || local_bp["id"],
          verified: backend_verified,
          line: backend_line,
          source: { path: source_path }
        }
      })
    end
  end
  @breakpoints_synced_to_backend = true
end

#sync_exception_breakpoints_to_backendObject



52
53
54
55
56
57
58
59
60
# File 'lib/milk_tea/dap/server/breakpoints.rb', line 52

def sync_exception_breakpoints_to_backend
  return if @exception_breakpoints_synced_to_backend

  exception_breakpoints = @session.exception_breakpoints
  return if exception_breakpoints.nil?

  backend_request("setExceptionBreakpoints", exception_breakpoints)
  @exception_breakpoints_synced_to_backend = true
end

#sync_function_breakpoints_to_backendObject



42
43
44
45
46
47
48
49
50
# File 'lib/milk_tea/dap/server/breakpoints.rb', line 42

def sync_function_breakpoints_to_backend
  return if @function_breakpoints_synced_to_backend
  return if @session.function_breakpoints.empty?

  backend_request("setFunctionBreakpoints", {
    "breakpoints" => @session.function_breakpoints.map { |bp| filter_breakpoint_for_backend(bp) }
  })
  @function_breakpoints_synced_to_backend = true
end