k0p*_*kus 9 scala code-formatting intellij-idea scalafmt
在一个使用IntelliJ社区版的scala项目中,我们希望每个文件使用多个包,以便我们可以使用较短的语法来引用它们:
package com.dreamlines.dragonfly
package api
package domain
package harbours
import common.entities.EsHarbour
import common.utils.date.DLDateTime
Run Code Online (Sandbox Code Playgroud)
但是,IntellJ希望强制使用完全合格的软件包名称,因此在优化导入时,它将代码更改为:
import com.dreamlines.dragonfly.common.entities.EsHarbour
import com.dreamlines.dragonfly.common.utils.date.DLDateTime
Run Code Online (Sandbox Code Playgroud)
如何配置优化导入的行为?
这应该
我想保持优化导入的其他行为,例如删除未使用的导入,添加缺失的导入,对导入进行排序。因此,我不认为不使用优化导入是一个有效的选项。
此外scalafmt,我们正在使用格式化程序,因此它可能与.scalafmt.conf此项目的外观有关:
version = 2.0.0
style = default
maxColumn = 120
continuationIndent.callSite = 2
continuationIndent.defnSite = 2
align.openParenDefnSite = false
align.openParenCallSite = false
danglingParentheses = true
indentOperator = spray
project.excludeFilters = [".*\\.sbt"]
rewrite.rules = [RedundantBraces, RedundantParens, prefercurlyfors]
unindentTopLevelOperators = true
importSelectors = singleLine
spaces.afterKeywordBeforeParen = true
lineEndings = unix
newlines.penalizeSingleSelectMultiArgList = false
newlines.alwaysBeforeElseAfterCurlyIf = false
binPack.literalArgumentLists = false
runner.optimizer.forceConfigStyleMinArgCount = 1
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
143 次 |
| 最近记录: |