| 429 | } |
| 430 | |
| 431 | void Declaration::setInternalContext(DUContext* context) |
| 432 | { |
| 433 | if (this->context()) { |
| 434 | ENSURE_CAN_WRITE |
| 435 | } |
| 436 | DUCHAIN_D_DYNAMIC(Declaration); |
| 437 | |
| 438 | if (context == d->m_internalContext.context()) |
| 439 | return; |
| 440 | |
| 441 | if (!m_topContext) { |
| 442 | //Take the top-context from the other side. We need to allocate an index, so we can safely call setOwner(..) |
| 443 | m_topContext = context->topContext(); |
| 444 | allocateOwnIndex(); |
| 445 | } |
| 446 | |
| 447 | DUContext* oldInternalContext = d->m_internalContext.context(); |
| 448 | |
| 449 | d->m_internalContext = context; |
| 450 | |
| 451 | //Q_ASSERT( !oldInternalContext || oldInternalContext->owner() == this ); |
| 452 | if (oldInternalContext && oldInternalContext->owner() == this) |
| 453 | oldInternalContext->setOwner(nullptr); |
| 454 | |
| 455 | if (context) |
| 456 | context->setOwner(this); |
| 457 | } |
| 458 | |
| 459 | bool Declaration::operator ==(const Declaration& other) const |
| 460 | { |
| 461 | ENSURE_CAN_READ |
| 462 | |
| 463 | return this == &other; |
| 464 | } |
| 465 | |
| 466 | QString Declaration::toString() const |
| 467 | { |
| 468 | return QStringLiteral("%3 %4").arg(abstractType() ? abstractType()->toString() : QStringLiteral( |
| 469 | "<notype>"), identifier().toString()); |
| 470 | } |
| 471 | |
| 472 | bool Declaration::isDefinition() const |
| 473 | { |
| 474 | ENSURE_CAN_READ |
| 475 | DUCHAIN_D(Declaration); |
| 476 | |
| 477 | return d->m_isDefinition; |
| 478 | } |
| 479 | |
| 480 | void Declaration::setDeclarationIsDefinition(bool dd) |
| 481 | { |
| 482 | ENSURE_CAN_WRITE |
| 483 | DUCHAIN_D_DYNAMIC(Declaration); |
| 484 | d->m_isDefinition = dd; |
| 485 | } |
| 486 | |
| 487 | bool Declaration::isAutoDeclaration() const |
| 488 | { |
no test coverage detected