11cb0ef41Sopenharmony_ci// Copyright 2019 the V8 project authors. All rights reserved. 21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be 31cb0ef41Sopenharmony_ci// found in the LICENSE file. 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci#ifndef V8_TORQUE_LS_MESSAGE_H_ 61cb0ef41Sopenharmony_ci#define V8_TORQUE_LS_MESSAGE_H_ 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ci#include "src/base/logging.h" 91cb0ef41Sopenharmony_ci#include "src/torque/ls/json.h" 101cb0ef41Sopenharmony_ci#include "src/torque/ls/message-macros.h" 111cb0ef41Sopenharmony_ci#include "src/torque/source-positions.h" 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_cinamespace v8 { 141cb0ef41Sopenharmony_cinamespace internal { 151cb0ef41Sopenharmony_cinamespace torque { 161cb0ef41Sopenharmony_cinamespace ls { 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_ci// Base class for Messages and Objects that are backed by either a 191cb0ef41Sopenharmony_ci// JsonValue or a reference to a JsonObject. 201cb0ef41Sopenharmony_ci// Helper methods are used by macros to implement typed accessors. 211cb0ef41Sopenharmony_ciclass BaseJsonAccessor { 221cb0ef41Sopenharmony_ci public: 231cb0ef41Sopenharmony_ci template <class T> 241cb0ef41Sopenharmony_ci T GetObject(const std::string& property) { 251cb0ef41Sopenharmony_ci return T(GetObjectProperty(property)); 261cb0ef41Sopenharmony_ci } 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ci bool HasProperty(const std::string& property) const { 291cb0ef41Sopenharmony_ci return object().count(property) > 0; 301cb0ef41Sopenharmony_ci } 311cb0ef41Sopenharmony_ci 321cb0ef41Sopenharmony_ci void SetNull(const std::string& property) { 331cb0ef41Sopenharmony_ci object()[property] = JsonValue::JsonNull(); 341cb0ef41Sopenharmony_ci } 351cb0ef41Sopenharmony_ci 361cb0ef41Sopenharmony_ci bool IsNull(const std::string& property) const { 371cb0ef41Sopenharmony_ci return HasProperty(property) && 381cb0ef41Sopenharmony_ci object().at(property).tag == JsonValue::IS_NULL; 391cb0ef41Sopenharmony_ci } 401cb0ef41Sopenharmony_ci 411cb0ef41Sopenharmony_ci protected: 421cb0ef41Sopenharmony_ci virtual const JsonObject& object() const = 0; 431cb0ef41Sopenharmony_ci virtual JsonObject& object() = 0; 441cb0ef41Sopenharmony_ci 451cb0ef41Sopenharmony_ci JsonObject& GetObjectProperty(const std::string& property) { 461cb0ef41Sopenharmony_ci if (!object()[property].IsObject()) { 471cb0ef41Sopenharmony_ci object()[property] = JsonValue::From(JsonObject{}); 481cb0ef41Sopenharmony_ci } 491cb0ef41Sopenharmony_ci return object()[property].ToObject(); 501cb0ef41Sopenharmony_ci } 511cb0ef41Sopenharmony_ci 521cb0ef41Sopenharmony_ci JsonArray& GetArrayProperty(const std::string& property) { 531cb0ef41Sopenharmony_ci if (!object()[property].IsArray()) { 541cb0ef41Sopenharmony_ci object()[property] = JsonValue::From(JsonArray{}); 551cb0ef41Sopenharmony_ci } 561cb0ef41Sopenharmony_ci return object()[property].ToArray(); 571cb0ef41Sopenharmony_ci } 581cb0ef41Sopenharmony_ci 591cb0ef41Sopenharmony_ci JsonObject& AddObjectElementToArrayProperty(const std::string& property) { 601cb0ef41Sopenharmony_ci JsonArray& array = GetArrayProperty(property); 611cb0ef41Sopenharmony_ci array.push_back(JsonValue::From(JsonObject{})); 621cb0ef41Sopenharmony_ci 631cb0ef41Sopenharmony_ci return array.back().ToObject(); 641cb0ef41Sopenharmony_ci } 651cb0ef41Sopenharmony_ci}; 661cb0ef41Sopenharmony_ci 671cb0ef41Sopenharmony_ci// Base class for Requests, Responses and Notifications. 681cb0ef41Sopenharmony_ci// In contrast to "BaseObject", a Message owns the backing JsonValue of the 691cb0ef41Sopenharmony_ci// whole object tree; i.e. value_ serves as root. 701cb0ef41Sopenharmony_ciclass Message : public BaseJsonAccessor { 711cb0ef41Sopenharmony_ci public: 721cb0ef41Sopenharmony_ci Message() { 731cb0ef41Sopenharmony_ci value_ = JsonValue::From(JsonObject{}); 741cb0ef41Sopenharmony_ci set_jsonrpc("2.0"); 751cb0ef41Sopenharmony_ci } 761cb0ef41Sopenharmony_ci explicit Message(JsonValue value) : value_(std::move(value)) { 771cb0ef41Sopenharmony_ci CHECK(value_.tag == JsonValue::OBJECT); 781cb0ef41Sopenharmony_ci } 791cb0ef41Sopenharmony_ci 801cb0ef41Sopenharmony_ci JsonValue& GetJsonValue() { return value_; } 811cb0ef41Sopenharmony_ci 821cb0ef41Sopenharmony_ci JSON_STRING_ACCESSORS(jsonrpc) 831cb0ef41Sopenharmony_ci 841cb0ef41Sopenharmony_ci protected: 851cb0ef41Sopenharmony_ci const JsonObject& object() const override { return value_.ToObject(); } 861cb0ef41Sopenharmony_ci JsonObject& object() override { return value_.ToObject(); } 871cb0ef41Sopenharmony_ci 881cb0ef41Sopenharmony_ci private: 891cb0ef41Sopenharmony_ci JsonValue value_; 901cb0ef41Sopenharmony_ci}; 911cb0ef41Sopenharmony_ci 921cb0ef41Sopenharmony_ci// Base class for complex type that might be part of a Message. 931cb0ef41Sopenharmony_ci// Instead of creating theses directly, use the accessors on the 941cb0ef41Sopenharmony_ci// root Message or a parent object. 951cb0ef41Sopenharmony_ciclass NestedJsonAccessor : public BaseJsonAccessor { 961cb0ef41Sopenharmony_ci public: 971cb0ef41Sopenharmony_ci explicit NestedJsonAccessor(JsonObject& object) : object_(object) {} 981cb0ef41Sopenharmony_ci 991cb0ef41Sopenharmony_ci const JsonObject& object() const override { return object_; } 1001cb0ef41Sopenharmony_ci JsonObject& object() override { return object_; } 1011cb0ef41Sopenharmony_ci 1021cb0ef41Sopenharmony_ci private: 1031cb0ef41Sopenharmony_ci JsonObject& object_; 1041cb0ef41Sopenharmony_ci}; 1051cb0ef41Sopenharmony_ci 1061cb0ef41Sopenharmony_ciclass ResponseError : public NestedJsonAccessor { 1071cb0ef41Sopenharmony_ci public: 1081cb0ef41Sopenharmony_ci using NestedJsonAccessor::NestedJsonAccessor; 1091cb0ef41Sopenharmony_ci 1101cb0ef41Sopenharmony_ci JSON_INT_ACCESSORS(code) 1111cb0ef41Sopenharmony_ci JSON_STRING_ACCESSORS(message) 1121cb0ef41Sopenharmony_ci}; 1131cb0ef41Sopenharmony_ci 1141cb0ef41Sopenharmony_ciclass InitializeParams : public NestedJsonAccessor { 1151cb0ef41Sopenharmony_ci public: 1161cb0ef41Sopenharmony_ci using NestedJsonAccessor::NestedJsonAccessor; 1171cb0ef41Sopenharmony_ci 1181cb0ef41Sopenharmony_ci JSON_INT_ACCESSORS(processId) 1191cb0ef41Sopenharmony_ci JSON_STRING_ACCESSORS(rootPath) 1201cb0ef41Sopenharmony_ci JSON_STRING_ACCESSORS(rootUri) 1211cb0ef41Sopenharmony_ci JSON_STRING_ACCESSORS(trace) 1221cb0ef41Sopenharmony_ci}; 1231cb0ef41Sopenharmony_ci 1241cb0ef41Sopenharmony_ciclass FileListParams : public NestedJsonAccessor { 1251cb0ef41Sopenharmony_ci public: 1261cb0ef41Sopenharmony_ci using NestedJsonAccessor::NestedJsonAccessor; 1271cb0ef41Sopenharmony_ci 1281cb0ef41Sopenharmony_ci // TODO(szuend): Implement read accessor for string 1291cb0ef41Sopenharmony_ci // arrays. "files" is managed directly. 1301cb0ef41Sopenharmony_ci}; 1311cb0ef41Sopenharmony_ci 1321cb0ef41Sopenharmony_ciclass FileSystemWatcher : public NestedJsonAccessor { 1331cb0ef41Sopenharmony_ci public: 1341cb0ef41Sopenharmony_ci using NestedJsonAccessor::NestedJsonAccessor; 1351cb0ef41Sopenharmony_ci 1361cb0ef41Sopenharmony_ci JSON_STRING_ACCESSORS(globPattern) 1371cb0ef41Sopenharmony_ci JSON_INT_ACCESSORS(kind) 1381cb0ef41Sopenharmony_ci 1391cb0ef41Sopenharmony_ci enum WatchKind { 1401cb0ef41Sopenharmony_ci kCreate = 1, 1411cb0ef41Sopenharmony_ci kChange = 2, 1421cb0ef41Sopenharmony_ci kDelete = 4, 1431cb0ef41Sopenharmony_ci 1441cb0ef41Sopenharmony_ci kAll = kCreate | kChange | kDelete, 1451cb0ef41Sopenharmony_ci }; 1461cb0ef41Sopenharmony_ci}; 1471cb0ef41Sopenharmony_ci 1481cb0ef41Sopenharmony_ciclass DidChangeWatchedFilesRegistrationOptions : public NestedJsonAccessor { 1491cb0ef41Sopenharmony_ci public: 1501cb0ef41Sopenharmony_ci using NestedJsonAccessor::NestedJsonAccessor; 1511cb0ef41Sopenharmony_ci 1521cb0ef41Sopenharmony_ci JSON_ARRAY_OBJECT_ACCESSORS(FileSystemWatcher, watchers) 1531cb0ef41Sopenharmony_ci}; 1541cb0ef41Sopenharmony_ci 1551cb0ef41Sopenharmony_ciclass FileEvent : public NestedJsonAccessor { 1561cb0ef41Sopenharmony_ci public: 1571cb0ef41Sopenharmony_ci using NestedJsonAccessor::NestedJsonAccessor; 1581cb0ef41Sopenharmony_ci 1591cb0ef41Sopenharmony_ci JSON_STRING_ACCESSORS(uri) 1601cb0ef41Sopenharmony_ci JSON_INT_ACCESSORS(type) 1611cb0ef41Sopenharmony_ci}; 1621cb0ef41Sopenharmony_ci 1631cb0ef41Sopenharmony_ciclass DidChangeWatchedFilesParams : public NestedJsonAccessor { 1641cb0ef41Sopenharmony_ci public: 1651cb0ef41Sopenharmony_ci using NestedJsonAccessor::NestedJsonAccessor; 1661cb0ef41Sopenharmony_ci 1671cb0ef41Sopenharmony_ci JSON_ARRAY_OBJECT_ACCESSORS(FileEvent, changes) 1681cb0ef41Sopenharmony_ci}; 1691cb0ef41Sopenharmony_ci 1701cb0ef41Sopenharmony_ciclass SaveOptions : public NestedJsonAccessor { 1711cb0ef41Sopenharmony_ci public: 1721cb0ef41Sopenharmony_ci using NestedJsonAccessor::NestedJsonAccessor; 1731cb0ef41Sopenharmony_ci 1741cb0ef41Sopenharmony_ci JSON_BOOL_ACCESSORS(includeText) 1751cb0ef41Sopenharmony_ci}; 1761cb0ef41Sopenharmony_ci 1771cb0ef41Sopenharmony_ciclass TextDocumentSyncOptions : public NestedJsonAccessor { 1781cb0ef41Sopenharmony_ci public: 1791cb0ef41Sopenharmony_ci using NestedJsonAccessor::NestedJsonAccessor; 1801cb0ef41Sopenharmony_ci 1811cb0ef41Sopenharmony_ci JSON_BOOL_ACCESSORS(openClose) 1821cb0ef41Sopenharmony_ci JSON_INT_ACCESSORS(change) 1831cb0ef41Sopenharmony_ci JSON_BOOL_ACCESSORS(willSave) 1841cb0ef41Sopenharmony_ci JSON_BOOL_ACCESSORS(willSaveWaitUntil) 1851cb0ef41Sopenharmony_ci JSON_OBJECT_ACCESSORS(SaveOptions, save) 1861cb0ef41Sopenharmony_ci}; 1871cb0ef41Sopenharmony_ci 1881cb0ef41Sopenharmony_ciclass ServerCapabilities : public NestedJsonAccessor { 1891cb0ef41Sopenharmony_ci public: 1901cb0ef41Sopenharmony_ci using NestedJsonAccessor::NestedJsonAccessor; 1911cb0ef41Sopenharmony_ci 1921cb0ef41Sopenharmony_ci JSON_OBJECT_ACCESSORS(TextDocumentSyncOptions, textDocumentSync) 1931cb0ef41Sopenharmony_ci JSON_BOOL_ACCESSORS(definitionProvider) 1941cb0ef41Sopenharmony_ci JSON_BOOL_ACCESSORS(documentSymbolProvider) 1951cb0ef41Sopenharmony_ci}; 1961cb0ef41Sopenharmony_ci 1971cb0ef41Sopenharmony_ciclass InitializeResult : public NestedJsonAccessor { 1981cb0ef41Sopenharmony_ci public: 1991cb0ef41Sopenharmony_ci using NestedJsonAccessor::NestedJsonAccessor; 2001cb0ef41Sopenharmony_ci 2011cb0ef41Sopenharmony_ci JSON_OBJECT_ACCESSORS(ServerCapabilities, capabilities) 2021cb0ef41Sopenharmony_ci}; 2031cb0ef41Sopenharmony_ci 2041cb0ef41Sopenharmony_ciclass Registration : public NestedJsonAccessor { 2051cb0ef41Sopenharmony_ci public: 2061cb0ef41Sopenharmony_ci using NestedJsonAccessor::NestedJsonAccessor; 2071cb0ef41Sopenharmony_ci 2081cb0ef41Sopenharmony_ci JSON_STRING_ACCESSORS(id) 2091cb0ef41Sopenharmony_ci JSON_STRING_ACCESSORS(method) 2101cb0ef41Sopenharmony_ci JSON_DYNAMIC_OBJECT_ACCESSORS(registerOptions) 2111cb0ef41Sopenharmony_ci}; 2121cb0ef41Sopenharmony_ci 2131cb0ef41Sopenharmony_ciclass RegistrationParams : public NestedJsonAccessor { 2141cb0ef41Sopenharmony_ci public: 2151cb0ef41Sopenharmony_ci using NestedJsonAccessor::NestedJsonAccessor; 2161cb0ef41Sopenharmony_ci 2171cb0ef41Sopenharmony_ci JSON_ARRAY_OBJECT_ACCESSORS(Registration, registrations) 2181cb0ef41Sopenharmony_ci}; 2191cb0ef41Sopenharmony_ci 2201cb0ef41Sopenharmony_ciclass JsonPosition : public NestedJsonAccessor { 2211cb0ef41Sopenharmony_ci public: 2221cb0ef41Sopenharmony_ci using NestedJsonAccessor::NestedJsonAccessor; 2231cb0ef41Sopenharmony_ci 2241cb0ef41Sopenharmony_ci JSON_INT_ACCESSORS(line) 2251cb0ef41Sopenharmony_ci JSON_INT_ACCESSORS(character) 2261cb0ef41Sopenharmony_ci}; 2271cb0ef41Sopenharmony_ci 2281cb0ef41Sopenharmony_ciclass Range : public NestedJsonAccessor { 2291cb0ef41Sopenharmony_ci public: 2301cb0ef41Sopenharmony_ci using NestedJsonAccessor::NestedJsonAccessor; 2311cb0ef41Sopenharmony_ci 2321cb0ef41Sopenharmony_ci JSON_OBJECT_ACCESSORS(JsonPosition, start) 2331cb0ef41Sopenharmony_ci JSON_OBJECT_ACCESSORS(JsonPosition, end) 2341cb0ef41Sopenharmony_ci}; 2351cb0ef41Sopenharmony_ci 2361cb0ef41Sopenharmony_ciclass Location : public NestedJsonAccessor { 2371cb0ef41Sopenharmony_ci public: 2381cb0ef41Sopenharmony_ci using NestedJsonAccessor::NestedJsonAccessor; 2391cb0ef41Sopenharmony_ci 2401cb0ef41Sopenharmony_ci JSON_STRING_ACCESSORS(uri) 2411cb0ef41Sopenharmony_ci JSON_OBJECT_ACCESSORS(Range, range) 2421cb0ef41Sopenharmony_ci 2431cb0ef41Sopenharmony_ci void SetTo(SourcePosition position) { 2441cb0ef41Sopenharmony_ci set_uri(SourceFileMap::AbsolutePath(position.source)); 2451cb0ef41Sopenharmony_ci range().start().set_line(position.start.line); 2461cb0ef41Sopenharmony_ci range().start().set_character(position.start.column); 2471cb0ef41Sopenharmony_ci range().end().set_line(position.end.line); 2481cb0ef41Sopenharmony_ci range().end().set_character(position.end.column); 2491cb0ef41Sopenharmony_ci } 2501cb0ef41Sopenharmony_ci}; 2511cb0ef41Sopenharmony_ci 2521cb0ef41Sopenharmony_ciclass TextDocumentIdentifier : public NestedJsonAccessor { 2531cb0ef41Sopenharmony_ci public: 2541cb0ef41Sopenharmony_ci using NestedJsonAccessor::NestedJsonAccessor; 2551cb0ef41Sopenharmony_ci 2561cb0ef41Sopenharmony_ci JSON_STRING_ACCESSORS(uri) 2571cb0ef41Sopenharmony_ci}; 2581cb0ef41Sopenharmony_ci 2591cb0ef41Sopenharmony_ciclass TextDocumentPositionParams : public NestedJsonAccessor { 2601cb0ef41Sopenharmony_ci public: 2611cb0ef41Sopenharmony_ci using NestedJsonAccessor::NestedJsonAccessor; 2621cb0ef41Sopenharmony_ci 2631cb0ef41Sopenharmony_ci JSON_OBJECT_ACCESSORS(TextDocumentIdentifier, textDocument) 2641cb0ef41Sopenharmony_ci JSON_OBJECT_ACCESSORS(JsonPosition, position) 2651cb0ef41Sopenharmony_ci}; 2661cb0ef41Sopenharmony_ci 2671cb0ef41Sopenharmony_ciclass Diagnostic : public NestedJsonAccessor { 2681cb0ef41Sopenharmony_ci public: 2691cb0ef41Sopenharmony_ci using NestedJsonAccessor::NestedJsonAccessor; 2701cb0ef41Sopenharmony_ci 2711cb0ef41Sopenharmony_ci enum DiagnosticSeverity { 2721cb0ef41Sopenharmony_ci kError = 1, 2731cb0ef41Sopenharmony_ci kWarning = 2, 2741cb0ef41Sopenharmony_ci kInformation = 3, 2751cb0ef41Sopenharmony_ci kHint = 4 2761cb0ef41Sopenharmony_ci }; 2771cb0ef41Sopenharmony_ci 2781cb0ef41Sopenharmony_ci JSON_OBJECT_ACCESSORS(Range, range) 2791cb0ef41Sopenharmony_ci JSON_INT_ACCESSORS(severity) 2801cb0ef41Sopenharmony_ci JSON_STRING_ACCESSORS(source) 2811cb0ef41Sopenharmony_ci JSON_STRING_ACCESSORS(message) 2821cb0ef41Sopenharmony_ci}; 2831cb0ef41Sopenharmony_ci 2841cb0ef41Sopenharmony_ciclass PublishDiagnosticsParams : public NestedJsonAccessor { 2851cb0ef41Sopenharmony_ci public: 2861cb0ef41Sopenharmony_ci using NestedJsonAccessor::NestedJsonAccessor; 2871cb0ef41Sopenharmony_ci 2881cb0ef41Sopenharmony_ci JSON_STRING_ACCESSORS(uri) 2891cb0ef41Sopenharmony_ci JSON_ARRAY_OBJECT_ACCESSORS(Diagnostic, diagnostics) 2901cb0ef41Sopenharmony_ci}; 2911cb0ef41Sopenharmony_ci 2921cb0ef41Sopenharmony_cienum SymbolKind { 2931cb0ef41Sopenharmony_ci kFile = 1, 2941cb0ef41Sopenharmony_ci kNamespace = 3, 2951cb0ef41Sopenharmony_ci kClass = 5, 2961cb0ef41Sopenharmony_ci kMethod = 6, 2971cb0ef41Sopenharmony_ci kProperty = 7, 2981cb0ef41Sopenharmony_ci kField = 8, 2991cb0ef41Sopenharmony_ci kConstructor = 9, 3001cb0ef41Sopenharmony_ci kFunction = 12, 3011cb0ef41Sopenharmony_ci kVariable = 13, 3021cb0ef41Sopenharmony_ci kConstant = 14, 3031cb0ef41Sopenharmony_ci kStruct = 23, 3041cb0ef41Sopenharmony_ci}; 3051cb0ef41Sopenharmony_ci 3061cb0ef41Sopenharmony_ciclass DocumentSymbolParams : public NestedJsonAccessor { 3071cb0ef41Sopenharmony_ci public: 3081cb0ef41Sopenharmony_ci using NestedJsonAccessor::NestedJsonAccessor; 3091cb0ef41Sopenharmony_ci 3101cb0ef41Sopenharmony_ci JSON_OBJECT_ACCESSORS(TextDocumentIdentifier, textDocument) 3111cb0ef41Sopenharmony_ci}; 3121cb0ef41Sopenharmony_ci 3131cb0ef41Sopenharmony_ciclass SymbolInformation : public NestedJsonAccessor { 3141cb0ef41Sopenharmony_ci public: 3151cb0ef41Sopenharmony_ci using NestedJsonAccessor::NestedJsonAccessor; 3161cb0ef41Sopenharmony_ci 3171cb0ef41Sopenharmony_ci JSON_STRING_ACCESSORS(name) 3181cb0ef41Sopenharmony_ci JSON_INT_ACCESSORS(kind) 3191cb0ef41Sopenharmony_ci JSON_OBJECT_ACCESSORS(Location, location) 3201cb0ef41Sopenharmony_ci JSON_STRING_ACCESSORS(containerName) 3211cb0ef41Sopenharmony_ci}; 3221cb0ef41Sopenharmony_ci 3231cb0ef41Sopenharmony_citemplate <class T> 3241cb0ef41Sopenharmony_ciclass Request : public Message { 3251cb0ef41Sopenharmony_ci public: 3261cb0ef41Sopenharmony_ci explicit Request(JsonValue value) : Message(std::move(value)) {} 3271cb0ef41Sopenharmony_ci Request() : Message() {} 3281cb0ef41Sopenharmony_ci 3291cb0ef41Sopenharmony_ci JSON_INT_ACCESSORS(id) 3301cb0ef41Sopenharmony_ci JSON_STRING_ACCESSORS(method) 3311cb0ef41Sopenharmony_ci JSON_OBJECT_ACCESSORS(T, params) 3321cb0ef41Sopenharmony_ci}; 3331cb0ef41Sopenharmony_ciusing InitializeRequest = Request<InitializeParams>; 3341cb0ef41Sopenharmony_ciusing RegistrationRequest = Request<RegistrationParams>; 3351cb0ef41Sopenharmony_ciusing TorqueFileListNotification = Request<FileListParams>; 3361cb0ef41Sopenharmony_ciusing GotoDefinitionRequest = Request<TextDocumentPositionParams>; 3371cb0ef41Sopenharmony_ciusing DidChangeWatchedFilesNotification = Request<DidChangeWatchedFilesParams>; 3381cb0ef41Sopenharmony_ciusing PublishDiagnosticsNotification = Request<PublishDiagnosticsParams>; 3391cb0ef41Sopenharmony_ciusing DocumentSymbolRequest = Request<DocumentSymbolParams>; 3401cb0ef41Sopenharmony_ci 3411cb0ef41Sopenharmony_citemplate <class T> 3421cb0ef41Sopenharmony_ciclass Response : public Message { 3431cb0ef41Sopenharmony_ci public: 3441cb0ef41Sopenharmony_ci explicit Response(JsonValue value) : Message(std::move(value)) {} 3451cb0ef41Sopenharmony_ci Response() : Message() {} 3461cb0ef41Sopenharmony_ci 3471cb0ef41Sopenharmony_ci JSON_INT_ACCESSORS(id) 3481cb0ef41Sopenharmony_ci JSON_OBJECT_ACCESSORS(ResponseError, error) 3491cb0ef41Sopenharmony_ci JSON_OBJECT_ACCESSORS(T, result) 3501cb0ef41Sopenharmony_ci}; 3511cb0ef41Sopenharmony_ciusing InitializeResponse = Response<InitializeResult>; 3521cb0ef41Sopenharmony_ciusing GotoDefinitionResponse = Response<Location>; 3531cb0ef41Sopenharmony_ci 3541cb0ef41Sopenharmony_ci// Same as "Response" but the result is T[] instead of T. 3551cb0ef41Sopenharmony_citemplate <class T> 3561cb0ef41Sopenharmony_ciclass ResponseArrayResult : public Message { 3571cb0ef41Sopenharmony_ci public: 3581cb0ef41Sopenharmony_ci explicit ResponseArrayResult(JsonValue value) : Message(std::move(value)) {} 3591cb0ef41Sopenharmony_ci ResponseArrayResult() : Message() {} 3601cb0ef41Sopenharmony_ci 3611cb0ef41Sopenharmony_ci JSON_INT_ACCESSORS(id) 3621cb0ef41Sopenharmony_ci JSON_OBJECT_ACCESSORS(ResponseError, error) 3631cb0ef41Sopenharmony_ci JSON_ARRAY_OBJECT_ACCESSORS(T, result) 3641cb0ef41Sopenharmony_ci}; 3651cb0ef41Sopenharmony_ciusing DocumentSymbolResponse = ResponseArrayResult<SymbolInformation>; 3661cb0ef41Sopenharmony_ci 3671cb0ef41Sopenharmony_ci} // namespace ls 3681cb0ef41Sopenharmony_ci} // namespace torque 3691cb0ef41Sopenharmony_ci} // namespace internal 3701cb0ef41Sopenharmony_ci} // namespace v8 3711cb0ef41Sopenharmony_ci 3721cb0ef41Sopenharmony_ci#endif // V8_TORQUE_LS_MESSAGE_H_ 373