- Enhancement: Improved Raw string support
This commit is contained in:
parent
20339b3e9a
commit
522722c418
1
NEWS.md
1
NEWS.md
|
@ -46,6 +46,7 @@ Red Panda C++ Version 2.26
|
|||
- Fix: Expression that starts with full scoped variables might be treated as var definition.
|
||||
- Enhancement: Don't auto-indent in raw string.
|
||||
- Fix: Function list is not correctly retrived for full-scoped functions.
|
||||
- Enhancement: Improved Raw string support
|
||||
|
||||
Red Panda C++ Version 2.25
|
||||
|
||||
|
|
|
@ -4351,7 +4351,6 @@ void Editor::updateFunctionTip(bool showTip)
|
|||
// Don't bother scanning the database when there's no identifier to scan for
|
||||
|
||||
// Only do the cumbersome list filling when showing a new tooltip...
|
||||
|
||||
if (s != pMainWindow->functionTip()->functionFullName()
|
||||
&& !mParser->parsing()) {
|
||||
pMainWindow->functionTip()->clearTips();
|
||||
|
|
|
@ -748,16 +748,38 @@ void CppTokenizer::skipRawString()
|
|||
{
|
||||
mCurrent++; //skip R
|
||||
bool noEscape = false;
|
||||
bool findDCharSeq = true;
|
||||
QString dCharSeq;
|
||||
while(true) {
|
||||
mCurrent++;
|
||||
switch(mCurrent->unicode()) {
|
||||
case '(':
|
||||
if (findDCharSeq) {
|
||||
noEscape = true;
|
||||
findDCharSeq = false;
|
||||
}
|
||||
break;
|
||||
case ')':
|
||||
noEscape = false;
|
||||
if (noEscape) {
|
||||
bool ok=true;
|
||||
QChar* pChar=mCurrent+1;
|
||||
for (int i=0;i<dCharSeq.length();i++) {
|
||||
if (*pChar!=dCharSeq[i]) {
|
||||
ok=false;
|
||||
break;
|
||||
}
|
||||
pChar++;
|
||||
}
|
||||
if (ok && *pChar=='\"') {
|
||||
noEscape = false;
|
||||
mCurrent = pChar;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (findDCharSeq) {
|
||||
dCharSeq+=*mCurrent;
|
||||
}
|
||||
if (*mCurrent == 0)
|
||||
break;
|
||||
if ((*mCurrent == '"') && !noEscape)
|
||||
|
|
|
@ -963,8 +963,13 @@ void CppSyntaxer::procQuestion()
|
|||
void CppSyntaxer::procRawString()
|
||||
{
|
||||
mTokenId = TokenId::RawString;
|
||||
if (mRange.state == RangeState::rsRawString)
|
||||
mRawStringInitialDCharSeq="";
|
||||
while (mRun<mLineSize) {
|
||||
if (mRange.state!=RangeState::rsRawStringNotEscaping && (mLine[mRun]=='"')) {
|
||||
if (mRange.state!=RangeState::rsRawStringNotEscaping &&
|
||||
(mLine[mRun]=='"'
|
||||
|| mLine[mRun].isSpace()
|
||||
|| mLine[mRun].unicode()>127)) {
|
||||
mRange.state = RangeState::rsUnknown;
|
||||
mRun+=1;
|
||||
return;
|
||||
|
@ -974,14 +979,25 @@ void CppSyntaxer::procRawString()
|
|||
case '\t':
|
||||
return;
|
||||
case '(':
|
||||
if (mRange.state==RangeState::rsRawString)
|
||||
if (mRange.state==RangeState::rsRawString) {
|
||||
mRange.state = RangeState::rsRawStringNotEscaping;
|
||||
mRawStringInitialDCharSeq += "\"";
|
||||
}
|
||||
break;
|
||||
case ')':
|
||||
if (mRange.state == RangeState::rsRawStringNotEscaping)
|
||||
mRange.state = RangeState::rsRawStringEnd;
|
||||
qDebug()<<mRawStringInitialDCharSeq;
|
||||
qDebug()<<mLine.mid(mRun+1,mRawStringInitialDCharSeq.length());
|
||||
qDebug()<<(mLine.mid(mRun+1,mRawStringInitialDCharSeq.length()) == mRawStringInitialDCharSeq);
|
||||
if (mRange.state == RangeState::rsRawStringNotEscaping
|
||||
&& mLine.mid(mRun+1,mRawStringInitialDCharSeq.length()) == mRawStringInitialDCharSeq) {
|
||||
mRun = mRun+1+mRawStringInitialDCharSeq.length();
|
||||
mRange.state = RangeState::rsUnknown;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (mRange.state == RangeState::rsRawString)
|
||||
mRawStringInitialDCharSeq += mLine[mRun];
|
||||
mRun+=1;
|
||||
}
|
||||
if (mRun>=mLineSize && mRange.state != RangeState::rsRawStringNotEscaping)
|
||||
|
|
|
@ -159,6 +159,8 @@ private:
|
|||
int mLeftBraces;
|
||||
int mRightBraces;
|
||||
|
||||
QString mRawStringInitialDCharSeq;
|
||||
|
||||
QSet<QString> mCustomTypeKeywords;
|
||||
|
||||
PTokenAttribute mPreprocessorAttribute;
|
||||
|
|
Loading…
Reference in New Issue