Changeset View
Changeset View
Standalone View
Standalone View
duchain/expressionvisitor.cpp
Context not available. | |||||
31 | #include <language/duchain/types/functiontype.h> | 31 | #include <language/duchain/types/functiontype.h> | ||
---|---|---|---|---|---|
32 | #include <language/duchain/types/integraltype.h> | 32 | #include <language/duchain/types/integraltype.h> | ||
33 | #include <language/duchain/types/structuretype.h> | 33 | #include <language/duchain/types/structuretype.h> | ||
34 | #include <language/duchain/types/unsuretype.h> | ||||
34 | 35 | | |||
35 | #include "duchaindebug.h" | 36 | #include "duchaindebug.h" | ||
36 | 37 | | |||
Context not available. | |||||
547 | if (node->objectProperty && node->objectProperty->objectDimList) { | 548 | if (node->objectProperty && node->objectProperty->objectDimList) { | ||
548 | //handle $foo->bar() and $foo->baz, $foo is m_result.type() | 549 | //handle $foo->bar() and $foo->baz, $foo is m_result.type() | ||
549 | 550 | | |||
550 | if (m_result.type() && StructureType::Ptr::dynamicCast(m_result.type())) { | 551 | AbstractType::Ptr type = m_result.type(); | ||
552 | | ||||
553 | //If the variable type is unsure, try to see if it contains a StructureType. If so, use that | ||||
554 | // (since the other types do not allow accessing properties) | ||||
555 | if (type && type.cast<UnsureType>()) { | ||||
556 | UnsureType::Ptr unsureType = type.cast<UnsureType>(); | ||||
557 | int numStructureType = 0; | ||||
558 | StructureType::Ptr structureType; | ||||
559 | | ||||
560 | for (unsigned int i = 0; i<unsureType->typesSize(); ++i) { | ||||
561 | StructureType::Ptr subType = unsureType->types()[i].type<StructureType>(); | ||||
562 | if (subType) { | ||||
563 | structureType = subType; | ||||
564 | ++numStructureType; | ||||
565 | } | ||||
566 | } | ||||
567 | | ||||
568 | //Only use the found structureType if there's exactly *one* such type | ||||
569 | if (numStructureType == 1) { | ||||
570 | Q_ASSERT(structureType); | ||||
571 | type = AbstractType::Ptr(structureType); | ||||
572 | } | ||||
573 | } | ||||
574 | | ||||
575 | if (type && StructureType::Ptr::dynamicCast(type)) { | ||||
551 | DUChainReadLocker lock(DUChain::lock()); | 576 | DUChainReadLocker lock(DUChain::lock()); | ||
552 | Declaration* declaration = StructureType::Ptr::staticCast(m_result.type())->declaration(m_currentContext->topContext()); | 577 | Declaration* declaration = StructureType::Ptr::staticCast(type)->declaration(m_currentContext->topContext()); | ||
553 | if (declaration) { | 578 | if (declaration) { | ||
554 | ifDebug(qCDebug(DUCHAIN) << "parent:" << declaration->toString();) | 579 | ifDebug(qCDebug(DUCHAIN) << "parent:" << declaration->toString();) | ||
555 | DUContext* context = declaration->internalContext(); | 580 | DUContext* context = declaration->internalContext(); | ||
Context not available. |