From kde-commits Wed Jan 28 23:56:32 2009 From: Aleix Pol Gonzalez Date: Wed, 28 Jan 2009 23:56:32 +0000 To: kde-commits Subject: KDE/kdevelop/plugins/managers/cmake Message-Id: <1233186992.560225.1914.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=123318700630259 SVN commit 918025 by apol: Fix variable resolution when many variables are in the same argument. M +13 -6 parser/cmakeprojectvisitor.cpp M +1 -1 parser/cmakeprojectvisitor.h M +2 -0 tests/cmake_cmakeprojectvisitor_test.cpp --- trunk/KDE/kdevelop/plugins/managers/cmake/parser/cmakeprojectvisitor.cpp #918024:918025 @@ -144,16 +144,19 @@ return var.mid(0, dollar)+value+var.mid(dollar+id.size(), var.size()-(dollar+id.size())); } -QStringList CMakeProjectVisitor::value(const QString& exp, const QList& poss, int desired) const +QStringList CMakeProjectVisitor::value(const QString& exp, const QList& poss, int& desired) const { QString var=exp; QList invars; invars += poss[desired]; + qDebug() << ">>>>>" << exp << desired << poss.count(); for(; desired+11; desired++) { invars+=poss[desired+1]; + qDebug() << "poss@"<< desired+1 << "="<< poss[desired+1].print(); } + qDebug() << ";;;;;" << invars.count(); if(invars.count()>1) { QList::const_iterator itConstEnd=invars.constEnd(); @@ -187,7 +190,7 @@ int i=0; IntPair last(-1,-1, 0); - for(QList::const_iterator it=var.constBegin(); it!=var.constEnd(); ++it) + for(QList::const_iterator it=var.constBegin(); it!=var.constEnd(); ++it, ++i) { while(it!=var.constEnd() && it->level>1) ++it; @@ -198,7 +201,7 @@ QString pre=exp.value.mid(last.second+1, dollar-last.second-1); QStringList vars = value(exp.value, var, i); -// qDebug() << "aaaaaaaaaA" << vars; +// qDebug() << "aaaaaaaaaA" << pre << vars; if(!vars.isEmpty()) { @@ -207,7 +210,9 @@ ret.last()+=pre; ret += vars; last=p; - i++; + +// qDebug() << "yaaaaaaa" << ret; +// i++; } ret.last().append(exp.value.mid(last.second+1, exp.value.count()-last.second)); @@ -844,6 +849,7 @@ SimpleRange sr=def.arguments.first().range(); SimpleRange endsr=end.arguments.first().range(); int idx; + if(!decls.isEmpty()) { idx=m_topctx->indexForUsedDeclaration(decls.first()); @@ -863,6 +869,7 @@ } d->setAbstractType( AbstractType::Ptr(func) ); idx=m_topctx->indexForUsedDeclaration(d); + qDebug() << "creating macro decl: " << m_topctx << m_topctx->localDeclarations(); } m_topctx->createUse(idx, endsr, 0); } @@ -1874,10 +1881,10 @@ element = new MacroCallAst; createUses(*it); - kDebug(9042) << "resolving:" << it->writeBack(); +// kDebug(9042) << "resolving:" << it->writeBack(); CMakeFunctionDesc func = resolveVariables(*it); //FIXME not correct in while case bool correct = element->parseFunctionInfo(func); - kDebug(9042) << "resolved:" << func.writeBack() << correct; +// kDebug(9042) << "resolved:" << func.writeBack() << correct; if(!correct) { kDebug(9042) << "error! found an error while processing" << func.writeBack() << "was" << it->writeBack() << endl --- trunk/KDE/kdevelop/plugins/managers/cmake/parser/cmakeprojectvisitor.h #918024:918025 @@ -160,7 +160,7 @@ void macroDeclaration(const CMakeFunctionDesc& def, const CMakeFunctionDesc& end, const QStringList& args); CMakeFunctionDesc resolveVariables(const CMakeFunctionDesc &exp); - QStringList value(const QString& exp, const QList& poss, int desired) const; + QStringList value(const QString& exp, const QList& poss, int& desired) const; QStringList theValue(const QString& exp, const IntPair& p) const; typedef QMap TargetProperties; --- trunk/KDE/kdevelop/plugins/managers/cmake/tests/cmake_cmakeprojectvisitor_test.cpp #918024:918025 @@ -305,6 +305,8 @@ "set(aaa ca)\n" "set(aab co)\n" "set(b a)\n" +// "message(STATUS \"${aaa}${aab} should be caco\")\n" +// "message(STATUS \"${a${b}a}${a${b}b} should be caco\")\n" "if(\"${a${b}a}${a${b}b}\" STREQUAL caco )\n" " set(GOOD TRUE)\n" "endif()\n"