Skip to content

feat(postprocessing): implement Java method deletion - #6436

Merged
yangyzs merged 6 commits into
googleapis:mainfrom
yangyzs:feat/method-operations-delete
Jun 17, 2026
Merged

yangyzs merged 6 commits into
googleapis:mainfrom
yangyzs:feat/method-operations-delete

Conversation

@yangyzs

@yangyzs yangyzs commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

This change adds DeleteMethod to internal/postprocessing as part of issue #6298. It uses regex pre-cleaning and brace tracking to safely delete Java method bodies.

For #6298

This change adds DeleteMethod to internal/postprocessing as part of issue googleapis#6298. It uses regex pre-cleaning and brace tracking to safely delete Java method bodies.

For googleapis#6298
@yangyzs
yangyzs requested a review from a team as a code owner June 15, 2026 22:03

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new utility, DeleteMethod, in internal/postprocessing/delete.go along with comprehensive unit tests in internal/postprocessing/delete_test.go. The utility deletes a specified Java method from a file by parsing and matching braces while ignoring braces inside comments, strings, and text blocks. The reviewer feedback focuses on performance and robustness improvements. Specifically, the reviewer recommends refactoring the file operations to work directly with []byte slices using the bytes package instead of converting to string, which avoids unnecessary memory allocations. Additionally, the reviewer points out limitations regarding exact string matching for method signatures, such as fragility to formatting differences and leaving behind dangling annotations or Javadoc comments.

Comment thread internal/postprocessing/delete.go Resolved
Comment thread internal/postprocessing/delete.go Resolved
Comment thread internal/postprocessing/delete.go Resolved
Comment thread internal/postprocessing/delete.go Resolved
Comment thread internal/postprocessing/delete.go Resolved
Comment thread internal/postprocessing/delete.go Resolved
Comment thread internal/postprocessing/delete.go Resolved
Comment thread internal/postprocessing/delete.go Resolved
Comment thread internal/postprocessing/delete.go Resolved
Comment thread internal/postprocessing/delete.go Resolved
Comment thread internal/postprocessing/delete.go Resolved
Comment thread internal/postprocessing/delete.go Resolved
Comment thread internal/postprocessing/delete_test.go Resolved
Comment thread internal/postprocessing/delete_test.go Resolved
Comment thread internal/postprocessing/delete_test.go Resolved
Comment thread internal/postprocessing/delete_test.go Resolved
Comment thread internal/postprocessing/delete_test.go Resolved
@JoeWang1127

JoeWang1127 commented Jun 16, 2026 •

Copy link
Copy Markdown
Contributor

Two things in our meeting:

  • Write a regex to verify the function exists in the file, return an error if no match or multiple matches. We expect full function name, i.e., <access modifiers> <static> <return type> <function name> (<function parameter>)
  • Write more unit tests to verify the regex can find the right function to delete.

We could create follow up pull requests to do these things.

yangyzs added 3 commits June 16, 2026 14:54
Address reviewer comments for Java method deletion. Refactor brace tracking to use ranges, fix variable casing, improve doc examples, and simplify tests by comparing sliced text.

Fixes googleapis#6298
Comment thread internal/postprocessing/delete.go Resolved
Comment thread internal/postprocessing/delete_test.go Resolved
Comment thread internal/postprocessing/delete_test.go Resolved
@yangyzs
yangyzs requested a review from JoeWang1127 June 16, 2026 22:04
@yangyzs
yangyzs merged commit 820646f into googleapis:main Jun 17, 2026
31 checks passed
yangyzs added a commit that referenced this pull request Jun 17, 2026
…xtract boundary finder (#6471)

This change is a follow-up to the initial implementation in #6436. It
adds support for deleting multiple occurrences of a method signature in
a Java file. It also extracts the boundary scanning logic into a
findMethodBounds helper function, preparing the package for future
duplicate and deprecate operations.

We decided not to use regex validation for method signatures due to
excessive edge cases and implementation complexity. Instead, we assume
all input signatures are correct and complete, and will iterate in the
future if any issues arise.

For #6298
codyoss pushed a commit to codyoss/librarian that referenced this pull request Jun 23, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.22.0](googleapis/librarian@v0.21.0...v0.22.0)
(2026-06-22)


### Features

* **internal/librarian/java:** remove redundant keep items in
librarian.yaml
([googleapis#6291](googleapis#6291))
([2965478](googleapis@2965478))
* **internal/librarian/java:** support alternate_headers for monolithc
libraries ([googleapis#6481](googleapis#6481))
([4165a09](googleapis@4165a09))
* **internal/librarian/nodejs:** add release level markdown generation
([googleapis#6476](googleapis#6476))
([1d1281f](googleapis@1d1281f))
* **internal/librarian/nodejs:** add support for readme partials
([googleapis#6505](googleapis#6505))
([eca8e3d](googleapis@eca8e3d)),
closes [googleapis#6442](googleapis#6442)
* **internal/librarian/nodejs:** extract sample metadata for node readme
([googleapis#6454](googleapis#6454))
([00e5e0d](googleapis@00e5e0d)),
closes [googleapis#6442](googleapis#6442)
* **internal/librarian/nodejs:** generate README in Node library
([googleapis#6520](googleapis#6520))
([68c0a20](googleapis@68c0a20))
* **internal/librarian/nodejs:** implement README generation without
partials ([googleapis#6488](googleapis#6488))
([44e6954](googleapis@44e6954))
* **internal/postprocessing:** implement Java method deprecation
([googleapis#6497](googleapis#6497))
([289a385](googleapis@289a385)),
closes [googleapis#6298](googleapis#6298)
* **internal/postprocessing:** implement Java method duplication
([googleapis#6484](googleapis#6484))
([0c5959c](googleapis@0c5959c)),
closes [googleapis#6298](googleapis#6298)
* **nodejs:** support per-API version mixin
configuration([googleapis#6462](googleapis#6462))
([71cd24e](googleapis@71cd24e))
* **postprocessing:** implement Java method deletion
([googleapis#6436](googleapis#6436))
([820646f](googleapis@820646f)),
closes [googleapis#6298](googleapis#6298)
* **sidekick/rust:** add condition to include `google-cloud-lro` as
dependency
([googleapis#6503](googleapis#6503))
([7a89172](googleapis@7a89172))
* **sidekick/rust:** bigquery query metadata
([googleapis#6407](googleapis#6407))
([6989ebc](googleapis@6989ebc))
* **sidekick/swift:** `bytes` for discovery docs
([googleapis#6433](googleapis#6433))
([d20f64c](googleapis@d20f64c))
* **sidekick/swift:** generate method signature overloads
([googleapis#6473](googleapis#6473))
([27a72be](googleapis@27a72be))
* **sidekick/swift:** qualified names for requests
([googleapis#6506](googleapis#6506))
([9489715](googleapis@9489715))
* **sidekick:** parse method signatures
([googleapis#6451](googleapis#6451))
([7a433e7](googleapis@7a433e7))
* **sidekick:** parse method signatures
([googleapis#6461](googleapis#6461))
([16aa2e6](googleapis@16aa2e6))


### Bug Fixes

* **internal/librarian/nodejs:** correct product doc link in readme
template ([googleapis#6519](googleapis#6519))
([9cd8ee9](googleapis@9cd8ee9)),
closes [googleapis#6442](googleapis#6442)
* **internal/librarian/nodejs:** path leak during generte_readme
([googleapis#6470](googleapis#6470))
([d3e7c16](googleapis@d3e7c16))
* **internal/postprocessing:** support deleting multiple methods and
extract boundary finder
([googleapis#6471](googleapis#6471))
([20442d8](googleapis@20442d8)),
closes [googleapis#6298](googleapis#6298)
* **librarian:** print errors on failure
([googleapis#6458](googleapis#6458))
([37e4f91](googleapis@37e4f91))
* **sidekick/rust:** disable docs/clippy warning for BQ generated files
([googleapis#6498](googleapis#6498))
([0a6a4d8](googleapis@0a6a4d8))
* **sidekick/rust:** use struct initializer for QueryMetadata
([googleapis#6504](googleapis#6504))
([2bdb3b5](googleapis@2bdb3b5))
* **sidekick/swift:** UrlSafe requires custom serialization
([googleapis#6522](googleapis#6522))
([09c74f6](googleapis@09c74f6))
* **surfer:** print errors on failure
([googleapis#6465](googleapis#6465))
([d91bf4c](googleapis@d91bf4c))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Joe Wang <[email protected]>
haphungw pushed a commit to haphungw/librarian that referenced this pull request Jun 26, 2026
This change adds DeleteMethod to internal/postprocessing as part of
issue googleapis#6298. It uses regex pre-cleaning and brace tracking to safely
delete Java method bodies.

For googleapis#6298
haphungw pushed a commit to haphungw/librarian that referenced this pull request Jun 26, 2026
…xtract boundary finder (googleapis#6471)

This change is a follow-up to the initial implementation in googleapis#6436. It
adds support for deleting multiple occurrences of a method signature in
a Java file. It also extracts the boundary scanning logic into a
findMethodBounds helper function, preparing the package for future
duplicate and deprecate operations.

We decided not to use regex validation for method signatures due to
excessive edge cases and implementation complexity. Instead, we assume
all input signatures are correct and complete, and will iterate in the
future if any issues arise.

For googleapis#6298
haphungw pushed a commit to haphungw/librarian that referenced this pull request Jun 26, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.22.0](googleapis/librarian@v0.21.0...v0.22.0)
(2026-06-22)


### Features

* **internal/librarian/java:** remove redundant keep items in
librarian.yaml
([googleapis#6291](googleapis#6291))
([2965478](googleapis@2965478))
* **internal/librarian/java:** support alternate_headers for monolithc
libraries ([googleapis#6481](googleapis#6481))
([4165a09](googleapis@4165a09))
* **internal/librarian/nodejs:** add release level markdown generation
([googleapis#6476](googleapis#6476))
([1d1281f](googleapis@1d1281f))
* **internal/librarian/nodejs:** add support for readme partials
([googleapis#6505](googleapis#6505))
([eca8e3d](googleapis@eca8e3d)),
closes [googleapis#6442](googleapis#6442)
* **internal/librarian/nodejs:** extract sample metadata for node readme
([googleapis#6454](googleapis#6454))
([00e5e0d](googleapis@00e5e0d)),
closes [googleapis#6442](googleapis#6442)
* **internal/librarian/nodejs:** generate README in Node library
([googleapis#6520](googleapis#6520))
([68c0a20](googleapis@68c0a20))
* **internal/librarian/nodejs:** implement README generation without
partials ([googleapis#6488](googleapis#6488))
([44e6954](googleapis@44e6954))
* **internal/postprocessing:** implement Java method deprecation
([googleapis#6497](googleapis#6497))
([289a385](googleapis@289a385)),
closes [googleapis#6298](googleapis#6298)
* **internal/postprocessing:** implement Java method duplication
([googleapis#6484](googleapis#6484))
([0c5959c](googleapis@0c5959c)),
closes [googleapis#6298](googleapis#6298)
* **nodejs:** support per-API version mixin
configuration([googleapis#6462](googleapis#6462))
([71cd24e](googleapis@71cd24e))
* **postprocessing:** implement Java method deletion
([googleapis#6436](googleapis#6436))
([820646f](googleapis@820646f)),
closes [googleapis#6298](googleapis#6298)
* **sidekick/rust:** add condition to include `google-cloud-lro` as
dependency
([googleapis#6503](googleapis#6503))
([7a89172](googleapis@7a89172))
* **sidekick/rust:** bigquery query metadata
([googleapis#6407](googleapis#6407))
([6989ebc](googleapis@6989ebc))
* **sidekick/swift:** `bytes` for discovery docs
([googleapis#6433](googleapis#6433))
([d20f64c](googleapis@d20f64c))
* **sidekick/swift:** generate method signature overloads
([googleapis#6473](googleapis#6473))
([27a72be](googleapis@27a72be))
* **sidekick/swift:** qualified names for requests
([googleapis#6506](googleapis#6506))
([9489715](googleapis@9489715))
* **sidekick:** parse method signatures
([googleapis#6451](googleapis#6451))
([7a433e7](googleapis@7a433e7))
* **sidekick:** parse method signatures
([googleapis#6461](googleapis#6461))
([16aa2e6](googleapis@16aa2e6))


### Bug Fixes

* **internal/librarian/nodejs:** correct product doc link in readme
template ([googleapis#6519](googleapis#6519))
([9cd8ee9](googleapis@9cd8ee9)),
closes [googleapis#6442](googleapis#6442)
* **internal/librarian/nodejs:** path leak during generte_readme
([googleapis#6470](googleapis#6470))
([d3e7c16](googleapis@d3e7c16))
* **internal/postprocessing:** support deleting multiple methods and
extract boundary finder
([googleapis#6471](googleapis#6471))
([20442d8](googleapis@20442d8)),
closes [googleapis#6298](googleapis#6298)
* **librarian:** print errors on failure
([googleapis#6458](googleapis#6458))
([37e4f91](googleapis@37e4f91))
* **sidekick/rust:** disable docs/clippy warning for BQ generated files
([googleapis#6498](googleapis#6498))
([0a6a4d8](googleapis@0a6a4d8))
* **sidekick/rust:** use struct initializer for QueryMetadata
([googleapis#6504](googleapis#6504))
([2bdb3b5](googleapis@2bdb3b5))
* **sidekick/swift:** UrlSafe requires custom serialization
([googleapis#6522](googleapis#6522))
([09c74f6](googleapis@09c74f6))
* **surfer:** print errors on failure
([googleapis#6465](googleapis#6465))
([d91bf4c](googleapis@d91bf4c))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Joe Wang <[email protected]>
@yangyzs
yangyzs deleted the feat/method-operations-delete branch June 28, 2026 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants