diff --git a/NEWS.md b/NEWS.md index 82bbedba..f522bab5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -15,6 +15,7 @@ Red Panda C++ Version 3.1 - fix: Mingw32-make doesn't work correctly if there are bash in the path. - fix: All color scheme names are incorrectly displayed as bold, if the current one is a customed one. - fix: Variables defined by using alias can't show completion info. + - enhancement: Support operator() overload. Red Panda C++ Version 3.0 diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index 84bea986..66da1f92 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -5127,6 +5127,24 @@ PEvalStatement CppParser::doEvalMemberAccess(const QString &fileName, // if (result->effectiveTypeStatement) // qDebug()<<"typeStatement"<effectiveTypeStatement->fullName; result->kind = EvalStatementKind::Variable; + } else if(result->kind == EvalStatementKind::Variable + && result->effectiveTypeStatement + && result->effectiveTypeStatement->kind == StatementKind::Class) { + //overload of operator () + const StatementMap& statementMap = mStatementList.childrenStatements(result->effectiveTypeStatement); + if (statementMap.isEmpty()) + result = PEvalStatement(); + else { + PStatement operStatement = statementMap.value("operator()"); + if (operStatement) { + doSkipInExpression(phraseExpression,pos,"(",")"); + PEvalStatement temp = doCreateEvalFunction(fileName,operStatement); + result->effectiveTypeStatement = temp->effectiveTypeStatement; + result->kind = EvalStatementKind::Variable; + } else { + result = PEvalStatement(); + } + } } else { result = PEvalStatement(); }