Getting the marked package with AnActionEvent

I want to be able to get the current package I am in or get a list of all the packages in the project so I can choose the one i want. As far as I can see I can only get a package by refering to it's nam, like so:

PsiPackage thePackage= JavaPsiFacade.getInstance(project).findPackage("package name");

Also is there a way to get all the sub packages without having to do a recursive function that looks for them?
The reason I want this is becouse I want to go trough a package, find all the classes in that package and it's sub packages and save a list of all the methods in them.

1 comment
Comment actions Permalink

Okey, so I have solved the problems with the iteration of the packages, I just did a recursive function to get all the classes in each subpackage. I still have the problem with getting the selected packge as a root package tho, at the moment I have to use the package name like so:

PsiPackage mainPackage = JavaPsiFacade.getInstance(project).findPackage("packageName");

but I want to be able to get the pacage I have selected in the project, I can do it with files in the project using the getData() function like so:

PsiJavaFile psi = e.getData(LangDataKeys.PSI_FILE);

there must be a simulair way for packages.

0

Please sign in to leave a comment.