void (PsiElement what, PsiElement from, boolean referencedFromClassInitializer) { if (what != null && from != null){ //from should be always in sources final Module fromModule = ModuleUtilCore.findModuleForFile(from.getContainingFile()); final Set<Module> onModules = getAllPossibleWhatModules(what); if (onModules != null && fromModule != null){ final RefModule refModule = myManager.getRefModule(fromModule); if (refModule != null) { HashSet<Module> modules = new HashSet<>(onModules); collectRequiredModulesInHierarchy(myManager.getReference(what), modules); modules.remove(fromModule); getModules(refModule).addAll(modules); } } } }