diff --git a/NEWS.md b/NEWS.md index 76db2545..0f28c305 100644 --- a/NEWS.md +++ b/NEWS.md @@ -9,6 +9,7 @@ Red Panda C++ Version 2.26 - fix: Code suggestions in namespace. - enhancement: Code suggestions for namespace alias. - fix: Correctly handle statements like 'using xxx::operator()'. + - fix: Link in the project options dialog / precompiled header pages is not clickable. Red Panda C++ Version 2.25 diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index c572e2fa..a67e9db5 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -1091,8 +1091,8 @@ void CppParser::resetParser() mStatementList.clear(); mProjectFiles.clear(); - mBlockBeginSkips.clear(); //list of for/catch block begin token index; - mBlockEndSkips.clear(); //list of for/catch block end token index; +// mBlockBeginSkips.clear(); //list of for/catch block begin token index; +// mBlockEndSkips.clear(); //list of for/catch block end token index; mInlineNamespaceEndSkips.clear(); // list for inline namespace end token index; mFilesToScan.clear(); // list of base files to scan mNamespaces.clear(); // namespace and the statements in its scope @@ -1717,8 +1717,8 @@ void CppParser::internalClear() mMemberAccessibilities.clear(); mIndex = 0; mCurrentMemberAccessibility = StatementAccessibility::None; - mBlockBeginSkips.clear(); - mBlockEndSkips.clear(); +// mBlockBeginSkips.clear(); +// mBlockEndSkips.clear(); mInlineNamespaceEndSkips.clear(); } @@ -2406,19 +2406,19 @@ QString CppParser::doFindTemplateParamOf(const QString &fileName, const QString return getTemplateParam(statement,fileName, phrase,index, currentScope); } -int CppParser::getCurrentBlockEndSkip() const -{ - if (mBlockEndSkips.isEmpty()) - return mTokenizer.tokenCount()+1; - return mBlockEndSkips.back(); -} +//int CppParser::getCurrentBlockEndSkip() const +//{ +// if (mBlockEndSkips.isEmpty()) +// return mTokenizer.tokenCount()+1; +// return mBlockEndSkips.back(); +//} -int CppParser::getCurrentBlockBeginSkip() const -{ - if (mBlockBeginSkips.isEmpty()) - return mTokenizer.tokenCount()+1; - return mBlockBeginSkips.back(); -} +//int CppParser::getCurrentBlockBeginSkip() const +//{ +// if (mBlockBeginSkips.isEmpty()) +// return mTokenizer.tokenCount()+1; +// return mBlockBeginSkips.back(); +//} int CppParser::getCurrentInlineNamespaceEndSkip() const { @@ -2541,43 +2541,43 @@ PStatement CppParser::getTypeDef(const PStatement& statement, return PStatement(); } -void CppParser::handleCatchBlock() -{ - int tokenCount = mTokenizer.tokenCount(); - int startLine= mTokenizer[mIndex]->line; - mIndex++; // skip for/catch; - if (!((mIndex < tokenCount) && (mTokenizer[mIndex]->text.startsWith('(')))) - return; - //skip params - int i2=mTokenizer[mIndex]->matchIndex+1; - if (i2>=tokenCount) - return; - if (mTokenizer[i2]->text.startsWith('{')) { - mBlockBeginSkips.append(i2); - int i = indexOfMatchingBrace(i2); - mBlockEndSkips.append(i); - } else { - int i=indexOfNextSemicolon(i2); - mBlockEndSkips.append(i); - } - // add a block - PStatement block = addStatement( - getCurrentScope(), - mCurrentFile, - "", - "", - "", - "", - "", - startLine, - StatementKind::skBlock, - getScope(), - mCurrentMemberAccessibility, - StatementProperty::spHasDefinition); - addSoloScopeLevel(block,startLine); - scanMethodArgs(block,mIndex); - mIndex=mTokenizer[mIndex]->matchIndex+1; -} +//void CppParser::handleCatchBlock() +//{ +// int tokenCount = mTokenizer.tokenCount(); +// int startLine= mTokenizer[mIndex]->line; +// mIndex++; // skip for/catch; +// if (!((mIndex < tokenCount) && (mTokenizer[mIndex]->text.startsWith('(')))) +// return; +// //skip params +// int i2=mTokenizer[mIndex]->matchIndex+1; +// if (i2>=tokenCount) +// return; +// if (mTokenizer[i2]->text.startsWith('{')) { +// mBlockBeginSkips.append(i2); +// int i = indexOfMatchingBrace(i2); +// mBlockEndSkips.append(i); +// } else { +// int i=indexOfNextSemicolon(i2); +// mBlockEndSkips.append(i); +// } +// // add a block +// PStatement block = addStatement( +// getCurrentScope(), +// mCurrentFile, +// "", +// "", +// "", +// "", +// "", +// startLine, +// StatementKind::skBlock, +// getScope(), +// mCurrentMemberAccessibility, +// StatementProperty::spHasDefinition); +// addSoloScopeLevel(block,startLine); +// scanMethodArgs(block,mIndex); +// mIndex=mTokenizer[mIndex]->matchIndex+1; +//} void CppParser::handleConcept() { @@ -2807,45 +2807,23 @@ void CppParser::handleForBlock() mIndex++; // skip for/catch; if (mIndex >= tokenCount) return; - if (mTokenizer[mIndex]->text!="(") + if (mTokenizer[mIndex]->text!='(') return; - int i=indexOfNextSemicolon(mIndex); - int i2 = i+1; //skip over ';' (tokenizer have change for(;;) to for(;) - - // for(int x:vec) - if (i2 > mTokenizer[mIndex]->matchIndex) - i2 = mTokenizer[mIndex]->matchIndex+1; - + int i=mTokenizer[mIndex]->matchIndex; //")" + int i2 = i+1; if (i2>=tokenCount) return; - if (mTokenizer[i2]->text.startsWith('{')) { - mBlockBeginSkips.append(i2); - i=indexOfMatchingBrace(i2); -// tokenizer will handle unbalanced braces, no need check here -// if (i==i2) -// mBlockEndSkips.append(mTokenizer.tokenCount()); -// else - mBlockEndSkips.append(i); + if (mTokenizer[i2]->text=='{') { + mTokenizer[mIndex]->text="{"; + mTokenizer[mIndex]->matchIndex = mTokenizer[i2]->matchIndex; + mTokenizer[mTokenizer[mIndex]->matchIndex]->matchIndex = mIndex; + mTokenizer[i]->text=";"; + mTokenizer[i2]->text=";"; } else { - i=indexOfNextSemicolon(i2); - mBlockEndSkips.append(i); + mTokenizer[mIndex]->text=";"; + mTokenizer[i]->text=";"; + mIndex++; //skip ';' } - // add a block - PStatement block = addStatement( - getCurrentScope(), - mCurrentFile, - "", - "", - "", - "", - "", - startLine, - StatementKind::skBlock, - getScope(), - mCurrentMemberAccessibility, - StatementProperty::spHasDefinition); - - addSoloScopeLevel(block,startLine); } void CppParser::handleKeyword(KeywordType skipType) @@ -3535,8 +3513,8 @@ void CppParser::handleAccessibilitySpecifiers(KeywordType keywordType) bool CppParser::handleStatement() { QString funcType,funcName; - int idx=getCurrentBlockEndSkip(); - int idx2=getCurrentBlockBeginSkip(); +// int idx=getCurrentBlockEndSkip(); +// int idx2=getCurrentBlockBeginSkip(); int idx3=getCurrentInlineNamespaceEndSkip(); KeywordType keywordType; #ifdef QT_DEBUG @@ -3546,21 +3524,22 @@ bool CppParser::handleStatement() #endif int tokenCount = mTokenizer.tokenCount(); - if (mIndex >= idx2) { - //skip (previous handled) block begin - mBlockBeginSkips.pop_back(); - if (mIndex == idx2) - mIndex++; - else if (mIndexline); - } else if (mIndex >= idx) { - //skip (previous handled) block end - mBlockEndSkips.pop_back(); - if (idx+1 < tokenCount) - removeScopeLevel(mTokenizer[idx+1]->line); - if (mIndex == idx) - mIndex++; - } else if (mIndex >= idx3) { +// if (mIndex >= idx2) { +// //skip (previous handled) block begin +// mBlockBeginSkips.pop_back(); +// if (mIndex == idx2) +// mIndex++; +// else if (mIndexline); +// } else if (mIndex >= idx) { +// //skip (previous handled) block end +// mBlockEndSkips.pop_back(); +// if (idx+1 < tokenCount) +// removeScopeLevel(mTokenizer[idx+1]->line); +// if (mIndex == idx) +// mIndex++; +// } else + if (mIndex >= idx3) { //skip (previous handled) inline name space end mInlineNamespaceEndSkips.pop_back(); if (mIndex == idx3) @@ -3619,10 +3598,8 @@ bool CppParser::handleStatement() handleConcept(); } else if (keywordType==KeywordType::Requires) { skipRequires(); - } else if (keywordType==KeywordType::For) { // (for/catch) + } else if (keywordType==KeywordType::For || keywordType==KeywordType::Catch) { // (for/catch) handleForBlock(); - } else if (keywordType==KeywordType::Catch) { // (for/catch) - handleCatchBlock(); } else if (checkForAccessibilitySpecifiers(keywordType)) { // public /private/proteced handleAccessibilitySpecifiers(keywordType); } else if (keywordType==KeywordType::Enum) { @@ -4388,17 +4365,17 @@ void CppParser::skipRequires() mIndex++; // skip '::'; } } - if (mIndex>=tokenCount) + if (mIndex+1>=tokenCount) return; - if (mTokenizer[mIndex]->text!="&&") + if (mTokenizer[mIndex]->text!="&" || mTokenizer[mIndex+1]->text!="&") break; - mIndex++; // skip '&&'; + mIndex+=2; // skip '&&'; } - if (mIndex>=tokenCount) + if (mIndex+1>=tokenCount) return; - if (mTokenizer[mIndex]->text!="||") + if (mTokenizer[mIndex]->text!="|" || mTokenizer[mIndex+1]->text!="|") break; - mIndex++; // skip '||'; + mIndex+=2; // skip '||'; } } @@ -4422,9 +4399,9 @@ void CppParser::internalParse(const QString &fileName) QStringList preprocessResult = mPreprocessor.result(); #ifdef QT_DEBUG -// stringsToFile(mPreprocessor.result(),QString("r:\\preprocess-%1.txt").arg(extractFileName(fileName))); -// mPreprocessor.dumpDefinesTo("r:\\defines.txt"); -// mPreprocessor.dumpIncludesListTo("r:\\includes.txt"); + stringsToFile(mPreprocessor.result(),QString("r:\\preprocess-%1.txt").arg(extractFileName(fileName))); + mPreprocessor.dumpDefinesTo("r:\\defines.txt"); + mPreprocessor.dumpIncludesListTo("r:\\includes.txt"); #endif //qDebug()<<"preprocess"< mProjectFiles; - QVector mBlockBeginSkips; //list of for/catch block begin token index; - QVector mBlockEndSkips; //list of for/catch block end token index; +// QVector mBlockBeginSkips; //list of for/catch block begin token index; +// QVector mBlockEndSkips; //list of for/catch block end token index; QVector mInlineNamespaceEndSkips; // list for inline namespace end token index; QSet mFilesToScan; // list of base files to scan int mFilesScannedCount; // count of files that have been scanned diff --git a/RedPandaIDE/parser/cpptokenizer.cpp b/RedPandaIDE/parser/cpptokenizer.cpp index 2cf64037..56f727ff 100644 --- a/RedPandaIDE/parser/cpptokenizer.cpp +++ b/RedPandaIDE/parser/cpptokenizer.cpp @@ -158,30 +158,30 @@ void CppTokenizer::countLines() } } -QString CppTokenizer::getForInit() -{ - QChar* startOffset = mCurrent; +//QString CppTokenizer::getForInit() +//{ +// QChar* startOffset = mCurrent; - // Step into the init statement - mCurrent++; +// // Step into the init statement +// mCurrent++; - TokenType tokenType; - // Process until ; or end of file - while (true) { - QString s = getNextToken(&tokenType); - simplify(s); - if (!s.isEmpty()) - addToken(s,mCurrentLine,tokenType); - if ( (s == "") || (s == ";") || (s==")") || (s=="(")) - break; - // : is used in for-each loop - } +// TokenType tokenType; +// // Process until ; or end of file +// while (true) { +// QString s = getNextToken(&tokenType); +// simplify(s); +// if (!s.isEmpty()) +// addToken(s,mCurrentLine,tokenType); +// if ( (s == "") || (s == ";") || (s==")") || (s=="(")) +// break; +// // : is used in for-each loop +// } - // Skip to end of for loop - mCurrent = startOffset; - skipPair('(', ')'); - return ""; -} +// // Skip to end of for loop +// mCurrent = startOffset; +// skipPair('(', ')'); +// return ""; +//} QString CppTokenizer::getNextToken(TokenType *pTokenType) { @@ -203,10 +203,10 @@ QString CppTokenizer::getNextToken(TokenType *pTokenType) } } done = (result != ""); - } else if (isForInit()) { - countLines(); - result = getForInit(); - done = (result != ""); +// } else if (isForInit()) { +// countLines(); +// result = getForInit(); +// done = (result != ""); // } else if (isArguments()) { // countLines(); // result = getArguments(); @@ -526,10 +526,10 @@ bool CppTokenizer::isArguments() return *mCurrent == '('; } -bool CppTokenizer::isForInit() -{ - return (*mCurrent == '(') && (mLastToken == "for"); -} +//bool CppTokenizer::isForInit() +//{ +// return (*mCurrent == '(') && (mLastToken == "for"); +//} bool CppTokenizer::isNumber() { diff --git a/RedPandaIDE/parser/cpptokenizer.h b/RedPandaIDE/parser/cpptokenizer.h index 9a1ae61c..08f0482b 100644 --- a/RedPandaIDE/parser/cpptokenizer.h +++ b/RedPandaIDE/parser/cpptokenizer.h @@ -75,14 +75,14 @@ private: void countLines(); PToken getToken(int index); - QString getForInit(); +// QString getForInit(); QString getNextToken( TokenType *pTokenType); QString getNumber(); QString getPreprocessor(); QString getWord(); bool isArguments(); - bool isForInit(); +// bool isForInit(); bool isNumber(); bool isPreprocessor(); bool isWord(); diff --git a/RedPandaIDE/settingsdialog/projectprecompilewidget.ui b/RedPandaIDE/settingsdialog/projectprecompilewidget.ui index 1ad0c090..bfd25cf2 100644 --- a/RedPandaIDE/settingsdialog/projectprecompilewidget.ui +++ b/RedPandaIDE/settingsdialog/projectprecompilewidget.ui @@ -78,6 +78,9 @@ Qt::AlignCenter + + true +