References for code strings Follow
Hi.
I want to do something similar to what AppCode does with [UIImage imageNamed:@"..."]. When you specify the image name on the @"..." string, Appcode shows a warning if the image doesn't exist. Furthermore, you can Command+Click on the image to go to it, or Control+Space to get a list of all the possible images, so it seems that for the string AppCode has created a PathReference to this string.
Is there an example of doing this? I can always create a Reference Contributor like in the plugin tutorial: http://confluence.jetbrains.com/display/IntelliJIDEA/Reference+Contributor but if I do this, I have to check, for every PsiStringLiteral, that its siblings are a function reference called imageNamed and that there is another sibling with a reference to the UIImage class. Maybe there is an easier / more correct way of doing this?
Thank you in advance
Please sign in to leave a comment.
Creating a reference contributor is exactly the right way of doing this.
Thank you! I was hoping to avoid the manual checkings for function and class names, though.
How could one avoid that? Our code does the same kind of checks when appopriate.
Well, maybe you had some kind of API to say something like: "only for something matching this list of psi elements, do this". Anyway, is better asking before doing something stupid, right? :)
Thank you for your responses, I'll try this.