MCPcopy Create free account
hub / github.com/argotorg/solidity / resolveInheritDoc

Method resolveInheritDoc

libsolidity/analysis/ReferencesResolver.cpp:421–489  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

419}
420
421void ReferencesResolver::resolveInheritDoc(StructuredDocumentation const& _documentation, StructurallyDocumentedAnnotation& _annotation)
422{
423 switch (_annotation.docTags.count("inheritdoc"))
424 {
425 case 0:
426 break;
427 case 1:
428 {
429 std::string const& name = _annotation.docTags.find("inheritdoc")->second.content;
430 if (name.empty())
431 {
432 m_errorReporter.docstringParsingError(
433 1933_error,
434 _documentation.location(),
435 "Expected contract name following documentation tag @inheritdoc."
436 );
437 return;
438 }
439
440 std::vector<std::string> path;
441 boost::split(path, name, boost::is_any_of("."));
442 if (any_of(path.begin(), path.end(), [](auto& _str) { return _str.empty(); }))
443 {
444 m_errorReporter.docstringParsingError(
445 5967_error,
446 _documentation.location(),
447 "Documentation tag @inheritdoc reference \"" +
448 name +
449 "\" is malformed."
450 );
451 return;
452 }
453 Declaration const* result = m_resolver.pathFromCurrentScope(path);
454
455 if (result == nullptr)
456 {
457 m_errorReporter.docstringParsingError(
458 9397_error,
459 _documentation.location(),
460 "Documentation tag @inheritdoc references inexistent contract \"" +
461 name +
462 "\"."
463 );
464 return;
465 }
466 else
467 {
468 _annotation.inheritdocReference = dynamic_cast<ContractDefinition const*>(result);
469
470 if (!_annotation.inheritdocReference)
471 m_errorReporter.docstringParsingError(
472 1430_error,
473 _documentation.location(),
474 "Documentation tag @inheritdoc reference \"" +
475 name +
476 "\" is not a contract."
477 );
478 }

Callers

nothing calls this directly

Calls 8

docstringParsingErrorMethod · 0.80
pathFromCurrentScopeMethod · 0.80
countMethod · 0.45
findMethod · 0.45
emptyMethod · 0.45
locationMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected