In a scala project where we are using IntelliJ community edition, we want to use multiple packages per file, so that we can reference them with shorter syntax:
package com.dreamlines.dragonfly
package api
package domain
package harbours
import common.entities.EsHarbour
import common.utils.date.DLDateTime
Yet IntellJ wants to enforce the fully qualified package name and hence on optimizing the imports it changes the code to:
import com.dreamlines.dragonfly.common.entities.EsHarbour
import com.dreamlines.dragonfly.common.utils.date.DLDateTime
How do I configure the behavior of optimize import?
It should
I want to keep the other behavior of optimize import intact, e.g. removing unused imports, adding missing imports, sorting imports. So I don't consider not using optimize imports a valid option.
We are furthermore using the scalafmt
formatter, so it may relate to our .scalafmt.conf
that looks like this for this project:
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
It seems that there is a code style option in IntelliJ that forces fully qualified package names. You can disable that and see if that helps:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With