Skip to content

Commit c352bb8

Browse files
committed
优化显示信息
1 parent fed5e19 commit c352bb8

File tree

12 files changed

+14
-34
lines changed

12 files changed

+14
-34
lines changed

CodeFormatServer/src/Service/CodeActionService.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ std::string CodeActionService::GetCode(DiagnosticCode code)
4040
{
4141
switch (code)
4242
{
43-
case DiagnosticCode::Spell: return "EmmyLua [spell-check]";
44-
case DiagnosticCode::Module: return "EmmyLua [module-check]";
45-
case DiagnosticCode::Reformat: return "EmmyLua [style-check]";
43+
case DiagnosticCode::Spell: return "spell-check";
44+
case DiagnosticCode::Module: return "module-check";
45+
case DiagnosticCode::Reformat: return "style-check";
4646
}
4747

4848
return "";

CodeFormatServer/src/Service/CodeFormatService.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ std::vector<vscode::Diagnostic> CodeFormatService::Diagnose(std::string_view fil
5252
diagnosisInfo.Range.End.Character
5353
));
5454
diagnosis.severity = vscode::DiagnosticSeverity::Warning;
55+
diagnosis.source = "EmmyLua";
5556
switch (diagnosisInfo.type)
5657
{
5758
case DiagnosisType::Indent:

CodeFormatServer/src/VSCode.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ nlohmann::json vscode::Diagnostic::Serialize()
7474
object["severity"] = static_cast<int>(severity);
7575
object["data"] = data;
7676
object["code"] = code;
77+
object["source"] = source;
7778
return object;
7879
}
7980

CodeService/src/FormatElement/BreakableElement.cpp

Lines changed: 0 additions & 10 deletions
This file was deleted.

CodeService/src/FormatElement/FormatElement.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ void FormatElement::GeneralIndentDiagnosis(DiagnosisContext& ctx, ChildIterator
164164
if (ctx.GetOptions().indent_style != indentState.Style)
165165
{
166166
ctx.PushDiagnosis(
167-
Util::format(LText("incorrect indentation style, expect {}, but here is {}"),
167+
Util::format(LText("incorrect indentation style expected {} but found {}"),
168168
GetIndentStyleName(state.Style),
169169
GetIndentStyleName(indentState.Style)
170170
),
@@ -180,7 +180,7 @@ void FormatElement::GeneralIndentDiagnosis(DiagnosisContext& ctx, ChildIterator
180180
if (state.SpaceIndent != indentState.SpaceIndent)
181181
{
182182
ctx.PushDiagnosis(
183-
Util::format(LText("incorrect indentation {}, here need {} space indentation"),
183+
Util::format(LText("incorrect indentation {} expected {} space indentation"),
184184
indentState.SpaceIndent, state.SpaceIndent),
185185
LuaDiagnosisPosition(line, 0),
186186
LuaDiagnosisPosition(line, character),
@@ -194,7 +194,7 @@ void FormatElement::GeneralIndentDiagnosis(DiagnosisContext& ctx, ChildIterator
194194
if (state.SpaceIndent != indentState.SpaceIndent || state.TabIndent != indentState.TabIndent)
195195
{
196196
ctx.PushDiagnosis(
197-
Util::format(LText("incorrect indentation, here need {} tab and {} space indentation"),
197+
Util::format(LText("incorrect indentation expected {} tab and {} space indentation"),
198198
state.TabIndent, state.SpaceIndent),
199199
LuaDiagnosisPosition(line, 0),
200200
LuaDiagnosisPosition(line, character),

CodeService/src/FormatElement/KeepLineElement.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void KeepLineElement::Diagnosis(DiagnosisContext& ctx, ChildIterator selfIt,
6060

6161
ctx.PushDiagnosis(
6262
Util::format(
63-
LText("expected {} blank lines, found {}"), _line,
63+
LText("expected {} blank lines found {}"), _line,
6464
(nextElementLine - lastElementLine - 1)),
6565
LuaDiagnosisPosition(nextElementLine, character),
6666
LuaDiagnosisPosition(nextElementLine + 1, 0), DiagnosisType::StatementLineSpace);

CodeService/src/FormatElement/MaxLineElement.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void MaxLineElement::Diagnosis(DiagnosisContext& ctx, ChildIterator selfIt, Form
5858
if (_line < (nextElementLine - lastElementLine - 1))
5959
{
6060
auto character = ctx.GetColumn(nextOffset);
61-
ctx.PushDiagnosis(Util::format(LText("The maximum empty line here is {}"), _line),
61+
ctx.PushDiagnosis(Util::format(LText("the maximum blank lines is {}, but found {}"), _line, (nextElementLine - lastElementLine - 1)),
6262
LuaDiagnosisPosition(nextElementLine, character),
6363
LuaDiagnosisPosition(nextElementLine + 1, 0), DiagnosisType::StatementLineSpace);
6464
}

CodeService/src/FormatElement/MaxSpaceElement.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ void MaxSpaceElement::Diagnosis(DiagnosisContext& ctx, ChildIterator selfIt, For
5757

5858
if (space > maxSpace)
5959
{
60-
ctx.PushDiagnosis(Util::format(LText("the maximum blank length here is {}"), maxSpace), TextRange(lastOffset, nextOffset), DiagnosisType::Blank);
60+
ctx.PushDiagnosis(Util::format(LText("the maximum whitespace length is {}"), maxSpace),
61+
TextRange(lastOffset, nextOffset), DiagnosisType::Blank);
6162
}
6263
}

CodeService/src/FormatElement/MinLineElement.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void MinLineElement::Diagnosis(DiagnosisContext& ctx, ChildIterator selfIt, Form
5959
if (_line > (nextElementLine - lastElementLine - 1))
6060
{
6161
auto character = ctx.GetColumn(nextOffset);
62-
ctx.PushDiagnosis(Util::format(LText("here need at least {} empty line"), _line),
62+
ctx.PushDiagnosis(Util::format(LText("at least {} blank lines is required"), _line),
6363
LuaDiagnosisPosition(nextElementLine, character),
6464
LuaDiagnosisPosition(nextElementLine + 1, 0), DiagnosisType::StatementLineSpace);
6565
}

include/CodeFormatServer/VSCode.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ class Diagnostic : public Serializable
138138
std::string message;
139139
std::string code;
140140
std::string data;
141+
std::string source;
141142

142143
nlohmann::json Serialize() override;
143144
void Deserialize(nlohmann::json json) override;

0 commit comments

Comments
 (0)