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

Method addSymbol

valdi_protobuf/src/valdi_protobuf/DescriptorDatabaseBuilder.cpp:306–326  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

304}
305
306bool DescriptorDatabaseBuilder::addSymbol(size_t fileIndex,
307 size_t packageIndex,
308 const FullyQualifiedName& name,
309 ExceptionTracker& exceptionTracker) {
310 if (_symbolIndexByName.find(name) != _symbolIndexByName.end()) {
311 exceptionTracker.onError(Error(STRING_FORMAT("Symbol '{}' already exist", name)));
312 return false;
313 }
314
315 auto symbolIndex = _symbols.size();
316 auto& symbol = _symbols.emplace_back();
317 symbol.fullName = name;
318 symbol.fileIndex = fileIndex;
319
320 _symbolIndexByName[name] = symbolIndex;
321
322 // Append our new message type inside the package
323 _packages[packageIndex].symbolIndexes.emplace_back(symbolIndex);
324
325 return true;
326}
327
328size_t DescriptorDatabaseBuilder::getOrCreatePackageIndex(const FullyQualifiedName& name) {
329 const auto& it = _packageIndexByName.find(name);

Callers

nothing calls this directly

Calls 5

endMethod · 0.65
onErrorMethod · 0.65
ErrorClass · 0.50
findMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected