Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support overlapping --lines ranges in google-java-format. #1093

Merged
merged 1 commit into from Apr 6, 2024

Conversation

copybara-service[bot]
Copy link

Support overlapping --lines ranges in google-java-format.

The strict behavior comes from the underlying ImmutableRangeSet.Builder class, which does not allow overlapping ranges to be added. Let's use TreeRangeSet instead.

I have also updated the documentation for the --lines flag to make it clear that the line numbers are a closed-closed interval.

Tested with:

blaze run :google_java_format_binary -- --lines=1:5 --lines=3:8 - < Foo.java

Before this CL the command fails with:

'--lines=1:5' '--lines=3:8' -
Overlapping ranges not permitted but found [0..5) overlapping [2..8)

After this CL the command succeeds.

The strict behavior comes from the underlying ImmutableRangeSet.Builder class, which does not allow overlapping ranges to be added. Let's use TreeRangeSet instead.

I have also updated the documentation for the --lines flag to make it clear that the line numbers are a closed-closed interval.

Tested with:
```
blaze run :google_java_format_binary -- --lines=1:5 --lines=3:8 - < Foo.java
```

Before this CL the command fails with:
```
'--lines=1:5' '--lines=3:8' -
Overlapping ranges not permitted but found [0..5) overlapping [2..8)
```

After this CL the command succeeds.

PiperOrigin-RevId: 622410610
@copybara-service copybara-service bot merged commit c4b467d into master Apr 6, 2024
@copybara-service copybara-service bot deleted the test_622171655 branch April 6, 2024 10:03
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.

None yet

1 participant