Hey guys. I have a data class named `UserModel`. T...
# android
f
Hey guys. I have a data class named
UserModel
. There exist cases in my code which I used
copy
to clone the user model. My question is that is there a way to find all UserModel.copy calls?
m
In Android Studio you can just cmd + shift + F to run a search in your entire project. Just type in the command or phrase that you’re looking for and you’re done.
f
Using
cmd+shift+F
I will find all usages of
copy
for all data classes, but I'm looking a way to find only calls on
UserModel.copy
w
Seems like a case for Structural Search. Unfortunately I just tried to search for
copy
usages and failed 😕 But perhaps you’ll figure it out (let me know then!)
Btw not sure which AS you use, but with 3.6 there’s new structural search dialog, which is more intuitive
t
I think if you find one occurrence then you can look from there. so,
Copy code
userModel.copy() //search here, right click, ctrl+shift+7, or whatever shortcut you use
f
@wasyl Thanks for introducing structural search. I use AS 3.5 and I see the option. But I can't figure out how to use structural search dialog.
@thanksforallthefish
ctrl+shift+f7
just highlights
copy
usages in current file. I need a way to search through all project files.
t
do right click -> find usages
next to it you will also what your shortcut is
a
Maybe just remove ’data’ from class and try compile?) Compiler show unknown function 'copy' usage in errors :)
👌 1
w
For me
find usages
on
copy
method finds usages of the class, not
copy
method
👌 1
t
I admit I use regular IDEA 2019.2, not Android Studio (and never used Android Studio, I am in this channel but never did Android dev)
f
@wasyl in AS 3.5 I can structurally search in java files (and not kotlin files).
w
I hoped I was just doing something wrong and in fact structural search would work in Kotlin as well 😞