MCPcopy Create free account
hub / github.com/Snapchat/Valdi / handleGetProperties

Method handleGetProperties

valdi/src/valdi/hermes/HermesDebuggerConnection.cpp:209–225  ·  view source on GitHub ↗

Compatability workaround for debugging Hermes with Block Scoping enabled Issue outlined here: https://github.com/facebook/hermes/issues/1355. Should be fixed in a future release of Static Hermes. This workaround removes duplicate variables from the getProperties response so they display properly in the UI

Source from the content-addressed store, hash-verified

207// Hermes. This workaround removes duplicate variables from the getProperties response so they display properly in the
208// UI
209void HermesDebuggerConnection::handleGetProperties(const Value& message) {
210 auto properties = message.getMapValue("result").getMapValue("result").getArrayRef();
211 if (properties != nullptr) {
212 struct ValueCompare {
213 bool operator()(const Value& lhs, const Value& rhs) const {
214 return lhs.getMapValue("name") == rhs.getMapValue("name");
215 }
216 };
217 std::unordered_set<Value, std::hash<Value>, ValueCompare> uniqueValues;
218 for (const auto& property : *properties) {
219 uniqueValues.insert(property);
220 }
221 std::vector<Value> uniqueProperties(uniqueValues.begin(), uniqueValues.end());
222 message.getMapValue("result").setMapValue("result", Value(ValueArray::make(std::move(uniqueProperties))));
223 }
224 submitMessageToCDP(message);
225}
226
227void HermesDebuggerConnection::handlePaused(const Value& message) {
228 auto callFrames = message.getMapValue("params").getMapValue("callFrames").getArrayRef();

Callers

nothing calls this directly

Calls 6

getArrayRefMethod · 0.80
getMapValueMethod · 0.80
insertMethod · 0.65
endMethod · 0.65
ValueClass · 0.50
beginMethod · 0.45

Tested by

no test coverage detected