- fix: Class constructor & destructor is not correctly handled.
This commit is contained in:
parent
0730aa6c22
commit
919ba31c32
1
NEWS.md
1
NEWS.md
|
@ -7,6 +7,7 @@ Red Panda C++ Version 2.19
|
||||||
- fix: Crash when drag the selection beyond the end of the document.
|
- fix: Crash when drag the selection beyond the end of the document.
|
||||||
- enhancement: Drag the selection beyond the end of the document, and move/copy it beyond the last line.
|
- enhancement: Drag the selection beyond the end of the document, and move/copy it beyond the last line.
|
||||||
- enhancement: Open Containing folder will auto select the file in windows file explore.
|
- enhancement: Open Containing folder will auto select the file in windows file explore.
|
||||||
|
- fix: Class constructor & destructor is not correctly handled.
|
||||||
|
|
||||||
Red Panda C++ Version 2.18
|
Red Panda C++ Version 2.18
|
||||||
|
|
||||||
|
|
|
@ -1930,10 +1930,14 @@ void CppParser::checkAndHandleMethodOrVar(KeywordType keywordType)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
bool isDestructor = false;
|
||||||
if (!sName.isEmpty()) {
|
if (!sName.isEmpty()) {
|
||||||
if (sName.endsWith("::"))
|
if (sName.endsWith("::"))
|
||||||
sName+=mTokenizer[mIndex]->text;
|
sName+=mTokenizer[mIndex]->text;
|
||||||
else {
|
else if (sName.endsWith("~")) {
|
||||||
|
isDestructor=true;
|
||||||
|
sName+=mTokenizer[mIndex]->text;
|
||||||
|
} else {
|
||||||
sType += " "+sName;
|
sType += " "+sName;
|
||||||
sName = mTokenizer[mIndex]->text;
|
sName = mTokenizer[mIndex]->text;
|
||||||
}
|
}
|
||||||
|
@ -1941,8 +1945,18 @@ void CppParser::checkAndHandleMethodOrVar(KeywordType keywordType)
|
||||||
sName = mTokenizer[mIndex]->text;
|
sName = mTokenizer[mIndex]->text;
|
||||||
mIndex++;
|
mIndex++;
|
||||||
|
|
||||||
handleMethod(StatementKind::skFunction,sType,
|
if (isDestructor)
|
||||||
|
handleMethod(StatementKind::skDestructor,sType,
|
||||||
|
sName,mIndex,false,isFriend);
|
||||||
|
else {
|
||||||
|
sType=sType.trimmed();
|
||||||
|
if (sType.isEmpty())
|
||||||
|
handleMethod(StatementKind::skConstructor,sType,
|
||||||
|
sName,mIndex,false,isFriend);
|
||||||
|
else
|
||||||
|
handleMethod(StatementKind::skFunction,sType,
|
||||||
sName,mIndex,isStatic,isFriend);
|
sName,mIndex,isStatic,isFriend);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} else if (
|
} else if (
|
||||||
|
@ -1956,6 +1970,9 @@ void CppParser::checkAndHandleMethodOrVar(KeywordType keywordType)
|
||||||
} else if ( mTokenizer[mIndex + 1]->text == "::") {
|
} else if ( mTokenizer[mIndex + 1]->text == "::") {
|
||||||
sName = sName + mTokenizer[mIndex]->text+ "::";
|
sName = sName + mTokenizer[mIndex]->text+ "::";
|
||||||
mIndex+=2;
|
mIndex+=2;
|
||||||
|
} else if (mTokenizer[mIndex]->text == "~") {
|
||||||
|
sName = sName + "~";
|
||||||
|
mIndex++;
|
||||||
} else {
|
} else {
|
||||||
QString s = mTokenizer[mIndex]->text;
|
QString s = mTokenizer[mIndex]->text;
|
||||||
if (sName.endsWith("::")) {
|
if (sName.endsWith("::")) {
|
||||||
|
@ -3178,10 +3195,11 @@ bool CppParser::handleStatement()
|
||||||
mIndex++;
|
mIndex++;
|
||||||
} else if (mTokenizer[mIndex]->text.startsWith('~')) {
|
} else if (mTokenizer[mIndex]->text.startsWith('~')) {
|
||||||
//it should be a destructor
|
//it should be a destructor
|
||||||
if (mIndex+1<tokenCount
|
if (mIndex+2<tokenCount
|
||||||
&& mTokenizer[mIndex+1]->text=='(') {
|
&& isIdentChar(mTokenizer[mIndex+1]->text[0])
|
||||||
|
&& mTokenizer[mIndex+2]->text=='(') {
|
||||||
//dont further check to speed up
|
//dont further check to speed up
|
||||||
handleMethod(StatementKind::skDestructor, "", '~'+mTokenizer[mIndex]->text, mIndex+1, false, false);
|
handleMethod(StatementKind::skDestructor, "", '~'+mTokenizer[mIndex+1]->text, mIndex+2, false, false);
|
||||||
} else {
|
} else {
|
||||||
//error
|
//error
|
||||||
mIndex=moveToEndOfStatement(mIndex,false);
|
mIndex=moveToEndOfStatement(mIndex,false);
|
||||||
|
|
Loading…
Reference in New Issue