I have project containing xml files which contains references into java code. In plugin I'm using static initialization of all references found in java codes but this approach sometimes fail with ProcessCancelledException when project is opened (initialization takes too much time).
I don't know what approach should I use. It must be something which I can do after project is opened. I was thinking about indexing java code and creation FileBasedIndex but for that I'd need serialization and my object contains PsiElement (used as reference).
Now, my static initialization uses search & psi facade look like:
JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
clazz = facade.findClass("some class", GlobalSearchScope.allScope(project));
PsiMethod method = clazz.findMethodsByName("some method", false);
Collection<PsiReference> methodRefs = MethodReferencesSearch.search(method).findAll();
and is initialized when @Referencing annotation is found during dom.extender phase.