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

Method createContext

plugins/clang/duchain/builder.cpp:471–509  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

469
470 template<CXCursorKind CK, DUContext::ContextType Type>
471 DUContext* createContext(CXCursor cursor, const QualifiedIdentifier& scopeId = {})
472 {
473 // wtf: why is the DUContext API requesting a QID when it needs a plain Id?!
474 // see: testNamespace
475 auto range = ClangRange(clang_getCursorExtent(cursor)).toRangeInRevision();
476 DUChainWriteLocker lock;
477 if (m_update) {
478 const IndexedQualifiedIdentifier indexedScopeId(scopeId);
479 auto it = m_parentContext->previousChildContexts.begin();
480 while (it != m_parentContext->previousChildContexts.end()) {
481 auto ctx = *it;
482 if (ctx->type() == Type && ctx->indexedLocalScopeIdentifier() == indexedScopeId) {
483 ctx->setRange(range);
484 m_parentContext->resortChildContexts = true;
485 m_parentContext->previousChildContexts.erase(it);
486 return ctx;
487 }
488 ++it;
489 }
490 }
491 //TODO: (..type, id..) constructor for DUContext?
492 auto context = new ClangNormalDUContext(range, m_parentContext->context);
493 context->setType(Type);
494 context->setLocalScopeIdentifier(scopeId);
495 if (Type == DUContext::Other || Type == DUContext::Function)
496 context->setInSymbolTable(false);
497
498 if (CK == CXCursor_CXXMethod) {
499 CXCursor semParent = clang_getCursorSemanticParent(cursor);
500 // only import the semantic parent if it differs from the lexical parent
501 if (!clang_Cursor_isNull(semParent) && !clang_equalCursors(semParent, clang_getCursorLexicalParent(cursor))) {
502 auto semParentDecl = findDeclaration(semParent);
503 if (semParentDecl) {
504 contextImportDecl(context, semParentDecl);
505 }
506 }
507 }
508 return context;
509 }
510
511 template<CXTypeKind TK, EnableIf<CursorKindTraits::integralType(TK) != IntegralType::TypeNotIntegralType> = dummy>
512 AbstractType *createType(CXType, CXCursor)

Callers 1

vm.jsFile · 0.80

Calls 11

findDeclarationFunction · 0.85
contextImportDeclFunction · 0.85
toRangeInRevisionMethod · 0.80
setRangeMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
typeMethod · 0.45
setTypeMethod · 0.45
setInSymbolTableMethod · 0.45

Tested by

no test coverage detected