From e8644dfd0b0717467ff0e71b910bda7b2344a134 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Wed, 8 Dec 2021 19:13:47 +0800 Subject: [PATCH] work save --- RedPandaIDE/parser/cppparser.cpp | 297 ++++++++++++++----- RedPandaIDE/parser/cppparser.h | 33 ++- RedPandaIDE/parser/parserutils.cpp | 2 +- RedPandaIDE/settingsdialog/settingsdialog.ui | 8 +- RedPandaIDE/widgets/codecompletionpopup.cpp | 162 ++++------ 5 files changed, 304 insertions(+), 198 deletions(-) diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index 5df734b8..5a724977 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -403,6 +403,7 @@ PEvalStatement CppParser::evalExpression( QMutexLocker locker(&mMutex); if (mParsing) return PEvalStatement(); + qDebug()<pointerLevel++; } } else - currentResult=PEvalStatement(); + break; } +// qDebug()<= phraseExpression.length() || phraseExpression[pos]!=")") { return PEvalStatement(); } else if (evalType && (evalType->kind == EvalStatementKind::Type)) { + pos++; // skip ")" + qDebug()<<"parse type cast exp"; //it's a type cast result = doEvalCCast(fileName, phraseExpression, @@ -3477,8 +3483,10 @@ PEvalStatement CppParser::doEvalCCast(const QString &fileName, scope, previousResult, freeScoped); - if (result) + if (result) { + qDebug()<<"type cast"; result->assignType(evalType); + } } else //it's not a type cast result = doEvalMemberAccess( fileName, @@ -3495,6 +3503,11 @@ PEvalStatement CppParser::doEvalCCast(const QString &fileName, scope, previousResult, freeScoped); + if (result) { + qDebug()<kind<baseType; + } else { + qDebug()<<"!!!!!!!!!!!not found"; + } return result; } @@ -3506,6 +3519,7 @@ PEvalStatement CppParser::doEvalMemberAccess(const QString &fileName, bool freeScoped) { +// qDebug()<<"eval member access "<=phraseExpression.length()) return result; @@ -3516,10 +3530,8 @@ PEvalStatement CppParser::doEvalMemberAccess(const QString &fileName, scope, previousResult, freeScoped); - bool isFreeScoped = freeScoped; if (!result) return PEvalStatement(); - pos++; while (poskind == EvalStatementKind::Function) { - doSkipInExpression("(",")"); + doSkipInExpression(phraseExpression,pos,"(",")"); //function call result->kind = EvalStatementKind::Variable; } else result = PEvalStatement(); } else if (phraseExpression[pos] == "[") { //skip to "]" - doSkipInExpression("[","]"); + doSkipInExpression(phraseExpression,pos,"[","]"); //todo: STL container; result->pointerLevel--; - return } else if (phraseExpression[pos] == ".") { pos++; result = doEvalScopeResolution( @@ -3560,6 +3571,7 @@ PEvalStatement CppParser::doEvalMemberAccess(const QString &fileName, scope, result, false); + qDebug()<<(result!=nullptr)<") { pos++; //todo: STL container @@ -3574,7 +3586,7 @@ PEvalStatement CppParser::doEvalMemberAccess(const QString &fileName, } else break; } - + return result; } PEvalStatement CppParser::doEvalScopeResolution(const QString &fileName, @@ -3584,6 +3596,7 @@ PEvalStatement CppParser::doEvalScopeResolution(const QString &fileName, const PEvalStatement& previousResult, bool freeScoped) { +// qDebug()<<"eval scope res "<=phraseExpression.length()) return result; @@ -3594,7 +3607,6 @@ PEvalStatement CppParser::doEvalScopeResolution(const QString &fileName, scope, previousResult, freeScoped); - pos++; while (posbaseType<=phraseExpression.length()) return result; @@ -3631,58 +3649,112 @@ PEvalStatement CppParser::doEvalTerm(const QString &fileName, pos++; // skip ")"; return result; } - } else if (isIdentifier(phraseExpression[pos])) { - PStatement statement; - if (freeScoped) { - if (previousResult) { - statement = findStatementStartingFrom( - fileName, - phraseExpression[pos], - previousResult->baseStatement); - } else { - statement = findStatementStartingFrom( - fileName, - phraseExpression[pos], - scope); - } - } else { - if (!previousResult) { - statement = findStatementInScope(phraseExpression[pos],PStatement()); - } else { - statement = findStatementInScope(phraseExpression[pos],previousResult->baseStatement); - } + } else { + int pointerLevel = 0; + //skip "struct", "const", "static", etc + while(pos < phraseExpression.length()) { + QString token = phraseExpression[pos]; + if (token=="*") // for expression like (const * char)? + pointerLevel++; + else if (mCppTypeKeywords.contains(token) + || !mCppKeywords.contains(token)) + break; + pos++; } - pos++; - if (statement) { - switch (statement->kind) { - case StatementKind::skNamespace: - result = doCreateEvalNamespace(statement); - break; - case StatementKind::skVariable: - result = doCreateEvalVariable(fileName,statement); - break; - case StatementKind::skEnumType: - case StatementKind::skClass: - case StatementKind::skEnumClassType: - case StatementKind::skTypedef: - result = doCreateEvalType(fileName,statement); - break; - case StatementKind::skFunction: - result = ; - break; + + if (pos>=phraseExpression.length() || phraseExpression[pos]==")") + return result; + if (mCppKeywords.contains(phraseExpression[pos])) { + result = doCreateEvalType(phraseExpression[pos]); + pos++; + } else if (isIdentifier(phraseExpression[pos])) { + PStatement statement; + if (freeScoped) { + if (!previousResult) { + statement = findStatementStartingFrom( + fileName, + phraseExpression[pos], + scope); + } else { + statement = findStatementStartingFrom( + fileName, + phraseExpression[pos], + previousResult->effectiveTypeStatement); + } + } else { + if (!previousResult) { + statement = findStatementInScope(phraseExpression[pos],PStatement()); + } else { + if (previousResult->effectiveTypeStatement) { + qDebug()<effectiveTypeStatement->fullName; + } else { + qDebug()<effectiveTypeStatement); +// if (!statement) { +// qDebug()<<"not found!"; +// } else { +// qDebug()<fullName; +// qDebug()<kind; +// } + } } - } else { - if (isTypeStatement()) + pos++; + if (statement) { + switch (statement->kind) { + case StatementKind::skNamespace: + result = doCreateEvalNamespace(statement); + break; + case StatementKind::skVariable: + case StatementKind::skParameter: + result = doCreateEvalVariable(fileName,statement); + break; + case StatementKind::skEnumType: + case StatementKind::skClass: + case StatementKind::skEnumClassType: + case StatementKind::skTypedef: + result = doCreateEvalType(fileName,statement); + break; + case StatementKind::skFunction: + result = doCreateEvalFunction(fileName,statement); + break; + default: + result = PEvalStatement(); + } + } + } else if (isIntegerLiteral(phraseExpression[pos])) { + result = doCreateEvalLiteral("int"); + } else if (isFloatLiteral(phraseExpression[pos])) { + result = doCreateEvalLiteral("double"); + } else if (isStringLiteral(phraseExpression[pos])) { + result = doCreateEvalLiteral("char"); + result->pointerLevel = 1; + } else if (isCharLiteral(phraseExpression[pos])) { + result = doCreateEvalLiteral("char"); + } else result = PEvalStatement(); + if (result) { + qDebug()<<"term kind:"<<(int)result->kind; } - } else if (isIntegerLiteral(phraseExpression[pos])) { - } else if (isIntegerLiteral(phraseExpression[pos])) { - } else if (isFloatLiteral(phraseExpression[pos])) { - } else if (isStringLiteral(phraseExpression[pos])) { - - } else - return PStatement(); - + if (result && result->kind == EvalStatementKind::Type) { + //skip "struct", "const", "static", etc + while(pos < phraseExpression.length()) { + QString token = phraseExpression[pos]; + if (token=="*") // for expression like (const * char)? + pointerLevel++; + else if (mCppTypeKeywords.contains(token) + || !mCppKeywords.contains(token)) + break; + pos++; + } + result->pointerLevel = pointerLevel; + } + } +// qDebug()<( namespaceStatement->fullName, EvalStatementKind::Namespace, - namespaceStatement, - PStatement()); + PStatement(), + namespaceStatement); } PEvalStatement CppParser::doCreateEvalType(const QString& fileName,const PStatement &typeStatement) @@ -3712,19 +3784,28 @@ PEvalStatement CppParser::doCreateEvalType(const QString& fileName,const PStatem return std::make_shared( baseType, EvalStatementKind::Type, - typeStatement, PStatement(), + typeStatement, pointerLevel ); } else { return std::make_shared( typeStatement->fullName, EvalStatementKind::Type, - typeStatement, - PStatement()); + PStatement(), + typeStatement); } } +PEvalStatement CppParser::doCreateEvalType(const QString &primitiveType) +{ + return std::make_shared( + primitiveType, + EvalStatementKind::Type, + PStatement(), + PStatement()); +} + PEvalStatement CppParser::doCreateEvalVariable(const QString &fileName, PStatement varStatement) { if (!varStatement) @@ -3767,6 +3848,67 @@ PEvalStatement CppParser::doCreateEvalFunction(const QString &fileName, PStateme ); } +PEvalStatement CppParser::doCreateEvalLiteral(const QString &type) +{ + return std::make_shared( + type, + EvalStatementKind::Literal, + PStatement(), + PStatement()); +} + +void CppParser::doSkipInExpression(const QStringList &expression, int &pos, const QString &startSymbol, const QString &endSymbol) +{ + int level = 0; + while (pos='0' && ch<='9' && !token.contains(".") && !token.contains("e")); +} + +bool CppParser::isFloatLiteral(const QString &token) const +{ + if (token.isEmpty()) + return false; + QChar ch = token.front(); + return (ch>='0' && ch<='9' && (token.contains(".") || token.contains("e"))); +} + +bool CppParser::isStringLiteral(const QString &token) const +{ + if (token.isEmpty()) + return false; + return (!token.startsWith('\'') && token.contains('"')); +} + +bool CppParser::isCharLiteral(const QString &token) const +{ + if (token.isEmpty()) + return false; + return (token.startsWith('\'')); +} + PStatement CppParser::doParseEvalTypeInfo( const QString &fileName, const PStatement &scope, @@ -3820,9 +3962,8 @@ PStatement CppParser::doParseEvalTypeInfo( } position--; } - - PStatement statement = findStatementOf(fileName,s,scope); - return getTypeDef(statement,fileName,type); + PStatement statement = findStatementOf(fileName,baseType,scope); + return getTypeDef(statement,fileName,baseType); } @@ -4147,12 +4288,12 @@ QString CppParser::removeArgNames(const QString &args) return result; } -bool CppParser::isSpaceChar(const QChar &ch) +bool CppParser::isSpaceChar(const QChar &ch) const { return ch==' ' || ch =='\t'; } -bool CppParser::isWordChar(const QChar &ch) +bool CppParser::isWordChar(const QChar &ch) const { // return (ch>= 'A' && ch<='Z') // || (ch>='a' && ch<='z') @@ -4162,7 +4303,7 @@ bool CppParser::isWordChar(const QChar &ch) || ch == '&'; } -bool CppParser::isLetterChar(const QChar &ch) +bool CppParser::isLetterChar(const QChar &ch) const { // return (ch>= 'A' && ch<='Z') // || (ch>='a' && ch<='z') @@ -4170,12 +4311,12 @@ bool CppParser::isLetterChar(const QChar &ch) || ch == '_'; } -bool CppParser::isDigitChar(const QChar &ch) +bool CppParser::isDigitChar(const QChar &ch) const { return (ch>='0' && ch<='9'); } -bool CppParser::isSeperator(const QChar &ch) { +bool CppParser::isSeperator(const QChar &ch) const { switch(ch.unicode()){ case '(': case ';': @@ -4189,7 +4330,7 @@ bool CppParser::isSeperator(const QChar &ch) { } } -bool CppParser::isblockChar(const QChar &ch) +bool CppParser::isblockChar(const QChar &ch) const { switch(ch.unicode()){ case ';': @@ -4201,7 +4342,7 @@ bool CppParser::isblockChar(const QChar &ch) } } -bool CppParser::isInvalidVarPrefixChar(const QChar &ch) +bool CppParser::isInvalidVarPrefixChar(const QChar &ch) const { switch (ch.unicode()) { case '#': @@ -4222,12 +4363,12 @@ bool CppParser::isInvalidVarPrefixChar(const QChar &ch) } } -bool CppParser::isBraceChar(const QChar &ch) +bool CppParser::isBraceChar(const QChar &ch) const { return ch == '{' || ch =='}'; } -bool CppParser::isLineChar(const QChar &ch) +bool CppParser::isLineChar(const QChar &ch) const { return ch=='\n' || ch=='\r'; } @@ -4279,7 +4420,7 @@ bool CppParser::isNotFuncArgs(const QString &args) return false; } -bool CppParser::isNamedScope(StatementKind kind) +bool CppParser::isNamedScope(StatementKind kind) const { switch(kind) { case StatementKind::skClass: @@ -4291,7 +4432,7 @@ bool CppParser::isNamedScope(StatementKind kind) } } -bool CppParser::isTypeStatement(StatementKind kind) +bool CppParser::isTypeStatement(StatementKind kind) const { switch(kind) { case StatementKind::skClass: @@ -4309,7 +4450,7 @@ void CppParser::updateSerialId() mSerialId = QString("%1 %2").arg(mParserId).arg(mSerialCount); } -bool CppParser::isMemberOperator(QString token) +bool CppParser::isMemberOperator(QString token) const { return mMemberOperators.contains(token); } diff --git a/RedPandaIDE/parser/cppparser.h b/RedPandaIDE/parser/cppparser.h index e27920b9..9d84d00c 100644 --- a/RedPandaIDE/parser/cppparser.h +++ b/RedPandaIDE/parser/cppparser.h @@ -91,7 +91,7 @@ public: * @param token * @return true if it is, false if not */ - bool isMemberOperator(QString token); + bool isMemberOperator(QString token) const; bool enabled() const; void setEnabled(bool newEnabled); @@ -266,10 +266,17 @@ private: PEvalStatement doCreateEvalNamespace(const PStatement& namespaceStatement); PEvalStatement doCreateEvalType(const QString& fileName,const PStatement& typeStatement); + PEvalStatement doCreateEvalType(const QString& primitiveType); PEvalStatement doCreateEvalVariable(const QString& fileName, PStatement varStatement); PEvalStatement doCreateEvalFunction(const QString& fileName, PStatement funcStatement); - + PEvalStatement doCreateEvalLiteral(const QString& type); + void doSkipInExpression(const QStringList& expression, int&pos, const QString& startSymbol, const QString& endSymbol); + bool isIdentifier(const QString& token) const; + bool isIntegerLiteral(const QString& token) const; + bool isFloatLiteral(const QString& token) const; + bool isStringLiteral(const QString& token) const; + bool isCharLiteral(const QString& token) const; PStatement doParseEvalTypeInfo( const QString& fileName, const PStatement& scope, @@ -351,27 +358,27 @@ private: QString removeArgNames(const QString& args); - bool isSpaceChar(const QChar& ch); + bool isSpaceChar(const QChar& ch) const; - bool isWordChar(const QChar& ch); + bool isWordChar(const QChar& ch) const; - bool isLetterChar(const QChar& ch); + bool isLetterChar(const QChar& ch) const; - bool isDigitChar(const QChar& ch); + bool isDigitChar(const QChar& ch) const; /*'(', ';', ':', '{', '}', '#' */ - bool isSeperator(const QChar& ch); + bool isSeperator(const QChar& ch) const; /*';', '{', '}'*/ - bool isblockChar(const QChar& ch); + bool isblockChar(const QChar& ch) const; /* '#', ',', ';', ':', '{', '}', '!', '/', '+', '-', '<', '>' */ - bool isInvalidVarPrefixChar(const QChar& ch); + bool isInvalidVarPrefixChar(const QChar& ch) const; /*'{', '}' */ - bool isBraceChar(const QChar& ch); + bool isBraceChar(const QChar& ch) const; - bool isLineChar(const QChar& ch); + bool isLineChar(const QChar& ch) const; bool isNotFuncArgs(const QString& args); @@ -380,14 +387,14 @@ private: * @param kind * @return */ - bool isNamedScope(StatementKind kind); + bool isNamedScope(StatementKind kind) const; /** * @brief Test if a statement is a class/struct/union/enum/enum class/typedef * @param kind * @return */ - bool isTypeStatement(StatementKind kind); + bool isTypeStatement(StatementKind kind) const; void updateSerialId(); diff --git a/RedPandaIDE/parser/parserutils.cpp b/RedPandaIDE/parser/parserutils.cpp index c9a92a68..ac44890f 100644 --- a/RedPandaIDE/parser/parserutils.cpp +++ b/RedPandaIDE/parser/parserutils.cpp @@ -518,5 +518,5 @@ void EvalStatement::assignType(const PEvalStatement &typeStatement) Q_ASSERT(typeStatement && typeStatement->kind==EvalStatementKind::Type); baseType = typeStatement->baseType; pointerLevel = typeStatement->pointerLevel; - effectiveTypeStatement = typeStatement->baseStatement; + effectiveTypeStatement = typeStatement->effectiveTypeStatement; } diff --git a/RedPandaIDE/settingsdialog/settingsdialog.ui b/RedPandaIDE/settingsdialog/settingsdialog.ui index 95e5152c..1546f0ae 100644 --- a/RedPandaIDE/settingsdialog/settingsdialog.ui +++ b/RedPandaIDE/settingsdialog/settingsdialog.ui @@ -103,8 +103,8 @@ 0 0 - 683 - 533 + 679 + 516 @@ -165,9 +165,9 @@ - + - Cancle + Cancel diff --git a/RedPandaIDE/widgets/codecompletionpopup.cpp b/RedPandaIDE/widgets/codecompletionpopup.cpp index b74e7f29..a7e1562d 100644 --- a/RedPandaIDE/widgets/codecompletionpopup.cpp +++ b/RedPandaIDE/widgets/codecompletionpopup.cpp @@ -543,27 +543,31 @@ void CodeCompletionPopup::getCompletionFor( return; if (memberExpression.length()>2) return; - QString scopeName = ownerExpression.join(""); + PStatement scope = mCurrentStatement;//the scope the expression in PStatement parentTypeStatement; - PStatement ownerStatement = mParser->findStatementOf( - fileName, - scopeName, - mCurrentStatement, - parentTypeStatement); +// QString scopeName = ownerExpression.join(""); +// PStatement ownerStatement = mParser->findStatementOf( +// fileName, +// scopeName, +// mCurrentStatement, +// parentTypeStatement); + PEvalStatement ownerStatement = mParser->evalExpression(fileName, + ownerExpression, + scope); // qDebug()<effectiveTypeStatement) { + qDebug()<<"statement not found!"; return; } // qDebug()<<"found: "<fullName; if (memberOperator == "::") { - if (ownerStatement->kind==StatementKind::skNamespace) { + if (ownerStatement->kind==EvalStatementKind::Namespace) { //there might be many statements corresponding to one namespace; PStatementList namespaceStatementsList = - mParser->findNamespace(ownerStatement->fullName); + mParser->findNamespace(ownerStatement->baseType); if (namespaceStatementsList) { foreach (const PStatement& namespaceStatement, *namespaceStatementsList) { addChildren(namespaceStatement, fileName, line); @@ -581,41 +585,10 @@ void CodeCompletionPopup::getCompletionFor( if ( (memberOperator != "::") && ( - ownerStatement->kind == StatementKind::skVariable - || ownerStatement->kind == StatementKind::skParameter - || ownerStatement->kind == StatementKind::skFunction) + ownerStatement->kind == EvalStatementKind::Variable) ) { // Get type statement of current (scope) statement - PStatement classTypeStatement; - PStatement parentScope = ownerStatement->parentScope.lock(); - if ((ownerStatement->kind == StatementKind::skFunction) - && parentScope - && STLContainers.contains(parentScope->fullName) - && STLElementMethods.contains(ownerStatement->command)){ - // it's an element method of STL container - // we must find the type in the template parameter - - // get the function's owner variable's definition - int lastI = mParser->findLastOperator(scopeName); - QString lastScopeName = scopeName.mid(0,lastI); - PStatement lastScopeStatement = - mParser->findStatementOf( - fileName, lastScopeName, - mCurrentStatement,parentTypeStatement); - if (!lastScopeStatement) - return; - - - QString typeName = - mParser->findFirstTemplateParamOf( - fileName,lastScopeStatement->type, - lastScopeStatement->parentScope.lock()); - classTypeStatement = mParser->findTypeDefinitionOf( - fileName, typeName, - lastScopeStatement->parentScope.lock()); - } else - classTypeStatement=mParser->findTypeDefinitionOf( - fileName, ownerStatement->type,parentTypeStatement); + PStatement classTypeStatement = ownerStatement->effectiveTypeStatement; if (!classTypeStatement) return; @@ -625,33 +598,19 @@ void CodeCompletionPopup::getCompletionFor( || memberOperator == "->*")) { QString typeName= mParser->findFirstTemplateParamOf( fileName, - ownerStatement->type, - parentScope); + ownerStatement->baseType, + scope); classTypeStatement = mParser->findTypeDefinitionOf( fileName, typeName, - parentScope); - if (!classTypeStatement) - return; - } - //is a stl container operator[] - if (STLContainers.contains(classTypeStatement->fullName) - && scopeName.endsWith(']')) { - QString typeName= mParser->findFirstTemplateParamOf( - fileName, - ownerStatement->type, - parentScope); - classTypeStatement = mParser->findTypeDefinitionOf( - fileName, - typeName, - parentScope); + scope); if (!classTypeStatement) return; } if (!isIncluded(classTypeStatement->fileName) && !isIncluded(classTypeStatement->definitionFileName)) return; - if ((classTypeStatement == scopeTypeStatement) || (ownerStatement->command == "this")) { + if ((classTypeStatement == scopeTypeStatement) || (ownerStatement->effectiveTypeStatement->command == "this")) { //we can use all members addChildren(classTypeStatement,fileName,-1); } else { // we can only use public members @@ -670,59 +629,58 @@ void CodeCompletionPopup::getCompletionFor( } //todo friend } else if ((memberOperator == "::") - && ((ownerStatement->kind == StatementKind::skEnumType) - || (ownerStatement->kind == StatementKind::skEnumClassType))) { + && (ownerStatement->kind == EvalStatementKind::Type)) { //we can add all child enum definess - PStatement classTypeStatement = ownerStatement; + PStatement classTypeStatement = ownerStatement->effectiveTypeStatement; + if (!classTypeStatement) + return; if (!isIncluded(classTypeStatement->fileName) && !isIncluded(classTypeStatement->definitionFileName)) return; - const StatementMap& children = - mParser->statementList().childrenStatements(classTypeStatement); - foreach (const PStatement& child,children) { - addStatement(child,fileName,line); - } - } else if ((memberOperator == "::") - && (ownerStatement->kind == StatementKind::skClass)) { - PStatement classTypeStatement = ownerStatement; - if (!isIncluded(classTypeStatement->fileName) && - !isIncluded(classTypeStatement->definitionFileName)) - return; - if (classTypeStatement == scopeTypeStatement) { - //we can use all static members + if (classTypeStatement->kind == StatementKind::skEnumType + || classTypeStatement->kind == StatementKind::skEnumClassType) { const StatementMap& children = mParser->statementList().childrenStatements(classTypeStatement); - foreach (const PStatement& childStatement, children) { - if ( - (childStatement->isStatic) - || (childStatement->kind == StatementKind::skTypedef - || childStatement->kind == StatementKind::skClass - || childStatement->kind == StatementKind::skEnum - || childStatement->kind == StatementKind::skEnumClassType - || childStatement->kind == StatementKind::skEnumType - )) { - addStatement(childStatement,fileName,-1); - } + foreach (const PStatement& child,children) { + addStatement(child,fileName,line); } } else { - // we can only use public static members - const StatementMap& children = - mParser->statementList().childrenStatements(classTypeStatement); - foreach (const PStatement& childStatement,children) { - if ( - (childStatement->isStatic) - || (childStatement->kind == StatementKind::skTypedef - || childStatement->kind == StatementKind::skClass - || childStatement->kind == StatementKind::skEnum - || childStatement->kind == StatementKind::skEnumClassType - || childStatement->kind == StatementKind::skEnumType - )) { - if (childStatement->classScope == StatementClassScope::scsPublic) + //class + if (classTypeStatement == scopeTypeStatement) { + //we can use all static members + const StatementMap& children = + mParser->statementList().childrenStatements(classTypeStatement); + foreach (const PStatement& childStatement, children) { + if ( + (childStatement->isStatic) + || (childStatement->kind == StatementKind::skTypedef + || childStatement->kind == StatementKind::skClass + || childStatement->kind == StatementKind::skEnum + || childStatement->kind == StatementKind::skEnumClassType + || childStatement->kind == StatementKind::skEnumType + )) { addStatement(childStatement,fileName,-1); + } + } + } else { + // we can only use public static members + const StatementMap& children = + mParser->statementList().childrenStatements(classTypeStatement); + foreach (const PStatement& childStatement,children) { + if ( + (childStatement->isStatic) + || (childStatement->kind == StatementKind::skTypedef + || childStatement->kind == StatementKind::skClass + || childStatement->kind == StatementKind::skEnum + || childStatement->kind == StatementKind::skEnumClassType + || childStatement->kind == StatementKind::skEnumType + )) { + if (childStatement->classScope == StatementClassScope::scsPublic) + addStatement(childStatement,fileName,-1); + } } } } - //todo friend } } }