Search in sources :

Example 36 with PsiDirectory

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);
}
Also used : GroovyFileBase(org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase) GrTypeDefinition(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition) PsiDirectory(com.intellij.psi.PsiDirectory) GrMethod(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod) PsiElement(com.intellij.psi.PsiElement)

Example 37 with PsiDirectory

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;
}
Also used : PsiDirectory(com.intellij.psi.PsiDirectory) Lesson(com.jetbrains.edu.learning.courseFormat.Lesson) Nullable(org.jetbrains.annotations.Nullable)

Example 38 with PsiDirectory

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);
}
Also used : Task(com.jetbrains.edu.learning.courseFormat.Task) PsiDirectory(com.intellij.psi.PsiDirectory) Lesson(com.jetbrains.edu.learning.courseFormat.Lesson)

Example 39 with PsiDirectory

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;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Task(com.jetbrains.edu.learning.courseFormat.Task) PsiDirectory(com.intellij.psi.PsiDirectory) Nullable(org.jetbrains.annotations.Nullable)

Example 40 with PsiDirectory

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;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiDirectory(com.intellij.psi.PsiDirectory) PsiFile(com.intellij.psi.PsiFile) PsiElement(com.intellij.psi.PsiElement) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

PsiDirectory (com.intellij.psi.PsiDirectory)321 VirtualFile (com.intellij.openapi.vfs.VirtualFile)122 PsiFile (com.intellij.psi.PsiFile)111 PsiElement (com.intellij.psi.PsiElement)79 Project (com.intellij.openapi.project.Project)73 Module (com.intellij.openapi.module.Module)68 Nullable (org.jetbrains.annotations.Nullable)62 NotNull (org.jetbrains.annotations.NotNull)50 IdeView (com.intellij.ide.IdeView)31 AbstractTreeNode (com.intellij.ide.util.treeView.AbstractTreeNode)24 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)24 PsiManager (com.intellij.psi.PsiManager)24 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)20 ArrayList (java.util.ArrayList)20 PsiPackage (com.intellij.psi.PsiPackage)17 File (java.io.File)15 PsiFileSystemItem (com.intellij.psi.PsiFileSystemItem)11 IncorrectOperationException (com.intellij.util.IncorrectOperationException)11 Course (com.jetbrains.edu.learning.courseFormat.Course)11 JSClass (com.intellij.lang.javascript.psi.ecmal4.JSClass)10