Getting all elements of specific type in whole project

I was trying to implement a class ReferenceSearch which extends QueryExecutorBase.
public class ReferenceSearch extends QueryExecutorBase<PsiReference, ReferencesSearch.SearchParameters> {
 
          @Override
     public void processQuery(@NotNull final ReferencesSearch.SearchParameters searchParameters, @NotNull final Processor<PsiReference> processor) {
          Collection<CustomElement> = PsiTreeUtil.collectElementsOfType(projectBaseDir, CustomElement.class);
          // perform operation
     }

}

PsiTreeUtil.collectElementsOfType(projectBaseDir, CustomElement.class);
Above line correctly works for smaller projects but takes long time or sometimes freezes for bigger projects(containing 5000 files)


Is there any efficient way of getting all elements which are of CustomElement type in project or any caching mechanism which will make it efficient?

1 comment
Comment actions Permalink

Yes, there is such a way and it's called stub index. Please refer to http://confluence.jetbrains.com/display/IDEADEV/Indexing+and+PSI+Stubs+in+IntelliJ+IDEA for more information.

0

Please sign in to leave a comment.