diff --git a/ecmascript/tooling/agent/js_backend.cpp b/ecmascript/tooling/agent/js_backend.cpp index 11f30e83bf1eefd3a5d809a4cc9f0461bb49b6e6..d25314ac220f52cba57325cda03069d932c5a717 100644 --- a/ecmascript/tooling/agent/js_backend.cpp +++ b/ecmascript/tooling/agent/js_backend.cpp @@ -105,6 +105,15 @@ void JSBackend::NotifyResume() frontend_->SendNotification(ecmaVm_, std::make_unique()); } +void JSBackend::NotifyAllScriptParsed() +{ + for (auto &script : scripts_) { + if (frontend_ != nullptr) { + frontend_->SendNotification(ecmaVm_, ScriptParsed::Create(script.second)); + } + } +} + bool JSBackend::NotifyScriptParsed(int32_t scriptId, const CString &fileName) { auto scriptFunc = []([[maybe_unused]] PtScript *script) -> bool { @@ -159,17 +168,8 @@ bool JSBackend::NotifyScriptParsed(int32_t scriptId, const CString &fileName) // Notify script parsed event std::unique_ptr script = std::make_unique(scriptId, fileName, url, source); - std::unique_ptr scriptParsed = std::make_unique(); - scriptParsed->SetScriptId(script->GetScriptId()) - .SetUrl(script->GetUrl()) - .SetStartLine(0) - .SetStartColumn(0) - .SetEndLine(script->GetEndLine()) - .SetEndColumn(0) - .SetExecutionContextId(0) - .SetHash(script->GetHash()); if (frontend_ != nullptr) { - frontend_->SendNotification(ecmaVm_, std::move(scriptParsed)); + frontend_->SendNotification(ecmaVm_, ScriptParsed::Create(script)); } // Store parsed script in map diff --git a/ecmascript/tooling/agent/js_backend.h b/ecmascript/tooling/agent/js_backend.h index 2cdff1cff7eca9a058015047dc70b8433039042f..add97b2059488a2fc80de71fcd2f6275696a2ce5 100644 --- a/ecmascript/tooling/agent/js_backend.h +++ b/ecmascript/tooling/agent/js_backend.h @@ -36,6 +36,7 @@ public: void WaitForDebugger(); void NotifyPaused(std::optional location, PauseReason reason); void NotifyResume(); + void NotifyAllScriptParsed(); bool NotifyScriptParsed(int32_t scriptId, const CString &fileName); bool StepComplete(const PtLocation &location); diff --git a/ecmascript/tooling/agent/runtime_impl.cpp b/ecmascript/tooling/agent/runtime_impl.cpp index 8d3d3758c150aa915e531d20e3495396ac055550..75b7c9809a37fcb37a5166c6c1ff68652f5a34d8 100644 --- a/ecmascript/tooling/agent/runtime_impl.cpp +++ b/ecmascript/tooling/agent/runtime_impl.cpp @@ -80,6 +80,7 @@ void RuntimeImpl::DispatcherImpl::GetProperties(const DispatchRequest &request) DispatchResponse RuntimeImpl::Enable() { Runtime::GetCurrent()->SetDebugMode(true); + backend_->NotifyAllScriptParsed(); return DispatchResponse::Ok(); } diff --git a/ecmascript/tooling/base/pt_events.cpp b/ecmascript/tooling/base/pt_events.cpp index 6b15c56e8edecebbf680ca62f3a4fb9f0df5f8b8..0bc303cca1f932872d9cac3afd04130daa2ab87e 100644 --- a/ecmascript/tooling/base/pt_events.cpp +++ b/ecmascript/tooling/base/pt_events.cpp @@ -449,6 +449,20 @@ Local ScriptFailedToParse::ToObject(const EcmaVM *ecmaVm) return object; } +std::unique_ptr ScriptParsed::Create(const std::unique_ptr &script) +{ + std::unique_ptr scriptParsed = std::make_unique(); + scriptParsed->SetScriptId(script->GetScriptId()) + .SetUrl(script->GetUrl()) + .SetStartLine(0) + .SetStartColumn(0) + .SetEndLine(script->GetEndLine()) + .SetEndColumn(0) + .SetExecutionContextId(0) + .SetHash(script->GetHash()); + return scriptParsed; +} + std::unique_ptr ScriptParsed::Create(const EcmaVM *ecmaVm, const Local ¶ms) { if (params.IsEmpty()) { diff --git a/ecmascript/tooling/base/pt_events.h b/ecmascript/tooling/base/pt_events.h index f60de50e9b8a2ac44854cd99dafd6a658f698aee..0ef5cf41775092d3c37e8c67358ddd18adbff4da 100644 --- a/ecmascript/tooling/base/pt_events.h +++ b/ecmascript/tooling/base/pt_events.h @@ -20,6 +20,7 @@ #include #include "libpandabase/macros.h" +#include "ecmascript/tooling/base/pt_script.h" #include "ecmascript/tooling/base/pt_types.h" #include "ecmascript/tooling/dispatcher.h" #include "ecmascript/mem/c_containers.h" @@ -474,6 +475,7 @@ class ScriptParsed final : public PtBaseEvents { public: ScriptParsed() = default; ~ScriptParsed() override = default; + static std::unique_ptr Create(const std::unique_ptr &script); static std::unique_ptr Create(const EcmaVM *ecmaVm, const Local ¶ms); Local ToObject(const EcmaVM *ecmaVm) override;