https://kotlinlang.org logo
#getting-started
Title
# getting-started
k

Kenneth

04/05/2022, 10:57 AM
Probably more a intellij question than kotlin, but is there a function to detect all full path
<http://com.my|com.my>.package.MyClass
in code? I refactored some packages and it got a bit messy, want to change it back to only MyClass.
j

Joffrey

04/05/2022, 10:59 AM
Do you want full-text search/replace (Ctrl+Alt+Shift+R)? Or something smarter?
k

Kenneth

04/05/2022, 11:01 AM
It is many different packages, so I would prefer something that detects all redundant qualifier names
v

Vampire

04/05/2022, 11:03 AM
If you do Alt+Enter on, it, there will be a quick fix to remove the redundant package, or to add an import instead, depending on whether you have an import already or not. If you don't execute it, but go to the details with right-arrow key or mouse hovering, there is na option to run this inspection on all your code and from there you can also fix it everywhere.
👍 1
j

Joffrey

04/05/2022, 11:05 AM
Ah if it's for redundant packages yes this would be a better option. I thought a refactoring went wrong and some packages within the imports were duplicated, like
<http://com.example.com|com.example.com>.example.Thing
(which happened to me when trying the "unnested" layout advised in the Kotlin docs)
k

Kenneth

04/05/2022, 11:06 AM
@Vampire Thanks! That was exactly what I was looking for, well hidden I may say.
j

Joffrey

04/05/2022, 11:08 AM
@Kenneth most quick fixes like this can be applied in bulk. Once you know it for one, you know it for everything 🙂
v

Vampire

04/05/2022, 11:09 AM
Well, there are many ways. You can also invoke the inspection by doing Ctrl+Alt+Shift+i and then search for it by name. Or if you don't remember the shortcut you can search for the action in Ctrl+Shift+A or in Shift-Shift
I just find it easier to go the quick-fix way as you don't have to remember or make up the name of the intention to execute
👍 2
k

Kenneth

04/05/2022, 11:12 AM
I actually tried to find an action for it, but I didn’t successfully locate it.
v

Vampire

04/05/2022, 11:14 AM
The action is "Run inspection by name"
5 Views