Obtaining .java files in source root Follow
Hi
Is there an API to obtain all all the .java files in the source directory of a module(preferably as a list of PsiClass) . Further, is there anyway for me to filter that class list based on a class level annotation present in those classes? (e.g: I want to filter the classes with annotation @Deprecated)
Thanks.
Please sign in to leave a comment.
Obtain Query from com.intellij.psi.search.searches.AllClassesSearch#search(com.intellij.psi.search.SearchScope, com.intellij.openapi.project.Project) and use com.intellij.util.Query#forEach to filter out @Deprecated classes.
SearchScope = com.intellij.psi.search.GlobalSearchScopesCore#directoryScope(com.intellij.psi.PsiDirectory, boolean)
Hi Yann,
Thank you for the response. What I did to obtain the class list was
Can you explain me how to use the Query class to filter out the annotations? I couldn't find an example in IDEA source code.
In com.intellij.util.Query#forEach you check com.intellij.psi.PsiDocCommentOwner#isDeprecated on given PsiClass and add it to results list/process it accordingly.
Hi Yann,
Got it. Thank you