Skip to content

Commit

Permalink
Revert the TextRowCol rename
Browse files Browse the repository at this point in the history
  • Loading branch information
BillyONeal committed Jan 26, 2024
1 parent 9396f8a commit 6e3f487
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 36 deletions.
6 changes: 3 additions & 3 deletions include/vcpkg/base/diagnostics.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace vcpkg
COUNT
};

struct TextPosition
struct TextRowCol
{
// '0' indicates uninitialized; '1' is the first row/column
int row = 0;
Expand All @@ -43,7 +43,7 @@ namespace vcpkg
}

template<class MessageLike, std::enable_if_t<std::is_convertible_v<MessageLike, LocalizedString>, 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)
Expand All @@ -66,7 +66,7 @@ namespace vcpkg
private:
DiagKind m_kind;
Optional<std::string> m_origin;
TextPosition m_position;
TextRowCol m_position;
LocalizedString m_message;
};

Expand Down
4 changes: 2 additions & 2 deletions include/vcpkg/base/parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -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'; }
Expand Down Expand Up @@ -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(); }

Expand Down
14 changes: 7 additions & 7 deletions include/vcpkg/paragraphparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace vcpkg
{
using Paragraph = std::map<std::string, std::pair<std::string, TextPosition>, std::less<>>;
using Paragraph = std::map<std::string, std::pair<std::string, TextRowCol>, std::less<>>;

struct ParagraphParser
{
Expand All @@ -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<LocalizedString> error() const;

Expand All @@ -43,15 +43,15 @@ namespace vcpkg
Optional<std::vector<std::string>> parse_default_features_list_context(DiagnosticContext& context,
const std::string& str,
StringView origin = "<unknown>",
TextPosition position = {1, 1});
TextRowCol position = {1, 1});
ExpectedL<std::vector<std::string>> parse_default_features_list(const std::string& str,
StringView origin = "<unknown>",
TextPosition position = {1, 1});
TextRowCol position = {1, 1});
Optional<std::vector<ParsedQualifiedSpecifier>> parse_qualified_specifier_list(DiagnosticContext& context,
const std::string& str,
StringView origin = "<unknown>",
TextPosition position = {1, 1});
TextRowCol position = {1, 1});
ExpectedL<std::vector<ParsedQualifiedSpecifier>> parse_qualified_specifier_list(const std::string& str,
StringView origin = "<unknown>",
TextPosition position = {1, 1});
TextRowCol position = {1, 1});
}
4 changes: 2 additions & 2 deletions include/vcpkg/sourceparagraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ namespace vcpkg
Optional<std::vector<Dependency>> parse_dependencies_list_context(DiagnosticContext& context,
const std::string& str,
StringView origin,
TextPosition position = {1, 1});
TextRowCol position = {1, 1});
ExpectedL<std::vector<Dependency>> parse_dependencies_list(const std::string& str,
StringView origin,
TextPosition position = {1, 1});
TextRowCol position = {1, 1});
}
4 changes: 2 additions & 2 deletions src/vcpkg-test/paragraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand All @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion src/vcpkg-test/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion src/vcpkg/base/diagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace

void append_file_prefix(std::string& target,
const Optional<std::string>& maybe_origin,
const TextPosition& position)
const TextRowCol& position)
{
// file:line:col: kind: message
if (auto origin = maybe_origin.get())
Expand Down
6 changes: 3 additions & 3 deletions src/vcpkg/base/parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
Expand All @@ -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)});
}
}
2 changes: 1 addition & 1 deletion src/vcpkg/binaryparagraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
20 changes: 10 additions & 10 deletions src/vcpkg/paragraphs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ static std::atomic<uint64_t> g_load_ports_stats(0);

namespace vcpkg
{
static Optional<std::pair<std::string, TextPosition>> remove_field(Paragraph* fields, StringView fieldname)
static Optional<std::pair<std::string, TextRowCol>> remove_field(Paragraph* fields, StringView fieldname)
{
auto it = fields->find(fieldname.to_string());
if (it == fields->end())
Expand All @@ -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())
Expand All @@ -47,7 +47,7 @@ namespace vcpkg

std::string ParagraphParser::optional_field(StringLiteral fieldname)
{
TextPosition ignore;
TextRowCol ignore;
return optional_field(fieldname, ignore);
}

Expand All @@ -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))
Expand Down Expand Up @@ -172,36 +172,36 @@ namespace vcpkg
Optional<std::vector<std::string>> 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<std::string>(msgExpectedDefaultFeaturesList, parser, &parse_feature_name);
}
ExpectedL<std::vector<std::string>> 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<std::vector<ParsedQualifiedSpecifier>> 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<ParsedQualifiedSpecifier>(
msgExpectedDependenciesList, parser, [](ParserBase& parser) { return parse_qualified_specifier(parser); });
}
ExpectedL<std::vector<ParsedQualifiedSpecifier>> 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<std::vector<Dependency>> 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<Dependency>(msgExpectedDependenciesList, parser, [](ParserBase& parser) {
Expand Down Expand Up @@ -233,7 +233,7 @@ namespace vcpkg
}
ExpectedL<std::vector<Dependency>> 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);
}
Expand Down
8 changes: 4 additions & 4 deletions src/vcpkg/sourceparagraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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())
{
Expand Down

0 comments on commit 6e3f487

Please sign in to comment.