[DEV] better while ==> not normalised

This commit is contained in:
Edouard DUPIN 2018-01-01 22:13:09 +01:00
parent f110a0ba66
commit 6e7c65fadb
4 changed files with 23 additions and 9 deletions

View File

@ -197,14 +197,17 @@ estyle::Generator::Generator():
propertyIndentSize(this, "indent-size", 4, "default 4 sapce in one tabulation indentation"),
propertyDoxygenOneLine(this, "doxygen-1-line-type", true, "true: single line doxygen comment is done with '//!', false '///'"),
propertyDoxygenMultipleLine(this, "doxygen-N-line-type", DOXYGEN_MULTI_LINE__NORMAL, "0: /** */ ..."),
propertyForConditionMultiLineBigSize(this, "for-condition-multi-line-big-size", 80, "If the condition inside for (...;...;...) if biger than XX char") {
propertyForConditionMultiLineBigSize(this, "for-condition-multi-line-big-size", 80, "If the condition inside for (...;...;...) if bigger than XX char"),
propertyIfConditionMultiLineBigSize(this, "if-condition-multi-line-big-size", 80, "If the condition inside if (...&&...) if bigger than XX char"),
propertyWhileConditionMultiLineBigSize(this, "while-condition-multi-line-big-size", 80, "If the condition inside while (...&&...) if bigger than XX char"),
propertyDoWhileConditionMultiLineBigSize(this, "do-while-condition-multi-line-big-size", 80, "If the condition inside do ... while (...&&...) if bigger than XX char") {
setPropertyDoxygenMultiLine(propertyDoxygenMultipleLine);
propertyBrace.set("if", etk::move(estyle::BraceProperty(this, "if")));
propertyBrace.set("else", etk::move(estyle::BraceProperty(this, "else")));
propertyBrace.set("function", etk::move(estyle::BraceProperty(this, "function", false)));
propertyBrace.set("for", etk::move(estyle::BraceProperty(this, "for")));
propertyBrace.set("while", etk::move(estyle::BraceProperty(this, "while")));
propertyBrace.set("do", etk::move(estyle::BraceProperty(this, "do")));
propertyBrace.set("switch", etk::move(estyle::BraceProperty(this, "switch", false)));
propertyBrace.set("namespace", etk::move(estyle::BraceProperty(this, "namespace", false)));
@ -677,13 +680,20 @@ int32_t estyle::Generator::process(int32_t _startId,
|| elem == estyle::lexer::RESERVED_WHILE) {
addNewLineIfSemiColon();
addSpace();
m_output += "if ";
typePush("if");
if (previousIs(iii, estyle::lexer::RESERVED_ELSE) == true) {
offsetPush(4 + 5);
if (elem == estyle::lexer::RESERVED_IF) {
m_output += "if ";
typePush("if");
if (previousIs(iii, estyle::lexer::RESERVED_ELSE) == true) {
offsetPush(4 + 5);
} else {
offsetPush(4);
}
} else {
offsetPush(4);
m_output += "while ";
typePush("while");
offsetPush(7);
}
for (int64_t jjj=iii+1; jjj<m_lexer.size(); ++jjj) {
enum estyle::lexer::tocken elem = m_lexer.getTocken(jjj);
if (elem == estyle::lexer::RESERVED_NEW_LINE) {
@ -1208,7 +1218,7 @@ int32_t estyle::Generator::countRawSize(int64_t _pos, int64_t _posEnd) {
out += (listElement[jjj].getStop() - listElement[jjj].getStart());
}
} else {
//ESTYLE_WARNING("add Size : '" << m_lexer.getData(iii) << "' " << out << " +=" << m_lexer.getData(iii).size());
ESTYLE_WARNING("add Size : '" << m_lexer.getData(iii) << "' " << out << " +=" << m_lexer.getData(iii).size());
out += m_lexer.getData(iii).size();
}
}

View File

@ -50,6 +50,9 @@ namespace estyle {
eproperty::List<int32_t> propertyDoxygenMultipleLine;
eproperty::Value<int32_t> propertyForConditionMultiLineBigSize;
eproperty::Value<int32_t> propertyIfConditionMultiLineBigSize;
eproperty::Value<int32_t> propertyWhileConditionMultiLineBigSize;
eproperty::Value<int32_t> propertyDoWhileConditionMultiLineBigSize;
// Brace section
// brace for "if"
etk::Map<etk::String, estyle::BraceProperty> propertyBrace;

View File

@ -25,6 +25,7 @@ def configure(target, my_module):
'test/testElse.cpp',
'test/testFunction.cpp',
'test/testFor.cpp',
'test/testWhile.cpp',
])
my_module.add_path("test")
my_module.copy_path('data/*','test')

View File

@ -435,7 +435,7 @@ TEST(testFor, condition_1) {
etk::String base = "action_A;for(instanciation=4; condition<6; ++inclemantation){action_B;}action_D;";
etk::String output = interface.process(base);
EXPECT_EQ(output, outputRef);
interface.properties.set("for-condition-multi-line-big-size", "20");
interface.properties.set("condition-for-multi-line-big-size", "20");
output = interface.process(base);
outputRef = "action_A;\nfor (instanciation =4;\n condition<6;\n ++inclemantation){action_B;}action_D;";
EXPECT_EQ(output, outputRef);