commit changes to pattern document before study check action
[idea/community.git] / python / educational-core / student / src / com / jetbrains / edu / learning / StudyUtils.java
index f0d68010a76dcc1d64867aea7d81e1852377c0dd..5c64769542d6c9da3d45f83364ceac20f8f1be0e 100644 (file)
@@ -529,4 +529,20 @@ public class StudyUtils {
     }
     return lesson.getTask(taskVF.getName());
   }
+
+  @Nullable
+  public static VirtualFile getTaskDir(@NotNull VirtualFile taskFile) {
+    VirtualFile parent = taskFile.getParent();
+    if (parent == null) {
+      return null;
+    }
+    String name = parent.getName();
+    if (name.contains(EduNames.TASK)) {
+      return parent;
+    }
+    if (EduNames.SRC.equals(name)) {
+      return parent.getParent();
+    }
+    return null;
+  }
 }