common method extracted
[idea/community.git] / platform / lang-impl / src / com / intellij / openapi / roots / impl / OrderEntryUtil.java
index d73c6d612f0c5feeca7b63f2814d456279233bcd..45f2d7c71a9a31799a4dbd4485aeaf27b23c52d7 100644 (file)
@@ -31,6 +31,9 @@ import com.intellij.util.Processor;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
+import java.util.ArrayList;
+import java.util.List;
+
 public class OrderEntryUtil {
   private OrderEntryUtil() {
   }
@@ -214,4 +217,19 @@ public class OrderEntryUtil {
     if (scope1 == DependencyScope.TEST || scope2 == DependencyScope.TEST) return DependencyScope.TEST;
     return scope1;
   }
+
+  @NotNull
+  public static List<Library> getModuleLibraries(@NotNull ModuleRootModel model) {
+    OrderEntry[] orderEntries = model.getOrderEntries();
+    List<Library> libraries = new ArrayList<Library>();
+    for (OrderEntry orderEntry : orderEntries) {
+      if (orderEntry instanceof LibraryOrderEntry) {
+        final LibraryOrderEntry entry = (LibraryOrderEntry)orderEntry;
+        if (entry.isModuleLevel()) {
+          libraries.add(entry.getLibrary());
+        }
+      }
+    }
+    return libraries;
+  }
 }