PLUGINAPI-200 Add explicit CPD unit boundaries to NewCpdTokens#304
PLUGINAPI-200 Add explicit CPD unit boundaries to NewCpdTokens#304henryju wants to merge 1 commit into
Conversation
Lets a sensor group tokens into CPD units via explicit withExplicitUnitBoundaries()/endUnit() calls instead of the default per-physical-line grouping, so languages using statement-shaped units (e.g. Java) don't need to bypass NewCpdTokens entirely.
| * Calling it more than once is allowed and has no additional effect. | ||
| * @since 13.9 | ||
| */ | ||
| NewCpdTokens withExplicitUnitBoundaries(); |
There was a problem hiding this comment.
💡 Quality: New abstract methods on public interface break implementers
Adding withExplicitUnitBoundaries() and endUnit() as abstract methods to the published NewCpdTokens interface is a source/binary-incompatible change for any code that implements the interface (test doubles, alternative scanner impls). Consider providing default implementations (e.g. endUnit() throwing UnsupportedOperationException and withExplicitUnitBoundaries() returning this) so existing implementers keep compiling, consistent with how additive interface methods are typically handled in a stable plugin API.
Was this helpful? React with 👍 / 👎
Code Review 👍 Approved with suggestions 0 resolved / 1 findingsIntroduces explicit CPD unit boundaries to the NewCpdTokens interface to support statement-shaped token grouping. Adding these as abstract methods creates a binary compatibility break for existing interface implementers; consider providing default implementations instead. 💡 Quality: New abstract methods on public interface break implementers📄 plugin-api/src/main/java/org/sonar/api/batch/sensor/cpd/NewCpdTokens.java:89 📄 plugin-api/src/main/java/org/sonar/api/batch/sensor/cpd/NewCpdTokens.java:96 Adding 🤖 Prompt for agentsOptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
|





Lets a sensor group tokens into CPD units via explicit withExplicitUnitBoundaries()/endUnit() calls instead of the default per-physical-line grouping, so languages using statement-shaped units (e.g. Java) don't need to bypass NewCpdTokens entirely.