- fix: Function parameters that is pointer,reference or array can't be correctly parsed.

This commit is contained in:
Roy Qu 2023-01-11 09:51:05 +08:00
parent 5f75fd97cd
commit 9a5f97cc7a
4 changed files with 26 additions and 30 deletions

View File

@ -23,6 +23,7 @@ Red Panda C++ Version 2.8
- fix: alt+shift+left/right can't select
- fix: Input any content will exit column mode.
- fix: Result of scope calculation not right if a for statement immediately follows another for statement.
- fix: Function parameters that is pointer,reference or array can't be correctly parsed.
Red Panda C++ Version 2.7

View File

@ -3819,7 +3819,7 @@ void CppParser::internalParse(const QString &fileName)
QStringList preprocessResult = mPreprocessor.result();
#ifdef QT_DEBUG
// stringsToFile(mPreprocessor.result(),QString("r:\\preprocess-%1.txt").arg(extractFileName(fileName)));
stringsToFile(mPreprocessor.result(),QString("r:\\preprocess-%1.txt").arg(extractFileName(fileName)));
// mPreprocessor.dumpDefinesTo("r:\\defines.txt");
// mPreprocessor.dumpIncludesListTo("r:\\includes.txt");
#endif
@ -3833,7 +3833,7 @@ void CppParser::internalParse(const QString &fileName)
if (mTokenizer.tokenCount() == 0)
return;
#ifdef QT_DEBUG
// mTokenizer.dumpTokens(QString("r:\\tokens-%1.txt").arg(extractFileName(fileName)));
mTokenizer.dumpTokens(QString("r:\\tokens-%1.txt").arg(extractFileName(fileName)));
#endif
#ifdef QT_DEBUG
lastIndex = -1;
@ -3844,8 +3844,8 @@ void CppParser::internalParse(const QString &fileName)
break;
}
#ifdef QT_DEBUG
// mStatementList.dumpAll(QString("r:\\all-stats-%1.txt").arg(extractFileName(fileName)));
// mStatementList.dump(QString("r:\\stats-%1.txt").arg(extractFileName(fileName)));
mStatementList.dumpAll(QString("r:\\all-stats-%1.txt").arg(extractFileName(fileName)));
mStatementList.dump(QString("r:\\stats-%1.txt").arg(extractFileName(fileName)));
#endif
//reduce memory usage
internalClear();
@ -5116,30 +5116,25 @@ void CppParser::scanMethodArgs(const PStatement& functionStatement, int argStart
} else if (isWordChar(mTokenizer[i]->text[0])) {
QString cmd=mTokenizer[i]->text;
if (i+1==argEnd || mTokenizer[i+1]->text==',' || mTokenizer[i+1]->text=='=') {
bool noCmd=false;
if (!cmd.startsWith('*')
&& !cmd.startsWith('&')
&& !cmd.endsWith(']')) {
PStatement statement=findStatementOf(mCurrentFile,cmd,functionStatement,true);
noCmd = (statement && isTypeStatement(statement->kind));
QString args,suffix;
parseCommandTypeAndArgs(cmd,suffix,args);
if (!cmd.isEmpty()) {
PStatement statement = findStatementOf(mCurrentFile,cmd,functionStatement,true);
bool noCmd = (statement && isTypeStatement(statement->kind));
if (!noCmd) {
QString args,suffix;
parseCommandTypeAndArgs(cmd,suffix,args);
if (!cmd.isEmpty()) {
addStatement(
functionStatement,
mCurrentFile,
varType+suffix, // 'int*'
cmd, // a
args,
"",
"",
mTokenizer[i]->line,
StatementKind::skParameter,
StatementScope::Local,
StatementClassScope::None,
StatementProperty::spHasDefinition);
}
addStatement(
functionStatement,
mCurrentFile,
varType+suffix, // 'int*'
cmd, // a
args,
"",
"",
mTokenizer[i]->line,
StatementKind::skParameter,
StatementScope::Local,
StatementClassScope::None,
StatementProperty::spHasDefinition);
}
}
} else {

View File

@ -5495,7 +5495,7 @@ void SynEdit::doInsertText(const BufferCoord& pos,
ensureCursorPosVisible();
break;
case SelectionMode::Column:
insertedLines = doInsertTextByColumnMode(pos,text, startLine,endLine);
insertedLines = doInsertTextByColumnMode(text, startLine,endLine);
doLinesInserted(endLine-insertedLines+1,insertedLines);
if (!text.isEmpty()) {
int textLen = text.back().length();
@ -5612,7 +5612,7 @@ int SynEdit::doInsertTextByNormalMode(const BufferCoord& pos, const QStringList&
return result;
}
int SynEdit::doInsertTextByColumnMode(const BufferCoord& pos, const QStringList& text, int startLine, int endLine)
int SynEdit::doInsertTextByColumnMode(const QStringList& text, int startLine, int endLine)
{
QString str;
QString tempString;

View File

@ -550,7 +550,7 @@ private:
void doDeleteText(BufferCoord startPos, BufferCoord endPos, SelectionMode mode);
void doInsertText(const BufferCoord& pos, const QStringList& text, SelectionMode mode, int startLine, int endLine);
int doInsertTextByNormalMode(const BufferCoord& pos, const QStringList& text, BufferCoord &newPos);
int doInsertTextByColumnMode(const BufferCoord& pos, const QStringList& text, int startLine, int endLine);
int doInsertTextByColumnMode(const QStringList& text, int startLine, int endLine);
int doInsertTextByLineMode(const BufferCoord& pos, const QStringList& text, BufferCoord &newPos);
void doTrimTrailingSpaces();