Completion for inner classes returned by PsiElementFinder
已回答
I want to provide additional Java classes without adding them to FileSystem. What I've done so far:
- I've implemented custom PsiElementFinder (methods #findClass, #findClasses). Symbols with qualified names are now recognized `package.ClsName`, but symbols with short names are not `ClsName`.
- I've added custom ShortNamesCache. Over the symbols with short names now I receive suggestions to import the class. This quickFix replaces short name with qualified name, even if the class in the same package. `ClsName` is replaced with `package.ClsName`.
- I've implemented #getClasses(PsiPackage) in the PsiElementFinder. Now short names are recognized `ClsName` and inner classes are recognized `ClsName.Builder`. But completion works for `ClsName` only, and not for `ClsName.Builder`.
- I've found CompletionContributor, but I don't need a custom logic. I want standard Java completion for methods in the `ClsName.Builder` class.
- I've also tested it on version 2018.1, and completion for inner classes worked there. But I need a solution for 2019.2. (Android Studio version)
How would I enable completion for `ClsName.Builder`? I've already spent few weeks on this problem, I've tried different combinations of classes returned by Finder and ShortNamesCache, but nothing worked for me.
请先登录再写评论。
Upd: I'll need to implement custom scope as well
https://youtrack.jetbrains.com/issue/IDEA-236676?_ga=2.265246223.1616662009.1585842988-2137421544.1561313206
Kata,
Sorry for the late reply.
I'm glad that you found the right solution!