Merge pull request #19 from xfournet/IDEA-91145-trunk
[idea/community.git] / plugins / maven / src / main / java / org / jetbrains / idea / maven / project / MavenProjectsTree.java
index 96ed1cff0bcdd535edad5a639f3038346e4566df..6a90cc88bbb748721469fa777250495c0c16d20c 100644 (file)
@@ -918,6 +918,33 @@ public class MavenProjectsTree {
     }
   }
 
+  public MavenProject findRootProject(@NotNull MavenProject project) {
+    readLock();
+    try {
+      MavenProject rootProject = project;
+      while (true) {
+        MavenProject aggregator = myModuleToAggregatorMapping.get(project);
+        if (aggregator == null) {
+          return rootProject;
+        }
+        rootProject = aggregator;
+      }
+    }
+    finally {
+      readUnlock();
+    }
+  }
+
+  public boolean isRootProject(@NotNull MavenProject project) {
+    readLock();
+    try {
+      return myModuleToAggregatorMapping.get(project) == null;
+    }
+    finally {
+      readUnlock();
+    }
+  }
+
   public List<MavenProject> getModules(MavenProject aggregator) {
     readLock();
     try {