Changeset View
Changeset View
Standalone View
Standalone View
duchain/builders/typebuilder.cpp
Show First 20 Lines • Show All 497 Lines • ▼ Show 20 Line(s) | 493 | if (foreachNode) { | |||
---|---|---|---|---|---|
498 | bool foundType = false; | 498 | bool foundType = false; | ||
499 | if (StructureType::Ptr type = StructureType::Ptr::dynamicCast(v.result().type())) { | 499 | if (StructureType::Ptr type = StructureType::Ptr::dynamicCast(v.result().type())) { | ||
500 | ClassDeclaration *classDec = dynamic_cast<ClassDeclaration*>(type->declaration(currentContext()->topContext())); | 500 | ClassDeclaration *classDec = dynamic_cast<ClassDeclaration*>(type->declaration(currentContext()->topContext())); | ||
501 | if (!classDec) { | 501 | if (!classDec) { | ||
502 | ///FIXME: this is just a hack for https://bugs.kde.org/show_bug.cgi?id=269369 | 502 | ///FIXME: this is just a hack for https://bugs.kde.org/show_bug.cgi?id=269369 | ||
503 | /// a proper fix needs full fledged two-pass, i.e. get rid of PreDeclarationBuilder | 503 | /// a proper fix needs full fledged two-pass, i.e. get rid of PreDeclarationBuilder | ||
504 | // 0 == global lookup and the delcaration is found again... | 504 | // 0 == global lookup and the delcaration is found again... | ||
505 | classDec = dynamic_cast<ClassDeclaration*>(type->declaration(nullptr)); | 505 | classDec = dynamic_cast<ClassDeclaration*>(type->declaration(nullptr)); | ||
506 | } | 506 | } | ||
zhigalin: Actually this performs a rescan using `CursorInRevision::invalid` | |||||
507 | if (classDec) { | 507 | if (classDec) { | ||
508 | /// Qualified identifier for 'iterator' | 508 | /// Qualified identifier for 'iterator' | ||
509 | static const QualifiedIdentifier iteratorQId(QStringLiteral("iterator")); | 509 | static const QualifiedIdentifier iteratorQId(QStringLiteral("iterator")); | ||
510 | ClassDeclaration* iteratorDecl = dynamic_cast<ClassDeclaration*>( | 510 | ClassDeclaration* iteratorDecl = dynamic_cast<ClassDeclaration*>( | ||
511 | findDeclarationImport(ClassDeclarationType, iteratorQId).data() | 511 | findDeclarationImport(ClassDeclarationType, iteratorQId).data() | ||
512 | ); | 512 | ); | ||
513 | Q_ASSERT(iteratorDecl); | 513 | Q_ASSERT(iteratorDecl); | ||
514 | if (classDec->isPublicBaseClass(iteratorDecl, currentContext()->topContext())) { | 514 | if (classDec->isPublicBaseClass(iteratorDecl, currentContext()->topContext())) { | ||
515 | /// Qualified identifier for 'current' | 515 | /// Qualified identifier for 'current' | ||
516 | static const QualifiedIdentifier currentQId(QStringLiteral("current")); | 516 | static const QualifiedIdentifier currentQId(QStringLiteral("current")); | ||
517 | foreach (Declaration *d, classDec->internalContext()->findDeclarations(currentQId)) { | 517 | auto classContext = classDec->internalContext(); | ||
518 | if (classContext) { | ||||
519 | foreach (Declaration *d, classContext->findDeclarations(currentQId)) { | ||||
518 | if (!dynamic_cast<ClassMethodDeclaration*>(d)) continue; | 520 | if (!dynamic_cast<ClassMethodDeclaration*>(d)) continue; | ||
519 | Q_ASSERT(d->type<FunctionType>()); | 521 | Q_ASSERT(d->type<FunctionType>()); | ||
520 | injectType(d->type<FunctionType>()->returnType()); | 522 | injectType(d->type<FunctionType>()->returnType()); | ||
521 | foundType = true; | 523 | foundType = true; | ||
522 | // qCDebug(DUCHAIN) << "that's it: " << d->type<FunctionType>()->returnType()->toString(); | 524 | // qCDebug(DUCHAIN) << "that's it: " << d->type<FunctionType>()->returnType()->toString(); | ||
523 | } | 525 | } | ||
524 | } | 526 | } | ||
525 | } | 527 | } | ||
526 | } | 528 | } | ||
529 | } | ||||
527 | if (!foundType) { | 530 | if (!foundType) { | ||
528 | injectType(AbstractType::Ptr(new IntegralType(IntegralType::TypeMixed))); | 531 | injectType(AbstractType::Ptr(new IntegralType(IntegralType::TypeMixed))); | ||
529 | } | 532 | } | ||
530 | } | 533 | } | ||
531 | } | 534 | } | ||
532 | 535 | | |||
533 | void TypeBuilder::visitCatchItem(Php::CatchItemAst *node) | 536 | void TypeBuilder::visitCatchItem(Php::CatchItemAst *node) | ||
534 | { | 537 | { | ||
Show All 17 Lines |
Actually this performs a rescan using CursorInRevision::invalid