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

Method declaration

kdevplatform/language/duchain/declarationid.cpp:136–190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134}
135
136Declaration* DeclarationId::declaration(const TopDUContext* top, bool instantiateIfRequired) const
137{
138 Declaration* ret = nullptr;
139
140 if (m_isDirect == false) {
141 //Find the declaration by its qualified identifier and additionalIdentity
142 const auto& id = m_indirectData.identifier;
143
144 auto visitDeclaration = [&](const IndexedDeclaration& indexedDecl) {
145 auto decl = indexedDecl.data();
146 if (decl && m_indirectData.additionalIdentity == decl->additionalIdentity()) {
147 // Hit
148 ret = decl;
149 if (!ret->isForwardDeclaration()) {
150 return PersistentSymbolTable::VisitorState::Break;
151 }
152 }
153 return PersistentSymbolTable::VisitorState::Continue;
154 };
155
156 if (top) {
157 // Do filtering
158 PersistentSymbolTable::self().visitFilteredDeclarations(id, top->recursiveImportIndices(),
159 visitDeclaration);
160 } else {
161 //Just accept anything
162 PersistentSymbolTable::self().visitDeclarations(id, [&](const IndexedDeclaration& indexedDecl) {
163 ///@todo think this over once we don't pull in all imported top-context any more
164 //Don't trigger loading of top-contexts from here, it will create a lot of problems
165 if (DUChain::self()->isInMemory(indexedDecl.topContextIndex())) {
166 return visitDeclaration(indexedDecl);
167 }
168 return PersistentSymbolTable::VisitorState::Continue;
169 });
170 }
171 } else {
172 //Find the declaration by m_topContext and m_declaration
173 ret = m_directData.declaration();
174 }
175
176 if (ret) {
177 if (m_specialization.isValid()) {
178 const TopDUContext* topContextForSpecialization = top;
179 if (!instantiateIfRequired)
180 topContextForSpecialization = nullptr; //If we don't want to instantiate new declarations, set the top-context to zero, so specialize(..) will only look-up
181 else if (!topContextForSpecialization)
182 topContextForSpecialization = ret->topContext();
183
184 return ret->specialize(m_specialization, topContextForSpecialization);
185 } else {
186 return ret;
187 }
188 } else
189 return nullptr;
190}
191
192QualifiedIdentifier DeclarationId::qualifiedIdentifier() const
193{

Callers 15

declarationsMethod · 0.45
resolveMethod · 0.45
addDeclarationMethod · 0.45
operator()Method · 0.45
FOREACH_FUNCTIONFunction · 0.45
toStringMethod · 0.45
~DUContextMethod · 0.45
setOwnerMethod · 0.45
checkMethod · 0.45

Calls 9

visitDeclarationsMethod · 0.80
isInMemoryMethod · 0.80
dataMethod · 0.45
additionalIdentityMethod · 0.45
isForwardDeclarationMethod · 0.45
isValidMethod · 0.45
topContextMethod · 0.45
specializeMethod · 0.45

Tested by 1

DeclarationTestFunction · 0.36