use of com.jetbrains.edu.learning.StudyLanguageManager in project intellij-community by JetBrains.
the class CCSubtaskChangeListener method subtaskChanged.
@Override
public void subtaskChanged(@NotNull Project project, @NotNull Task task, int oldSubtaskNumber, int newSubtaskNumber) {
VirtualFile taskDir = task.getTaskDir(project);
if (taskDir == null) {
return;
}
Course course = StudyTaskManager.getInstance(project).getCourse();
if (course == null) {
return;
}
StudyLanguageManager manager = StudyUtils.getLanguageManager(course);
if (manager == null) {
return;
}
String testFileName = manager.getTestFileName();
if (newSubtaskNumber != 0) {
String nameWithoutExtension = FileUtil.getNameWithoutExtension(testFileName);
String extension = FileUtilRt.getExtension(testFileName);
testFileName = nameWithoutExtension + EduNames.SUBTASK_MARKER + newSubtaskNumber + "." + extension;
}
VirtualFile newTestFile = taskDir.findChild(testFileName);
if (newTestFile == null) {
return;
}
FileEditorManager editorManager = FileEditorManager.getInstance(project);
List<VirtualFile> testFiles = ContainerUtil.filter(taskDir.getChildren(), file -> CCUtils.isTestsFile(project, file) && editorManager.isFileOpen(file));
if (testFiles.isEmpty()) {
return;
}
Editor selectedTextEditor = editorManager.getSelectedTextEditor();
for (VirtualFile testFile : testFiles) {
editorManager.closeFile(testFile);
}
editorManager.openFile(newTestFile, true);
if (selectedTextEditor != null) {
reopenSelectedEditor(editorManager, selectedTextEditor);
}
}
use of com.jetbrains.edu.learning.StudyLanguageManager in project intellij-community by JetBrains.
the class CCTestsTabTitleProvider method getEditorTabTitle.
@Nullable
@Override
public String getEditorTabTitle(Project project, VirtualFile file) {
if (!CCUtils.isCourseCreator(project)) {
return null;
}
if (!CCUtils.isTestsFile(project, file)) {
return null;
}
Course course = StudyTaskManager.getInstance(project).getCourse();
assert course != null;
StudyLanguageManager manager = StudyUtils.getLanguageManager(course);
if (manager == null) {
return null;
}
return manager.getTestFileName();
}
use of com.jetbrains.edu.learning.StudyLanguageManager in project intellij-community by JetBrains.
the class CCTaskDirectoryNode method modifyChildNode.
@Nullable
@Override
public AbstractTreeNode modifyChildNode(AbstractTreeNode childNode) {
AbstractTreeNode node = super.modifyChildNode(childNode);
if (node != null) {
return node;
}
Object value = childNode.getValue();
if (value instanceof PsiElement) {
PsiElement psiElement = (PsiElement) value;
PsiFile psiFile = psiElement.getContainingFile();
VirtualFile virtualFile = psiFile.getVirtualFile();
if (virtualFile == null) {
return null;
}
if (StudyUtils.isTaskDescriptionFile(virtualFile.getName())) {
return null;
}
Course course = StudyTaskManager.getInstance(myProject).getCourse();
if (course == null) {
return null;
}
StudyLanguageManager manager = StudyUtils.getLanguageManager(course);
if (manager == null) {
return new CCStudentInvisibleFileNode(myProject, psiFile, myViewSettings);
}
if (!CCUtils.isTestsFile(myProject, virtualFile)) {
return new CCStudentInvisibleFileNode(myProject, psiFile, myViewSettings);
}
if (!myTask.hasSubtasks()) {
return new CCStudentInvisibleFileNode(myProject, psiFile, myViewSettings, getTestNodeName(manager, psiElement));
}
String testFileName = getTestNodeName(manager, psiElement);
return isActiveSubtaskTest(virtualFile) ? new CCStudentInvisibleFileNode(myProject, psiFile, myViewSettings, testFileName) : null;
}
return null;
}
use of com.jetbrains.edu.learning.StudyLanguageManager in project intellij-community by JetBrains.
the class CCDirectoryNode method modifyChildNode.
@Nullable
@Override
public AbstractTreeNode modifyChildNode(AbstractTreeNode childNode) {
final AbstractTreeNode node = super.modifyChildNode(childNode);
if (node != null)
return node;
Object value = childNode.getValue();
if (value instanceof PsiElement) {
PsiFile psiFile = ((PsiElement) value).getContainingFile();
VirtualFile virtualFile = psiFile.getVirtualFile();
Course course = StudyTaskManager.getInstance(myProject).getCourse();
if (course == null) {
return null;
}
StudyLanguageManager manager = StudyUtils.getLanguageManager(course);
if (manager == null) {
return new CCStudentInvisibleFileNode(myProject, psiFile, myViewSettings);
}
if (!CCUtils.isTestsFile(myProject, virtualFile)) {
return new CCStudentInvisibleFileNode(myProject, psiFile, myViewSettings);
}
}
return null;
}
Aggregations