ModCommand (@NotNull Project project, @NotNull ProblemDescriptor descriptor) { PsiElement psiElement = descriptor.getPsiElement(); return ModCommand.updateOption(psiElement, SuspiciousPackagePrivateAccessInspection.this, inspection -> { Map<String, ModulesSet> moduleSetByModule = inspection.myModuleSetByModuleName.getValue(); ModulesSet module1Set = moduleSetByModule.get(myModule1); ModulesSet module2Set = moduleSetByModule.get(myModule2); if (module1Set == null) { if (module2Set == null) { ModulesSet modulesSet = new ModulesSet(); modulesSet.modules.add(myModule1); modulesSet.modules.add(myModule2); inspection.MODULES_SETS_LOADED_TOGETHER.add(modulesSet); } else { module2Set.modules.add(myModule1); } } else if (module2Set == null) { module1Set.modules.add(myModule2); } else if (module1Set != module2Set) { module1Set.modules.addAll(module2Set.modules); inspection.MODULES_SETS_LOADED_TOGETHER.remove(module2Set); } inspection.myModuleSetByModuleName.drop(); }); }