コード例 #1
0
 @Nullable
 public Module findIntellijModuleByName(@NotNull String name) {
   for (Module module : myFacade.getModules(myProject)) {
     if (name.equals(module.getName())) {
       return module;
     }
   }
   return null;
 }
コード例 #2
0
  /**
   * Allows to answer if target library dependency is still available at the target project.
   *
   * @param id target library id
   * @return <code>true</code> if target library dependency is still available at the target
   *     project; <code>false</code> otherwise
   */
  public boolean isIntellijLibraryDependencyExist(@NotNull final GradleLibraryDependencyId id) {
    final Module module = findIntellijModuleByName(id.getModuleName());
    if (module == null) {
      return false;
    }

    RootPolicy<Boolean> visitor =
        new RootPolicy<Boolean>() {
          @Override
          public Boolean visitLibraryOrderEntry(
              LibraryOrderEntry libraryOrderEntry, Boolean value) {
            return id.getLibraryName().equals(libraryOrderEntry.getLibraryName());
          }
        };
    for (OrderEntry entry : myFacade.getOrderEntries(module)) {
      if (entry.accept(visitor, false)) {
        return true;
      }
    }
    return false;
  }