I think the (Java inherited?) habit of IntelliJ to...
# intellij
l
I think the (Java inherited?) habit of IntelliJ to show members before extensions is a big problem in idiomatic Kotlin codebases where members are the lowest level API. Could that change? https://twitter.com/Snokbert/status/1752272566679446011?t=l8go-N31vk8HnwBBWwqzRw&s=19
7
🥺 2
👌 8
r
Unfortunately I am not well-versed in the Compose framework, so could somebody please elaborate on the following: It is possible to just write
modifier = Modifier
, right? Or does the author of the tweet wants
Modifier
to be completed to be able to complete some
fun Modifier.Companion.ext(): Modifier {...}
function later on?
l
Here, there's another example of auto-complete being even worse. Let me explain the context and the issue better in the subsequent message.
The most relevant option here is
Modifier
, that's all. As I commented,
Modifier
(companion object) itself implements the
Modifier
interface. That's to make all common "modifiers" like
padding(…)
,
fillMaxSize()
,
sizeIn(…)
,
background(…)
, etc, autcomplete either on the base empty modifier that is
Modifier
(the companion object)`, or when chained with another
Modifier
instance returned by any modifier like the ones I just mentioned. The
Modifier
companion object is defined as such:
Copy code
// The companion object implements `Modifier` so that it may be used as the start of a
// modifier extension factory expression.
companion object : Modifier {
    override fun <R> foldIn(initial: R, operation: (R, Element) -> R): R = initial
    override fun <R> foldOut(initial: R, operation: (Element, R) -> R): R = initial
    override fun any(predicate: (Element) -> Boolean): Boolean = false
    override fun all(predicate: (Element) -> Boolean): Boolean = true
    override infix fun then(other: Modifier): Modifier = other
    override fun toString() = "Modifier"
}
There are 3 problems. • First the IDE wants to go too far. Instead of just suggesting the shortest option:
Modifier
, it tries to go the extra mile and save you characters in case you want to call the overrides from
Modifier
. It's annoying because if it was really necessary, it could let me do so in two steps. First autocomplete
Modifier
, then autocomplete whatever is next based on the first or subsequent characters I type, after I type
.
that comes after
Modifier
, if I ever do. • Second, the IDE seems to believe that those overrides are members found exclusively in the
Modifier
companion objects, while they're not, it's merely an implementation to conform to the
Modifier
interface, and the signature is exactly the same as in the
interface
, so they should not take priority. • Third, the IDE never seems to learn that I'm never using
Modifier.foldIn
,
Modifier.foldOut
,
Modifier.then
, and other irrelevant options when a
Modifier
type is expected. It's annoying as an experienced dev, it'd most likely be misleading as a beginner.
thank you color 1
r
Thank you @louiscad for such a detailed message! Here’s the first issue that I think can be unambiguously addressed: KTIJ-28887
🙏🏼 1
It’s currently in the backlog because we need to discuss it with our team first; feel free to vote for it if you feel that it’s important for you 🙏
l
Any reason you didn't mention that it affects all Compose UI users in the issue?
🚫 1
Shall I add the link to the Tweet + my screenshot in a comment?
r
Let me add a comment about that 👍
l
Alright, I'll you do it
Thank you 🙏🏼
👍 1
k
You guys are awesome 🙌
🤝🏼 1
🤝 1
💯 1