Skip to content

Commit b124c4a

Browse files
committed
Merge branch 'master' of github.com:CppCXY/EmmyLuaCodeStyle
2 parents 590f18d + 540eb4d commit b124c4a

File tree

8 files changed

+36
-8
lines changed

8 files changed

+36
-8
lines changed

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ option(EnableTest "Test project" ON)
1111

1212
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
1313
add_definitions(-DMSVC)
14-
# ÓÅ»¯Ñ¡Ïî
1514
else()
1615
set(CMAKE_C_FLAGS_RELEASE "-O2")
1716
set(CMAKE_CXX_FLAGS_RELEASE "-O2")

CodeFormatServer/src/Service/AstUtil/ModuleFinder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void ModuleFinder::VisitParamList(const std::shared_ptr<LuaAstNode>& paramList)
4646
{
4747
for (auto param : paramList->GetChildren())
4848
{
49-
if (param->GetType() == LuaAstNodeType::Identify)
49+
if (param->GetType() == LuaAstNodeType::Param)
5050
{
5151
RecordLocalVariable(param);
5252
}

CodeService/src/LuaFormatter.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,12 +1088,13 @@ std::shared_ptr<FormatElement> LuaFormatter::FormatIfStatement(std::shared_ptr<L
10881088
}
10891089

10901090
env->AddChild(FormatExpression(child, expression));
1091-
env->Add<KeepBlankElement>(1);
1091+
env->Add<KeepElement>(1);
10921092
break;
10931093
}
10941094
default:
10951095
{
10961096
DefaultHandle(child, env);
1097+
env->Add<KeepElement>(1);
10971098
break;
10981099
}
10991100
}
@@ -1196,6 +1197,10 @@ std::shared_ptr<FormatElement> LuaFormatter::FormatCallArgList(std::shared_ptr<L
11961197
layout = std::make_shared<AlignToFirstElement>();
11971198
}
11981199
}
1200+
else
1201+
{
1202+
layout = std::make_shared<IndentOnLineBreakElement>();
1203+
}
11991204

12001205
env->AddChild(FormatExpressionList(child, layout));
12011206
env->Add<KeepElement>(0);
@@ -1803,7 +1808,7 @@ std::shared_ptr<FormatElement> LuaFormatter::FormatNodeAndBlockOrEnd(LuaAstNode:
18031808
else
18041809
{
18051810
singleLineBlock = true;
1806-
env->Add<KeepBlankElement>(1);
1811+
env->Add<KeepElement>(1);
18071812

18081813
for (auto blockChild : block->GetChildren())
18091814
{
@@ -1812,7 +1817,7 @@ std::shared_ptr<FormatElement> LuaFormatter::FormatNodeAndBlockOrEnd(LuaAstNode:
18121817
auto shortExpression = std::make_shared<ExpressionElement>();
18131818
shortExpression->AddChildren(blockChild->GetChildren());
18141819
env->AddChild(shortExpression);
1815-
env->Add<KeepBlankElement>(1);
1820+
env->Add<KeepElement>(1);
18161821
}
18171822
}
18181823
}

CodeService/src/NameStyle/NameStyleChecker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ void NameStyleChecker::VisitParamList(const std::shared_ptr<LuaAstNode>& paramLi
195195
{
196196
for (auto param : paramList->GetChildren())
197197
{
198-
if (param->GetType() == LuaAstNodeType::Identify)
198+
if (param->GetType() == LuaAstNodeType::Param && param->GetText() != "...")
199199
{
200200
_nameStyleCheckVector.push_back(std::make_shared<CheckElement>(NameDefineType::ParamName, param));
201201
}

Test/test_script/format_text/wait_format/expression.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,8 @@ function f()
3636
dd.e().e().aaa =1231
3737
end
3838

39+
call(
40+
call(aaa,
41+
aaaa),
42+
call(aaa,bbbb,ccc)
43+
)

Test/test_script/format_text/wait_format/if.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ else
1818
end
1919

2020

21+
if a then return a --end
2122

2223

24+
end
2325

24-
25-
26+
if a --
27+
then
28+
end
2629

Test/test_script/format_text/wait_format_should_be/expression.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,9 @@ function f()
3535
local fff = function() end
3636
dd.e().e().aaa = 1231
3737
end
38+
39+
call(
40+
call(aaa,
41+
aaaa),
42+
call(aaa, bbbb, ccc)
43+
)

Test/test_script/format_text/wait_format_should_be/if.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,13 @@ elseif aa then
1616
elseif ccc then
1717
else
1818
end
19+
20+
21+
if a then return a --end
22+
23+
24+
end
25+
26+
if a --
27+
then
28+
end

0 commit comments

Comments
 (0)