Skip to content

Commit

Permalink
cleanup(generator): remove unused fields (#14506)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbolduc authored Jul 19, 2024
1 parent 7603af8 commit 3fed367
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 34 deletions.
24 changes: 0 additions & 24 deletions generator/internal/http_option_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -414,30 +414,6 @@ ParseHttpExtension(google::protobuf::MethodDescriptor const& method) {
out->append(absl::visit(SegmentAsStringVisitor{}, s->value));
};

auto first_variable = std::find_if(
parsed_http_rule->segments.begin(), parsed_http_rule->segments.end(),
[](std::shared_ptr<PathTemplate::Segment> const& s) {
return absl::holds_alternative<PathTemplate::Variable>(s->value);
});
PathTemplate path_prefix;
path_prefix.segments = PathTemplate::Segments{
parsed_http_rule->segments.begin(), first_variable};
info.path_prefix = absl::StrCat(
"/", absl::StrJoin(path_prefix.segments, "/", segment_formatter), "/");

auto last_variable = std::find_if(
parsed_http_rule->segments.rbegin(), parsed_http_rule->segments.rend(),
[](std::shared_ptr<PathTemplate::Segment> const& s) {
return absl::holds_alternative<PathTemplate::Variable>(s->value);
});
PathTemplate path_suffix;
path_suffix.segments = PathTemplate::Segments{
parsed_http_rule->segments.rbegin(), last_variable};
if (!path_suffix.segments.empty()) {
info.path_suffix = absl::StrCat(
"/", absl::StrJoin(path_suffix.segments, "/", segment_formatter));
}

auto rest_path_visitor = RestPathVisitor(*api_version, info.rest_path);
for (auto const& s : parsed_http_rule->segments) {
if (absl::holds_alternative<PathTemplate::Variable>(s->value)) {
Expand Down
2 changes: 0 additions & 2 deletions generator/internal/http_option_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ struct HttpExtensionInfo {
std::string url_path;
std::vector<std::pair<std::string, std::string>> field_substitutions;
std::string body;
std::string path_prefix;
std::string path_suffix;
std::vector<RestPathPiece> rest_path;
std::string rest_path_verb;
};
Expand Down
8 changes: 0 additions & 8 deletions generator/internal/http_option_utils_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,6 @@ TEST_F(HttpOptionUtilsTest, ParseHttpExtensionWithPrefixAndSuffix) {
Eq("projects/*/instances/*"));
EXPECT_THAT(extension_info.body, Eq("*"));
EXPECT_THAT(extension_info.http_verb, Eq("Post"));
EXPECT_THAT(extension_info.path_prefix, Eq("/v1/"));
EXPECT_THAT(extension_info.path_suffix, Eq("/databases"));
}

TEST_F(HttpOptionUtilsTest,
Expand All @@ -464,8 +462,6 @@ TEST_F(HttpOptionUtilsTest,
EXPECT_THAT(extension_info.field_substitutions[0].second, Eq("project"));
EXPECT_THAT(extension_info.body, Eq("body"));
EXPECT_THAT(extension_info.http_verb, Eq("Post"));
EXPECT_THAT(extension_info.path_prefix, Eq("/v1/projects/"));
EXPECT_THAT(extension_info.path_suffix, Eq("/databases"));
}

TEST_F(HttpOptionUtilsTest,
Expand All @@ -486,8 +482,6 @@ TEST_F(HttpOptionUtilsTest,
EXPECT_THAT(extension_info.field_substitutions[1].second, Eq("instance"));
EXPECT_THAT(extension_info.body, Eq("*"));
EXPECT_THAT(extension_info.http_verb, Eq("Post"));
EXPECT_THAT(extension_info.path_prefix, Eq("/v1/projects/"));
EXPECT_THAT(extension_info.path_suffix, Eq("/databases"));
}

TEST_F(HttpOptionUtilsTest, ParseHttpExtensionWithOnlyPrefix) {
Expand All @@ -506,8 +500,6 @@ TEST_F(HttpOptionUtilsTest, ParseHttpExtensionWithOnlyPrefix) {
Eq("projects/*/instances/*/backups/*"));
EXPECT_THAT(extension_info.body, Eq(""));
EXPECT_THAT(extension_info.http_verb, Eq("Delete"));
EXPECT_THAT(extension_info.path_prefix, Eq("/v1/"));
EXPECT_THAT(extension_info.path_suffix, Eq(""));
}

TEST_F(HttpOptionUtilsTest, ParseHttpExtensionSimpleInfo) {
Expand Down

0 comments on commit 3fed367

Please sign in to comment.