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

Method Analyze

CodeFormatCore/src/Format/Analyzer/LineBreakAnalyzer.cpp:12–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10}
11
12void LineBreakAnalyzer::Analyze(FormatState &f, const LuaSyntaxTree &t) {
13 for (auto syntaxNode: t.GetSyntaxNodes()) {
14 if (syntaxNode.IsToken(t)) {
15 switch (syntaxNode.GetTokenKind(t)) {
16 case TK_SHEBANG:
17 case TK_SHORT_COMMENT: {
18 BreakAfter(syntaxNode, t, LineSpace(LineSpaceType::Keep));
19 break;
20 }
21 case '{':
22 case '}': {
23 if (f.GetStyle().break_before_braces) {
24 auto parent = syntaxNode.GetParent(t);
25 if (parent.GetSyntaxKind(t) == LuaSyntaxNodeKind::TableExpression && !parent.IsSingleLineNode(t)) {
26 BreakBefore(syntaxNode, t, LineSpace(LineSpaceType::Keep));
27 }
28 }
29 break;
30 }
31 default: {
32 break;
33 }
34 }
35 }
36 }
37}
38
39void LineBreakAnalyzer::ComplexAnalyze(FormatState &f, const LuaSyntaxTree &t) {
40 for (auto syntaxNode: t.GetSyntaxNodes()) {

Callers

nothing calls this directly

Calls 7

LineSpaceClass · 0.85
GetStyleMethod · 0.80
GetSyntaxKindMethod · 0.80
IsSingleLineNodeMethod · 0.80
IsTokenMethod · 0.45
GetTokenKindMethod · 0.45
GetParentMethod · 0.45

Tested by

no test coverage detected