Changeset View
Changeset View
Standalone View
Standalone View
duchain/builders/typebuilder.cpp
Show All 23 Lines | |||||
24 | #include <language/duchain/duchain.h> | 24 | #include <language/duchain/duchain.h> | ||
25 | #include <language/duchain/duchainlock.h> | 25 | #include <language/duchain/duchainlock.h> | ||
26 | #include <language/duchain/ducontext.h> | 26 | #include <language/duchain/ducontext.h> | ||
27 | #include <language/duchain/declaration.h> | 27 | #include <language/duchain/declaration.h> | ||
28 | #include <language/duchain/types/integraltype.h> | 28 | #include <language/duchain/types/integraltype.h> | ||
29 | #include "../declarations/classdeclaration.h" | 29 | #include "../declarations/classdeclaration.h" | ||
30 | #include "../types/integraltypeextended.h" | 30 | #include "../types/integraltypeextended.h" | ||
31 | #include "../types/structuretype.h" | 31 | #include "../types/structuretype.h" | ||
32 | #include "../duchaindebug.h" | 32 | #include <duchaindebug.h> | ||
33 | 33 | | |||
34 | #include "editorintegrator.h" | 34 | #include "editorintegrator.h" | ||
35 | #include "parsesession.h" | 35 | #include "parsesession.h" | ||
36 | #include "phpdebugvisitor.h" | 36 | #include "phpdebugvisitor.h" | ||
37 | #include "expressionparser.h" | 37 | #include "expressionparser.h" | ||
38 | #include "expressionvisitor.h" | 38 | #include "expressionvisitor.h" | ||
39 | #include "../declarations/classmethoddeclaration.h" | 39 | #include "../declarations/classmethoddeclaration.h" | ||
40 | #include <language/duchain/types/unsuretype.h> | 40 | #include <language/duchain/types/unsuretype.h> | ||
▲ Show 20 Lines • Show All 311 Lines • ▼ Show 20 Line(s) | 351 | } else { | |||
352 | currentAbstractType()->setModifiers(currentAbstractType()->modifiers() & AbstractType::ConstModifier); | 352 | currentAbstractType()->setModifiers(currentAbstractType()->modifiers() & AbstractType::ConstModifier); | ||
353 | TypeBuilderBase::visitConstantDeclaration(node); | 353 | TypeBuilderBase::visitConstantDeclaration(node); | ||
354 | } | 354 | } | ||
355 | } | 355 | } | ||
356 | 356 | | |||
357 | void TypeBuilder::visitParameter(ParameterAst *node) | 357 | void TypeBuilder::visitParameter(ParameterAst *node) | ||
358 | { | 358 | { | ||
359 | AbstractType::Ptr type; | 359 | AbstractType::Ptr type; | ||
360 | if (node->parameterType) { | 360 | if (node->isVariadic != -1) { | ||
361 | type = AbstractType::Ptr(new IntegralType(IntegralType::TypeArray)); | ||||
362 | } else if (node->parameterType) { | ||||
361 | //don't use openTypeFromName as it uses cursor for findDeclarations | 363 | //don't use openTypeFromName as it uses cursor for findDeclarations | ||
362 | DeclarationPointer decl = findDeclarationImport(ClassDeclarationType, | 364 | DeclarationPointer decl = findDeclarationImport(ClassDeclarationType, | ||
363 | identifierForNamespace(node->parameterType, editor())); | 365 | identifierForNamespace(node->parameterType, editor())); | ||
364 | if (decl) { | 366 | if (decl) { | ||
365 | type = decl->abstractType(); | 367 | type = decl->abstractType(); | ||
366 | } | 368 | } | ||
367 | } else if (node->arrayType != -1) { | 369 | } else if (node->arrayType != -1) { | ||
368 | type = AbstractType::Ptr(new IntegralType(IntegralType::TypeArray)); | 370 | type = AbstractType::Ptr(new IntegralType(IntegralType::TypeArray)); | ||
▲ Show 20 Lines • Show All 134 Lines • ▼ Show 20 Line(s) | 475 | if (ft->returnType() && !ft->returnType()->equals(type.data())) { | |||
503 | } | 505 | } | ||
504 | } else { | 506 | } else { | ||
505 | ft->setReturnType(type); | 507 | ft->setReturnType(type); | ||
506 | } | 508 | } | ||
507 | updateCurrentType(); | 509 | updateCurrentType(); | ||
508 | } | 510 | } | ||
509 | } | 511 | } | ||
510 | 512 | | |||
511 | AstNode *foreachNode = 0; | 513 | AstNode *foreachNode = nullptr; | ||
512 | if (node->foreachVar) { | 514 | if (node->foreachVar) { | ||
513 | foreachNode = node->foreachVar; | 515 | foreachNode = node->foreachVar; | ||
514 | } else if (node->foreachExpr) { | 516 | } else if (node->foreachExpr) { | ||
515 | foreachNode = node->foreachExpr; | 517 | foreachNode = node->foreachExpr; | ||
516 | } else if (node->foreachExprAsVar) { | 518 | } else if (node->foreachExprAsVar) { | ||
517 | foreachNode = node->foreachExprAsVar; | 519 | foreachNode = node->foreachExprAsVar; | ||
518 | } | 520 | } | ||
519 | if (foreachNode) { | 521 | if (foreachNode) { | ||
520 | ExpressionVisitor v(editor()); | 522 | ExpressionVisitor v(editor()); | ||
521 | foreachNode->ducontext = currentContext(); | 523 | foreachNode->ducontext = currentContext(); | ||
522 | v.visitNode(foreachNode); | 524 | v.visitNode(foreachNode); | ||
523 | DUChainReadLocker lock(DUChain::lock()); | 525 | DUChainReadLocker lock(DUChain::lock()); | ||
524 | bool foundType = false; | 526 | bool foundType = false; | ||
525 | if (StructureType::Ptr type = StructureType::Ptr::dynamicCast(v.result().type())) { | 527 | if (StructureType::Ptr type = StructureType::Ptr::dynamicCast(v.result().type())) { | ||
526 | ClassDeclaration *classDec = dynamic_cast<ClassDeclaration*>(type->declaration(currentContext()->topContext())); | 528 | ClassDeclaration *classDec = dynamic_cast<ClassDeclaration*>(type->declaration(currentContext()->topContext())); | ||
527 | if (!classDec) { | 529 | if (!classDec) { | ||
528 | ///FIXME: this is just a hack for https://bugs.kde.org/show_bug.cgi?id=269369 | 530 | ///FIXME: this is just a hack for https://bugs.kde.org/show_bug.cgi?id=269369 | ||
529 | /// a proper fix needs full fledged two-pass, i.e. get rid of PreDeclarationBuilder | 531 | /// a proper fix needs full fledged two-pass, i.e. get rid of PreDeclarationBuilder | ||
530 | // 0 == global lookup and the delcaration is found again... | 532 | // 0 == global lookup and the delcaration is found again... | ||
531 | classDec = dynamic_cast<ClassDeclaration*>(type->declaration(0)); | 533 | classDec = dynamic_cast<ClassDeclaration*>(type->declaration(nullptr)); | ||
532 | } | 534 | } | ||
533 | if (classDec) { | 535 | if (classDec) { | ||
534 | /// Qualified identifier for 'iterator' | 536 | /// Qualified identifier for 'iterator' | ||
535 | static const QualifiedIdentifier iteratorQId(QStringLiteral("iterator")); | 537 | static const QualifiedIdentifier iteratorQId(QStringLiteral("iterator")); | ||
536 | ClassDeclaration* iteratorDecl = dynamic_cast<ClassDeclaration*>( | 538 | ClassDeclaration* iteratorDecl = dynamic_cast<ClassDeclaration*>( | ||
537 | findDeclarationImport(ClassDeclarationType, iteratorQId).data() | 539 | findDeclarationImport(ClassDeclarationType, iteratorQId).data() | ||
538 | ); | 540 | ); | ||
539 | Q_ASSERT(iteratorDecl); | 541 | Q_ASSERT(iteratorDecl); | ||
Show All 38 Lines |