如果我有一個Scala的方法聲明太長,不適合在單行線,我想它在幾個線分開,和我重新格式化的期望是:IntelliJ IDEA的格式化Scala代碼
protected def pruneFilterProject(
relation: LogicalRelation,
projectList: Seq[NamedExpression],
filterPredicates: Seq[Expression],
scanBuilder: (Array[String], Array[Filter]) => RDD[Row]) = {
pruneFilterProjectRaw(
relation,
projectList,
filterPredicates,
(requestedColumns, pushedFilters) => {
scanBuilder(requestedColumns.map(_.name).toArray, selectFilters(pushedFilters).toArray)
})
}
但重新格式化代碼後( control + alt + L
),輸出爲:
protected def pruneFilterProject(
relation: LogicalRelation,
projectList: Seq[NamedExpression],
filterPredicates: Seq[Expression],
scanBuilder: (Array[String], Array[Filter]) => RDD[Row]) = {
pruneFilterProjectRaw(
relation,
projectList,
filterPredicates,
(requestedColumns, pushedFilters) => {
scanBuilder(requestedColumns.map(_.name).toArray, selectFilters(pushedFilters).toArray)
})
}
什麼是IntelliJ IDEA的正確的代碼樣式規則斯卡拉郎,我應該設置覆蓋默認行爲,並讓我的期望輸出的風格?
編輯
取消選擇Align when multiline
將導致:
protected def pruneFilterProject(
relation: LogicalRelation,
projectList: Seq[NamedExpression],
filterPredicates: Seq[Expression],
scanBuilder: (Array[String], Array[Filter]) => RDD[Row]) = {
pruneFilterProjectRaw(
relation,
projectList,
filterPredicates,
(requestedColumns, pushedFilters) => {
scanBuilder(requestedColumns.map(_.name).toArray, selectFilters(pushedFilters).toArray)
})
}
參數和方法體將具有同樣的凹口(2空間),而不是所希望的一個: 參數列表具有兩個凹口( 4空格),只有一個縮進的方法列表(2個空格)
謝謝,我把結果格式放在答案的「編輯」部分,你會介意再幫助我嗎? –
感謝您的更新。我認爲我需要的只是'方法聲明參數''繼續縮進'到4和其他'延續縮進'到2,這在Intellij IDEA中似乎不可用? –