Extracting member information
This question is about the IntelliJ API best practices way of extracting the members of the class which is in currently the editor.
Basically, just want to extract all the members of the current class so they can be presented in a dialog. Obviously super classes and inner classes and interfaces are of interest also but this is probably just a recursive procedure. Like ExtractClass or ExtractInterface refactorings do. Did find ExtractinterfaceDialog and ExtractInterfaceHandler and all this to use as exemplars. Nosing around ran into MemberInfo.extractClassMembers but it seems to not be used that much in the IntelliJ source, which suggests there's some other more efficient way somewhere?
Regarding MemberInfo.extractClassMembers- it puts everything into an typed List : List<MemberInfo> and then the consumers of this list end up having to instanceof the individual items to identify them as being a field or method or whatnot. Is this just how it's done or is there another way? It seems like there ought to be a more natural API like getFields() getMethods getInnerClasses etc etc. but maybe there's more to it than that.
Any knowledge at all is more than appreciated.
Please sign in to leave a comment.
Hello bassybassy,
PsiClass.getMethods()/getFileds()/getInnerClasses() is the API that you need.
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"