/** * FIXME module editing is generally done through descriptor and reload. Although I do not mind * exposing add/remove methods here, it should be consistent! */ @Nullable public Dependency addDependency(@NotNull SModuleReference moduleRef, boolean reexport) { assertCanChange(); ModuleDescriptor descriptor = getModuleDescriptor(); if (descriptor == null) { return null; } for (Dependency dep : descriptor.getDependencies()) { if (!EqualUtil.equals(dep.getModuleRef(), moduleRef)) { continue; } if (reexport && !dep.isReexport()) { dep.setReexport(true); dependenciesChanged(); fireChanged(); setChanged(); } return dep; } Dependency dep = new Dependency(); dep.setModuleRef(moduleRef); dep.setReexport(reexport); descriptor.getDependencies().add(dep); dependenciesChanged(); fireChanged(); setChanged(); return dep; }
// todo should be replaced with events public final void setModuleDescriptor(ModuleDescriptor moduleDescriptor) { assertCanChange(); doSetModuleDescriptor(moduleDescriptor); setChanged(); reloadAfterDescriptorChange(); fireChanged(); dependenciesChanged(); }
public void removeDependency(@NotNull Dependency dependency) { assertCanChange(); ModuleDescriptor descriptor = getModuleDescriptor(); if (descriptor == null) { return; } if (!descriptor.getDependencies().contains(dependency)) { return; } descriptor.getDependencies().remove(dependency); dependenciesChanged(); fireChanged(); setChanged(); }
@Override protected void dependenciesChanged() { super.dependenciesChanged(); if (!willLoad()) return; fireDependenciesChanged(); }