[vcpkg] Emit parse errors to match '<file>:<line>:<col>: error: <text>' for better IDE compatibility (#15926)

Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
This commit is contained in:
ras0219 2021-02-03 11:17:07 -08:00 committed by GitHub
parent 0c32fc522d
commit 5f05aa2b6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 5 deletions

View File

@ -234,7 +234,7 @@ TEST_CASE ("JSON track newlines", "[json]")
auto res = Json::parse("{\n,", fs::u8path("filename")); auto res = Json::parse("{\n,", fs::u8path("filename"));
REQUIRE(!res); REQUIRE(!res);
REQUIRE(res.error()->format() == REQUIRE(res.error()->format() ==
R"(Error: filename:2:1: Unexpected character; expected property name R"(filename:2:1: error: Unexpected character; expected property name
on expression: , on expression: ,
^ ^
)"); )");

View File

@ -1062,7 +1062,7 @@ namespace vcpkg::Json
ExpectedT<std::pair<Value, JsonStyle>, std::unique_ptr<Parse::IParseError>> parse(StringView json, ExpectedT<std::pair<Value, JsonStyle>, std::unique_ptr<Parse::IParseError>> parse(StringView json,
const fs::path& filepath) noexcept const fs::path& filepath) noexcept
{ {
return Parser::parse(json, fs::generic_u8string(filepath)); return Parser::parse(json, fs::u8string(filepath));
} }
ExpectedT<std::pair<Value, JsonStyle>, std::unique_ptr<Parse::IParseError>> parse(StringView json, ExpectedT<std::pair<Value, JsonStyle>, std::unique_ptr<Parse::IParseError>> parse(StringView json,
StringView origin) noexcept StringView origin) noexcept

View File

@ -34,13 +34,12 @@ namespace vcpkg::Parse
caret_spacing.push_back(cp == '\t' ? '\t' : ' '); caret_spacing.push_back(cp == '\t' ? '\t' : ' ');
} }
return Strings::concat("Error: ", return Strings::concat(origin,
origin,
":", ":",
row, row,
":", ":",
column, column,
": ", ": error: ",
message, message,
"\n" "\n"
" on expression: ", // 18 columns " on expression: ", // 18 columns