diff options
| author | Rider Linden <rider@lindenlab.com> | 2026-04-29 14:43:08 -0700 |
|---|---|---|
| committer | Rider Linden <rider@lindenlab.com> | 2026-04-29 14:43:08 -0700 |
| commit | 84e806f71492a76ab28e049ec255df479ffbb339 (patch) | |
| tree | 3e7934f174cb271fd2fa290337fc78f099cd7395 /indra/newview/llscripteditorws.cpp | |
| parent | 364ff6e6d45087653a302b96ccd8c9e02db2b9d1 (diff) | |
Added support to jsonrpc server for the viewer based syntax cache.
Diffstat (limited to 'indra/newview/llscripteditorws.cpp')
| -rw-r--r-- | indra/newview/llscripteditorws.cpp | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/indra/newview/llscripteditorws.cpp b/indra/newview/llscripteditorws.cpp index 11aacd791e..3ca9be44bc 100644 --- a/indra/newview/llscripteditorws.cpp +++ b/indra/newview/llscripteditorws.cpp @@ -2,6 +2,9 @@ * @file llscripteditorws.cpp * @brief JSON-RPC 2.0 WebSocket server implementation for external script editor integration * + * For a full description of the JSON-RPC protocol and all supported methods, + * see doc/external-editor-json-rpc.md in the repository root. + * * $LicenseInfo:firstyear=2025&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2025, Linden Research, Inc. @@ -272,6 +275,26 @@ void LLScriptEditorWSServer::setupConnectionMethods(LLJSONRPCConnection::ptr_t c } return LLSD(); }); + script_connection->registerMethod("language.syntax.cache", + [that](const std::string&, const LLSD&, const LLSD& params) + { + auto server = that.lock(); + if (server) + { + return server->handleSyntaxCacheRequest(); + } + return LLSD(); + }); + script_connection->registerMethod("language.syntax.get", + [that](const std::string&, const LLSD&, const LLSD& params) + { + auto server = that.lock(); + if (server) + { + return server->handleSyntaxCacheFileRequest(params); + } + return LLSD(); + }); script_connection->registerMethod("script.subscribe", [that, connection_id](const std::string&, const LLSD&, const LLSD& params) -> LLSD { @@ -356,6 +379,71 @@ LLSD LLScriptEditorWSServer::handleSyntaxRequest(const LLSD& params) const return response; } +LLSD LLScriptEditorWSServer::handleSyntaxCacheRequest() const +{ + LLSD response; + // Add array of cached syntax definition files + LLSD syntax_files = LLSD::emptyArray(); + for (const auto& name : LLSyntaxDefCache::instance().getCacheFileNames()) + { + syntax_files.append(name); + } + response["files"] = syntax_files; + response["success"] = true; + return response; +} + +LLSD LLScriptEditorWSServer::handleSyntaxCacheFileRequest(const LLSD& params) const +{ + std::string filename = params["filename"].asString(); + bool as_json = params["as_json"].asBoolean(); + + LLSyntaxDefCache& cache = LLSyntaxDefCache::instance(); + LLSD response; + + if (filename.empty()) + { + response["error"] = "No filename specified"; + response["success"] = false; + return response; + } + if (!cache.hasCacheFile(filename)) + { + response["error"] = "Requested syntax cache file not found"; + response["success"] = false; + return response; + } + bool success = false; + if (as_json) + { + LLSD file_content = cache.loadCacheFileAsLLSD(filename); + if (file_content.isDefined()) + { + response["content"] = file_content; + success = true; + } + else + { + response["error"] = "Failed to load and format syntax cache file."; + } + } + else + { + std::string content = cache.loadCacheFile(filename); + if (!content.empty()) + { + response["content"] = content; + success = true; + } + else + { + response["error"] = "Failed to load syntax cache file"; + } + } + response["success"] = success; + return response; +} + LLSD LLScriptEditorWSServer::handleScriptSubscribe(U32 connection_id, const LLSD& params) { LLSD response(LLSD::emptyMap()); @@ -716,6 +804,7 @@ void LLScriptEditorWSConnection::onOpen() LLSD features; features["live_sync"] = true; features["compilation"] = true; + features["syntax_cache"] = true; handshake["features"] = features; wptr_t that = shared_from_this(); |
