Skip to content

Commit 6034561

Browse files
committed
试图让折行更合理一些
1 parent 8f2ed58 commit 6034561

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

CodeService/src/FormatElement/AlignToFirstElement.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ void AlignToFirstElement::Serialize(SerializeContext& ctx, ChildIterator selfIt,
7070

7171
keepElement->AllowBreakLineSerialize(ctx, it, *this);
7272
}
73+
else if(child->Is(FormatElementType::SubExpressionElement))
74+
{
75+
SerializeSubExpression(ctx, *child);
76+
}
7377
else
7478
{
7579
child->Serialize(ctx, it, *this);
@@ -143,3 +147,26 @@ void AlignToFirstElement::Diagnosis(DiagnosisContext& ctx, ChildIterator selfIt,
143147
ctx.RecoverIndent();
144148
}
145149
}
150+
151+
void AlignToFirstElement::SerializeSubExpression(SerializeContext& ctx, FormatElement& parent)
152+
{
153+
auto& children = parent.GetChildren();
154+
for (auto it = children.begin(); it != children.end(); ++it)
155+
{
156+
auto child = *it;
157+
158+
if (child->Is(FormatElementType::SubExpressionElement))
159+
{
160+
SerializeSubExpression(ctx, *child);
161+
}
162+
else if (child->Is(FormatElementType::KeepElement))
163+
{
164+
auto keepElement = std::dynamic_pointer_cast<KeepElement>(child);
165+
keepElement->AllowBreakLineSerialize(ctx, it, parent);
166+
}
167+
else
168+
{
169+
child->Serialize(ctx, it, parent);
170+
}
171+
}
172+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#include "CodeService/FormatElement/SubExpressionElement.h"
22

3+
#include "CodeService/FormatElement/KeepElement.h"
4+
35
FormatElementType SubExpressionElement::GetType()
46
{
57
return FormatElementType::SubExpressionElement;
68
}
9+

include/CodeService/FormatElement/AlignToFirstElement.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#pragma once
1+
#pragma once
22

33
#include "FormatElement.h"
44

@@ -11,4 +11,6 @@ class AlignToFirstElement : public FormatElement
1111

1212
void Serialize(SerializeContext& ctx, ChildIterator selfIt, FormatElement& parent) override;
1313
void Diagnosis(DiagnosisContext& ctx, ChildIterator selfIt, FormatElement& parent) override;
14+
private:
15+
void SerializeSubExpression(SerializeContext& ctx, FormatElement& parent);
1416
};

include/CodeService/LuaCodeStyleOptions.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ class LuaCodeStyleOptions
5454
*/
5555
AlignCallArgs align_call_args = AlignCallArgs::False;
5656

57-
bool only_align_call_args_after_assignment = false;
58-
5957
/*
6058
* 函数定义的参数保持对齐到第一个参数
6159
* 函数的定义通常不会太长,这种默认行为是可以接受的

0 commit comments

Comments
 (0)