`As` keyword alias about kotlin

This is like this, I am in the project, I use a lot of as, used to alias for the type of import. But I found that in Idea, it is not very friendly for aliahe automatic filling.

For example, I wrote this code:

import xxx.xxx.xxx.databinding.ActivityLoginBinding as Binding

class LoginActivity : BaseActivity<Binding>()
{
    override fun Binding.initData(savedInstanceState: Bundle?)
    {

    }
}

But in fact, IDEA automatically completes this code:

import xxx.xxx.xxx.databinding.ActivityLoginBinding as Binding

class LoginActivity : BaseActivity<Binding>()
{
    // See here, there is no use of alias `binding.
    override fun xxx.xxx.xxx.databinding.ActivityLoginBinding.initData(savedInstanceState: Bundle?)
    {
            
    }
}

Obviously, in this class, IDEA should automatically use my alias, not a real class name.

So you mean that IntelliJ doesn’t autocomplete aliases for you? Well, it does for me:

Screenshot from 2022-04-08 10-23-55

Also, maybe your specific case requires this, but I think it is generally not a good idea to make many of such aliases. If you do this just to have shorter names then I think this obfuscates the code and confuses the reader, because while reading the code we have to check aliases all the time to understand what is going on.

Thanks, I mean, when I declare this alias at the top of the code, all the auto-generated functions in my current class should have this alias as the name, not the full package name.

For example, the code I posted above, the initData function was automatically filled in by IDEA, but the function was prefixed with the full package name, not the alias I defined.

I’m using the latest release of IDEA Ultimate 2022.1, and it seems to work fine for me.