Mar*_*ark 10 java eclipse format formatting autoformatting
通过eclipse自动格式化java代码非常棒!你可以编写可怕的代码,然后简单的类型CTRL+ SHIFT+ f- 代码是惊人的.
但是,有时我想将部分代码标记为不自动格式化.例如,通过流畅的界面:
public void fluentInterfaceJooqDemo() {
create.select(AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME, count())
.from(AUTHOR)
.join(BOOK).on(AUTHOR.ID.equal(BOOK.AUTHOR_ID))
.where(BOOK.LANGUAGE.eq("DE"))
.and(BOOK.PUBLISHED.gt(date("2008-01-01")))
.groupBy(AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME)
.having(count().gt(5))
.orderBy(AUTHOR.LAST_NAME.asc().nullsFirst())
.limit(2)
.offset(1)
.forUpdate()
.of(AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME);
}
Run Code Online (Sandbox Code Playgroud)
并且在CTRL+ SHIFT+之后f
public void fluentInterfaceJooqDemo() {
create.select(AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME, count()).from(AUTHOR).join(BOOK).on(AUTHOR.ID.equal(BOOK.AUTHOR_ID))
.where(BOOK.LANGUAGE.eq("DE")).and(BOOK.PUBLISHED.gt(date("2008-01-01"))).groupBy(AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME)
.having(count().gt(5)).orderBy(AUTHOR.LAST_NAME.asc().nullsFirst()).limit(2).offset(1).forUpdate()
.of(AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME);
}
Run Code Online (Sandbox Code Playgroud)
但是,我正在寻找一些方法来标记这样的代码non-autoformat,例如
//non-format
public void fluentInterfaceJooqDemo() {
...
}
Run Code Online (Sandbox Code Playgroud)
Tod*_*odd 10
我想你可以使用@formatter:off和@formatter:on
// @formatter:off
public void fluentIterfaceThingy() {
...
}
// @formatter:on
Run Code Online (Sandbox Code Playgroud)
您可能必须在代码样式部分中启用此选项:Window->Preferences->Java->Formatter->Edit->On/Of Tags
| 归档时间: |
|
| 查看次数: |
505 次 |
| 最近记录: |