diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index 0fe09911..50b050c5 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -338,7 +338,6 @@ PStatement CppParser::findStatementOf(const QString &fileName, const QString &ph if (!statement) return PStatement(); } - qDebug()<<"-----"; PStatement lastScopeStatement; QString typeName; PStatement typeStatement; @@ -404,6 +403,18 @@ PStatement CppParser::findStatementOf(const QString &fileName, const QString &ph return statement; } +PStatement CppParser::findStatement( + const QString &fileName, + const QStringList &phraseExpression, + const PStatement ¤tScope) +{ + QMutexLocker locker(&mMutex); + if (mParsing) + return PStatement(); + int pos = 0; + return doFindStatement(fileName,phraseExpression,pos,currentScope,PStatement()); +} + PStatement CppParser::findStatementOf(const QString &fileName, const QString &phrase, const PStatement& currentClass, bool force) { PStatement statementParentType; @@ -3345,6 +3356,66 @@ PStatement CppParser::findStatementInNamespace(const QString &name, const QStrin return PStatement(); } +PStatement CppParser::doParseSubExpression3(const QString &fileName, + const QStringList &phraseExpression, + int &pos, + const PStatement ¤tScope, + const PStatement &ownerStatement) +{ + if (pos>=phraseExpression.length()) + return PStatement(); + if (phraseExpression[pos]=="*") { + pos++; + return doParseSubExpression3(fileName, + phraseExpression, + pos, + currentScope, + ownerStatement); + } else if (phraseExpression[pos]=="&") { + pos++; + return doParseSubExpression3(fileName, + phraseExpression, + pos, + currentScope, + ownerStatement); + } + return doParseSubExpression2(fileName, + phraseExpression, + pos, + currentScope, + ownerStatement); +} + +PStatement CppParser::doFindStatement(const QString &fileName, + const QStringList &phraseExpression, + int& pos, + const PStatement ¤tScope, + const PStatement &ownerStatement) +{ + if (pos>=phraseExpression.length()) + return PStatement(); + //find the start scope statement + PStatement currentStatement = doParseSubExpression3(fileName,phraseExpression,pos,currentScope, ownerStatement); + while (pos < phraseExpression.length() ) { + if (currentStatement && + (currentStatement->kind == StatementKind::skVariable + || currentStatement->kind == StatementKind::skFunction) + && (phraseExpression[pos]==".*" + || phraseExpression[pos]=="->*")) { + pos++; // skip '::'; + PStatement currentStatementScope = findTypeDefinitionOf( + fileName, + currentStatement->type, + currentStatement->parentScope.lock()); + currentStatement = doParseSubExpression3(fileName,phraseExpression,pos,currentScope, currentStatementScope); + + } else { + break; + } + } + return currentStatement; +} + int CppParser::getBracketEnd(const QString &s, int startAt) { int i = startAt; diff --git a/RedPandaIDE/parser/cppparser.h b/RedPandaIDE/parser/cppparser.h index 2890c349..955860f3 100644 --- a/RedPandaIDE/parser/cppparser.h +++ b/RedPandaIDE/parser/cppparser.h @@ -49,6 +49,9 @@ public: const QString& phrase, const PStatement& currentClass, bool force = false); + PStatement findStatement(const QString& fileName, + const QStringList& phraseExpression, + const PStatement& currentScope); //{Find statement starting from startScope} PStatement findStatementStartingFrom(const QString& fileName, const QString& phrase, @@ -198,6 +201,18 @@ private: PStatement findStatementInNamespace( const QString& name, const QString& namespaceName); + + PStatement doParseSubExpression3( + const QString& fileName, + const QStringList& phraseExpression, + int &pos, + const PStatement& currentScope, + const PStatement& ownerStatement); + PStatement doFindStatement(const QString& fileName, + const QStringList& phraseExpression, + int &pos, + const PStatement& currentScope, + const PStatement& ownerStatement); int getBracketEnd(const QString& s, int startAt); StatementClassScope getClassScope(int index); int getCurrentBlockBeginSkip(); @@ -311,6 +326,8 @@ private: bool isTypeStatement(StatementKind kind); void updateSerialId(); + + private: int mParserId; int mSerialCount; diff --git a/RedPandaIDE/widgets/codecompletionpopup.h b/RedPandaIDE/widgets/codecompletionpopup.h index d7c72b2a..02e946e1 100644 --- a/RedPandaIDE/widgets/codecompletionpopup.h +++ b/RedPandaIDE/widgets/codecompletionpopup.h @@ -37,7 +37,7 @@ public: const QStringList& memberExpression, const QString& filename, int line); - bool search(const QString& phrase, bool autoHideOnSingleResult); + bool search(const QString& memberPhrase, bool autoHideOnSingleResult); PStatement selectedStatement(); @@ -86,7 +86,7 @@ private: const QStringList& memberExpression, const QString& fileName, int line); - void getFullCompletionListFor(const QString& preWord); + void getCompletionListForPreWord(const QString& preWord); void addKeyword(const QString& keyword); bool isIncluded(const QString& fileName); private: