added validation to answer files rename (part of EDU-341)
[idea/community.git] / python / educational / course-creator / src / com / jetbrains / edu / coursecreator / CCUtils.java
1 package com.jetbrains.edu.coursecreator;
2
3 import com.intellij.lang.Language;
4 import com.intellij.openapi.vfs.VirtualFile;
5 import com.intellij.psi.PsiElement;
6 import com.intellij.psi.PsiFile;
7 import com.jetbrains.edu.courseFormat.Course;
8 import org.jetbrains.annotations.NotNull;
9 import org.jetbrains.annotations.Nullable;
10
11 public class CCUtils {
12   @Nullable
13   public static CCLanguageManager getStudyLanguageManager(@NotNull final Course course) {
14     Language language = Language.findLanguageByID(course.getLanguage());
15     return language == null ? null :  CCLanguageManager.INSTANCE.forLanguage(language);
16   }
17
18   public static boolean isAnswerFile(PsiElement element) {
19     if (!(element instanceof PsiFile)) {
20       return false;
21     }
22     VirtualFile file = ((PsiFile)element).getVirtualFile();
23     return CCProjectService.getInstance(element.getProject()).isAnswerFile(file);
24   }
25 }