how to get list of packages
so i was thinking about a plugin and i want to get a list of all packages in the current project, how would i go about that? i've been looking through the api but it is not really clear to me at this point.
thanks
-Andre
Please sign in to leave a comment.
Have you looked at the PSI API?
Timur
I could be totally wrong here but it could be something like this:
1) Get all source roots.
2) Get psiElements for them.
3) Process their children till you get all packages.
Timur
Hey thanks for the tips, appreciate it, i'm trying to understand how the method findClass(java.lang.String) of PsiManager works, i've tried giving it virtualFile.getNAme and virtualFile.getNameWithoutExtension neither seems to be working. any clues? thanks
-Andre
virtualFile.getName() returns something like "List.java". I guess getNameWithoutExtension() will return "List". I would also try a fully qualified class name (e.g. "java.util.List").
Timur