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

Method documentationForDeclaration

plugins/qthelp/qthelpproviderabstract.cpp:84–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82}
83
84IDocumentation::Ptr QtHelpProviderAbstract::documentationForDeclaration(Declaration* dec) const
85{
86 if (dec) {
87 static const IndexedString qmlJs("QML/JS");
88 QString id;
89 QString fallbackId;
90
91 {
92 DUChainReadLocker lock;
93 const auto qualifiedId = dec->qualifiedIdentifier();
94
95 id = qualifiedId.toString(RemoveTemplateInformation);
96 if (dec->topContext()->parsingEnvironmentFile()->language() == qmlJs && !id.isEmpty())
97 id = QLatin1String("QML.") + id;
98
99 // for enumerators we might need to remove the enum, i.e. look for Qt::black instead of Qt::GlobalColor::black
100 // for enumerators in an `enum class` this removal is not appropriate, so only do that as a fallback
101 const auto qualifiedIdCount = qualifiedId.count();
102 if (qualifiedIdCount > 1 && dec->type<EnumeratorType>()) {
103 const auto enumeratorId = qualifiedId.at(qualifiedIdCount - 1).toString(RemoveTemplateInformation);
104 const auto enumId = qualifiedId.at(qualifiedIdCount - 2).toString(RemoveTemplateInformation);
105 fallbackId = id;
106 fallbackId.replace(enumId + QLatin1String("::") + enumeratorId, enumeratorId);
107 }
108 }
109
110 for (const auto& identifier : {id, fallbackId}) {
111 if (!identifier.isEmpty()) {
112 const QList<QHelpLink> links = m_engine.documentsForIdentifier(identifier);
113 if (!links.isEmpty()) {
114 return IDocumentation::Ptr(
115 new QtHelpDocumentation(const_cast<QtHelpProviderAbstract*>(this), id, links));
116 }
117 }
118 }
119 }
120
121 return {};
122}
123
124KDevelop::IDocumentation::Ptr QtHelpProviderAbstract::documentation(const QUrl& url) const
125{

Callers 1

Calls 9

qualifiedIdentifierMethod · 0.45
toStringMethod · 0.45
languageMethod · 0.45
topContextMethod · 0.45
isEmptyMethod · 0.45
countMethod · 0.45
atMethod · 0.45
replaceMethod · 0.45

Tested by 1