google / google/google-java-format

document/explain logic of ignoring --lines

未关闭
#1,276 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Java
星标
6.2k
派生
937
平均合并
6 分钟
30 天内合并 PR
3

描述

as seen in #942 and #1000 (and others) use of `--lines` does not reliably work.

I'm trying to grok how/why....

As an example:

```hello.java
///usr/bin/env jbang "$0" "$@" ; exit $?

import static java.lang.System.*;

public class hello {

public static void main(String... args) {
out.println("Hello World");
}
}
```

I want google java format to ignore the first line - reading other isseues I should --skip-* as much as possible ...

`jbang com.google.googlejavaformat:google-java-format:1.28.0 --lines 2:9999 --skip-javadoc-formatting --skip-reflowing-long-strings --skip-sorting-imports --skip-removing-unused-imports hello.java`

result in first line being formatted as: `/// usr/bin/env jbang "$0" "$@" ; exit $?`

why ?

If I add `--lines 1000:9999` it works...but now the code is not formatted at all.

is this really the intended behavior of --lines ?

any way to have it not try include outside the lines requested?

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。