refactor test for operator

This commit is contained in:
Roy Qu 2023-03-12 12:42:44 +08:00
parent b246e3d145
commit f04c7c0221
3 changed files with 6 additions and 4 deletions

View File

@ -1631,6 +1631,7 @@ bool CppParser::checkForKeyword(KeywordType& keywordType)
case KeywordType::None: case KeywordType::None:
case KeywordType::NotKeyword: case KeywordType::NotKeyword:
case KeywordType::DeclType: case KeywordType::DeclType:
case KeywordType::Operator:
return false; return false;
default: default:
return true; return true;
@ -1753,13 +1754,12 @@ bool CppParser::checkForTypedefStruct()
bool CppParser::checkForUsing(KeywordType keywordType) bool CppParser::checkForUsing(KeywordType keywordType)
{ {
return keywordType==KeywordType::Using && (mIndex < mTokenizer.tokenCount()-1); return keywordType==KeywordType::Using && (mIndex < mTokenizer.tokenCount()-1);
} }
void CppParser::checkAndHandleMethodOrVar(KeywordType keywordType) void CppParser::checkAndHandleMethodOrVar(KeywordType keywordType)
{ {
if (mIndex+2>=mTokenizer.tokenCount()) { if (mIndex+2>=mTokenizer.tokenCount()) {
mIndex+=2; // left's finish; mIndex+=2; // let's finish;
return; return;
} }
QString currentText=mTokenizer[mIndex]->text; QString currentText=mTokenizer[mIndex]->text;
@ -1773,7 +1773,7 @@ void CppParser::checkAndHandleMethodOrVar(KeywordType keywordType)
mIndex+=2; mIndex+=2;
} }
} else { } else {
if (currentText=="operator") { if (keywordType == KeywordType::Operator) {
handleOperatorOverloading("", handleOperatorOverloading("",
mIndex, mIndex,
false); false);

View File

@ -184,8 +184,9 @@ void initParser()
CppKeywords.insert("const",KeywordType::None); CppKeywords.insert("const",KeywordType::None);
CppKeywords.insert("extern",KeywordType::None); CppKeywords.insert("extern",KeywordType::None);
CppKeywords.insert("operator",KeywordType::Operator);
// handled elsewhere // handled elsewhere
CppKeywords.insert("operator",KeywordType::None);
CppKeywords.insert("static",KeywordType::None); CppKeywords.insert("static",KeywordType::None);
//struct/class/union //struct/class/union

View File

@ -76,6 +76,7 @@ enum class KeywordType {
Typedef, //typedef Typedef, //typedef
Using, //using Using, //using
DeclType, // decltype DeclType, // decltype
Operator, //operator
None, // It's a keyword but don't process here None, // It's a keyword but don't process here
NotKeyword NotKeyword
}; };