Version
1.18.1 all-deps.
Description
google-java-format formats the whole while even when --lines options is provided.
Example
I have a Java file that looks like this:
public class FormattingTest {
protected void method1(Vehicle vehicle) {
vehicle.getTechnicalDetails().getWheels().stream().anyMatch(wheel -> wheel.getManufacturer().equals("Goodyear"));
}
protected void method2(Vehicle vehicle) {
vehicle.getTechnicalDetails().getWheels().stream().anyMatch(wheel -> wheel.getManufacturer().equals("Goodyear"));
}
}
I wan't to only format method1 which is on lines 2 to 4 so I run google-java-format with the --lines option:
google-java-format --lines 2:4 FormattingTest.java
As output I get:
public class FormattingTest {
protected void method1(Vehicle vehicle) {
vehicle.getTechnicalDetails().getWheels().stream()
.anyMatch(wheel -> wheel.getManufacturer().equals("Goodyear"));
}
protected void method2(Vehicle vehicle) {
vehicle.getTechnicalDetails().getWheels().stream()
.anyMatch(wheel -> wheel.getManufacturer().equals("Goodyear"));
}
}
The whole file is formatted when only lines from 2 to 4 should be.
I expected to see this output:
public class FormattingTest {
protected void method1(Vehicle vehicle) {
vehicle.getTechnicalDetails().getWheels().stream()
.anyMatch(wheel -> wheel.getManufacturer().equals("Goodyear"));
}
protected void method2(Vehicle vehicle) {
vehicle.getTechnicalDetails().getWheels().stream().anyMatch(wheel -> wheel.getManufacturer().equals("Goodyear"));
}
}
Changing the --lines option to any of the aliases -lines, --line, -line does not make a difference.
Also using --offset and --length does not make a difference. Although these options are so poorly documented I'm not sure if I am using them correctly.
google-java-format --offset 2 --length 2 FormattingTest.java
Version
1.18.1 all-deps.
Description
google-java-formatformats the whole while even when--linesoptions is provided.Example
I have a Java file that looks like this:
I wan't to only format
method1which is on lines 2 to 4 so I rungoogle-java-formatwith the--linesoption:As output I get:
The whole file is formatted when only lines from 2 to 4 should be.
I expected to see this output:
Changing the
--linesoption to any of the aliases-lines,--line,-linedoes not make a difference.Also using
--offsetand--lengthdoes not make a difference. Although these options are so poorly documented I'm not sure if I am using them correctly.