Skip to content

Commit 111a848

Browse files
committed
format提供命名空间
1 parent 8c2fdc0 commit 111a848

23 files changed

+54
-52
lines changed

CodeFormat/src/CodeFormat.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ int main(int argc, char** argv)
8787
{
8888
if (!luaFormat->SetInputFile(cmd.Get<std::string>("file")))
8989
{
90-
std::cerr << format("Can not find file {}", cmd.Get<std::string>("file")) << std::endl;
90+
std::cerr << Util::format("Can not find file {}", cmd.Get<std::string>("file")) << std::endl;
9191
return -1;
9292
}
9393
}
@@ -133,7 +133,7 @@ int main(int argc, char** argv)
133133
{
134134
if (!luaFormat->Reformat())
135135
{
136-
std::cerr << format("Exist lua syntax error") << std::endl;
136+
std::cerr << Util::format("Exist lua syntax error") << std::endl;
137137
return -1;
138138
}
139139
}

CodeFormat/src/LuaFormat.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ bool LuaFormat::Check(std::string_view workspace, std::shared_ptr<CodeSpellCheck
155155
{
156156
auto errors = _parser->GetErrors();
157157

158-
std::cerr << format("Check {}\t{} error", inputFile, errors.size()) << std::endl;
158+
std::cerr << Util::format("Check {}\t{} error", inputFile, errors.size()) << std::endl;
159159

160160
for (auto& error : errors)
161161
{
@@ -194,7 +194,7 @@ bool LuaFormat::Check(std::string_view workspace, std::shared_ptr<CodeSpellCheck
194194
auto diagnosis = ctx.GetDiagnosisInfos();
195195
if (!diagnosis.empty())
196196
{
197-
std::cerr << format("Check {}\t{} warning", inputFile, diagnosis.size()) << std::endl;
197+
std::cerr << Util::format("Check {}\t{} warning", inputFile, diagnosis.size()) << std::endl;
198198

199199
for (auto& d : diagnosis)
200200
{
@@ -208,7 +208,7 @@ bool LuaFormat::Check(std::string_view workspace, std::shared_ptr<CodeSpellCheck
208208

209209
return false;
210210
}
211-
std::cout << format("Check {} OK", inputFile) << std::endl;
211+
std::cout << Util::format("Check {} OK", inputFile) << std::endl;
212212
return true;
213213
}
214214

@@ -220,6 +220,6 @@ void LuaFormat::DiagnosisInspection(std::string_view message, TextRange range, s
220220
auto startChar = file->GetColumn(range.StartOffset);
221221
auto endLine = file->GetLine(range.EndOffset);
222222
auto endChar = file->GetColumn(range.EndOffset);
223-
std::cerr << format("{}({}:{} to {}:{}): {}", path, startLine + 1, startChar, endLine + 1, endChar,
223+
std::cerr << Util::format("{}({}:{} to {}:{}): {}", path, startLine + 1, startChar, endLine + 1, endChar,
224224
message) << std::endl;
225225
}

CodeFormat/src/LuaWorkspaceFormat.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ void LuaWorkspaceFormat::ReformatWorkspace()
9494
luaFormat.SetOutputFile(file);
9595
if (luaFormat.Reformat())
9696
{
97-
std::cerr << format("reformat {} succeed.", file) << std::endl;
97+
std::cerr << Util::format("reformat {} succeed.", file) << std::endl;
9898
}
9999
else
100100
{
101-
std::cerr << format("reformat {} fail.", file) << std::endl;
101+
std::cerr << Util::format("reformat {} fail.", file) << std::endl;
102102
}
103103
}
104104
}

CodeFormatServer/src/LanguageClient.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void LanguageClient::SendNotification(std::string_view method, std::shared_ptr<v
6262
if (_session)
6363
{
6464
auto dumpResult = json.dump();
65-
std::string message = format("Content-Length:{}\r\n\r\n", dumpResult.size());
65+
std::string message = Util::format("Content-Length:{}\r\n\r\n", dumpResult.size());
6666

6767
message.append(dumpResult);
6868
_session->Send(std::move(message));
@@ -80,7 +80,7 @@ void LanguageClient::SendRequest(std::string_view method, std::shared_ptr<vscode
8080
if (_session)
8181
{
8282
auto dumpResult = json.dump();
83-
std::string message = format("Content-Length:{}\r\n\r\n", dumpResult.size());
83+
std::string message = Util::format("Content-Length:{}\r\n\r\n", dumpResult.size());
8484

8585
message.append(dumpResult);
8686
_session->Send(std::move(message));

CodeFormatServer/src/LanguageService.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ std::shared_ptr<vscode::Serializable> LanguageService::OnExecuteCommand(
459459

460460
std::string moduleDefineName = param->arguments[3];
461461

462-
std::string requireString = format("local {} = {}(\"{}\")\n", moduleDefineName, config->import_function,
462+
std::string requireString = Util::format("local {} = {}(\"{}\")\n", moduleDefineName, config->import_function,
463463
moduleName);
464464
auto parser = LanguageClient::GetInstance().GetFileParser(uri);
465465
auto applyParams = std::make_shared<vscode::ApplyWorkspaceEditParams>();

CodeFormatServer/src/Protocol/ProtocolParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ std::string ProtocolParser::SerializeProtocol(std::shared_ptr<vscode::Serializab
5555
json["result"] = result->Serialize();
5656
json["jsonrpc"] = "2.0";
5757
auto dumpResult = json.dump(-1,' ', true, nlohmann::detail::error_handler_t::ignore);
58-
std::string message = format("Content-Length:{}\r\n\r\n", dumpResult.size());
58+
std::string message = Util::format("Content-Length:{}\r\n\r\n", dumpResult.size());
5959

6060
message.append(dumpResult);
6161
return std::move(message);

CodeFormatServer/src/Service/ModuleService.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,15 +258,15 @@ std::vector<vscode::CompletionItem> ModuleService::GetModuleCompletions(std::sha
258258
if (pair.second.size() == 1)
259259
{
260260
auto& luaModule = pair.second.front();
261-
completion.detail = format("({})", name);
261+
completion.detail = Util::format("({})", name);
262262
completion.documentation = format("import from {}", luaModule->FilePath);
263263
auto object = nlohmann::json::object();
264264
object["moduleName"] = luaModule->ModuleName;
265265
object["path"] = luaModule->FilePath;
266266
object["name"] = name;
267267
command.arguments.push_back(object);
268-
labelDetails.detail = format("[{}]", luaModule->ModuleName);
269-
labelDetails.description = format("[{}]", luaModule->ModuleName);
268+
labelDetails.detail = Util::format("[{}]", luaModule->ModuleName);
269+
labelDetails.description = Util::format("[{}]", luaModule->ModuleName);
270270
}
271271
else
272272
{
@@ -279,8 +279,8 @@ std::vector<vscode::CompletionItem> ModuleService::GetModuleCompletions(std::sha
279279
object["name"] = name;
280280
command.arguments.push_back(object);
281281
}
282-
labelDetails.detail = format("[{}]", completion.detail);
283-
labelDetails.description = format("[{}]", completion.detail);
282+
labelDetails.detail = Util::format("[{}]", completion.detail);
283+
labelDetails.description = Util::format("[{}]", completion.detail);
284284
}
285285
completion.command = command;
286286
completion.labelDetails = labelDetails;

CodeFormatServer/src/Session/IOSession.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ std::string IOSession::Handle(std::shared_ptr<ProtocolParser> parser)
6565
{
6666
auto start = chrono::system_clock::now();
6767
auto result = _service.Dispatch(parser->GetMethod(), params);
68-
std::cerr << format("request {}, it cost: {}ms\n", parser->GetMethod(),
68+
std::cerr << Util::format("request {}, it cost: {}ms\n", parser->GetMethod(),
6969
chrono::duration_cast<chrono::milliseconds>(
7070
chrono::system_clock::now() - start
7171
).count());

CodeService/src/FormatElement/AlignmentElement.cpp

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

CodeService/src/FormatElement/DiagnosisContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ std::vector<LuaDiagnosisInfo> DiagnosisContext::GetDiagnosisInfos()
3939
{
4040
LuaDiagnosisPosition start(line, _options.max_line_length);
4141
LuaDiagnosisPosition end(line, character);
42-
PushDiagnosis(format(LText("The line width should not exceed {}"), _options.max_line_length), start, end,
42+
PushDiagnosis(Util::format(LText("The line width should not exceed {}"), _options.max_line_length), start, end,
4343
DiagnosisType::MaxLineWidth);
4444
}
4545
_lineMaxLengthMap.clear();

0 commit comments

Comments
 (0)