public static boolean addDependency(@NotNull PsiJavaModule from,
                                      @NotNull String to,
                                      @Nullable DependencyScope scope,
                                      boolean isExported) {
    if (to.equals(JAVA_BASE)) return false;
    if (!PsiUtil.isAvailable(JavaFeature.MODULES, from)) return false;
    if (from instanceof LightJavaModule) return false;
    if (to.equals(from.getName())) return false;
    if (!PsiNameHelper.isValidModuleName(to, from)) return false;
    if (alreadyContainsRequires(from, to)) return false;
    PsiUtil.addModuleStatement(from, PsiKeyword.REQUIRES + " " +
                                     (isStaticModule(to, scope) ? PsiKeyword.STATIC + " " : "") +
                                     (isExported ? PsiKeyword.TRANSITIVE + " " : "") +
                                     to);
    PsiJavaModule toModule = findDependencyByName(from, to);
    if (toModule != null) optimizeDependencies(from, toModule);
    return true;
  }
public static boolean addDependency(@NotNull PsiJavaModule from,
                                      @NotNull String to,
                                      @Nullable DependencyScope scope,
                                      boolean isExported)