MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / AddInvertIndent

Method AddInvertIndent

CodeFormatCore/src/Format/FormatState.cpp:92–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90}
91
92void FormatState::AddInvertIndent(LuaSyntaxNode syntaxNoe, std::size_t indent) {
93 if (_indentStack.empty()) {
94 _indentStack.emplace(syntaxNoe, 0, 0);
95 return;
96 }
97 auto top = _indentStack.top();
98 switch (_formatStyle.indent_style) {
99 case IndentStyle::Space: {
100 std::size_t spaceSize = 0;
101 if (top.SpaceSize > indent) {
102 spaceSize = top.SpaceSize - indent;
103 }
104 _indentStack.emplace(syntaxNoe, spaceSize, top.TabSize);
105 break;
106 }
107 case IndentStyle::Tab: {
108 auto tabIndent = indent / _formatStyle.tab_width;
109 auto spaceIndent = indent % _formatStyle.tab_width;
110 std::size_t spaceSize = 0;
111 std::size_t tabSize = 0;
112 if (top.SpaceSize > spaceIndent) {
113 spaceSize = top.SpaceSize - spaceIndent;
114 }
115 if (top.TabSize > tabIndent) {
116 tabSize = top.TabSize - tabIndent;
117 }
118
119 _indentStack.emplace(syntaxNoe, spaceSize, tabSize);
120 break;
121 }
122 }
123}
124
125void FormatState::RecoverIndent() {
126 if (_indentStack.empty()) {

Callers

nothing calls this directly

Calls 3

topMethod · 0.80
emptyMethod · 0.45
emplaceMethod · 0.45

Tested by

no test coverage detected