Skip to content

Commit a4af2ae

Browse files
committed
修改父指针为引用
1 parent f10a671 commit a4af2ae

27 files changed

+50
-50
lines changed

CodeService/src/FormatElement/AlignToFirstElement.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ FormatElementType AlignToFirstElement::GetType()
1010
return FormatElementType::AlignToFirstElement;
1111
}
1212

13-
void AlignToFirstElement::Serialize(FormatContext& ctx, int position, FormatElement* parent)
13+
void AlignToFirstElement::Serialize(FormatContext& ctx, int position, FormatElement& parent)
1414
{
1515
for (int i = 0; i != _children.size(); i++)
1616
{
@@ -37,7 +37,7 @@ void AlignToFirstElement::Serialize(FormatContext& ctx, int position, FormatElem
3737
}
3838
}
3939

40-
_children[i]->Serialize(ctx, i, this);
40+
_children[i]->Serialize(ctx, i, *this);
4141

4242
if(i == _children.size() - 1)
4343
{

CodeService/src/FormatElement/AlignmentElement.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ FormatElementType AlignmentElement::GetType()
1111
return FormatElementType::AlignmentElement;
1212
}
1313

14-
void AlignmentElement::Serialize(FormatContext& ctx, int position, FormatElement* parent)
14+
void AlignmentElement::Serialize(FormatContext& ctx, int position, FormatElement& parent)
1515
{
1616
int blank = _alignmentPosition - ctx.GetCharacterCount();
1717
if (blank > 0)

CodeService/src/FormatElement/AlignmentLayoutElement.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ FormatElementType AlignmentLayoutElement::GetType()
2121
return FormatElementType::AlignmentLayoutElement;
2222
}
2323

24-
void AlignmentLayoutElement::Serialize(FormatContext& ctx, int position, FormatElement* parent)
24+
void AlignmentLayoutElement::Serialize(FormatContext& ctx, int position, FormatElement& parent)
2525
{
2626
int eqAlignedPosition = 0;
2727
bool firstContainEq = true;
@@ -49,15 +49,15 @@ void AlignmentLayoutElement::Serialize(FormatContext& ctx, int position, FormatE
4949
auto lastValidIndex = FindLastValidChildIndex(index, statChildren);
5050
if (lastValidIndex == -1)
5151
{
52-
return normalSerialize(ctx, position, this);
52+
return normalSerialize(ctx, position, *this);
5353
}
5454
auto lastStatChild = statChildren[lastValidIndex];
5555
auto lastPosition = ctx.GetColumn(lastStatChild->GetTextRange().EndOffset);
5656

5757

5858
if (eqPosition - lastPosition <= 2)
5959
{
60-
return normalSerialize(ctx, position, this);
60+
return normalSerialize(ctx, position, *this);
6161
}
6262
}
6363

@@ -70,10 +70,10 @@ void AlignmentLayoutElement::Serialize(FormatContext& ctx, int position, FormatE
7070
}
7171
}
7272

73-
return alignmentSerialize(ctx, position, this, eqAlignedPosition);
73+
return alignmentSerialize(ctx, position, *this, eqAlignedPosition);
7474
}
7575

76-
void AlignmentLayoutElement::alignmentSerialize(FormatContext& ctx, int position, FormatElement* parent, int eqPosition)
76+
void AlignmentLayoutElement::alignmentSerialize(FormatContext& ctx, int position, FormatElement& parent, int eqPosition)
7777
{
7878
for (auto statChild : _children)
7979
{
@@ -98,7 +98,7 @@ void AlignmentLayoutElement::alignmentSerialize(FormatContext& ctx, int position
9898
return normalSerialize(ctx, position, parent);
9999
}
100100

101-
void AlignmentLayoutElement::normalSerialize(FormatContext& ctx, int position, FormatElement* parent)
101+
void AlignmentLayoutElement::normalSerialize(FormatContext& ctx, int position, FormatElement& parent)
102102
{
103103
FormatElement::Serialize(ctx, position, parent);
104104
}

CodeService/src/FormatElement/FormatElement.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,17 @@ std::shared_ptr<FormatElement> FormatElement::LastValidElement() const
5656
return nullptr;
5757
}
5858

59-
void FormatElement::Serialize(FormatContext& ctx, int position, FormatElement* parent)
59+
void FormatElement::Serialize(FormatContext& ctx, int position, FormatElement& parent)
6060
{
6161
for (std::size_t i = 0; i != _children.size(); i++)
6262
{
63-
_children[i]->Serialize(ctx, i, this);
63+
_children[i]->Serialize(ctx, i, *this);
6464
}
6565
}
6666

6767
void FormatElement::Format(FormatContext& ctx)
6868
{
69-
return Serialize(ctx, 0, nullptr);
69+
return Serialize(ctx, 0, *this);
7070
}
7171

7272
void FormatElement::AddTextRange(TextRange range)

CodeService/src/FormatElement/IndentElement.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ FormatElementType IndentElement::GetType()
1111
return FormatElementType::IndentElement;
1212
}
1313

14-
void IndentElement::Serialize(FormatContext& ctx, int position, FormatElement* parent)
14+
void IndentElement::Serialize(FormatContext& ctx, int position, FormatElement& parent)
1515
{
1616
ctx.AddIndent(_specialIndent);
1717

CodeService/src/FormatElement/KeepBlankElement.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ FormatElementType KeepBlankElement::GetType()
1111
return FormatElementType::KeepBlankElement;
1212
}
1313

14-
void KeepBlankElement::Serialize(FormatContext& ctx, int position, FormatElement* parent)
14+
void KeepBlankElement::Serialize(FormatContext& ctx, int position, FormatElement& parent)
1515
{
1616
ctx.PrintBlank(_blank);
1717
}

CodeService/src/FormatElement/KeepElement.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ FormatElementType KeepElement::GetType()
1212
return FormatElementType::KeepElement;
1313
}
1414

15-
void KeepElement::Serialize(FormatContext& ctx, int position, FormatElement* parent)
15+
void KeepElement::Serialize(FormatContext& ctx, int position, FormatElement& parent)
1616
{
1717
int lastElementLine = getLastValidLine(ctx, position, parent);
1818
int nextElementLine = getNextValidLine(ctx, position, parent);

CodeService/src/FormatElement/KeepLineElement.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ FormatElementType KeepLineElement::GetType()
1212
return FormatElementType::KeepLineElement;
1313
}
1414

15-
void KeepLineElement::Serialize(FormatContext& ctx, int position, FormatElement* parent)
15+
void KeepLineElement::Serialize(FormatContext& ctx, int position, FormatElement& parent)
1616
{
1717
int line = _line;
1818
if (_line == -1)
@@ -35,9 +35,9 @@ void KeepLineElement::Serialize(FormatContext& ctx, int position, FormatElement*
3535
ctx.PrintLine(line);
3636
}
3737

38-
int KeepLineElement::getLastValidLine(FormatContext& ctx, int position, FormatElement* parent)
38+
int KeepLineElement::getLastValidLine(FormatContext& ctx, int position, FormatElement& parent)
3939
{
40-
auto& siblings = parent->GetChildren();
40+
auto& siblings = parent.GetChildren();
4141
for (int index = position - 1; index >= 0; index--)
4242
{
4343
if(siblings[index]->HasValidTextRange())
@@ -47,12 +47,12 @@ int KeepLineElement::getLastValidLine(FormatContext& ctx, int position, FormatEl
4747
}
4848

4949
// 那么一定是往上找不到有效范围元素
50-
return ctx.GetLine(parent->GetTextRange().StartOffset);
50+
return ctx.GetLine(parent.GetTextRange().StartOffset);
5151
}
5252

53-
int KeepLineElement::getNextValidLine(FormatContext& ctx, int position, FormatElement* parent)
53+
int KeepLineElement::getNextValidLine(FormatContext& ctx, int position, FormatElement& parent)
5454
{
55-
auto& siblings = parent->GetChildren();
55+
auto& siblings = parent.GetChildren();
5656
for (std::size_t index = position + 1; index < siblings.size(); index++)
5757
{
5858
if (siblings[index]->HasValidTextRange())

CodeService/src/FormatElement/LineElement.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ FormatElementType LineElement::GetType()
1111
return FormatElementType::LineElement;
1212
}
1313

14-
void LineElement::Serialize(FormatContext& ctx, int position,FormatElement* parent)
14+
void LineElement::Serialize(FormatContext& ctx, int position, FormatElement& parent)
1515
{
1616
ctx.PrintLine(1);
1717
}

CodeService/src/FormatElement/LongExpressionLayoutElement.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,25 @@ FormatElementType LongExpressionLayoutElement::GetType()
1010
return FormatElementType::LongExpressionLayoutElement;
1111
}
1212

13-
void LongExpressionLayoutElement::Serialize(FormatContext& ctx, int position, FormatElement* parent)
13+
void LongExpressionLayoutElement::Serialize(FormatContext& ctx, int position, FormatElement& parent)
1414
{
15-
SerializeSubExpression(ctx, this);
15+
SerializeSubExpression(ctx, *this);
1616
if (_hasIndent)
1717
{
1818
ctx.RecoverIndent();
1919
}
2020
}
2121

22-
void LongExpressionLayoutElement::SerializeSubExpression(FormatContext& ctx, FormatElement* parent)
22+
void LongExpressionLayoutElement::SerializeSubExpression(FormatContext& ctx, FormatElement& parent)
2323
{
24-
auto& children = parent->GetChildren();
24+
auto& children = parent.GetChildren();
2525
for (std::size_t i = 0; i != children.size(); i++)
2626
{
2727
auto child = children[i];
2828

2929
if (child->GetType() == FormatElementType::SubExpressionElement)
3030
{
31-
SerializeSubExpression(ctx, child.get());
31+
SerializeSubExpression(ctx, *child);
3232
}
3333
else
3434
{

0 commit comments

Comments
 (0)