From 6e3f48719d2353bfca9a83488bacc55faad8959b Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Fri, 26 Jan 2024 13:51:14 -0800 Subject: [PATCH] Revert the TextRowCol rename --- include/vcpkg/base/diagnostics.h | 6 +++--- include/vcpkg/base/parse.h | 4 ++-- include/vcpkg/paragraphparser.h | 14 +++++++------- include/vcpkg/sourceparagraph.h | 4 ++-- src/vcpkg-test/paragraph.cpp | 4 ++-- src/vcpkg-test/util.cpp | 2 +- src/vcpkg/base/diagnostics.cpp | 2 +- src/vcpkg/base/parse.cpp | 6 +++--- src/vcpkg/binaryparagraph.cpp | 2 +- src/vcpkg/paragraphs.cpp | 20 ++++++++++---------- src/vcpkg/sourceparagraph.cpp | 8 ++++---- 11 files changed, 36 insertions(+), 36 deletions(-) diff --git a/include/vcpkg/base/diagnostics.h b/include/vcpkg/base/diagnostics.h index 01bef61aa1..296b5ae75a 100644 --- a/include/vcpkg/base/diagnostics.h +++ b/include/vcpkg/base/diagnostics.h @@ -21,7 +21,7 @@ namespace vcpkg COUNT }; - struct TextPosition + struct TextRowCol { // '0' indicates uninitialized; '1' is the first row/column int row = 0; @@ -43,7 +43,7 @@ namespace vcpkg } template, int> = 0> - DiagnosticLine(DiagKind kind, StringView origin, TextPosition position, MessageLike&& message) + DiagnosticLine(DiagKind kind, StringView origin, TextRowCol position, MessageLike&& message) : m_kind(kind) , m_origin(origin.to_string()) , m_position(position) @@ -66,7 +66,7 @@ namespace vcpkg private: DiagKind m_kind; Optional m_origin; - TextPosition m_position; + TextRowCol m_position; LocalizedString m_message; }; diff --git a/include/vcpkg/base/parse.h b/include/vcpkg/base/parse.h index 1bad6828c2..7dec02083f 100644 --- a/include/vcpkg/base/parse.h +++ b/include/vcpkg/base/parse.h @@ -39,7 +39,7 @@ namespace vcpkg struct ParserBase { - ParserBase(DiagnosticContext& context, StringView text, StringView origin, TextPosition init_rowcol = {1, 1}); + ParserBase(DiagnosticContext& context, StringView text, StringView origin, TextRowCol init_rowcol = {1, 1}); static constexpr bool is_whitespace(char32_t ch) { return ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n'; } static constexpr bool is_lower_alpha(char32_t ch) { return ch >= 'a' && ch <= 'z'; } @@ -95,7 +95,7 @@ namespace vcpkg Unicode::Utf8Decoder it() const { return m_it; } char32_t cur() const { return m_it == m_it.end() ? Unicode::end_of_file : *m_it; } SourceLoc cur_loc() const { return {m_it, m_start_of_line, m_row, m_column}; } - TextPosition cur_rowcol() const { return {m_row, m_column}; } + TextRowCol cur_rowcol() const { return {m_row, m_column}; } char32_t next(); bool at_eof() const { return m_it == m_it.end(); } diff --git a/include/vcpkg/paragraphparser.h b/include/vcpkg/paragraphparser.h index 19c795ccfe..fc57174364 100644 --- a/include/vcpkg/paragraphparser.h +++ b/include/vcpkg/paragraphparser.h @@ -16,7 +16,7 @@ namespace vcpkg { - using Paragraph = std::map, std::less<>>; + using Paragraph = std::map, std::less<>>; struct ParagraphParser { @@ -28,9 +28,9 @@ namespace vcpkg std::string required_field(StringLiteral fieldname); std::string optional_field(StringLiteral fieldname); - std::string optional_field(StringLiteral fieldname, TextPosition& position); + std::string optional_field(StringLiteral fieldname, TextRowCol& position); - void add_error(TextPosition position, msg::MessageT<> error_content); + void add_error(TextRowCol position, msg::MessageT<> error_content); Optional error() const; @@ -43,15 +43,15 @@ namespace vcpkg Optional> parse_default_features_list_context(DiagnosticContext& context, const std::string& str, StringView origin = "", - TextPosition position = {1, 1}); + TextRowCol position = {1, 1}); ExpectedL> parse_default_features_list(const std::string& str, StringView origin = "", - TextPosition position = {1, 1}); + TextRowCol position = {1, 1}); Optional> parse_qualified_specifier_list(DiagnosticContext& context, const std::string& str, StringView origin = "", - TextPosition position = {1, 1}); + TextRowCol position = {1, 1}); ExpectedL> parse_qualified_specifier_list(const std::string& str, StringView origin = "", - TextPosition position = {1, 1}); + TextRowCol position = {1, 1}); } diff --git a/include/vcpkg/sourceparagraph.h b/include/vcpkg/sourceparagraph.h index 3a57ed549f..ae4668ecde 100644 --- a/include/vcpkg/sourceparagraph.h +++ b/include/vcpkg/sourceparagraph.h @@ -222,8 +222,8 @@ namespace vcpkg Optional> parse_dependencies_list_context(DiagnosticContext& context, const std::string& str, StringView origin, - TextPosition position = {1, 1}); + TextRowCol position = {1, 1}); ExpectedL> parse_dependencies_list(const std::string& str, StringView origin, - TextPosition position = {1, 1}); + TextRowCol position = {1, 1}); } diff --git a/src/vcpkg-test/paragraph.cpp b/src/vcpkg-test/paragraph.cpp index 3f29fb14c6..6c74c1d7c1 100644 --- a/src/vcpkg-test/paragraph.cpp +++ b/src/vcpkg-test/paragraph.cpp @@ -15,7 +15,7 @@ namespace { pghs.emplace_back(); for (auto&& kv : p) - pghs.back().emplace(kv.first, std::make_pair(kv.second, vcpkg::TextPosition{})); + pghs.back().emplace(kv.first, std::make_pair(kv.second, vcpkg::TextRowCol{})); } return vcpkg::SourceControlFile::parse_control_file("", std::move(pghs)); } @@ -24,7 +24,7 @@ namespace { Paragraph pgh; for (auto&& kv : v) - pgh.emplace(kv.first, std::make_pair(kv.second, vcpkg::TextPosition{})); + pgh.emplace(kv.first, std::make_pair(kv.second, vcpkg::TextRowCol{})); return vcpkg::BinaryParagraph("test", std::move(pgh)); } diff --git a/src/vcpkg-test/util.cpp b/src/vcpkg-test/util.cpp index 7306a2f1ee..914b70e97d 100644 --- a/src/vcpkg-test/util.cpp +++ b/src/vcpkg-test/util.cpp @@ -63,7 +63,7 @@ namespace vcpkg::Test pghs.emplace_back(); for (auto&& kv : p) { - pghs.back().emplace(kv.first, std::make_pair(kv.second, vcpkg::TextPosition{})); + pghs.back().emplace(kv.first, std::make_pair(kv.second, vcpkg::TextRowCol{})); } } return vcpkg::SourceControlFile::parse_control_file("", std::move(pghs)); diff --git a/src/vcpkg/base/diagnostics.cpp b/src/vcpkg/base/diagnostics.cpp index 27aba53636..dd10961329 100644 --- a/src/vcpkg/base/diagnostics.cpp +++ b/src/vcpkg/base/diagnostics.cpp @@ -12,7 +12,7 @@ namespace void append_file_prefix(std::string& target, const Optional& maybe_origin, - const TextPosition& position) + const TextRowCol& position) { // file:line:col: kind: message if (auto origin = maybe_origin.get()) diff --git a/src/vcpkg/base/parse.cpp b/src/vcpkg/base/parse.cpp index 9afac167fc..867c82577f 100644 --- a/src/vcpkg/base/parse.cpp +++ b/src/vcpkg/base/parse.cpp @@ -90,7 +90,7 @@ namespace vcpkg } } - ParserBase::ParserBase(DiagnosticContext& context, StringView text, StringView origin, TextPosition init_rowcol) + ParserBase::ParserBase(DiagnosticContext& context, StringView text, StringView origin, TextRowCol init_rowcol) : m_it(text.begin(), text.end()) , m_start_of_line(m_it) , m_row(init_rowcol.row) @@ -191,7 +191,7 @@ namespace vcpkg message.append_raw('\n'); append_caret_line(message, loc); m_context.report( - DiagnosticLine{DiagKind::Error, m_origin, TextPosition{loc.row, loc.column}, std::move(message)}); + DiagnosticLine{DiagKind::Error, m_origin, TextRowCol{loc.row, loc.column}, std::move(message)}); m_any_errors = true; // Avoid error loops by skipping to the end skip_to_eof(); @@ -205,6 +205,6 @@ namespace vcpkg message.append_raw('\n'); append_caret_line(message, loc); m_context.report( - DiagnosticLine{DiagKind::Warning, m_origin, TextPosition{loc.row, loc.column}, std::move(message)}); + DiagnosticLine{DiagKind::Warning, m_origin, TextRowCol{loc.row, loc.column}, std::move(message)}); } } diff --git a/src/vcpkg/binaryparagraph.cpp b/src/vcpkg/binaryparagraph.cpp index cabf0e8e5d..6741a48816 100644 --- a/src/vcpkg/binaryparagraph.cpp +++ b/src/vcpkg/binaryparagraph.cpp @@ -35,7 +35,7 @@ namespace vcpkg // one or the other this->version.text = parser.optional_field(Fields::VERSION); - TextPosition pv_position; + TextRowCol pv_position; auto pv_str = parser.optional_field(Fields::PORT_VERSION, pv_position); this->version.port_version = 0; if (!pv_str.empty()) diff --git a/src/vcpkg/paragraphs.cpp b/src/vcpkg/paragraphs.cpp index d0642cc4d1..f1fa8c3a79 100644 --- a/src/vcpkg/paragraphs.cpp +++ b/src/vcpkg/paragraphs.cpp @@ -20,7 +20,7 @@ static std::atomic g_load_ports_stats(0); namespace vcpkg { - static Optional> remove_field(Paragraph* fields, StringView fieldname) + static Optional> remove_field(Paragraph* fields, StringView fieldname) { auto it = fields->find(fieldname.to_string()); if (it == fields->end()) @@ -33,7 +33,7 @@ namespace vcpkg return value; } - std::string ParagraphParser::optional_field(StringLiteral fieldname, TextPosition& position) + std::string ParagraphParser::optional_field(StringLiteral fieldname, TextRowCol& position) { auto maybe_field = remove_field(&fields, fieldname); if (auto field = maybe_field.get()) @@ -47,7 +47,7 @@ namespace vcpkg std::string ParagraphParser::optional_field(StringLiteral fieldname) { - TextPosition ignore; + TextRowCol ignore; return optional_field(fieldname, ignore); } @@ -66,7 +66,7 @@ namespace vcpkg return std::string(); } - void ParagraphParser::add_error(TextPosition position, msg::MessageT<> error_content) + void ParagraphParser::add_error(TextRowCol position, msg::MessageT<> error_content) { errors.emplace_back(LocalizedString::from_raw(origin) .append_raw(fmt::format("{}:{}: ", position.row, position.column)) @@ -172,21 +172,21 @@ namespace vcpkg Optional> parse_default_features_list_context(DiagnosticContext& context, const std::string& str, StringView origin, - TextPosition position) + TextRowCol position) { auto parser = ParserBase(context, str, origin, position); return parse_list_until_eof(msgExpectedDefaultFeaturesList, parser, &parse_feature_name); } ExpectedL> parse_default_features_list(const std::string& str, StringView origin, - TextPosition position) + TextRowCol position) { return adapt_context_to_expected(parse_default_features_list_context, str, origin, position); } Optional> parse_qualified_specifier_list_context(DiagnosticContext& context, const std::string& str, StringView origin, - TextPosition position) + TextRowCol position) { auto parser = ParserBase(context, str, origin, position); return parse_list_until_eof( @@ -194,14 +194,14 @@ namespace vcpkg } ExpectedL> parse_qualified_specifier_list(const std::string& str, StringView origin, - TextPosition position) + TextRowCol position) { return adapt_context_to_expected(parse_qualified_specifier_list_context, str, origin, position); } Optional> parse_dependencies_list_context(DiagnosticContext& context, const std::string& str, StringView origin, - TextPosition position) + TextRowCol position) { auto parser = ParserBase(context, str, origin, position); return parse_list_until_eof(msgExpectedDependenciesList, parser, [](ParserBase& parser) { @@ -233,7 +233,7 @@ namespace vcpkg } ExpectedL> parse_dependencies_list(const std::string& str, StringView origin, - TextPosition position) + TextRowCol position) { return adapt_context_to_expected(parse_dependencies_list_context, str, origin, position); } diff --git a/src/vcpkg/sourceparagraph.cpp b/src/vcpkg/sourceparagraph.cpp index 62306317f1..a546cb7525 100644 --- a/src/vcpkg/sourceparagraph.cpp +++ b/src/vcpkg/sourceparagraph.cpp @@ -300,7 +300,7 @@ namespace vcpkg spgh->name = parser.required_field(SourceParagraphFields::NAME); spgh->version.text = parser.required_field(SourceParagraphFields::VERSION); - TextPosition pv_position; + TextRowCol pv_position; auto pv_str = parser.optional_field(SourceParagraphFields::PORT_VERSION, pv_position); if (!pv_str.empty()) { @@ -322,7 +322,7 @@ namespace vcpkg trim_all(spgh->maintainers); spgh->homepage = parser.optional_field(SourceParagraphFields::HOMEPAGE); - TextPosition build_depends_position; + TextRowCol build_depends_position; std::string buf = parser.optional_field(SourceParagraphFields::BUILD_DEPENDS, build_depends_position); auto maybe_dependencies = parse_dependencies_list(buf, origin, build_depends_position); @@ -335,7 +335,7 @@ namespace vcpkg return std::move(maybe_dependencies).error(); } - TextPosition default_features_position; + TextRowCol default_features_position; buf = parser.optional_field(SourceParagraphFields::DEFAULT_FEATURES, default_features_position); auto maybe_default_features = parse_default_features_list(buf, origin, default_features_position); @@ -369,7 +369,7 @@ namespace vcpkg return std::move(maybe_default_features).error(); } - TextPosition supports_position; + TextRowCol supports_position; auto supports_text = parser.optional_field(SourceParagraphFields::SUPPORTS, supports_position); if (!supports_text.empty()) {