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

Method addChildContext

kdevplatform/language/duchain/ducontext.cpp:245–282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

243}
244
245void DUContextDynamicData::addChildContext(DUContext* context)
246{
247 // Internal, don't need to assert a lock
248 Q_ASSERT(!context->m_dynamicData->m_parentContext
249 || context->m_dynamicData->m_parentContext.data()->m_dynamicData == this);
250
251 LocalIndexedDUContext indexed(context->m_dynamicData->m_indexInTopContext);
252
253 //If this context is temporary, added declarations should be as well, and viceversa
254 Q_ASSERT(isContextTemporary(m_indexInTopContext) == isContextTemporary(indexed.localIndex()));
255
256 bool inserted = false;
257
258 int childCount = m_childContexts.size();
259
260 for (int i = childCount - 1; i >= 0; --i) {///@todo Do binary search to find the position
261 DUContext* child = m_childContexts[i];
262 Q_ASSERT(d_func_dynamic()->m_childContexts()[i] == LocalIndexedDUContext(child));
263 if (context == child)
264 return;
265 if (context->range().start >= child->range().start) {
266 m_childContexts.insert(i + 1, context);
267 d_func_dynamic()->m_childContextsList().insert(i + 1, indexed);
268 context->m_dynamicData->m_parentContext = m_context;
269 inserted = true;
270 break;
271 }
272 }
273
274 if (!inserted) {
275 m_childContexts.insert(0, context);
276
277 auto& childContexts = d_func_dynamic()->m_childContextsList();
278 childContexts.insert(childContexts.begin(), indexed);
279
280 context->m_dynamicData->m_parentContext = m_context;
281 }
282}
283
284bool DUContextDynamicData::removeChildContext(DUContext* context)
285{

Callers 1

DUContextMethod · 0.80

Calls 6

isContextTemporaryFunction · 0.85
dataMethod · 0.45
sizeMethod · 0.45
rangeMethod · 0.45
insertMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected