| 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) |
no test coverage detected