#pragma once #include "ASTNodeBreakpointMapper.h" #include "DebugAdapterRouter.h" #include #include namespace whetstone { struct HitResult { std::string language; std::string astNodeId; int line = 0; bool dispatched = false; }; class DAPBreakpointHitDispatcher { public: // Find the first active breakpoint at source:line, set router to its language. HitResult dispatch(const std::string& source, int line, const ASTNodeBreakpointMapper& mapper, DebugAdapterRouter& router) const { for (const auto& bp : mapper.allBreakpoints()) { if (bp.active && bp.source == source && bp.line == line) { router.setActiveLanguage(bp.language); return {bp.language, bp.astNodeId, bp.line, true}; } } return {"", "", line, false}; } // Return a HitResult for every active breakpoint at source:line. // Router ends at the language of the last match. std::vector dispatchAll(const std::string& source, int line, const ASTNodeBreakpointMapper& mapper, DebugAdapterRouter& router) const { std::vector results; for (const auto& bp : mapper.allBreakpoints()) { if (bp.active && bp.source == source && bp.line == line) { router.setActiveLanguage(bp.language); results.push_back({bp.language, bp.astNodeId, bp.line, true}); } } return results; } }; } // namespace whetstone