MCPcopy Create free account
hub / github.com/KDE/kdevelop / usefulDeclaration

Function usefulDeclaration

kdevplatform/shell/documentationcontroller.cpp:55–74  ·  view source on GitHub ↗

* Return a "more useful" declaration that documentation providers can look-up * * @code * QPoint point; * ^-- cursor here * @endcode * * In this case, this method returns a Declaration pointer to the *type* * instead of a pointer to the instance, which is more useful when looking for help * * @return A more appropriate Declaration pointer or the given parameter @p decl */

Source from the content-addressed store, hash-verified

53 * @return A more appropriate Declaration pointer or the given parameter @p decl
54 */
55Declaration* usefulDeclaration(Declaration* decl)
56{
57 if (!decl)
58 return nullptr;
59
60 // First: Attempt to find the declaration of a definition
61 decl = DUChainUtils::declarationForDefinition(decl);
62
63 // Convenience feature: Retrieve the type declaration of instances,
64 // it makes no sense to pass the declaration pointer of instances of types
65 if (decl->kind() == Declaration::Instance) {
66 AbstractType::Ptr type = TypeUtils::targetTypeKeepAliases(decl->abstractType(), decl->topContext());
67 auto* idType = dynamic_cast<IdentifiedType*>(type.data());
68 Declaration* idDecl = idType ? idType->declaration(decl->topContext()) : nullptr;
69 if (idDecl) {
70 decl = idDecl;
71 }
72 }
73 return decl;
74}
75
76}
77

Callers 1

doShowDocumentationMethod · 0.85

Calls 6

targetTypeKeepAliasesFunction · 0.85
kindMethod · 0.45
abstractTypeMethod · 0.45
topContextMethod · 0.45
dataMethod · 0.45
declarationMethod · 0.45

Tested by

no test coverage detected