[DEV] 95% of brace property is OK (if only)
This commit is contained in:
parent
7c34efef74
commit
9c051cd9ed
@ -98,146 +98,6 @@ static void setPropertyDoxygenMultiLine(eproperty::List<int32_t>& _data) {
|
||||
_data.add(DOXYGEN_MULTI_LINE__NORMAL_SINGLE_LINE_EXCLAMATION, "single-line-exclamation");
|
||||
}
|
||||
|
||||
estyle::GroupProperty::GroupProperty() :
|
||||
inNewLineBefore(false),
|
||||
inNewLineAfter(false),
|
||||
inSpaceBefore(false),
|
||||
inSpaceAfter(false),
|
||||
inIndentBefore(false),
|
||||
inIndentAfter(false),
|
||||
outNewLineBefore(false),
|
||||
outNewLineAfter(false),
|
||||
outSpaceBefore(false),
|
||||
outSpaceAfter(false),
|
||||
outIndentBefore(false),
|
||||
outIndentAfter(false),
|
||||
oneLineIfSingleMaxSize(-1),
|
||||
single(false),
|
||||
singleInNewLine(false),
|
||||
singleInSpace(false),
|
||||
singleOutNewLine(false),
|
||||
singleOutSpace(false) {
|
||||
|
||||
}
|
||||
estyle::GroupProperty::GroupProperty(class estyle::Generator* _generator, const etk::String& _groupName, const etk::String& _typeName, bool _allowSingle):
|
||||
inNewLineBefore(_generator, _groupName + "-" + _typeName + "-in-new-line-before", false, "Set a new line before the input brace"),
|
||||
inNewLineAfter(_generator, _groupName + "-" + _typeName + "-in-new-line-after", false, "Set a new line after the input brace"),
|
||||
inSpaceBefore(_generator, _groupName + "-" + _typeName + "-in-space-before", false, "Set a space before the input brace (if not already present)"),
|
||||
inSpaceAfter(_generator, _groupName + "-" + _typeName + "-in-space-after", false, "Set a space after the input brace (if not already present)"),
|
||||
inIndentBefore(_generator, _groupName + "-" + _typeName + "-in-indent-before", false, "Increment indendation before adding brace"),
|
||||
inIndentAfter(_generator, _groupName + "-" + _typeName + "-in-indent-after", false, "Increment indendation after adding brace"),
|
||||
outNewLineBefore(_generator, _groupName + "-" + _typeName + "-out-new-line-before", false, "Set a new line before the input " + _groupName + ""),
|
||||
outNewLineAfter(_generator, _groupName + "-" + _typeName + "-out-new-line-after", false, "Set a new line after the input " + _groupName + ""),
|
||||
outSpaceBefore(_generator, _groupName + "-" + _typeName + "-out-space-before", false, "Set a space before the input " + _groupName + " (if not already present)"),
|
||||
outSpaceAfter(_generator, _groupName + "-" + _typeName + "-out-space-after", false, "Set a space after the input " + _groupName + " (if not already present)"),
|
||||
outIndentBefore(_generator, _groupName + "-" + _typeName + "-out-indent-before", false, "Decrement indendation before adding " + _groupName + ""),
|
||||
outIndentAfter(_generator, _groupName + "-" + _typeName + "-out-indent-after", false, "Decrement indendation after adding " + _groupName + ""),
|
||||
oneLineIfSingleMaxSize((_allowSingle==true?
|
||||
etk::move(eproperty::Value<int32_t>(_generator, _groupName + "-" + _typeName + "-single-one-line-size-max", -1, "Set i a single line if the size if < XXX (-1 to disable)")):
|
||||
etk::move(eproperty::Value<int32_t>(-1)) )),
|
||||
single((_allowSingle==true?
|
||||
etk::move(eproperty::Value<bool>(_generator, _groupName + "-" + _typeName + "-single", false, "remove or add " + _groupName + " if only 1 action is present.")):
|
||||
etk::move(eproperty::Value<bool>(false)) )),
|
||||
singleInNewLine((_allowSingle==true?
|
||||
etk::move(eproperty::Value<bool>(_generator, _groupName + "-" + _typeName + "-single-in-new-line", false, "Set new line before action.")):
|
||||
etk::move(eproperty::Value<bool>(false)) )),
|
||||
singleInSpace((_allowSingle==true?
|
||||
etk::move(eproperty::Value<bool>(_generator, _groupName + "-" + _typeName + "-single-in-space", false, "Set Space before action.")):
|
||||
etk::move(eproperty::Value<bool>(false)) )),
|
||||
singleOutNewLine((_allowSingle==true?
|
||||
etk::move(eproperty::Value<bool>(_generator, _groupName + "-" + _typeName + "-single-out-new-line", false, "Set new line after action.")):
|
||||
etk::move(eproperty::Value<bool>(false)) )),
|
||||
singleOutSpace((_allowSingle==true?
|
||||
etk::move(eproperty::Value<bool>(_generator, _groupName + "-" + _typeName + "-single-out-space", false, "Set space after action.")):
|
||||
etk::move(eproperty::Value<bool>(false)) )) {
|
||||
|
||||
}
|
||||
|
||||
estyle::GroupProperty::GroupProperty(estyle::GroupProperty&& _obj) :
|
||||
inNewLineBefore(etk::move(_obj.inNewLineBefore)),
|
||||
inNewLineAfter(etk::move(_obj.inNewLineAfter)),
|
||||
inSpaceBefore(etk::move(_obj.inSpaceBefore)),
|
||||
inSpaceAfter(etk::move(_obj.inSpaceAfter)),
|
||||
inIndentBefore(etk::move(_obj.inIndentBefore)),
|
||||
inIndentAfter(etk::move(_obj.inIndentAfter)),
|
||||
outNewLineBefore(etk::move(_obj.outNewLineBefore)),
|
||||
outNewLineAfter(etk::move(_obj.outNewLineAfter)),
|
||||
outSpaceBefore(etk::move(_obj.outSpaceBefore)),
|
||||
outSpaceAfter(etk::move(_obj.outSpaceAfter)),
|
||||
outIndentBefore(etk::move(_obj.outIndentBefore)),
|
||||
outIndentAfter(etk::move(_obj.outIndentAfter)),
|
||||
oneLineIfSingleMaxSize(etk::move(_obj.oneLineIfSingleMaxSize)),
|
||||
single(etk::move(_obj.single)),
|
||||
singleInNewLine(etk::move(_obj.singleInNewLine)),
|
||||
singleInSpace(etk::move(_obj.singleInSpace)),
|
||||
singleOutNewLine(etk::move(_obj.singleOutNewLine)),
|
||||
singleOutSpace(etk::move(_obj.singleOutSpace)) {
|
||||
|
||||
}
|
||||
|
||||
estyle::GroupProperty& estyle::GroupProperty::operator=(GroupProperty&& _obj) {
|
||||
inNewLineBefore = etk::move(_obj.inNewLineBefore);
|
||||
inNewLineAfter = etk::move(_obj.inNewLineAfter);
|
||||
inSpaceBefore = etk::move(_obj.inSpaceBefore);
|
||||
inSpaceAfter = etk::move(_obj.inSpaceAfter);
|
||||
inIndentBefore = etk::move(_obj.inIndentBefore);
|
||||
inIndentAfter = etk::move(_obj.inIndentAfter);
|
||||
outNewLineBefore = etk::move(_obj.outNewLineBefore);
|
||||
outNewLineAfter = etk::move(_obj.outNewLineAfter);
|
||||
outSpaceBefore = etk::move(_obj.outSpaceBefore);
|
||||
outSpaceAfter = etk::move(_obj.outSpaceAfter);
|
||||
outIndentBefore = etk::move(_obj.outIndentBefore);
|
||||
outIndentAfter = etk::move(_obj.outIndentAfter);
|
||||
oneLineIfSingleMaxSize = etk::move(_obj.oneLineIfSingleMaxSize);
|
||||
single = etk::move(_obj.single);
|
||||
singleInNewLine = etk::move(_obj.singleInNewLine);
|
||||
singleInSpace = etk::move(_obj.singleInSpace);
|
||||
singleOutNewLine = etk::move(_obj.singleOutNewLine);
|
||||
singleOutSpace = etk::move(_obj.singleOutSpace);
|
||||
return *this;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
estyle::ParentheseProperty::ParentheseProperty() :
|
||||
inSpaceBefore(false),
|
||||
inSpaceAfter(false),
|
||||
outSpaceBefore(false),
|
||||
outSpaceAfter(false),
|
||||
oneLineMaxSize(20000) {
|
||||
|
||||
}
|
||||
estyle::ParentheseProperty::ParentheseProperty(class estyle::Generator* _generator, const etk::String& _typeName):
|
||||
inSpaceBefore(_generator, "parenthese-" + _typeName + "-in-space-before", false, "Set a space before the input parenthese (if not already present)"),
|
||||
inSpaceAfter(_generator, "parenthese-" + _typeName + "-in-space-after", false, "Set a space after the input parenthese (if not already present)"),
|
||||
outSpaceBefore(_generator, "parenthese-" + _typeName + "-out-space-before", false, "Set a space before the input parenthese (if not already present)"),
|
||||
outSpaceAfter(_generator, "parenthese-" + _typeName + "-out-space-after", false, "Set a space after the input parenthese (if not already present)"),
|
||||
oneLineMaxSize(_generator, "parenthese-" + _typeName + "-single-one-line-size-max", 20000, "Set in a single line if the size if < XXX (-1 to disable)") {
|
||||
|
||||
}
|
||||
|
||||
estyle::ParentheseProperty::ParentheseProperty(estyle::ParentheseProperty&& _obj) :
|
||||
inSpaceBefore(etk::move(_obj.inSpaceBefore)),
|
||||
inSpaceAfter(etk::move(_obj.inSpaceAfter)),
|
||||
outSpaceBefore(etk::move(_obj.outSpaceBefore)),
|
||||
outSpaceAfter(etk::move(_obj.outSpaceAfter)),
|
||||
oneLineMaxSize(etk::move(_obj.oneLineMaxSize)) {
|
||||
|
||||
}
|
||||
|
||||
estyle::ParentheseProperty& estyle::ParentheseProperty::operator=(ParentheseProperty&& _obj) {
|
||||
inSpaceBefore = etk::move(_obj.inSpaceBefore);
|
||||
inSpaceAfter = etk::move(_obj.inSpaceAfter);
|
||||
outSpaceBefore = etk::move(_obj.outSpaceBefore);
|
||||
outSpaceAfter = etk::move(_obj.outSpaceAfter);
|
||||
oneLineMaxSize = etk::move(_obj.oneLineMaxSize);
|
||||
return *this;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
void estyle::Generator::clear() {
|
||||
m_offset = 0;
|
||||
m_offsetStack.clear();
|
||||
@ -269,13 +129,21 @@ estyle::Generator::Generator():
|
||||
propertyBrace.set("switch", etk::move(estyle::GroupProperty(this, "brace", "switch", false)));
|
||||
propertyBrace.set("class", etk::move(estyle::GroupProperty(this, "brace", "class", false)));
|
||||
propertyBrace.set("struct", etk::move(estyle::GroupProperty(this, "brace", "struct", false)));
|
||||
propertyBrace.set("try", etk::move(estyle::GroupProperty(this, "brace", "try", false)));
|
||||
propertyBrace.set("catch", etk::move(estyle::GroupProperty(this, "brace", "catch", false)));
|
||||
|
||||
propertyParenthese.set("if", etk::move(estyle::GroupProperty(this, "parenthese", "if")));
|
||||
propertyParenthese["if"].oneLineMaxSize.set(2000);
|
||||
propertyParenthese.set("for", etk::move(estyle::GroupProperty(this, "parenthese", "for")));
|
||||
propertyParenthese["for"].oneLineMaxSize.set(2000);
|
||||
propertyParenthese.set("while", etk::move(estyle::GroupProperty(this, "parenthese", "while")));
|
||||
propertyParenthese["while"].oneLineMaxSize.set(2000);
|
||||
propertyParenthese.set("do-while", etk::move(estyle::GroupProperty(this, "parenthese", "do-while")));
|
||||
propertyParenthese["do-while"].oneLineMaxSize.set(2000);
|
||||
propertyParenthese.set("switch", etk::move(estyle::GroupProperty(this, "parenthese", "switch")));
|
||||
propertyParenthese["switch"].oneLineMaxSize.set(2000);
|
||||
propertyParenthese.set("block", etk::move(estyle::GroupProperty(this, "parenthese", "block")));
|
||||
propertyParenthese["block"].oneLineMaxSize.set(2000);
|
||||
|
||||
}
|
||||
|
||||
@ -309,11 +177,13 @@ etk::String estyle::Generator::getDoxygenNLine(const etk::String& _data) {
|
||||
}
|
||||
|
||||
|
||||
void estyle::Generator::addNewLine() {
|
||||
while ( ( m_output.back() == ' '
|
||||
|| m_output.back() == '\t')
|
||||
&& m_output.size()>0) {
|
||||
m_output.popBack();
|
||||
void estyle::Generator::addNewLine(bool _force) {
|
||||
if (_force == false) {
|
||||
while ( ( m_output.back() == ' '
|
||||
|| m_output.back() == '\t')
|
||||
&& m_output.size()>0) {
|
||||
m_output.popBack();
|
||||
}
|
||||
}
|
||||
if (m_output.size() == 0) {
|
||||
return;
|
||||
@ -1039,58 +909,81 @@ int64_t estyle::Generator::generateBrace(int64_t _start, int64_t _stop, bool _ne
|
||||
ESTYLE_ERROR(" outNewLineAfter " << propertyBrace[m_type].outNewLineAfter.get());
|
||||
*/
|
||||
int32_t rawSize = countRawSize(_start, _stop);
|
||||
bool removeNewLine = propertyBrace[m_type].oneLineIfSingleMaxSize.get() >= rawSize;
|
||||
ESTYLE_ERROR("check: " << propertyBrace[m_type].oneLineIfSingleMaxSize.get() << " >= " << rawSize);
|
||||
ESTYLE_ERROR(" rawSize = " << rawSize);
|
||||
bool removeNewLine = propertyBrace[m_type].oneLineMaxSize.get() >= rawSize;
|
||||
ESTYLE_ERROR("check: " << propertyBrace[m_type].oneLineMaxSize.get() << " >= " << rawSize);
|
||||
if (_needBrace == false) {
|
||||
if (propertyBrace[m_type].single.get() == false) {
|
||||
_needBrace = true;
|
||||
}
|
||||
}
|
||||
if (_needBrace == true) {
|
||||
if ( _needBrace == true
|
||||
|| rawSize == 0) {
|
||||
if (propertyBrace[m_type].inIndentBefore.get() == true) {
|
||||
indentationPush();
|
||||
addIndent();
|
||||
}
|
||||
if ( propertyBrace[m_type].inNewLineBefore.get() == true
|
||||
&& removeNewLine == false) {
|
||||
addNewLine();
|
||||
// add indentation
|
||||
addSpace();
|
||||
} else if (propertyBrace[m_type].inSpaceBefore.get() == true) {
|
||||
// add 1 space if needed
|
||||
addSpace();
|
||||
}
|
||||
m_output += "{";
|
||||
if (propertyBrace[m_type].inIndentAfter.get() == true) {
|
||||
indentationPush();
|
||||
}
|
||||
if ( propertyBrace[m_type].inNewLineAfter.get() == true
|
||||
&& removeNewLine == false) {
|
||||
addNewLine();
|
||||
} else if (propertyBrace[m_type].inSpaceAfter.get() == true) {
|
||||
// add 1 space if needed
|
||||
} else if ( propertyBrace[m_type].inSpaceAfter.get() == true
|
||||
&& rawSize != 0) {
|
||||
addSpace();
|
||||
}
|
||||
if (rawSize == 0) {
|
||||
if ( m_output.back() == '\n'
|
||||
|| m_output.back() == '\r') {
|
||||
if (propertyBrace[m_type].emptyIndent.get() == true) {
|
||||
addIndent();
|
||||
addNewLine(true);
|
||||
}
|
||||
} else if (propertyBrace[m_type].emptySpace.get() == true) {
|
||||
addSpace();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (propertyBrace[m_type].singleIndent.get() == true) {
|
||||
indentationPush();
|
||||
}
|
||||
if ( propertyBrace[m_type].singleInNewLine.get() == true
|
||||
&& removeNewLine == false) {
|
||||
addNewLine();
|
||||
} else if (propertyBrace[m_type].singleInSpace.get() == true) {
|
||||
// add 1 space if needed
|
||||
addSpace();
|
||||
} else {
|
||||
addSpaceIfNeeded();
|
||||
}
|
||||
}
|
||||
indentationPush();
|
||||
// TODO: maybe check the last element
|
||||
int64_t out = process(_start, _stop);
|
||||
|
||||
indentationPop();
|
||||
if (_needBrace == true) {
|
||||
if (propertyBrace[m_type].outUnIndentBefore.get() == true) {
|
||||
indentationPop();
|
||||
}
|
||||
if ( propertyBrace[m_type].outNewLineBefore.get() == true
|
||||
&& removeNewLine == false) {
|
||||
addNewLine();
|
||||
// add indentation
|
||||
addSpace();
|
||||
} else if (propertyBrace[m_type].outSpaceBefore.get() == true) {
|
||||
// add 1 space if needed
|
||||
} else if ( propertyBrace[m_type].outSpaceBefore.get() == true
|
||||
&& rawSize != 0) {
|
||||
addSpace();
|
||||
}
|
||||
m_output += "}";
|
||||
if (propertyBrace[m_type].outUnIndentAfter.get() == true) {
|
||||
indentationPop();
|
||||
}
|
||||
if ( propertyBrace[m_type].outSpaceAfter.get() == true
|
||||
&& propertyBrace[m_type].outNewLineAfter.get() == false) {
|
||||
// add 1 space if needed
|
||||
@ -1109,6 +1002,9 @@ int64_t estyle::Generator::generateBrace(int64_t _start, int64_t _stop, bool _ne
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (propertyBrace[m_type].singleIndent.get() == true) {
|
||||
indentationPop();
|
||||
}
|
||||
if (propertyBrace[m_type].singleOutSpace.get() == true) {
|
||||
// add 1 space if needed
|
||||
addSpace();
|
||||
|
@ -7,56 +7,13 @@
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <estyle/lexer/Lexer.hpp>
|
||||
#include <estyle/GroupProperty.hpp>
|
||||
#include <ememory/memory.hpp>
|
||||
#include <eproperty/Value.hpp>
|
||||
#include <eproperty/List.hpp>
|
||||
#include <eproperty/Interface.hpp>
|
||||
|
||||
namespace estyle {
|
||||
class Generator;
|
||||
class GroupProperty {
|
||||
public:
|
||||
GroupProperty();
|
||||
GroupProperty(estyle::Generator* _generator, const etk::String& _groupName, const etk::String& _typeName, bool _allowSingle=true);
|
||||
eproperty::Value<bool> inNewLineBefore;
|
||||
eproperty::Value<bool> inNewLineAfter;
|
||||
eproperty::Value<bool> inSpaceBefore;
|
||||
eproperty::Value<bool> inSpaceAfter;
|
||||
eproperty::Value<bool> inIndentBefore;
|
||||
eproperty::Value<bool> inIndentAfter;
|
||||
eproperty::Value<bool> outNewLineBefore;
|
||||
eproperty::Value<bool> outNewLineAfter;
|
||||
eproperty::Value<bool> outSpaceBefore;
|
||||
eproperty::Value<bool> outSpaceAfter;
|
||||
eproperty::Value<bool> outIndentBefore;
|
||||
eproperty::Value<bool> outIndentAfter;
|
||||
eproperty::Value<int32_t> oneLineIfSingleMaxSize;
|
||||
eproperty::Value<bool> single;
|
||||
eproperty::Value<bool> singleInNewLine;
|
||||
eproperty::Value<bool> singleInSpace;
|
||||
eproperty::Value<bool> singleOutNewLine;
|
||||
eproperty::Value<bool> singleOutSpace;
|
||||
GroupProperty(const GroupProperty& _obj) = delete;
|
||||
GroupProperty(GroupProperty&& _obj);
|
||||
~GroupProperty() = default;
|
||||
GroupProperty& operator=(GroupProperty&& _obj);
|
||||
GroupProperty& operator=(const GroupProperty& _obj) = delete;
|
||||
};
|
||||
class ParentheseProperty {
|
||||
public:
|
||||
ParentheseProperty();
|
||||
ParentheseProperty(estyle::Generator* _generator, const etk::String& _typeName);
|
||||
eproperty::Value<bool> inSpaceBefore;
|
||||
eproperty::Value<bool> inSpaceAfter;
|
||||
eproperty::Value<bool> outSpaceBefore;
|
||||
eproperty::Value<bool> outSpaceAfter;
|
||||
eproperty::Value<int32_t> oneLineMaxSize;
|
||||
ParentheseProperty(const ParentheseProperty& _obj) = delete;
|
||||
ParentheseProperty(ParentheseProperty&& _obj);
|
||||
~ParentheseProperty() = default;
|
||||
ParentheseProperty& operator=(ParentheseProperty&& _obj);
|
||||
ParentheseProperty& operator=(const ParentheseProperty& _obj) = delete;
|
||||
};
|
||||
class Generator : public eproperty::Interface {
|
||||
public:
|
||||
Generator();
|
||||
@ -114,7 +71,7 @@ namespace estyle {
|
||||
/**
|
||||
* @brief Add newline if no newLine is set before
|
||||
*/
|
||||
void addNewLine();
|
||||
void addNewLine(bool _force=false);
|
||||
void addNewLineIfSemiColon();
|
||||
/// check if the previous cheracter is a newline or not...
|
||||
bool onNewLine();
|
||||
|
119
estyle/GroupProperty.cpp
Normal file
119
estyle/GroupProperty.cpp
Normal file
@ -0,0 +1,119 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2017, Edouard DUPIN, all right reserved
|
||||
* @license MPL-2 (see license file)
|
||||
*/
|
||||
#include <estyle/Generator.hpp>
|
||||
#include <estyle/debug.hpp>
|
||||
|
||||
estyle::GroupProperty::GroupProperty() :
|
||||
inNewLineBefore(false),
|
||||
inNewLineAfter(false),
|
||||
inSpaceBefore(false),
|
||||
inSpaceAfter(false),
|
||||
inIndentBefore(false),
|
||||
inIndentAfter(false),
|
||||
outNewLineBefore(false),
|
||||
outNewLineAfter(false),
|
||||
outSpaceBefore(false),
|
||||
outSpaceAfter(false),
|
||||
outUnIndentBefore(false),
|
||||
outUnIndentAfter(false),
|
||||
oneLineMaxSize(-1),
|
||||
single(false),
|
||||
singleInNewLine(false),
|
||||
singleInSpace(false),
|
||||
singleOutNewLine(false),
|
||||
singleOutSpace(false),
|
||||
singleIndent(false),
|
||||
emptySpace(false),
|
||||
emptyIndent(false) {
|
||||
|
||||
}
|
||||
|
||||
estyle::GroupProperty::GroupProperty(class estyle::Generator* _generator, const etk::String& _groupName, const etk::String& _typeName, bool _allowSingle):
|
||||
inNewLineBefore(_generator, _groupName + "-" + _typeName + "-in-new-line-before", false, "Set a new line before the input brace"),
|
||||
inNewLineAfter(_generator, _groupName + "-" + _typeName + "-in-new-line-after", false, "Set a new line after the input brace"),
|
||||
inSpaceBefore(_generator, _groupName + "-" + _typeName + "-in-space-before", false, "Set a space before the input brace (if not already present)"),
|
||||
inSpaceAfter(_generator, _groupName + "-" + _typeName + "-in-space-after", false, "Set a space after the input brace (if not already present)"),
|
||||
inIndentBefore(_generator, _groupName + "-" + _typeName + "-in-indent-before", false, "Increment indendation before adding brace"),
|
||||
inIndentAfter(_generator, _groupName + "-" + _typeName + "-in-indent-after", false, "Increment indendation after adding brace"),
|
||||
outNewLineBefore(_generator, _groupName + "-" + _typeName + "-out-new-line-before", false, "Set a new line before the input " + _groupName + ""),
|
||||
outNewLineAfter(_generator, _groupName + "-" + _typeName + "-out-new-line-after", false, "Set a new line after the input " + _groupName + ""),
|
||||
outSpaceBefore(_generator, _groupName + "-" + _typeName + "-out-space-before", false, "Set a space before the input " + _groupName + " (if not already present)"),
|
||||
outSpaceAfter(_generator, _groupName + "-" + _typeName + "-out-space-after", false, "Set a space after the input " + _groupName + " (if not already present)"),
|
||||
outUnIndentBefore(_generator, _groupName + "-" + _typeName + "-out-unindent-before", false, "Decrement indendation before adding " + _groupName + ""),
|
||||
outUnIndentAfter(_generator, _groupName + "-" + _typeName + "-out-unindent-after", false, "Decrement indendation after adding " + _groupName + ""),
|
||||
oneLineMaxSize(_generator, _groupName + "-" + _typeName + "-one-line-size-max", -1, "Set i a single line if the size if < XXX (-1 to disable)"),
|
||||
single((_allowSingle==true?
|
||||
etk::move(eproperty::Value<bool>(_generator, _groupName + "-" + _typeName + "-single", false, "remove or add " + _groupName + " if only 1 action is present.")):
|
||||
etk::move(eproperty::Value<bool>(false)) )),
|
||||
singleInNewLine((_allowSingle==true?
|
||||
etk::move(eproperty::Value<bool>(_generator, _groupName + "-" + _typeName + "-single-in-new-line", false, "Set new line before action.")):
|
||||
etk::move(eproperty::Value<bool>(false)) )),
|
||||
singleInSpace((_allowSingle==true?
|
||||
etk::move(eproperty::Value<bool>(_generator, _groupName + "-" + _typeName + "-single-in-space", false, "Set Space before action.")):
|
||||
etk::move(eproperty::Value<bool>(false)) )),
|
||||
singleOutNewLine((_allowSingle==true?
|
||||
etk::move(eproperty::Value<bool>(_generator, _groupName + "-" + _typeName + "-single-out-new-line", false, "Set new line after action.")):
|
||||
etk::move(eproperty::Value<bool>(false)) )),
|
||||
singleOutSpace((_allowSingle==true?
|
||||
etk::move(eproperty::Value<bool>(_generator, _groupName + "-" + _typeName + "-single-out-space", false, "Set space after action.")):
|
||||
etk::move(eproperty::Value<bool>(false)) )),
|
||||
singleIndent((_allowSingle==true?
|
||||
etk::move(eproperty::Value<bool>(_generator, _groupName + "-" + _typeName + "-single-indent", false, "Enable indentation inside single element.")):
|
||||
etk::move(eproperty::Value<bool>(false)) )),
|
||||
emptySpace(_generator, _groupName + "-" + _typeName + "-empty-space", false, "Set One space inside the group"),
|
||||
emptyIndent(_generator, _groupName + "-" + _typeName + "-empty-indent", false, "Set an indented empty line if multiple-line") {
|
||||
|
||||
}
|
||||
|
||||
estyle::GroupProperty::GroupProperty(estyle::GroupProperty&& _obj) :
|
||||
inNewLineBefore(etk::move(_obj.inNewLineBefore)),
|
||||
inNewLineAfter(etk::move(_obj.inNewLineAfter)),
|
||||
inSpaceBefore(etk::move(_obj.inSpaceBefore)),
|
||||
inSpaceAfter(etk::move(_obj.inSpaceAfter)),
|
||||
inIndentBefore(etk::move(_obj.inIndentBefore)),
|
||||
inIndentAfter(etk::move(_obj.inIndentAfter)),
|
||||
outNewLineBefore(etk::move(_obj.outNewLineBefore)),
|
||||
outNewLineAfter(etk::move(_obj.outNewLineAfter)),
|
||||
outSpaceBefore(etk::move(_obj.outSpaceBefore)),
|
||||
outSpaceAfter(etk::move(_obj.outSpaceAfter)),
|
||||
outUnIndentBefore(etk::move(_obj.outUnIndentBefore)),
|
||||
outUnIndentAfter(etk::move(_obj.outUnIndentAfter)),
|
||||
oneLineMaxSize(etk::move(_obj.oneLineMaxSize)),
|
||||
single(etk::move(_obj.single)),
|
||||
singleInNewLine(etk::move(_obj.singleInNewLine)),
|
||||
singleInSpace(etk::move(_obj.singleInSpace)),
|
||||
singleOutNewLine(etk::move(_obj.singleOutNewLine)),
|
||||
singleOutSpace(etk::move(_obj.singleOutSpace)),
|
||||
singleIndent(etk::move(_obj.singleIndent)),
|
||||
emptySpace(etk::move(_obj.emptySpace)),
|
||||
emptyIndent(etk::move(_obj.emptyIndent)) {
|
||||
|
||||
}
|
||||
|
||||
estyle::GroupProperty& estyle::GroupProperty::operator=(GroupProperty&& _obj) {
|
||||
inNewLineBefore = etk::move(_obj.inNewLineBefore);
|
||||
inNewLineAfter = etk::move(_obj.inNewLineAfter);
|
||||
inSpaceBefore = etk::move(_obj.inSpaceBefore);
|
||||
inSpaceAfter = etk::move(_obj.inSpaceAfter);
|
||||
inIndentBefore = etk::move(_obj.inIndentBefore);
|
||||
inIndentAfter = etk::move(_obj.inIndentAfter);
|
||||
outNewLineBefore = etk::move(_obj.outNewLineBefore);
|
||||
outNewLineAfter = etk::move(_obj.outNewLineAfter);
|
||||
outSpaceBefore = etk::move(_obj.outSpaceBefore);
|
||||
outSpaceAfter = etk::move(_obj.outSpaceAfter);
|
||||
outUnIndentBefore = etk::move(_obj.outUnIndentBefore);
|
||||
outUnIndentAfter = etk::move(_obj.outUnIndentAfter);
|
||||
oneLineMaxSize = etk::move(_obj.oneLineMaxSize);
|
||||
single = etk::move(_obj.single);
|
||||
singleInNewLine = etk::move(_obj.singleInNewLine);
|
||||
singleInSpace = etk::move(_obj.singleInSpace);
|
||||
singleOutNewLine = etk::move(_obj.singleOutNewLine);
|
||||
singleOutSpace = etk::move(_obj.singleOutSpace);
|
||||
singleIndent = etk::move(_obj.singleIndent);
|
||||
emptySpace = etk::move(_obj.emptySpace);
|
||||
emptyIndent = etk::move(_obj.emptyIndent);
|
||||
return *this;
|
||||
}
|
54
estyle/GroupProperty.hpp
Normal file
54
estyle/GroupProperty.hpp
Normal file
@ -0,0 +1,54 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2017, Edouard DUPIN, all right reserved
|
||||
* @license MPL-2 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <estyle/lexer/Lexer.hpp>
|
||||
#include <estyle/GroupProperty.hpp>
|
||||
#include <ememory/memory.hpp>
|
||||
#include <eproperty/Value.hpp>
|
||||
#include <eproperty/List.hpp>
|
||||
#include <eproperty/Interface.hpp>
|
||||
|
||||
namespace estyle {
|
||||
class Generator;
|
||||
class GroupProperty {
|
||||
public:
|
||||
GroupProperty();
|
||||
GroupProperty(estyle::Generator* _generator, const etk::String& _groupName, const etk::String& _typeName, bool _allowSingle=true);
|
||||
// in
|
||||
eproperty::Value<bool> inNewLineBefore;
|
||||
eproperty::Value<bool> inNewLineAfter;
|
||||
eproperty::Value<bool> inSpaceBefore;
|
||||
eproperty::Value<bool> inSpaceAfter;
|
||||
eproperty::Value<bool> inIndentBefore;
|
||||
eproperty::Value<bool> inIndentAfter;
|
||||
// out
|
||||
eproperty::Value<bool> outNewLineBefore;
|
||||
eproperty::Value<bool> outNewLineAfter;
|
||||
eproperty::Value<bool> outSpaceBefore;
|
||||
eproperty::Value<bool> outSpaceAfter;
|
||||
eproperty::Value<bool> outUnIndentBefore;
|
||||
eproperty::Value<bool> outUnIndentAfter;
|
||||
// single
|
||||
eproperty::Value<int32_t> oneLineMaxSize;
|
||||
eproperty::Value<bool> single;
|
||||
eproperty::Value<bool> singleInNewLine;
|
||||
eproperty::Value<bool> singleInSpace;
|
||||
eproperty::Value<bool> singleOutNewLine;
|
||||
eproperty::Value<bool> singleOutSpace;
|
||||
eproperty::Value<bool> singleIndent;
|
||||
// empty
|
||||
eproperty::Value<bool> emptySpace;
|
||||
eproperty::Value<bool> emptyIndent;
|
||||
|
||||
GroupProperty(const GroupProperty& _obj) = delete;
|
||||
GroupProperty(GroupProperty&& _obj);
|
||||
~GroupProperty() = default;
|
||||
GroupProperty& operator=(GroupProperty&& _obj);
|
||||
GroupProperty& operator=(const GroupProperty& _obj) = delete;
|
||||
};
|
||||
}
|
@ -19,6 +19,7 @@ def configure(target, my_module):
|
||||
my_module.add_src_file([
|
||||
'estyle/debug.cpp',
|
||||
'estyle/estyle.cpp',
|
||||
'estyle/GroupProperty.cpp',
|
||||
'estyle/Generator.cpp',
|
||||
'estyle/lexer/Lexer.cpp',
|
||||
'estyle/lexer/tocken.cpp',
|
||||
@ -26,6 +27,7 @@ def configure(target, my_module):
|
||||
my_module.add_header_file([
|
||||
'estyle/debug.hpp',
|
||||
'estyle/estyle.hpp',
|
||||
'estyle/GroupProperty.hpp',
|
||||
'estyle/Generator.hpp',
|
||||
'estyle/lexer/Lexer.hpp',
|
||||
'estyle/lexer/tocken.hpp',
|
||||
|
1521
test/testIf.cpp
1521
test/testIf.cpp
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user