- enhancement: Auto insert spaces between #include and <> when reformat
- enhancement: Auto insert spaces between #include and "" when reformat
This commit is contained in:
parent
5e71973152
commit
55353859d0
2
NEWS.md
2
NEWS.md
|
@ -33,6 +33,8 @@ Red Panda C++ Version 2.23
|
|||
- enhancement: Folder mode in "File in files" dialog.
|
||||
- enhancement: When open a file, test if it contains binary contains.
|
||||
- enhancement: Correctly reformat C++ three-way comparision operator "<=>"
|
||||
- enhancement: Auto insert spaces between #include and <> when reformat
|
||||
|
||||
|
||||
Red Panda C++ Version 2.22
|
||||
|
||||
|
|
|
@ -210,6 +210,7 @@ void ASFormatter::init(ASSourceIterator* si)
|
|||
isInPreprocessor = false;
|
||||
isInPreprocessorDefineDef = false;
|
||||
isInPreprocessorBeautify = false;
|
||||
isInPreprocessorInclude = false;
|
||||
doesLineStartComment = false;
|
||||
lineEndsInCommentOnly = false;
|
||||
lineIsCommentOnly = false;
|
||||
|
@ -592,6 +593,13 @@ string ASFormatter::nextLine()
|
|||
if (currentChar == '"'
|
||||
|| (currentChar == '\'' && !isDigitSeparator(currentLine, charNum)))
|
||||
{
|
||||
|
||||
if (isInPreprocessor && isInPreprocessorInclude &&
|
||||
currentChar=='\"') {
|
||||
if (previousChar!=' ' && previousChar!='\t')
|
||||
appendSpacePad();
|
||||
isInPreprocessorInclude=false;
|
||||
}
|
||||
formatQuoteOpener();
|
||||
testForTimeToSplitFormattedLine();
|
||||
continue;
|
||||
|
@ -626,10 +634,18 @@ string ASFormatter::nextLine()
|
|||
|
||||
if (isInPreprocessor)
|
||||
{
|
||||
if (isInPreprocessorInclude &&
|
||||
(currentChar=='<' || currentChar=='\"')) {
|
||||
if (previousChar!=' ' && previousChar!='\t')
|
||||
appendSpacePad();
|
||||
isInPreprocessorInclude=false;
|
||||
}
|
||||
|
||||
appendCurrentChar();
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (isInTemplate && shouldCloseTemplates)
|
||||
{
|
||||
if (previousNonWSChar == '>' && isWhiteSpace(currentChar) && peekNextChar() == '>')
|
||||
|
@ -2673,6 +2689,7 @@ bool ASFormatter::getNextLine(bool emptyLineWasDeleted /*false*/)
|
|||
&& (previousNonWSChar != '\\'
|
||||
|| isEmptyLine(currentLine)))
|
||||
{
|
||||
isInPreprocessorInclude = false;
|
||||
isInPreprocessor = false;
|
||||
isInPreprocessorDefineDef = false;
|
||||
}
|
||||
|
@ -5652,7 +5669,11 @@ void ASFormatter::processPreprocessor()
|
|||
for (int i = 0; i < addedPreproc; i++)
|
||||
braceTypeStack->pop_back();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (currentLine.compare(preproc, 7, "include") == 0)
|
||||
{
|
||||
isInPreprocessorInclude = true;
|
||||
}
|
||||
else if (currentLine.compare(preproc, 6, "define") == 0)
|
||||
isInPreprocessorDefineDef = true;
|
||||
}
|
||||
|
|
|
@ -240,8 +240,8 @@ void ASResource::buildCastOperators(vector<const string*>* castOperators)
|
|||
*/
|
||||
void ASResource::buildHeaders(vector<const string*>* headers, int fileType, bool beautifier)
|
||||
{
|
||||
const size_t elements = 25;
|
||||
headers->reserve(elements);
|
||||
const size_t elements = 25;
|
||||
headers->reserve(elements);
|
||||
|
||||
headers->emplace_back(&AS_IF);
|
||||
headers->emplace_back(&AS_ELSE);
|
||||
|
@ -262,7 +262,7 @@ void ASResource::buildHeaders(vector<const string*>* headers, int fileType, bool
|
|||
{
|
||||
headers->emplace_back(&_AS_TRY); // __try
|
||||
headers->emplace_back(&_AS_FINALLY); // __finally
|
||||
headers->emplace_back(&_AS_EXCEPT); // __except
|
||||
headers->emplace_back(&_AS_EXCEPT); // __except
|
||||
}
|
||||
if (fileType == JAVA_TYPE)
|
||||
{
|
||||
|
@ -295,7 +295,7 @@ void ASResource::buildHeaders(vector<const string*>* headers, int fileType, bool
|
|||
}
|
||||
}
|
||||
|
||||
assert(headers->size() < elements);
|
||||
assert(headers->size() < elements);
|
||||
sort(headers->begin(), headers->end(), sortOnName);
|
||||
}
|
||||
|
||||
|
|
|
@ -939,7 +939,8 @@ private: // variables
|
|||
bool noTrimCommentContinuation;
|
||||
bool isInPreprocessor;
|
||||
bool isInPreprocessorDefineDef;
|
||||
bool isInPreprocessorBeautify;
|
||||
bool isInPreprocessorBeautify;
|
||||
bool isInPreprocessorInclude;
|
||||
bool isInTemplate;
|
||||
bool doesLineStartComment;
|
||||
bool lineEndsInCommentOnly;
|
||||
|
|
Loading…
Reference in New Issue