Skip to content

Commit 417f9be

Browse files
committed
修改格式检查信息
1 parent 6034561 commit 417f9be

File tree

4 files changed

+26
-10
lines changed

4 files changed

+26
-10
lines changed

CodeService/src/FormatElement/AlignmentElement.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ void AlignmentElement::Diagnosis(DiagnosisContext& ctx, ChildIterator selfIt, Fo
3333
if (character != _alignmentPosition)
3434
{
3535
ctx.PushDiagnosis(Util::format(LText("'=' should align to character {}"), _alignmentPosition),
36-
TextRange(nextOffset, nextOffset + 1), DiagnosisType::Align);
36+
TextRange(nextOffset, nextOffset), DiagnosisType::Align);
3737
}
3838
}

CodeService/src/FormatElement/KeepBlankElement.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,16 @@ void KeepBlankElement::Diagnosis(DiagnosisContext& ctx, ChildIterator selfIt, Fo
3636

3737
if (nextElementLine == lastElementLine)
3838
{
39-
if (nextOffset - lastOffset - 1 != _blank)
39+
if (nextOffset - lastOffset - 1 < _blank)
4040
{
41-
ctx.PushDiagnosis(Util::format(LText("here need keep {} space"), _blank), TextRange(lastOffset, nextOffset),
41+
ctx.PushDiagnosis(Util::format(LText("{} space should be reserved here"), _blank),
42+
TextRange(lastOffset, nextOffset),
43+
DiagnosisType::Blank);
44+
}
45+
else
46+
{
47+
ctx.PushDiagnosis(Util::format(LText("{} space should be kept here"), _blank),
48+
TextRange(lastOffset + 1, nextOffset - 1),
4249
DiagnosisType::Blank);
4350
}
4451
}

CodeService/src/FormatElement/KeepElement.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,17 @@ void KeepElement::Diagnosis(DiagnosisContext& ctx, ChildIterator selfIt,
6868

6969
if (nextElementLine == lastElementLine)
7070
{
71-
if (nextOffset - lastOffset - 1 != _keepBlank)
71+
if (nextOffset - lastOffset - 1 < _keepBlank)
7272
{
73-
ctx.PushDiagnosis(Util::format(LText("here need keep {} space"), _keepBlank),
74-
TextRange(lastOffset, nextOffset), DiagnosisType::Blank);
73+
ctx.PushDiagnosis(Util::format(LText("missing whitespace")),
74+
TextRange(lastOffset, nextOffset),
75+
DiagnosisType::Blank);
76+
}
77+
else
78+
{
79+
ctx.PushDiagnosis(Util::format(LText("multiple spaces")),
80+
TextRange(lastOffset + 1, nextOffset - 1),
81+
DiagnosisType::Blank);
7582
}
7683
}
7784
else
@@ -82,7 +89,7 @@ void KeepElement::Diagnosis(DiagnosisContext& ctx, ChildIterator selfIt,
8289

8390
void KeepElement::AllowBreakLineSerialize(SerializeContext& ctx, ChildIterator selfIt, FormatElement& parent)
8491
{
85-
if(!_allowContinueIndent)
92+
if (!_allowContinueIndent)
8693
{
8794
return Serialize(ctx, selfIt, parent);
8895
}

CodeService/src/FormatElement/KeepLineElement.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@ void KeepLineElement::Diagnosis(DiagnosisContext& ctx, ChildIterator selfIt,
5858
{
5959
auto character = ctx.GetColumn(nextElementOffset);
6060

61-
ctx.PushDiagnosis(Util::format(LText("here need keep {} empty line"), _line),
62-
LuaDiagnosisPosition(nextElementLine, character),
63-
LuaDiagnosisPosition(nextElementLine + 1, 0), DiagnosisType::StatementLineSpace);
61+
ctx.PushDiagnosis(
62+
Util::format(
63+
LText("expected {} blank lines, found {}"), _line, (nextElementLine - lastElementLine - 1)),
64+
LuaDiagnosisPosition(nextElementLine, character),
65+
LuaDiagnosisPosition(nextElementLine + 1, 0), DiagnosisType::StatementLineSpace);
6466
}
6567
}
6668
}

0 commit comments

Comments
 (0)