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

Method declarations

kdevplatform/language/duchain/declarationid.cpp:85–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83}
84
85KDevVarLengthArray<Declaration*> DeclarationId::declarations(const TopDUContext* top) const
86{
87 KDevVarLengthArray<Declaration*> ret;
88
89 if (m_isDirect == false) {
90 //Find the declaration by its qualified identifier and additionalIdentity
91 const auto& id = m_indirectData.identifier;
92
93 auto visitDeclaration = [&](const IndexedDeclaration& indexedDecl) {
94 auto decl = indexedDecl.data();
95 if (decl && m_indirectData.additionalIdentity == decl->additionalIdentity()) {
96 // Hit
97 ret.append(decl);
98 }
99 return PersistentSymbolTable::VisitorState::Continue;
100 };
101
102 if (top) {
103 //Do filtering
104 PersistentSymbolTable::self().visitFilteredDeclarations(id, top->recursiveImportIndices(),
105 visitDeclaration);
106 } else {
107 //Just accept anything
108 PersistentSymbolTable::self().visitDeclarations(id, [&](const IndexedDeclaration& indexedDecl) {
109 ///@todo think this over once we don't pull in all imported top-context any more
110 //Don't trigger loading of top-contexts from here, it will create a lot of problems
111 if (DUChain::self()->isInMemory(indexedDecl.topContextIndex())) {
112 return visitDeclaration(indexedDecl);
113 }
114 return PersistentSymbolTable::VisitorState::Continue;
115 });
116 }
117 } else {
118 Declaration* decl = m_directData.declaration();
119 if (decl)
120 ret.append(decl);
121 }
122
123 if (!ret.isEmpty() && m_specialization.index()) {
124 KDevVarLengthArray<Declaration*> newRet;
125 for (Declaration* decl : std::as_const(ret)) {
126 Declaration* specialized = decl->specialize(m_specialization, top ? top : decl->topContext());
127 if (specialized)
128 newRet.append(specialized);
129 }
130
131 return newRet;
132 }
133 return ret;
134}
135
136Declaration* DeclarationId::declaration(const TopDUContext* top, bool instantiateIfRequired) const
137{

Callers 6

declarationMethod · 0.45
addDeclarationMethod · 0.45
removeDeclarationMethod · 0.45
visitDeclarationsMethod · 0.45
operator()Method · 0.45

Calls 11

visitDeclarationsMethod · 0.80
isInMemoryMethod · 0.80
dataMethod · 0.45
additionalIdentityMethod · 0.45
appendMethod · 0.45
declarationMethod · 0.45
isEmptyMethod · 0.45
indexMethod · 0.45
specializeMethod · 0.45
topContextMethod · 0.45

Tested by

no test coverage detected