- enhancement: support C++ using type alias;
This commit is contained in:
parent
3afe034aa1
commit
60759cef9b
3
NEWS.md
3
NEWS.md
|
@ -1,3 +1,6 @@
|
|||
Version 0.2.2
|
||||
- enhancement: support C++ using type alias;
|
||||
|
||||
Version 0.2.1
|
||||
- fix: crash when load last opens
|
||||
|
||||
|
|
|
@ -2814,6 +2814,35 @@ void CppParser::handleUsing()
|
|||
|
||||
mIndex++; //skip 'using'
|
||||
|
||||
//handle things like 'using vec = std::vector; '
|
||||
if (mIndex+1 < mTokenizer.tokenCount()
|
||||
&& mTokenizer[mIndex+1]->text == "=") {
|
||||
QString fullName = mTokenizer[mIndex]->text;
|
||||
QString aliasName;
|
||||
mIndex+=2;
|
||||
while (mIndex<mTokenizer.tokenCount() &&
|
||||
mTokenizer[mIndex]->text!=';') {
|
||||
aliasName += mTokenizer[mIndex]->text;
|
||||
mIndex++;
|
||||
}
|
||||
addStatement(
|
||||
getCurrentScope(),
|
||||
mCurrentFile,
|
||||
"using "+fullName+" = " + aliasName, //hint text
|
||||
aliasName, // name of the alias (type)
|
||||
fullName, // command
|
||||
"", // args
|
||||
"", // values
|
||||
startLine,
|
||||
StatementKind::skTypedef,
|
||||
getScope(),
|
||||
mClassScope,
|
||||
true,
|
||||
false);
|
||||
// skip ;
|
||||
mIndex++;
|
||||
return;
|
||||
}
|
||||
//handle things like 'using std::vector;'
|
||||
if ((mIndex+2>=mTokenizer.tokenCount())
|
||||
|| (mTokenizer[mIndex]->text != "namespace")) {
|
||||
|
@ -3078,12 +3107,12 @@ void CppParser::internalParse(const QString &fileName)
|
|||
break;
|
||||
}
|
||||
#ifdef QT_DEBUG
|
||||
// StringsToFile(mPreprocessor.result(),"f:\\preprocess.txt");
|
||||
// mPreprocessor.dumpDefinesTo("f:\\defines.txt");
|
||||
// mPreprocessor.dumpIncludesListTo("f:\\includes.txt");
|
||||
// mStatementList.dump("f:\\stats.txt");
|
||||
// mTokenizer.dumpTokens("f:\\tokens.txt");
|
||||
// mStatementList.dumpAll("f:\\all-stats.txt");
|
||||
StringsToFile(mPreprocessor.result(),"f:\\preprocess.txt");
|
||||
mPreprocessor.dumpDefinesTo("f:\\defines.txt");
|
||||
mPreprocessor.dumpIncludesListTo("f:\\includes.txt");
|
||||
mStatementList.dump("f:\\stats.txt");
|
||||
mTokenizer.dumpTokens("f:\\tokens.txt");
|
||||
mStatementList.dumpAll("f:\\all-stats.txt");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -578,9 +578,15 @@ void CppTokenizer::advance()
|
|||
else
|
||||
mCurrent++;
|
||||
break;
|
||||
case '=':
|
||||
skipAssignment();
|
||||
case '=': {
|
||||
if (mTokenList.size()>2
|
||||
&& mTokenList[mTokenList.size()-2]->text == "using") {
|
||||
addToken("=",mCurrentLine);
|
||||
mCurrent++;
|
||||
} else
|
||||
skipAssignment();
|
||||
break;
|
||||
}
|
||||
case '&':
|
||||
case '*':
|
||||
case '!':
|
||||
|
|
Loading…
Reference in New Issue