use of com.intellij.psi.PsiDirectory in project intellij-community by JetBrains.
the class GrIntroduceValidatorEngine method validateVariableOccurrencesUp.
private void validateVariableOccurrencesUp(PsiElement startElement, MultiMap<PsiElement, String> conflicts, @NotNull String varName, double startOffset) {
PsiElement prevSibling = startElement.getPrevSibling();
while (prevSibling != null) {
if (!(GroovyRefactoringUtil.isAppropriateContainerForIntroduceVariable(prevSibling) && prevSibling.getTextRange().getEndOffset() < startOffset)) {
validateOccurrencesDown(prevSibling, conflicts, varName, startOffset);
}
prevSibling = prevSibling.getPrevSibling();
}
PsiElement parent = startElement.getParent();
// Do not check context out of method, type definition and directories
if (parent == null || parent instanceof GrMethod || parent instanceof GrTypeDefinition || parent instanceof GroovyFileBase || parent instanceof PsiDirectory) {
return;
}
validateVariableOccurrencesUp(parent, conflicts, varName, startOffset);
}
use of com.intellij.psi.PsiDirectory in project intellij-community by JetBrains.
the class CourseDirectoryNode method modifyChildNode.
@Nullable
public AbstractTreeNode modifyChildNode(AbstractTreeNode childNode) {
Object value = childNode.getValue();
if (value instanceof PsiDirectory) {
PsiDirectory directory = (PsiDirectory) value;
if (EduNames.SANDBOX_DIR.equals(directory.getName())) {
return new SandboxDirectoryNode(myProject, directory, myViewSettings);
}
Lesson lesson = myCourse.getLesson(directory.getName());
return lesson != null ? createChildDirectoryNode(lesson, directory) : null;
}
return null;
}
use of com.intellij.psi.PsiDirectory in project intellij-community by JetBrains.
the class CourseDirectoryNode method createChildDirectoryNode.
@Override
public PsiDirectoryNode createChildDirectoryNode(StudyItem item, PsiDirectory directory) {
final List<Lesson> lessons = myCourse.getLessons();
final Lesson lesson = (Lesson) item;
if (directory.getChildren().length > 0 && lessons.size() == 1) {
final List<Task> tasks = lesson.getTaskList();
if (tasks.size() == 1) {
PsiDirectory taskDirectory = (PsiDirectory) directory.getChildren()[0];
PsiDirectory srcDir = taskDirectory.findSubdirectory(EduNames.SRC);
if (srcDir != null) {
taskDirectory = srcDir;
}
return new TaskDirectoryNode(myProject, taskDirectory, myViewSettings, tasks.get(0));
}
}
return new LessonDirectoryNode(myProject, directory, myViewSettings, lesson);
}
use of com.intellij.psi.PsiDirectory in project intellij-community by JetBrains.
the class LessonDirectoryNode method modifyChildNode.
@Nullable
@Override
public AbstractTreeNode modifyChildNode(AbstractTreeNode childNode) {
Object value = childNode.getValue();
if (value instanceof PsiDirectory) {
PsiDirectory directory = (PsiDirectory) value;
Task task = myLesson.getTask(directory.getName());
if (task == null) {
return null;
}
VirtualFile srcDir = directory.getVirtualFile().findChild(EduNames.SRC);
if (srcDir != null) {
directory = PsiManager.getInstance(myProject).findDirectory(srcDir);
if (directory == null) {
return null;
}
}
return createChildDirectoryNode(task, directory);
}
return null;
}
use of com.intellij.psi.PsiDirectory in project intellij-community by JetBrains.
the class TaskDirectoryNode method modifyChildNode.
@Nullable
@Override
public AbstractTreeNode modifyChildNode(AbstractTreeNode childNode) {
Object value = childNode.getValue();
if (value instanceof PsiDirectory && !((PsiDirectory) value).getName().equals(EduNames.SRC)) {
return createChildDirectoryNode(null, (PsiDirectory) value);
}
if (value instanceof PsiElement) {
PsiFile psiFile = ((PsiElement) value).getContainingFile();
if (psiFile == null)
return null;
VirtualFile virtualFile = psiFile.getVirtualFile();
if (virtualFile == null) {
return null;
}
return StudyUtils.getTaskFile(myProject, virtualFile) != null ? childNode : null;
}
return null;
}
Aggregations