Compare commits

...
25 Commits
Author SHA1 Message Date
saalen 2d7211aa6c removed ASBase inheritance from ASResource 2024-09-10 22:34:31 +02:00
saalen 96d2c94500 updated copyright notes 2024-09-10 21:57:42 +02:00
saalen 723c3d9d67 apply clang-tidy readability-container-size-empty option 2024-09-10 21:51:26 +02:00
saalen 436c1a9abc apply clang-tidy modernize and performance options 2024-09-10 21:29:17 +02:00
saalen 91402fea65 Merge branch 'master' of gitlab.com:saalen/astyle 2024-09-10 16:47:23 +02:00
saalen 91acbad5d8 updated version 2024-09-10 16:46:43 +02:00
saalen f1424af25b https://gitlab.com/saalen/astyle/-/issues/35 reverted - too many regressions 2024-09-10 15:28:00 +02:00
saalen 84ae8ff727 https://gitlab.com/saalen/astyle/-/issues/53 fix padding of multiplier before fct calls 2024-09-09 16:06:45 +02:00
Andre Simon 38c12d4e2f Merge branch 'master' of https://gitlab.com/saalen/astyle 2024-09-05 21:24:34 +02:00
saalen 258aa4fc93 https://sourceforge.net/p/astyle/bugs/580/ fix pad-include with UTF-8 BOM 2024-09-04 15:46:00 +02:00
saalen b75b162f07 updated changes 2024-09-04 14:34:43 +02:00
saalen 55e03f5b74 https://sourceforge.net/p/astyle/bugs/580/ fix pad-include and pad-negation setters 2024-09-04 14:33:08 +02:00
saalen e34c3c3962 fix CI pipeline 2024-09-01 13:43:02 +02:00
saalen b7ddacb2bf updated JNI interface to offer old API and Arduino IDE interface 2024-08-31 16:19:29 +02:00
saalen b3f6f32474 updated docs 2024-08-30 16:10:42 +02:00
saalen ec5e6033ca https://sourceforge.net/p/astyle/tickets/578/ improve --align-pointer=type after parens and brackets 2024-08-30 15:55:27 +02:00
saalen 5c25e14984 updated JNI interface to use Arduino IDE conventions 2024-08-29 15:05:43 +02:00
saalen 7ed1905602 removed VMS compilation options 2024-08-29 14:01:12 +02:00
saalen 859e318894 https://sourceforge.net/p/astyle/bugs/572/ disabled alignment of multiplication operands 2024-08-29 13:59:38 +02:00
Andre Simon 3fab90db91 Merge branch 'master' of https://gitlab.com/saalen/astyle 2024-08-20 20:05:34 +02:00
saalen 1563bf4e80 apply clang-tidy modernize-use-emplace 2024-08-20 12:16:26 +02:00
saalen df35491d3b apply clang-tidy modernize-use-auto 2024-08-20 12:11:54 +02:00
saalen 913f24c3ef https://sourceforge.net/p/astyle/bugs/563 fix indent of member function call parameters 2024-08-20 10:58:48 +02:00
Andre Simon 6ea6067349 Merge branch 'master' of https://gitlab.com/saalen/astyle 2024-08-09 23:19:54 +02:00
Andre Simon 5a79a97e5c https://sourceforge.net/p/astyle/bugs/576/ fix some typos
Signed-off-by: Andre Simon <as@andre-simon.de>
2024-07-24 21:39:57 +02:00
23 changed files with 781 additions and 852 deletions
+20 -6
View File
@@ -15,19 +15,33 @@
</head>
<body>
<h1>Artistic Style Release Notes</h1>
<h3>Artistic Style 3.6.2 (September 2024)</h3>
<ul>
<li>Reverted alignment of user defined types using --align-pointer (https://gitlab.com/saalen/astyle/-/issues/35)</li>
</ul>
<h3>Artistic Style 3.6.1 (September 2024)</h3>
<ul>
<li>Fix setting of --pad-negation and --pad-include options (https://sourceforge.net/p/astyle/bugs/580/)</li>
<li>Fix --pad-include with UTF-8 BOM (https://sourceforge.net/p/astyle/bugs/580/)</li>
<li>Improve multiplication recognition with --align-pointer=type (https://sourceforge.net/p/astyle/bugs/572/)</li>
<li>Improve --align-pointer=type after parens and brackets (https://sourceforge.net/p/astyle/bugs/578/)</li>
<li>Removed VMS compilation options</li>
<li>Updated JNI interface to use Arduino IDE conventions</li>
</ul>
<h3>Artistic Style 3.6 (August 2024)</h3>
<ul>
<li>Add option --pad-include (https://sourceforge.net/p/astyle/tickets/117/)</li>
<li>combined GHC and GSC style options</li>
<li>improve combination of --align-pointer=type and --pad-oper (https://sourceforge.net/p/astyle/tickets/578/)</li>
<li>improve multiplication recognition with --align-pointer=type (https://sourceforge.net/p/astyle/tickets/572/)</li>
<li>update compiler options in build files</li>
<li>fix indent of assignments within macros ( https://gitlab.com/saalen/astyle/-/issues/47)</li>
<li>Combined GHC and GSC style options</li>
<li>Improve combination of --align-pointer=type and --pad-oper (https://sourceforge.net/p/astyle/bugs/578/)</li>
<li>Improve multiplication recognition with --align-pointer=type (https://sourceforge.net/p/astyle/bugs/572/)</li>
<li>Update compiler options in build files</li>
<li>Fix indent of assignments within macros ( https://gitlab.com/saalen/astyle/-/issues/47)</li>
</ul>
<h3>Artistic Style 3.5.2 (July 2024)</h3>
+3
View File
@@ -92,6 +92,9 @@ parser:flag "--pad-comma"
parser:flag "--pad-negation"
:description "Insert space padding after negations"
parser:flag "--pad-include"
:description "Insert space padding after include directives"
parser:flag "--pad-paren"
:description "Insert space padding around parenthesis on both the outside and the inside"
+184 -181
View File
@@ -1,5 +1,5 @@
// ASBeautifier.cpp
// Copyright (c) 2023 The Artistic Style Authors.
// Copyright (c) 2024 The Artistic Style Authors.
// This code is licensed under the MIT License.
// License.md describes the conditions under which this software may be distributed.
@@ -11,11 +11,13 @@
#include <algorithm>
//-----------------------------------------------------------------------------
// astyle namespace
//-----------------------------------------------------------------------------
namespace astyle {
//
// this must be global
static int g_preprocessorCppExternCBrace;
@@ -535,7 +537,7 @@ std::string ASBeautifier::beautify(const std::string& originalLine)
else
{
line = trim(originalLine);
if (line.length() > 0)
if (!line.empty())
{
if (line[0] == '{')
lineBeginsWithOpenBrace = true;
@@ -543,16 +545,16 @@ std::string ASBeautifier::beautify(const std::string& originalLine)
lineBeginsWithCloseBrace = true;
else if (line[0] == ',')
lineBeginsWithComma = true;
else if (line.compare(0, AS_OPEN_LINE_COMMENT.length(), AS_OPEN_LINE_COMMENT) == 0)
else if (line.compare(0, ASResource::AS_OPEN_LINE_COMMENT.length(), ASResource::AS_OPEN_LINE_COMMENT) == 0)
lineIsLineCommentOnly = true;
else if (line.compare(0, AS_OPEN_COMMENT.length(), AS_OPEN_COMMENT) == 0)
else if (line.compare(0, ASResource::AS_OPEN_COMMENT.length(), ASResource::AS_OPEN_COMMENT) == 0)
{
if (line.find(AS_CLOSE_COMMENT, AS_CLOSE_COMMENT.length()) != std::string::npos)
if (line.find(ASResource::AS_CLOSE_COMMENT, ASResource::AS_CLOSE_COMMENT.length()) != std::string::npos)
lineIsCommentOnly = true;
}
else if (line.compare(0, AS_GSC_OPEN_COMMENT.length(), AS_GSC_OPEN_COMMENT) == 0)
else if (line.compare(0, ASResource::AS_GSC_OPEN_COMMENT.length(), ASResource::AS_GSC_OPEN_COMMENT) == 0)
{
if (line.find(AS_GSC_CLOSE_COMMENT, AS_GSC_CLOSE_COMMENT.length()) != std::string::npos)
if (line.find(ASResource::AS_GSC_CLOSE_COMMENT, ASResource::AS_GSC_CLOSE_COMMENT.length()) != std::string::npos)
lineIsCommentOnly = true;
}
}
@@ -560,11 +562,11 @@ std::string ASBeautifier::beautify(const std::string& originalLine)
isInRunInComment = false;
size_t j = line.find_first_not_of(" \t{");
if ( j != std::string::npos
&& line.compare(j, AS_OPEN_LINE_COMMENT.length(), AS_OPEN_LINE_COMMENT) == 0)
&& line.compare(j, ASResource::AS_OPEN_LINE_COMMENT.length(), ASResource::AS_OPEN_LINE_COMMENT) == 0)
lineOpensWithLineComment = true;
if (j != std::string::npos
&& (line.compare(j, AS_OPEN_COMMENT.length(), AS_OPEN_COMMENT) == 0
|| line.compare(j, AS_GSC_OPEN_COMMENT.length(), AS_GSC_OPEN_COMMENT) == 0))
&& (line.compare(j, ASResource::AS_OPEN_COMMENT.length(), ASResource::AS_OPEN_COMMENT) == 0
|| line.compare(j, ASResource::AS_GSC_OPEN_COMMENT.length(), ASResource::AS_GSC_OPEN_COMMENT) == 0))
{
lineOpensWithComment = true;
size_t k = line.find_first_not_of(" \t");
@@ -579,7 +581,7 @@ std::string ASBeautifier::beautify(const std::string& originalLine)
&& line.find("*INDENT-OFF*", 0) != std::string::npos)
isIndentModeOff = true;
if (line.length() == 0)
if (line.empty())
{
if (backslashEndsPrevLine)
{
@@ -612,7 +614,7 @@ std::string ASBeautifier::beautify(const std::string& originalLine)
// handle preprocessor commands
if (isInIndentablePreprocBlock
&& line.length() > 0
&& !line.empty()
&& line[0] != '#')
{
if (isIndentModeOff)
@@ -629,7 +631,7 @@ std::string ASBeautifier::beautify(const std::string& originalLine)
if (!isInComment
&& !isInQuoteContinuation
&& line.length() > 0
&& !line.empty()
&& ((line[0] == '#' && !isIndentedPreprocessor(line, 0))
|| backslashEndsPrevLine))
{
@@ -665,7 +667,7 @@ std::string ASBeautifier::beautify(const std::string& originalLine)
else
return indentedLine;
}
if (shouldIndentPreprocConditional && preproc.length() > 0)
if (shouldIndentPreprocConditional && !preproc.empty())
{
if (isIndentModeOff)
@@ -707,7 +709,7 @@ std::string ASBeautifier::beautify(const std::string& originalLine)
}
// check if the last char is a backslash
if (line.length() > 0)
if (!line.empty())
backslashEndsPrevLine = (line[line.length() - 1] == '\\');
// comments within the definition line can be continued without the backslash
if (isInPreprocessorUnterminatedComment(line))
@@ -763,7 +765,7 @@ std::string ASBeautifier::beautify(const std::string& originalLine)
bool isInExtraHeaderIndent = false;
if (!headerStack->empty()
&& lineBeginsWithOpenBrace
&& (headerStack->back() != &AS_OPEN_BRACE
&& (headerStack->back() != &ASResource::AS_OPEN_BRACE
|| probationHeader != nullptr))
isInExtraHeaderIndent = true;
@@ -792,7 +794,7 @@ std::string ASBeautifier::beautify(const std::string& originalLine)
if (isInDefine)
{
if (line.length() > 0 && line[0] == '#')
if (!line.empty() && line[0] == '#')
{
// the 'define' does not have to be attached to the '#'
std::string preproc = trim(line.substr(1));
@@ -1470,10 +1472,10 @@ std::pair<int, int> ASBeautifier::computePreprocessorIndent()
std::pair<int, int> entry(indentCount, spaceIndentCount);
if (!headerStack->empty()
&& entry.first > 0
&& (headerStack->back() == &AS_IF
|| headerStack->back() == &AS_ELSE
|| headerStack->back() == &AS_FOR
|| headerStack->back() == &AS_WHILE))
&& (headerStack->back() == &ASResource::AS_IF
|| headerStack->back() == &ASResource::AS_ELSE
|| headerStack->back() == &ASResource::AS_FOR
|| headerStack->back() == &ASResource::AS_WHILE))
--entry.first;
return entry;
}
@@ -1494,8 +1496,8 @@ int ASBeautifier::getNextProgramCharDistance(std::string_view line, int i) const
ch = line[i + charDistance];
if (inComment)
{
if (line.compare(i + charDistance, AS_CLOSE_COMMENT.length(), AS_CLOSE_COMMENT) == 0
|| line.compare(i + charDistance, AS_GSC_CLOSE_COMMENT.length(), AS_GSC_CLOSE_COMMENT) == 0)
if (line.compare(i + charDistance, ASResource::AS_CLOSE_COMMENT.length(), ASResource::AS_CLOSE_COMMENT) == 0
|| line.compare(i + charDistance, ASResource::AS_GSC_CLOSE_COMMENT.length(), ASResource::AS_GSC_CLOSE_COMMENT) == 0)
{
charDistance++;
inComment = false;
@@ -1506,10 +1508,10 @@ int ASBeautifier::getNextProgramCharDistance(std::string_view line, int i) const
continue;
if (ch == '/')
{
if (line.compare(i + charDistance, AS_OPEN_LINE_COMMENT.length(), AS_OPEN_LINE_COMMENT) == 0)
if (line.compare(i + charDistance, ASResource::AS_OPEN_LINE_COMMENT.length(), ASResource::AS_OPEN_LINE_COMMENT) == 0)
return remainingCharNum;
if (line.compare(i + charDistance, AS_OPEN_COMMENT.length(), AS_OPEN_COMMENT) == 0
|| line.compare(i + charDistance, AS_GSC_OPEN_COMMENT.length(), AS_GSC_OPEN_COMMENT) == 0)
if (line.compare(i + charDistance, ASResource::AS_OPEN_COMMENT.length(), ASResource::AS_OPEN_COMMENT) == 0
|| line.compare(i + charDistance, ASResource::AS_GSC_OPEN_COMMENT.length(), ASResource::AS_GSC_OPEN_COMMENT) == 0)
{
charDistance++;
inComment = true;
@@ -1598,13 +1600,13 @@ std::string ASBeautifier::rtrim(std::string_view str) const
*/
std::vector<std::vector<const std::string*>*>* ASBeautifier::copyTempStacks(const ASBeautifier& other) const
{
std::vector<std::vector<const std::string*>*>* tempStacksNew = new std::vector<std::vector<const std::string*>*>;
auto* tempStacksNew = new std::vector<std::vector<const std::string*>*>;
std::vector<std::vector<const std::string*>*>::iterator iter;
for (iter = other.tempStacks->begin();
iter != other.tempStacks->end();
++iter)
{
std::vector<const std::string*>* newVec = new std::vector<const std::string*>;
auto* newVec = new std::vector<const std::string*>;
*newVec = **iter;
tempStacksNew->emplace_back(newVec);
}
@@ -1652,7 +1654,7 @@ void ASBeautifier::deleteBeautifierContainer(std::vector<ASBeautifier*>*& contai
{
if (container != nullptr)
{
std::vector<ASBeautifier*>::iterator iter = container->begin();
auto iter = container->begin();
while (iter < container->end())
{
delete *iter;
@@ -1673,7 +1675,7 @@ void ASBeautifier::deleteTempStacksContainer(std::vector<std::vector<const std::
{
if (container != nullptr)
{
std::vector<std::vector<const std::string*>*>::iterator iter = container->begin();
auto iter = container->begin();
while (iter < container->end())
{
delete *iter;
@@ -1736,7 +1738,7 @@ bool ASBeautifier::statementEndsWithComma(std::string_view line, int index) cons
if (isInComment_)
{
if (line.compare(i, AS_CLOSE_COMMENT.length(), AS_CLOSE_COMMENT) == 0)
if (line.compare(i, ASResource::AS_CLOSE_COMMENT.length(), ASResource::AS_CLOSE_COMMENT) == 0)
{
isInComment_ = false;
++i;
@@ -1765,11 +1767,11 @@ bool ASBeautifier::statementEndsWithComma(std::string_view line, int index) cons
continue;
}
if (line.compare(i, AS_OPEN_LINE_COMMENT.length(), AS_OPEN_LINE_COMMENT) == 0)
if (line.compare(i, ASResource::AS_OPEN_LINE_COMMENT.length(), ASResource::AS_OPEN_LINE_COMMENT) == 0)
break;
if (line.compare(i, AS_OPEN_COMMENT.length(), AS_OPEN_COMMENT) == 0
|| line.compare(i, AS_GSC_OPEN_COMMENT.length(), AS_GSC_OPEN_COMMENT) == 0)
if (line.compare(i, ASResource::AS_OPEN_COMMENT.length(), ASResource::AS_OPEN_COMMENT) == 0
|| line.compare(i, ASResource::AS_GSC_OPEN_COMMENT.length(), ASResource::AS_GSC_OPEN_COMMENT) == 0)
{
if (isLineEndComment(line, i))
break;
@@ -1803,13 +1805,13 @@ bool ASBeautifier::statementEndsWithComma(std::string_view line, int index) cons
*/
bool ASBeautifier::isLineEndComment(std::string_view line, int startPos) const
{
assert(line.compare(startPos, AS_OPEN_COMMENT.length(), AS_OPEN_COMMENT) == 0
|| line.compare(startPos, AS_GSC_OPEN_COMMENT.length(), AS_GSC_OPEN_COMMENT) == 0 );
assert(line.compare(startPos, ASResource::AS_OPEN_COMMENT.length(), ASResource::AS_OPEN_COMMENT) == 0
|| line.compare(startPos, ASResource::AS_GSC_OPEN_COMMENT.length(), ASResource::AS_GSC_OPEN_COMMENT) == 0 );
bool isCppComment = line.compare(startPos, AS_OPEN_COMMENT.length(), AS_OPEN_COMMENT);
bool isCppComment = line.compare(startPos, ASResource::AS_OPEN_COMMENT.length(), ASResource::AS_OPEN_COMMENT);
// comment must be closed on this line with nothing after it
size_t endNum = line.find(isCppComment ? AS_CLOSE_COMMENT : AS_GSC_CLOSE_COMMENT, startPos + 2);
size_t endNum = line.find(isCppComment ? ASResource::AS_CLOSE_COMMENT : ASResource::AS_GSC_CLOSE_COMMENT, startPos + 2);
if (endNum != std::string::npos)
{
size_t nextChar = line.find_first_not_of(" \t", endNum + 2);
@@ -1995,11 +1997,11 @@ bool ASBeautifier::isInPreprocessorUnterminatedComment(std::string_view line)
{
if (!isInPreprocessorComment)
{
size_t startPos = line.find(AS_OPEN_COMMENT);
size_t startPos = line.find(ASResource::AS_OPEN_COMMENT);
if (startPos == std::string::npos)
return false;
}
size_t endNum = line.find(AS_CLOSE_COMMENT);
size_t endNum = line.find(ASResource::AS_CLOSE_COMMENT);
if (endNum != std::string::npos)
{
isInPreprocessorComment = false;
@@ -2044,7 +2046,7 @@ void ASBeautifier::processPreprocessor(std::string_view preproc, std::string_vie
// push a new beautifier into the active stack
// this beautifier will be used for the indentation of this define
ASBeautifier* defineBeautifier = new ASBeautifier(*this);
auto* defineBeautifier = new ASBeautifier(*this);
activeBeautifierStack->emplace_back(defineBeautifier);
}
else
@@ -2135,31 +2137,31 @@ void ASBeautifier::computePreliminaryIndentation()
if (blockIndent)
{
// do NOT indent opening block for these headers
if (!((*headerStack)[i] == &AS_NAMESPACE
|| (*headerStack)[i] == &AS_MODULE
|| (*headerStack)[i] == &AS_CLASS
|| (*headerStack)[i] == &AS_STRUCT
|| (*headerStack)[i] == &AS_UNION
|| (*headerStack)[i] == &AS_INTERFACE
|| (*headerStack)[i] == &AS_THROWS
|| (*headerStack)[i] == &AS_STATIC))
if (!((*headerStack)[i] == &ASResource::AS_NAMESPACE
|| (*headerStack)[i] == &ASResource::AS_MODULE
|| (*headerStack)[i] == &ASResource::AS_CLASS
|| (*headerStack)[i] == &ASResource::AS_STRUCT
|| (*headerStack)[i] == &ASResource::AS_UNION
|| (*headerStack)[i] == &ASResource::AS_INTERFACE
|| (*headerStack)[i] == &ASResource::AS_THROWS
|| (*headerStack)[i] == &ASResource::AS_STATIC))
++indentCount;
} else {
//GL37
if (!(i > 0 && (*headerStack)[i - 1] != &AS_OPEN_BRACE
&& (*headerStack)[i] == &AS_OPEN_BRACE))
if (!(i > 0 && (*headerStack)[i - 1] != &ASResource::AS_OPEN_BRACE
&& (*headerStack)[i] == &ASResource::AS_OPEN_BRACE))
++indentCount;
}
if (!isJavaStyle() && !namespaceIndent && i > 0
&& ((*headerStack)[i - 1] == &AS_NAMESPACE
|| (*headerStack)[i - 1] == &AS_MODULE)
&& (*headerStack)[i] == &AS_OPEN_BRACE)
&& ((*headerStack)[i - 1] == &ASResource::AS_NAMESPACE
|| (*headerStack)[i - 1] == &ASResource::AS_MODULE)
&& (*headerStack)[i] == &ASResource::AS_OPEN_BRACE)
--indentCount;
if (isCStyle() && i >= 1
&& (*headerStack)[i - 1] == &AS_CLASS
&& (*headerStack)[i] == &AS_OPEN_BRACE)
&& (*headerStack)[i - 1] == &ASResource::AS_CLASS
&& (*headerStack)[i] == &ASResource::AS_OPEN_BRACE)
{
if (classIndent)
++indentCount;
@@ -2168,8 +2170,8 @@ void ASBeautifier::computePreliminaryIndentation()
// is the switchIndent option is on, indent switch statements an additional indent.
else if (switchIndent && i > 1
&& (*headerStack)[i - 1] == &AS_SWITCH
&& (*headerStack)[i] == &AS_OPEN_BRACE)
&& (*headerStack)[i - 1] == &ASResource::AS_SWITCH
&& (*headerStack)[i] == &ASResource::AS_OPEN_BRACE)
{
++indentCount;
isInSwitch = true;
@@ -2236,8 +2238,8 @@ void ASBeautifier::computePreliminaryIndentation()
&& isInClass
&& classIndent
&& headerStack->size() >= 2
&& (*headerStack)[headerStack->size() - 2] == &AS_CLASS
&& (*headerStack)[headerStack->size() - 1] == &AS_OPEN_BRACE
&& (*headerStack)[headerStack->size() - 2] == &ASResource::AS_CLASS
&& (*headerStack)[headerStack->size() - 1] == &ASResource::AS_OPEN_BRACE
&& lineBeginsWithCloseBrace
&& braceBlockStateStack->back())
--indentCount;
@@ -2247,8 +2249,8 @@ void ASBeautifier::computePreliminaryIndentation()
&& isInSwitch
&& switchIndent
&& headerStack->size() >= 2
&& (*headerStack)[headerStack->size() - 2] == &AS_SWITCH
&& (*headerStack)[headerStack->size() - 1] == &AS_OPEN_BRACE
&& (*headerStack)[headerStack->size() - 2] == &ASResource::AS_SWITCH
&& (*headerStack)[headerStack->size() - 1] == &ASResource::AS_OPEN_BRACE
&& lineBeginsWithCloseBrace)
--indentCount;
@@ -2258,7 +2260,7 @@ void ASBeautifier::computePreliminaryIndentation()
&& isInRunInComment
&& !lineOpensWithComment
&& headerStack->size() > 1
&& (*headerStack)[headerStack->size() - 2] == &AS_CLASS)
&& (*headerStack)[headerStack->size() - 2] == &ASResource::AS_CLASS)
--indentCount;
if (isInConditional)
@@ -2291,7 +2293,7 @@ void ASBeautifier::adjustParsedLineIndentation(size_t iPrelim, bool isInExtraHea
else if (!blockIndent
&& lineBeginsWithOpenBrace
&& !(lineOpeningBlocksNum > 0 && lineOpeningBlocksNum <= lineClosingBlocksNum)
&& (headerStack->size() > 1 && (*headerStack)[headerStack->size() - 2] != &AS_OPEN_BRACE)
&& (headerStack->size() > 1 && (*headerStack)[headerStack->size() - 2] != &ASResource::AS_OPEN_BRACE)
&& shouldIndentBracedLine)
--indentCount;
@@ -2300,7 +2302,7 @@ void ASBeautifier::adjustParsedLineIndentation(size_t iPrelim, bool isInExtraHea
&& !blockIndent
&& lineBeginsWithOpenBrace
&& !(lineOpeningBlocksNum > 0 && lineOpeningBlocksNum <= lineClosingBlocksNum)
&& (headerStack->size() > 2 && (*headerStack)[headerStack->size() - 3] != &AS_OPEN_BRACE)
&& (headerStack->size() > 2 && (*headerStack)[headerStack->size() - 3] != &ASResource::AS_OPEN_BRACE)
&& shouldIndentBracedLine)
--indentCount;
@@ -2332,21 +2334,21 @@ void ASBeautifier::adjustParsedLineIndentation(size_t iPrelim, bool isInExtraHea
bool haveUnindentedBrace = false;
for (size_t i = 0; i < headerStack->size(); i++)
{
if (((*headerStack)[i] == &AS_NAMESPACE
|| (*headerStack)[i] == &AS_MODULE
|| (*headerStack)[i] == &AS_CLASS
|| (*headerStack)[i] == &AS_STRUCT)
if (((*headerStack)[i] == &ASResource::AS_NAMESPACE
|| (*headerStack)[i] == &ASResource::AS_MODULE
|| (*headerStack)[i] == &ASResource::AS_CLASS
|| (*headerStack)[i] == &ASResource::AS_STRUCT)
&& i + 1 < headerStack->size()
&& (*headerStack)[i + 1] == &AS_OPEN_BRACE)
&& (*headerStack)[i + 1] == &ASResource::AS_OPEN_BRACE)
i++;
else if (lineBeginsWithOpenBrace)
{
// don't double count the current brace
if (i + 1 < headerStack->size()
&& (*headerStack)[i] == &AS_OPEN_BRACE)
&& (*headerStack)[i] == &ASResource::AS_OPEN_BRACE)
haveUnindentedBrace = true;
}
else if ((*headerStack)[i] == &AS_OPEN_BRACE)
else if ((*headerStack)[i] == &ASResource::AS_OPEN_BRACE)
haveUnindentedBrace = true;
} // end of for loop
if (haveUnindentedBrace)
@@ -2369,7 +2371,7 @@ int ASBeautifier::adjustIndentCountForBreakElseIfComments() const
{
for (const std::string* const lastTemp : *lastTempStack)
{
if (*lastTemp == AS_ELSE)
if (*lastTemp == ASResource::AS_ELSE)
indentCountIncrement++;
}
}
@@ -2396,7 +2398,7 @@ std::string ASBeautifier::extractPreprocessorStatement(std::string_view line) co
void ASBeautifier::adjustObjCMethodDefinitionIndentation(std::string_view line_)
{
// register indent for Objective-C continuation line
if (line_.length() > 0
if (!line_.empty()
&& (line_[0] == '-' || line_[0] == '+'))
{
if (shouldAlignMethodColon && objCColonAlignSubsequent != -1)
@@ -2637,23 +2639,23 @@ bool ASBeautifier::isTopLevel() const
{
if (headerStack->empty())
return true;
if (headerStack->back() == &AS_OPEN_BRACE
if (headerStack->back() == &ASResource::AS_OPEN_BRACE
&& headerStack->size() >= 2)
{
if ((*headerStack)[headerStack->size() - 2] == &AS_NAMESPACE
|| (*headerStack)[headerStack->size() - 2] == &AS_MODULE
|| (*headerStack)[headerStack->size() - 2] == &AS_CLASS
|| (*headerStack)[headerStack->size() - 2] == &AS_INTERFACE
|| (*headerStack)[headerStack->size() - 2] == &AS_STRUCT
|| (*headerStack)[headerStack->size() - 2] == &AS_UNION)
if ((*headerStack)[headerStack->size() - 2] == &ASResource::AS_NAMESPACE
|| (*headerStack)[headerStack->size() - 2] == &ASResource::AS_MODULE
|| (*headerStack)[headerStack->size() - 2] == &ASResource::AS_CLASS
|| (*headerStack)[headerStack->size() - 2] == &ASResource::AS_INTERFACE
|| (*headerStack)[headerStack->size() - 2] == &ASResource::AS_STRUCT
|| (*headerStack)[headerStack->size() - 2] == &ASResource::AS_UNION)
return true;
}
if (headerStack->back() == &AS_NAMESPACE
|| headerStack->back() == &AS_MODULE
|| headerStack->back() == &AS_CLASS
|| headerStack->back() == &AS_INTERFACE
|| headerStack->back() == &AS_STRUCT
|| headerStack->back() == &AS_UNION)
if (headerStack->back() == &ASResource::AS_NAMESPACE
|| headerStack->back() == &ASResource::AS_MODULE
|| headerStack->back() == &ASResource::AS_CLASS
|| headerStack->back() == &ASResource::AS_INTERFACE
|| headerStack->back() == &ASResource::AS_STRUCT
|| headerStack->back() == &ASResource::AS_UNION)
return true;
return false;
}
@@ -2808,7 +2810,7 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
// handle comments
if (!(isInComment || isInLineComment) && line.compare(i, AS_OPEN_LINE_COMMENT.length(), AS_OPEN_LINE_COMMENT) == 0)
if (!(isInComment || isInLineComment) && line.compare(i, ASResource::AS_OPEN_LINE_COMMENT.length(), ASResource::AS_OPEN_LINE_COMMENT) == 0)
{
// if there is a 'case' statement after these comments unindent by 1
if (isCaseHeaderCommentIndent)
@@ -2822,8 +2824,8 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
continue;
}
if (!(isInComment || isInLineComment)
&& (line.compare(i, AS_OPEN_COMMENT.length(), AS_OPEN_COMMENT) == 0
|| line.compare(i, AS_GSC_OPEN_COMMENT.length(), AS_GSC_OPEN_COMMENT) == 0))
&& (line.compare(i, ASResource::AS_OPEN_COMMENT.length(), ASResource::AS_OPEN_COMMENT) == 0
|| line.compare(i, ASResource::AS_GSC_OPEN_COMMENT.length(), ASResource::AS_GSC_OPEN_COMMENT) == 0))
{
// if there is a 'case' statement after these comments unindent by 1
if (isCaseHeaderCommentIndent && lineOpensWithComment)
@@ -2839,8 +2841,8 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
continue;
}
if ((isInComment || isInLineComment)
&& (line.compare(i, AS_CLOSE_COMMENT.length(), AS_CLOSE_COMMENT) == 0
|| line.compare(i, AS_GSC_CLOSE_COMMENT.length(), AS_GSC_CLOSE_COMMENT) == 0))
&& (line.compare(i, ASResource::AS_CLOSE_COMMENT.length(), ASResource::AS_CLOSE_COMMENT) == 0
|| line.compare(i, ASResource::AS_GSC_CLOSE_COMMENT.length(), ASResource::AS_GSC_CLOSE_COMMENT) == 0))
{
size_t firstText = line.find_first_not_of(" \t");
// if there is a 'case' statement after these comments unindent by 1
@@ -2885,7 +2887,7 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
indentCount += adjustIndentCountForBreakElseIfComments();
// bypass rest of the comment up to the comment end
while (i + 1 < line.length()
&& line.compare(i + 1, AS_CLOSE_COMMENT.length(), AS_CLOSE_COMMENT) != 0)
&& line.compare(i + 1, ASResource::AS_CLOSE_COMMENT.length(), ASResource::AS_CLOSE_COMMENT) != 0)
i++;
continue;
@@ -2895,21 +2897,21 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
if (probationHeader != nullptr)
{
if ((probationHeader == &AS_STATIC && ch == '{')
|| (probationHeader == &AS_SYNCHRONIZED && ch == '('))
if ((probationHeader == &ASResource::AS_STATIC && ch == '{')
|| (probationHeader == &ASResource::AS_SYNCHRONIZED && ch == '('))
{
// insert the probation header as a new header
isInHeader = true;
headerStack->emplace_back(probationHeader);
// handle the specific probation header
isInConditional = (probationHeader == &AS_SYNCHRONIZED);
isInConditional = (probationHeader == &ASResource::AS_SYNCHRONIZED);
isContinuation = false;
// if the probation comes from the previous line, then indent by 1 tab count.
if (previousLineProbation
&& ch == '{'
&& !(blockIndent && probationHeader == &AS_STATIC))
&& !(blockIndent && probationHeader == &ASResource::AS_STATIC))
{
++indentCount;
previousLineProbationTab = true;
@@ -2941,7 +2943,7 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
if (isCStyle() && isInTemplate
&& (ch == '<' || ch == '>')
&& !(line.length() > i + 1 && line.compare(i, AS_GR_EQUAL.length(), AS_GR_EQUAL) == 0))
&& !(line.length() > i + 1 && line.compare(i, ASResource::AS_GR_EQUAL.length(), ASResource::AS_GR_EQUAL) == 0))
{
if (ch == '<')
{
@@ -2972,7 +2974,7 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
// if have a struct header, this is a declaration not a definition
if (ch == '('
&& !headerStack->empty()
&& headerStack->back() == &AS_STRUCT)
&& headerStack->back() == &ASResource::AS_STRUCT)
{
headerStack->pop_back();
isInClassHeader = false;
@@ -2994,7 +2996,7 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
{
++squareBracketCount;
// #525 Maybe check for opening brace in the line
if (squareBracketCount == 1 && isObjCStyle() && line.find("{", i + 1 ) == std::string::npos)
if (squareBracketCount == 1 && isObjCStyle() && line.find('{', i + 1 ) == std::string::npos)
{
isInObjCMethodCall = true;
isInObjCMethodCallFirst = true;
@@ -3005,7 +3007,7 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
&& prevNonSpaceCh != ']'
&& prevNonSpaceCh != ')'
&& prevNonSpaceCh != '*' // GL #11
//&& line.find(AS_AUTO, 0 ) == std::string::npos
//&& line.find(ASResource::AS_AUTO, 0 ) == std::string::npos
)
{
lambdaIndicator = true;
@@ -3083,7 +3085,7 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
|| isSharpDelegate
|| isInExternC
|| isInAsmBlock
//|| getNextWord(line, i) == AS_NEW // #487
//|| getNextWord(line, i) == ASResource::AS_NEW // #487
|| (isInDefine
&& (prevNonSpaceCh == '('
|| isLegalNameChar(prevNonSpaceCh))));
@@ -3149,7 +3151,7 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
indentCount -= classInitializerIndents;
// decrease one more if an empty class
if (!headerStack->empty()
&& (*headerStack).back() == &AS_CLASS)
&& (*headerStack).back() == &ASResource::AS_CLASS)
{
int nextChar = getNextProgramCharDistance(line, i);
if ((int) line.length() > nextChar && line[nextChar] == '}')
@@ -3166,8 +3168,8 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
}
if (braceIndent && !namespaceIndent && !headerStack->empty()
&& ((*headerStack).back() == &AS_NAMESPACE
|| (*headerStack).back() == &AS_MODULE))
&& ((*headerStack).back() == &ASResource::AS_NAMESPACE
|| (*headerStack).back() == &ASResource::AS_MODULE))
{
shouldIndentBracedLine = false;
--indentCount;
@@ -3175,9 +3177,9 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
// an indentable struct is treated like a class in the header stack
if (!headerStack->empty()
&& (*headerStack).back() == &AS_STRUCT
&& (*headerStack).back() == &ASResource::AS_STRUCT
&& isInIndentableStruct)
(*headerStack).back() = &AS_CLASS;
(*headerStack).back() = &ASResource::AS_CLASS;
// is a brace inside a paren?
parenDepthStack->emplace_back(parenDepth);
@@ -3215,8 +3217,8 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
isInExternC = false;
tempStacks->emplace_back(new std::vector<const std::string*>);
headerStack->emplace_back(&AS_OPEN_BRACE);
lastLineHeader = &AS_OPEN_BRACE;
headerStack->emplace_back(&ASResource::AS_OPEN_BRACE);
lastLineHeader = &ASResource::AS_OPEN_BRACE;
continue;
} // end '{'
@@ -3229,23 +3231,23 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
const std::string* newHeader = findHeader(line, i, headers);
// java can have a 'default' not in a switch
if (newHeader == &AS_DEFAULT
if (newHeader == &ASResource::AS_DEFAULT
&& peekNextChar(line, (i + (*newHeader).length() - 1)) != ':')
newHeader = nullptr;
// Qt headers may be variables in C++
if (isCStyle()
&& (newHeader == &AS_FOREVER || newHeader == &AS_FOREACH))
&& (newHeader == &ASResource::AS_FOREVER || newHeader == &ASResource::AS_FOREACH))
{
if (line.find_first_of("=;", i) != std::string::npos)
newHeader = nullptr;
}
else if (isSharpStyle()
&& (newHeader == &AS_GET || newHeader == &AS_SET))
&& (newHeader == &ASResource::AS_GET || newHeader == &ASResource::AS_SET))
{
if (getNextWord(std::string(line), i + (*newHeader).length()) == "is")
newHeader = nullptr;
}
else if (newHeader == &AS_USING
else if (newHeader == &ASResource::AS_USING
&& peekNextChar(line, i + (*newHeader).length() - 1) != '(')
newHeader = nullptr;
@@ -3264,18 +3266,18 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
// future list of headers in the new block.
// take care of the special case: 'else if (...)'
if (newHeader == &AS_IF && lastLineHeader == &AS_ELSE)
if (newHeader == &ASResource::AS_IF && lastLineHeader == &ASResource::AS_ELSE)
{
if (!headerStack->empty())
headerStack->pop_back();
}
// take care of 'else'
else if (newHeader == &AS_ELSE)
else if (newHeader == &ASResource::AS_ELSE)
{
if (lastTempStack != nullptr)
{
int indexOfIf = indexOf(*lastTempStack, &AS_IF);
int indexOfIf = indexOf(*lastTempStack, &ASResource::AS_IF);
if (indexOfIf != -1)
{
// recreate the header list in headerStack up to the previous 'if'
@@ -3298,11 +3300,11 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
}
// check if 'while' closes a previous 'do'
else if (newHeader == &AS_WHILE)
else if (newHeader == &ASResource::AS_WHILE)
{
if (lastTempStack != nullptr)
{
int indexOfDo = indexOf(*lastTempStack, &AS_DO);
int indexOfDo = indexOf(*lastTempStack, &ASResource::AS_DO);
if (indexOfDo != -1)
{
// recreate the header list in headerStack up to the previous 'do'
@@ -3319,13 +3321,13 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
}
}
// check if 'catch' closes a previous 'try' or 'catch'
else if (newHeader == &AS_CATCH || newHeader == &AS_FINALLY)
else if (newHeader == &ASResource::AS_CATCH || newHeader == &ASResource::AS_FINALLY)
{
if (lastTempStack != nullptr)
{
int indexOfTry = indexOf(*lastTempStack, &AS_TRY);
int indexOfTry = indexOf(*lastTempStack, &ASResource::AS_TRY);
if (indexOfTry == -1)
indexOfTry = indexOf(*lastTempStack, &AS_CATCH);
indexOfTry = indexOf(*lastTempStack, &ASResource::AS_CATCH);
if (indexOfTry != -1)
{
// recreate the header list in headerStack up to the previous 'try'
@@ -3342,7 +3344,7 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
}
}
}
else if (newHeader == &AS_CASE)
else if (newHeader == &ASResource::AS_CASE)
{
isInCase = true;
if (!haveCaseIndent)
@@ -3352,17 +3354,17 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
--indentCount;
}
}
else if (newHeader == &AS_DEFAULT)
else if (newHeader == &ASResource::AS_DEFAULT)
{
isInCase = true;
--indentCount;
}
else if (newHeader == &AS_STATIC
|| newHeader == &AS_SYNCHRONIZED)
else if (newHeader == &ASResource::AS_STATIC
|| newHeader == &ASResource::AS_SYNCHRONIZED)
{
if (!headerStack->empty()
&& (headerStack->back() == &AS_STATIC
|| headerStack->back() == &AS_SYNCHRONIZED))
&& (headerStack->back() == &ASResource::AS_STATIC
|| headerStack->back() == &ASResource::AS_SYNCHRONIZED))
{
isIndentableHeader = false;
}
@@ -3372,7 +3374,7 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
probationHeader = newHeader;
}
}
else if (newHeader == &AS_TEMPLATE)
else if (newHeader == &ASResource::AS_TEMPLATE)
{
isInTemplate = true;
isIndentableHeader = false;
@@ -3402,36 +3404,36 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
foundPreCommandHeader = true;
// Objective-C NSException macros are preCommandHeaders
if (isObjCStyle() && findKeyword(line, i, AS_NS_DURING))
if (isObjCStyle() && findKeyword(line, i, ASResource::AS_NS_DURING))
foundPreCommandMacro = true;
if (isObjCStyle() && findKeyword(line, i, AS_NS_HANDLER))
if (isObjCStyle() && findKeyword(line, i, ASResource::AS_NS_HANDLER))
foundPreCommandMacro = true;
//https://sourceforge.net/p/astyle/bugs/353/
// new is ending the line?
if (isJavaStyle() && findKeyword(line, i, AS_NEW) && line.length() - 3 == i)
if (isJavaStyle() && findKeyword(line, i, ASResource::AS_NEW) && line.length() - 3 == i)
{
headerStack->emplace_back(&AS_FIXED); // needs to be something which will not match - need to define a token which will never match
headerStack->emplace_back(&ASResource::AS_FIXED); // needs to be something which will not match - need to define a token which will never match
}
//https://sourceforge.net/p/astyle/bugs/550/
//enum can be function return value
if (parenDepth == 0 && findKeyword(line, i, AS_ENUM) && line.find_first_of(AS_OPEN_PAREN, i) == std::string::npos){
if (parenDepth == 0 && findKeyword(line, i, ASResource::AS_ENUM) && line.find_first_of(ASResource::AS_OPEN_PAREN, i) == std::string::npos){
isInEnum = true;
}
if (parenDepth == 0 && (findKeyword(line, i, AS_TYPEDEF_STRUCT) || findKeyword(line, i, AS_STRUCT)) && line.find_first_of(AS_SEMICOLON, i) == std::string::npos)
if (parenDepth == 0 && (findKeyword(line, i, ASResource::AS_TYPEDEF_STRUCT) || findKeyword(line, i, ASResource::AS_STRUCT)) && line.find_first_of(ASResource::AS_SEMICOLON, i) == std::string::npos)
{
isInStruct = true;
}
// avoid regression with neovim test dataset
if (parenDepth == 0 && findKeyword(line, i, AS_UNION) )
if (parenDepth == 0 && findKeyword(line, i, ASResource::AS_UNION) )
{
isInStruct = false;
}
if (isSharpStyle() && findKeyword(line, i, AS_LET))
if (isSharpStyle() && findKeyword(line, i, ASResource::AS_LET))
isInLet = true;
} // isPotentialHeader
@@ -3499,14 +3501,14 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
}
else if (isCStyle() && !isInClass
&& headerStack->size() >= 2
&& (*headerStack)[headerStack->size() - 2] == &AS_CLASS
&& (*headerStack)[headerStack->size() - 1] == &AS_OPEN_BRACE)
&& (*headerStack)[headerStack->size() - 2] == &ASResource::AS_CLASS
&& (*headerStack)[headerStack->size() - 1] == &ASResource::AS_OPEN_BRACE)
{
// found a 'private:' or 'public:' inside a class definition
// and on the same line as the class opening brace
// do nothing
}
else if (isJavaStyle() && lastLineHeader == &AS_FOR)
else if (isJavaStyle() && lastLineHeader == &ASResource::AS_FOR)
{
// found a java for-each statement
// so do nothing special
@@ -3553,9 +3555,9 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
size_t nextChar = line.find_first_not_of(" \t", i + 1);
if (nextChar != std::string::npos)
{
if (line.compare(nextChar, AS_OPEN_LINE_COMMENT.length(), AS_OPEN_LINE_COMMENT) == 0
|| line.compare(nextChar, AS_OPEN_COMMENT.length(), AS_OPEN_COMMENT) == 0
|| line.compare(nextChar, AS_GSC_OPEN_COMMENT.length(), AS_GSC_OPEN_COMMENT) == 0)
if (line.compare(nextChar, ASResource::AS_OPEN_LINE_COMMENT.length(), ASResource::AS_OPEN_LINE_COMMENT) == 0
|| line.compare(nextChar, ASResource::AS_OPEN_COMMENT.length(), ASResource::AS_OPEN_COMMENT) == 0
|| line.compare(nextChar, ASResource::AS_GSC_OPEN_COMMENT.length(), ASResource::AS_GSC_OPEN_COMMENT) == 0)
nextChar = std::string::npos;
}
// register indent
@@ -3643,11 +3645,11 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
isInAsm = isInAsmOneLine = isInQuote = false; // close these just in case
isInStruct = false;
int headerPlace = indexOf(*headerStack, &AS_OPEN_BRACE);
int headerPlace = indexOf(*headerStack, &ASResource::AS_OPEN_BRACE);
if (headerPlace != -1)
{
const std::string* popped = headerStack->back();
while (popped != &AS_OPEN_BRACE)
while (popped != &ASResource::AS_OPEN_BRACE)
{
headerStack->pop_back();
popped = headerStack->back();
@@ -3659,8 +3661,8 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
// do not indent namespace brace unless namespaces are indented
if (!namespaceIndent && !headerStack->empty()
&& ((*headerStack).back() == &AS_NAMESPACE
|| (*headerStack).back() == &AS_MODULE)
&& ((*headerStack).back() == &ASResource::AS_NAMESPACE
|| (*headerStack).back() == &ASResource::AS_MODULE)
&& i == 0) // must be the first brace on the line
shouldIndentBracedLine = false;
@@ -3687,7 +3689,7 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
if (!tempStacks->back()->empty())
while (!tempStacks->back()->empty())
tempStacks->back()->pop_back();
while (!headerStack->empty() && headerStack->back() != &AS_OPEN_BRACE)
while (!headerStack->empty() && headerStack->back() != &ASResource::AS_OPEN_BRACE)
{
tempStacks->back()->emplace_back(headerStack->back());
headerStack->pop_back();
@@ -3728,39 +3730,39 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
{
const std::string* newHeader = findHeader(line, i, preBlockStatements);
// CORBA IDL module
if (newHeader == &AS_MODULE)
if (newHeader == &ASResource::AS_MODULE)
{
char nextChar = peekNextChar(line, i + newHeader->length() - 1);
if (prevNonSpaceCh == ')' || !isalpha(nextChar))
newHeader = nullptr;
}
if (newHeader != nullptr
&& !(isCStyle() && newHeader == &AS_CLASS && (isInEnum || isInStruct)) // is not 'enum class'
&& !(isCStyle() && newHeader == &AS_INTERFACE // CORBA IDL interface
&& !(isCStyle() && newHeader == &ASResource::AS_CLASS && (isInEnum || isInStruct)) // is not 'enum class'
&& !(isCStyle() && newHeader == &ASResource::AS_INTERFACE // CORBA IDL interface
&& (headerStack->empty()
|| headerStack->back() != &AS_OPEN_BRACE)))
|| headerStack->back() != &ASResource::AS_OPEN_BRACE)))
{
if (!isSharpStyle())
headerStack->emplace_back(newHeader);
// do not need 'where' in the headerStack
// do not need second 'class' statement in a row
else if (!(newHeader == &AS_WHERE
|| ((newHeader == &AS_CLASS || newHeader == &AS_STRUCT)
else if (!(newHeader == &ASResource::AS_WHERE
|| ((newHeader == &ASResource::AS_CLASS || newHeader == &ASResource::AS_STRUCT)
&& !headerStack->empty()
&& (headerStack->back() == &AS_CLASS
|| headerStack->back() == &AS_STRUCT))))
&& (headerStack->back() == &ASResource::AS_CLASS
|| headerStack->back() == &ASResource::AS_STRUCT))))
headerStack->emplace_back(newHeader);
if (!headerStack->empty())
{
if ((*headerStack).back() == &AS_CLASS
|| (*headerStack).back() == &AS_STRUCT
|| (*headerStack).back() == &AS_INTERFACE)
if ((*headerStack).back() == &ASResource::AS_CLASS
|| (*headerStack).back() == &ASResource::AS_STRUCT
|| (*headerStack).back() == &ASResource::AS_INTERFACE)
{
isInClassHeader = true;
}
else if ((*headerStack).back() == &AS_NAMESPACE
|| (*headerStack).back() == &AS_MODULE)
else if ((*headerStack).back() == &ASResource::AS_NAMESPACE
|| (*headerStack).back() == &ASResource::AS_MODULE)
{
// remove continuationIndent from namespace
if (!continuationIndentStack->empty())
@@ -3787,36 +3789,36 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
continue;
}
if (isCStyle() && findKeyword(line, i, AS_OPERATOR))
if (isCStyle() && findKeyword(line, i, ASResource::AS_OPERATOR))
isInOperator = true;
if (g_preprocessorCppExternCBrace == 1 && findKeyword(line, i, AS_EXTERN))
if (g_preprocessorCppExternCBrace == 1 && findKeyword(line, i, ASResource::AS_EXTERN))
++g_preprocessorCppExternCBrace;
if (g_preprocessorCppExternCBrace == 3) // extern "C" is not followed by a '{'
g_preprocessorCppExternCBrace = 0;
// "new" operator is a pointer, not a calculation
if (findKeyword(line, i, AS_NEW))
if (findKeyword(line, i, ASResource::AS_NEW))
{
if (isContinuation && !continuationIndentStack->empty() && prevNonSpaceCh == '=')
continuationIndentStack->back() = 0;
}
if (isCStyle() && findKeyword(line, i, AS_AUTO) && isTopLevel())
if (isCStyle() && findKeyword(line, i, ASResource::AS_AUTO) && isTopLevel())
{
isInTrailingReturnType = true;
}
if (isCStyle())
{
if (findKeyword(line, i, AS_ASM)
|| findKeyword(line, i, AS__ASM__))
if (findKeyword(line, i, ASResource::AS_ASM)
|| findKeyword(line, i, ASResource::AS__ASM__))
{
isInAsm = true;
}
else if (findKeyword(line, i, AS_MS_ASM) // microsoft specific
|| findKeyword(line, i, AS_MS__ASM))
else if (findKeyword(line, i, ASResource::AS_MS_ASM) // microsoft specific
|| findKeyword(line, i, ASResource::AS_MS__ASM))
{
int index = 4;
if (peekNextChar(line, i) == '_') // check for __asm
@@ -3845,7 +3847,7 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
&& isCharPotentialHeader(line, i + 1))
{
std::string_view curWord = getCurrentWord(line, i + 1);
if (curWord == AS_INTERFACE || curWord == AS_AUTORELEASEPOOL)
if (curWord == ASResource::AS_INTERFACE || curWord == ASResource::AS_AUTORELEASEPOOL)
{
isInObjCInterface = true;
std::string name = '@' + std::string(curWord);
@@ -3859,9 +3861,9 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
isInObjCInterface = false;
}
if (curWord == AS_PUBLIC
|| curWord == AS_PRIVATE
|| curWord == AS_PROTECTED)
if (curWord == ASResource::AS_PUBLIC
|| curWord == ASResource::AS_PRIVATE
|| curWord == ASResource::AS_PROTECTED)
{
--indentCount;
if (modifierIndent)
@@ -3871,7 +3873,7 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
continue;
}
if (curWord == AS_END)
if (curWord == ASResource::AS_END)
{
popLastContinuationIndent();
spaceIndentCount = 0;
@@ -3908,9 +3910,9 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
if (foundNonAssignmentOp != nullptr)
{
if (foundNonAssignmentOp == &AS_LAMBDA)
if (foundNonAssignmentOp == &ASResource::AS_LAMBDA)
foundPreCommandHeader = true;
if (isInTemplate && foundNonAssignmentOp == &AS_GR_GR)
if (isInTemplate && foundNonAssignmentOp == &ASResource::AS_GR_GR)
foundNonAssignmentOp = nullptr;
}
@@ -3936,7 +3938,8 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
// also not in the "operator<<(...)" header line
// GL28: method calls have to contain only alphanumeric identifier
size_t openParenPos = line.find(AS_OPEN_PAREN, i);
size_t openParenPos = line.find(ASResource::AS_OPEN_PAREN, i);
size_t closeParenPos = line.find(ASResource::AS_CLOSE_PAREN, openParenPos);
std::string methodName = getNextWord(std::string(line), i);
size_t methodNameEndPos = i + methodName.length() + 1;
@@ -3961,9 +3964,9 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
&& continuationIndentStack->empty()
&& isCStyle()
&& !lineStartsWithDot
&& ( (foundNonAssignmentOp == &AS_GR_GR && countLS < 2 )
|| foundNonAssignmentOp == &AS_LS_LS
|| (foundNonAssignmentOp == &AS_DOT && openParenPos == methodNameEndPos)))
&& ( (foundNonAssignmentOp == &ASResource::AS_GR_GR && countLS < 2 )
|| foundNonAssignmentOp == &ASResource::AS_LS_LS
|| (foundNonAssignmentOp == &ASResource::AS_DOT && openParenPos == methodNameEndPos && closeParenPos != std::string::npos )))
{
// this will be true if the line begins with the operator
if (i < foundNonAssignmentOp->length() && spaceIndentCount == 0)
@@ -3987,12 +3990,12 @@ void ASBeautifier::parseCurrentLine(std::string_view line)
if (!isInOperator && !isInTemplate && (!isNonInStatementArray || isInEnum || isInStruct))
{
// if multiple assignments, align on the previous word
if (foundAssignmentOp == &AS_ASSIGN
if (foundAssignmentOp == &ASResource::AS_ASSIGN
&& prevNonSpaceCh != ']' // an array
&& statementEndsWithComma(line, i))
{
// only one assignment indent per line + GH #10
if (!haveAssignmentThisLine && line.find(AS_SCOPE_RESOLUTION) == std::string::npos)
if (!haveAssignmentThisLine && line.find(ASResource::AS_SCOPE_RESOLUTION) == std::string::npos)
{
// register indent at previous word
haveAssignmentThisLine = true;
+3 -3
View File
@@ -1,5 +1,5 @@
// ASEnhancer.cpp
// Copyright (c) 2023 The Artistic Style Authors.
// Copyright (c) 2024 The Artistic Style Authors.
// This code is licensed under the MIT License.
// License.md describes the conditions under which this software may be distributed.
@@ -104,7 +104,7 @@ void ASEnhancer::enhance(std::string& line, bool isInNamespace, bool isInPreproc
nextLineIsDeclareIndent = false;
}
if (line.length() == 0
if (line.empty()
&& !isInEventTable
&& !isInDeclareSection
&& !emptyLineFill)
@@ -238,7 +238,7 @@ size_t ASEnhancer::findCaseColon(std::string_view line, size_t caseIndex) const
*/
int ASEnhancer::indentLine(std::string& line, int indent) const
{
if (line.length() == 0
if (line.empty()
&& !emptyLineFill)
return 0;
+295 -290
View File
File diff suppressed because it is too large Load Diff
+3 -7
View File
@@ -1,5 +1,5 @@
// ASLocalizer.cpp
// Copyright (c) 2023 The Artistic Style Authors.
// Copyright (c) 2024 The Artistic Style Authors.
// This code is licensed under the MIT License.
// License.md describes the conditions under which this software may be distributed.
//
@@ -43,12 +43,8 @@
#include <Windows.h>
#endif
#ifdef __VMS
#define __USE_STD_IOSTREAM 1
#include <assert>
#else
#include <cassert>
#endif
#include <cassert>
#include <clocale> // needed by some compilers
#include <cstdio>
+1 -1
View File
@@ -1,5 +1,5 @@
// ASLocalizer.h
// Copyright (c) 2023 The Artistic Style Authors.
// Copyright (c) 2024 The Artistic Style Authors.
// This code is licensed under the MIT License.
// License.md describes the conditions under which this software may be distributed.
+4 -4
View File
@@ -1,5 +1,5 @@
// ASResource.cpp
// Copyright (c) 2023 The Artistic Style Authors.
// Copyright (c) 2024 The Artistic Style Authors.
// This code is licensed under the MIT License.
// License.md describes the conditions under which this software may be distributed.
@@ -663,9 +663,9 @@ const std::string* ASBase::findHeader(std::string_view line, int i,
// the following accessor definitions are NOT headers
// goto default; is NOT a header
// default(int) keyword in C# is NOT a header
if ((header == &AS_GET
|| header == &AS_SET
|| header == &AS_DEFAULT)
if ((header == &ASResource::AS_GET
|| header == &ASResource::AS_SET
|| header == &ASResource::AS_DEFAULT)
&& (peekChar == '.' || peekChar == ';' || peekChar == '(' || peekChar == '='))
break;
return header;
+16 -50
View File
@@ -1,5 +1,5 @@
// astyle.h
// Copyright (c) 2023 The Artistic Style Authors.
// Copyright (c) 2024 The Artistic Style Authors.
// This code is licensed under the MIT License.
// License.md describes the conditions under which this software may be distributed.
@@ -10,15 +10,10 @@
// headers
//-----------------------------------------------------------------------------
#ifdef __VMS
#define __USE_STD_IOSTREAM 1
#include <assert>
#else
#include <cassert>
#endif
#include <cassert>
#include <cctype>
#include <iostream> // for cout
#include <iostream>
#include <memory>
#include <string>
#include <string_view>
@@ -28,36 +23,7 @@
#include <cstring> // need both string and cstring for GCC
#endif
//-----------------------------------------------------------------------------
// declarations
//-----------------------------------------------------------------------------
#ifdef _MSC_VER
#pragma warning(disable: 4267) // conversion from size_t to int
#endif
#ifdef __BORLANDC__
#pragma warn -8004 // variable is assigned a value that is never used
#endif
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wconversion"
#endif
#ifdef __INTEL_COMPILER
// #pragma warning disable 383 // value copied to temporary, reference to temporary used
// #pragma warning disable 981 // operands are evaluated in unspecified order
#endif
#ifdef __clang__
#pragma clang diagnostic ignored "-Wshorten-64-to-32"
#endif
#define ASTYLE_VERSION "3.6"
//-----------------------------------------------------------------------------
// astyle namespace
//-----------------------------------------------------------------------------
#define ASTYLE_VERSION "3.6.2"
namespace astyle {
@@ -244,17 +210,17 @@ public:
class ASResource
{
public:
void buildAssignmentOperators(std::vector<const std::string*>* assignmentOperators);
void buildCastOperators(std::vector<const std::string*>* castOperators);
void buildHeaders(std::vector<const std::string*>* headers, int fileType, bool beautifier = false);
void buildIndentableMacros(std::vector<const std::pair<const std::string, const std::string>* >* indentableMacros);
void buildIndentableHeaders(std::vector<const std::string*>* indentableHeaders);
void buildNonAssignmentOperators(std::vector<const std::string*>* nonAssignmentOperators);
void buildNonParenHeaders(std::vector<const std::string*>* nonParenHeaders, int fileType, bool beautifier = false);
void buildOperators(std::vector<const std::string*>* operators, int fileType);
void buildPreBlockStatements(std::vector<const std::string*>* preBlockStatements, int fileType);
void buildPreCommandHeaders(std::vector<const std::string*>* preCommandHeaders, int fileType);
void buildPreDefinitionHeaders(std::vector<const std::string*>* preDefinitionHeaders, int fileType);
static void buildAssignmentOperators(std::vector<const std::string*>* assignmentOperators);
static void buildCastOperators(std::vector<const std::string*>* castOperators);
static void buildHeaders(std::vector<const std::string*>* headers, int fileType, bool beautifier = false);
static void buildIndentableMacros(std::vector<const std::pair<const std::string, const std::string>* >* indentableMacros);
static void buildIndentableHeaders(std::vector<const std::string*>* indentableHeaders);
static void buildNonAssignmentOperators(std::vector<const std::string*>* nonAssignmentOperators);
static void buildNonParenHeaders(std::vector<const std::string*>* nonParenHeaders, int fileType, bool beautifier = false);
static void buildOperators(std::vector<const std::string*>* operators, int fileType);
static void buildPreBlockStatements(std::vector<const std::string*>* preBlockStatements, int fileType);
static void buildPreCommandHeaders(std::vector<const std::string*>* preCommandHeaders, int fileType);
static void buildPreDefinitionHeaders(std::vector<const std::string*>* preDefinitionHeaders, int fileType);
public:
static const std::string AS_IF, AS_ELSE;
@@ -307,7 +273,7 @@ public:
// Functions definitions are at the end of ASResource.cpp.
//-----------------------------------------------------------------------------
class ASBase : protected ASResource
class ASBase
{
private:
// all variables should be set by the "init" function
+217 -282
View File
File diff suppressed because it is too large Load Diff
+10 -2
View File
@@ -1,5 +1,5 @@
// astyle_main.h
// Copyright (c) 2023 The Artistic Style Authors.
// Copyright (c) 2024 The Artistic Style Authors.
// This code is licensed under the MIT License.
// License.md describes the conditions under which this software may be distributed.
@@ -332,7 +332,7 @@ private: // functions
bool isOption(const std::string& arg, const char* op);
bool isOption(const std::string& arg, const char* a, const char* b);
bool isParamOption(const std::string& arg, const char* option);
bool isPathExclued(const std::string& subPath);
bool isPathExcluded(const std::string& subPath);
void launchDefaultBrowser(const char* filePathIn = nullptr) const;
void printHelp() const;
void printMsg(const char* msg, const std::string& data) const;
@@ -387,6 +387,7 @@ private:
void STDCALL javaErrorHandler(int errorNumber, const char* errorMessage);
char* STDCALL javaMemoryAlloc(unsigned long memoryNeeded);
// the following function names are constructed from method names in the calling java program
extern "C" EXPORT
jstring STDCALL Java_AStyleInterface_AStyleGetVersion(JNIEnv* env, jclass);
extern "C" EXPORT
@@ -394,6 +395,13 @@ jstring STDCALL Java_AStyleInterface_AStyleMain(JNIEnv* env,
jobject obj,
jstring textInJava,
jstring optionsJava);
extern "C" EXPORT
jstring STDCALL Java_cc_arduino_packages_formatter_AStyleInterface_AStyleGetVersion(JNIEnv* env, jclass);
extern "C" EXPORT
jstring STDCALL Java_cc_arduino_packages_formatter_AStyleInterface_AStyleMain(JNIEnv* env,
jobject obj,
jstring textInJava,
jstring optionsJava);
#endif // ASTYLE_JNI
//----------------------------------------------------------------------------
+5 -6
View File
@@ -92,14 +92,14 @@
ErrorHandler method.</p>
<p>
The function will NOT fail for an invalid option in the formatting options. In this case, an error message is
sent to the error handling function and the formatted source code is returned without using the invalid
sent to the error handling function and the formatted source code is returned without using the invalid
option.</p>
<h4>Remarks</h4>
<p>
The ASyleMain function must be called from the class AStyleInterface. The name of the function in Artistic Style
is Java_AStyleInterface_AStyleMain. If the class name is changed, or the method name is changed, the function
is Java_cc_arduino_packages_formatter_AStyleInterface_AStyleMain. If the class name is changed, or the method name is changed, the function
names in the Artistic Style shared library must also be changed.</p>
<p>
The call to AStyleMain should be placed in a try/catch block that contains an UnsatisfiedLinkError to handle not
@@ -127,7 +127,7 @@
<p>
The AStyleGetVersion function must be called from the class AStyleInterface. The name of the function in Artistic
Style is Java_AStyleInterface_AStyleGetVersion. If the class name is changed, or the method name is changed, the
Style is Java_cc_arduino_packages_formatter_AStyleInterface_AStyleGetVersion. If the class name is changed, or the method name is changed, the
function names in the Artistic Style shared library must also be changed.</p>
<p>
The call to AStyleMain should be placed in a try/catch block that contains an UnsatisfiedLinkError to handle not
@@ -183,7 +183,7 @@
<p>
&nbsp;</p>
<div class="hl">
<pre class="hl">
<pre class="hl">
<span class="hl slc">// Example.java</span>
<span class="hl com">/*</span>
@@ -328,7 +328,7 @@
<p>
&nbsp;</p>
<div class="hl">
<pre class="hl">
<pre class="hl">
<span class="hl slc">// AStyleInterface.java</span>
<span class="hl com">/**</span>
@@ -497,4 +497,3 @@
</body>
</html>
+1 -1
View File
@@ -38,7 +38,7 @@ fi
# astyle -R "%indir%\*.cpp" "%indir%\*.h"
# if [ $? -ne 0 ] ; then read -sn1 -p "Error executing astyle!"; fi
# variables for fle processing
# variables for file processing
#echo "processing files..."
fileHasSpaces=false # a file or directory name has spaces
extLength=${#fileext} # length of the file extension
+2 -2
View File
@@ -104,7 +104,7 @@ def get_library_name():
elif platform.system() == "Darwin":
libext = ".dylib"
else:
error("Cannot indentify platform: " + platform.system())
error("Cannot identify platform: " + platform.system())
# IronPython needs the '.'
for file_name in os.listdir('.'):
if (os.path.isfile(file_name)
@@ -138,7 +138,7 @@ def get_source_code_bytes(file_path):
"""
# read the file as a byte string by declaring it as binary
# version 3 will read unicode if not declared as binary
# IronPython must be explicitely converted to bytes???
# IronPython must be explicitly converted to bytes???
try:
file_in = open(file_path, 'rb')
bytes_in = bytes(file_in.read())
+2 -2
View File
@@ -44,7 +44,7 @@ def main():
text_in = get_source_code(file_path)
# unicode must be encoded to utf-8 bytes
# encoding to utf-8 will not cause an exception
# IronPython must be explicitely converted to bytes???
# IronPython must be explicitly converted to bytes???
if __is_unicode__ or __is_iron_python__:
text_in = bytes(text_in.encode('utf-8'))
options_in = bytes(options.encode('utf-8'))
@@ -119,7 +119,7 @@ def get_library_name():
elif platform.system() == "Darwin":
libext = ".dylib"
else:
error("Cannot indentify platform: " + platform.system())
error("Cannot identify platform: " + platform.system())
# IronPython needs the '.'
for file_name in os.listdir('.'):
if (os.path.isfile(file_name)
+1 -1
View File
@@ -1,6 +1,6 @@
#! /usr/bin/python3
"""Check AboutDlgBase.h to AboutDlg.h to verify that all virtual fuctions
"""Check AboutDlgBase.h to AboutDlg.h to verify that all virtual functions
are overridden.
"""
+2 -2
View File
@@ -1,7 +1,7 @@
#! /usr/bin/python3
"""Check AStyleDlgBase.h to AstyleDlg.h to verify that all virtual fuctions are overridden.
Check AStyleDlgBase.h to AstyleDlgBase.cpp to verify that all identifiers have an exent
"""Check AStyleDlgBase.h to AstyleDlg.h to verify that all virtual functions are overridden.
Check AStyleDlgBase.h to AstyleDlgBase.cpp to verify that all identifiers have an extent
and therefore a preview display.
Check AStyleDlgBase.h to AstyleDlg.cpp to verify that all radio buttons hhave a
bind event so a mouse click will be displayed in the preview widdow..
+1 -1
View File
@@ -67,7 +67,7 @@ def find_class_diffs(header_variables, class_variables):
# -----------------------------------------------------------------------------
def get_constructor_variables(class_variables, astyleiface_path):
"""Read the AStyleIFace file and save the class constuctor variables."""
"""Read the AStyleIFace file and save the class constructor variables."""
class_lines = [0, 0] # line numbers for class constructor
class_total = 0 # total variables for class constructor
+1 -1
View File
@@ -1,6 +1,6 @@
#! /usr/bin/python3
"""Check EditorDlgBase.h to EditorDlg.h to verify that all virtual fuctions
"""Check EditorDlgBase.h to EditorDlg.h to verify that all virtual functions
are overridden.
"""
+1 -1
View File
@@ -1,6 +1,6 @@
#! /usr/bin/python3
"""Check AStyleIFace.h to Main_Test.h to verify that all virtual fuctions are overridden.
"""Check AStyleIFace.h to Main_Test.h to verify that all virtual functions are overridden.
"""
# to disable the print statement and use the print() function (version 3 format)
+3 -3
View File
@@ -86,7 +86,7 @@ def change_static_configs(line, file_path):
line = line.replace("true", "false")
#
# TESTS FOR VS 2010 ONLY
# Later relases use macros defined in a "props" file
# Later releases use macros defined in a "props" file
# and macros are used for the variables.
if "_vc10_" in file_path:
line = change_vs2010_multiple_lines(line)
@@ -99,7 +99,7 @@ def change_static_configs(line, file_path):
def change_vs2010_multiple_lines(line):
""" TESTS FOR VS 2010 ONLY
These tests change data that is defined in a Static ItemDefinitionGroup.
Later relases use macros defined in a "props" file.
Later releases use macros defined in a "props" file.
Return the updated line.
"""
old_lib = "wxmsw30" + "u_"
@@ -124,7 +124,7 @@ def change_vs2010_multiple_lines(line):
def change_vs2010_single_line_data(line):
""" TESTS FOR VS 2010 ONLY
These tests change data that is defined on a single line.
Later relases use macros defined in a "props" file.
Later releases use macros defined in a "props" file.
Return the updated line.
"""
old_lib = "wxmsw30" + "u_"
+3 -3
View File
@@ -505,9 +505,9 @@ def process_file_suppressions(file_suppression_list):
""" Generate suppressions for an entire file.
"""
file_suppression_list.append("// Suppressed on the Command Line\n")
file_suppression_list.append("// functionStatic is supressed for the entire project.\n")
file_suppression_list.append("// noValidConfiguration is supressed for the entire project.\n")
#~ file_suppression_list.append("// purgedConfiguration is supressed for the entire project.\n")
file_suppression_list.append("// functionStatic is suppressed for the entire project.\n")
file_suppression_list.append("// noValidConfiguration is suppressed for the entire project.\n")
#~ file_suppression_list.append("// purgedConfiguration is suppressed for the entire project.\n")
file_suppression_list.append("//\n")
# -----------------------------------------------------------------------------
+3 -3
View File
@@ -24,11 +24,11 @@ AS_RELEASE = "3.2"
#EXTRACT_ALL = False
EXTRACT_ALL = True
# inut from AStyleWx directory
# input from AStyleWx directory
__astylewx_dir = libastylewx.get_astylewx_directory()
# inut from AStyleWxTest directory
# input from AStyleWxTest directory
__astylewxtest_dir = libastylewx.get_astylewxtest_directory()
# inut from AStyle directory
# input from AStyle directory
__astyle_dir = libastylewx.get_astyle_directory()
# output to Project directory
__base_dir = libastylewx.get_project_directory()