- 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
|
Version 0.2.1
|
||||||
- fix: crash when load last opens
|
- fix: crash when load last opens
|
||||||
|
|
||||||
|
|
|
@ -2814,6 +2814,35 @@ void CppParser::handleUsing()
|
||||||
|
|
||||||
mIndex++; //skip 'using'
|
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;'
|
//handle things like 'using std::vector;'
|
||||||
if ((mIndex+2>=mTokenizer.tokenCount())
|
if ((mIndex+2>=mTokenizer.tokenCount())
|
||||||
|| (mTokenizer[mIndex]->text != "namespace")) {
|
|| (mTokenizer[mIndex]->text != "namespace")) {
|
||||||
|
@ -3078,12 +3107,12 @@ void CppParser::internalParse(const QString &fileName)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifdef QT_DEBUG
|
#ifdef QT_DEBUG
|
||||||
// StringsToFile(mPreprocessor.result(),"f:\\preprocess.txt");
|
StringsToFile(mPreprocessor.result(),"f:\\preprocess.txt");
|
||||||
// mPreprocessor.dumpDefinesTo("f:\\defines.txt");
|
mPreprocessor.dumpDefinesTo("f:\\defines.txt");
|
||||||
// mPreprocessor.dumpIncludesListTo("f:\\includes.txt");
|
mPreprocessor.dumpIncludesListTo("f:\\includes.txt");
|
||||||
// mStatementList.dump("f:\\stats.txt");
|
mStatementList.dump("f:\\stats.txt");
|
||||||
// mTokenizer.dumpTokens("f:\\tokens.txt");
|
mTokenizer.dumpTokens("f:\\tokens.txt");
|
||||||
// mStatementList.dumpAll("f:\\all-stats.txt");
|
mStatementList.dumpAll("f:\\all-stats.txt");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -578,9 +578,15 @@ void CppTokenizer::advance()
|
||||||
else
|
else
|
||||||
mCurrent++;
|
mCurrent++;
|
||||||
break;
|
break;
|
||||||
case '=':
|
case '=': {
|
||||||
skipAssignment();
|
if (mTokenList.size()>2
|
||||||
|
&& mTokenList[mTokenList.size()-2]->text == "using") {
|
||||||
|
addToken("=",mCurrentLine);
|
||||||
|
mCurrent++;
|
||||||
|
} else
|
||||||
|
skipAssignment();
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case '&':
|
case '&':
|
||||||
case '*':
|
case '*':
|
||||||
case '!':
|
case '!':
|
||||||
|
|
Loading…
Reference in New Issue