Search in sources :

Example 26 with PyClass

use of com.jetbrains.python.psi.PyClass in project intellij-community by JetBrains.

the class PyContainingFileRenamerFactory method isApplicable.

@Override
public boolean isApplicable(PsiElement element) {
    if (!(element instanceof PyClass)) {
        return false;
    }
    ScopeOwner scopeOwner = PsiTreeUtil.getParentOfType(element, ScopeOwner.class);
    if (scopeOwner instanceof PyFile) {
        String className = ((PyClass) element).getName();
        String fileName = FileUtil.getNameWithoutExtension(scopeOwner.getName());
        return fileName.equalsIgnoreCase(className);
    }
    return false;
}
Also used : PyClass(com.jetbrains.python.psi.PyClass) ScopeOwner(com.jetbrains.python.codeInsight.controlflow.ScopeOwner) PyFile(com.jetbrains.python.psi.PyFile)

Example 27 with PyClass

use of com.jetbrains.python.psi.PyClass in project intellij-community by JetBrains.

the class MembersBasedPresenterImpl method getConflicts.

/**
   * Checks if one of destination classes already has members that should be moved, so conflict would take place.
   *
   * @return map of conflicts (if any)
   * @see #getDestClassesToCheckConflicts()
   */
@NotNull
protected final MultiMap<PyClass, PyMemberInfo<?>> getConflicts() {
    final MultiMap<PyClass, PyMemberInfo<?>> result = new MultiMap<>();
    final Collection<PyMemberInfo<PyElement>> memberInfos = myView.getSelectedMemberInfos();
    for (final PyClass destinationClass : getDestClassesToCheckConflicts()) {
        for (final PyMemberInfo<PyElement> pyMemberInfo : memberInfos) {
            if (pyMemberInfo.hasConflict(destinationClass)) {
                result.putValue(destinationClass, pyMemberInfo);
            }
        }
    }
    return result;
}
Also used : PyClass(com.jetbrains.python.psi.PyClass) MultiMap(com.intellij.util.containers.MultiMap) PyMemberInfo(com.jetbrains.python.refactoring.classes.membersManager.PyMemberInfo) PyElement(com.jetbrains.python.psi.PyElement) NotNull(org.jetbrains.annotations.NotNull)

Example 28 with PyClass

use of com.jetbrains.python.psi.PyClass in project intellij-community by JetBrains.

the class PyClassCellRenderer method customizeRenderer.

public JLabel customizeRenderer(final Object value, final boolean showReadOnly) {
    PyClass aClass = (PyClass) value;
    setText(getClassText(aClass));
    int flags = Iconable.ICON_FLAG_VISIBILITY;
    if (showReadOnly) {
        flags |= Iconable.ICON_FLAG_READ_STATUS;
    }
    Icon icon = aClass.getIcon(flags);
    if (icon != null) {
        setIcon(icon);
    }
    return this;
}
Also used : PyClass(com.jetbrains.python.psi.PyClass)

Example 29 with PyClass

use of com.jetbrains.python.psi.PyClass in project intellij-community by JetBrains.

the class PyExtractMethodHandler method rangeBelongsToSameClassBody.

private static boolean rangeBelongsToSameClassBody(@NotNull PsiElement element1, @NotNull PsiElement element2) {
    final PyClass firstScopeOwner = PsiTreeUtil.getParentOfType(element1, PyClass.class, false, ScopeOwner.class);
    final PyClass secondScopeOwner = PsiTreeUtil.getParentOfType(element2, PyClass.class, false, ScopeOwner.class);
    return firstScopeOwner != null && firstScopeOwner == secondScopeOwner;
}
Also used : PyClass(com.jetbrains.python.psi.PyClass)

Example 30 with PyClass

use of com.jetbrains.python.psi.PyClass in project intellij-community by JetBrains.

the class PyInheritorsSearchTest method testInheritorsWhenSuperClassImportedWithAs.

// PY-19461
public void testInheritorsWhenSuperClassImportedWithAs() throws Exception {
    setupProject();
    final PyClass pyClass = findClass("C");
    final Collection<PyClass> inheritors = PyClassInheritorsSearch.search(pyClass, false).findAll();
    assertSameElements(inheritors, findClass("D"));
}
Also used : PyClass(com.jetbrains.python.psi.PyClass)

Aggregations

PyClass (com.jetbrains.python.psi.PyClass)88 PyFunction (com.jetbrains.python.psi.PyFunction)32 PsiElement (com.intellij.psi.PsiElement)22 NotNull (org.jetbrains.annotations.NotNull)17 ArrayList (java.util.ArrayList)15 Nullable (org.jetbrains.annotations.Nullable)15 PyElement (com.jetbrains.python.psi.PyElement)12 PyMemberInfo (com.jetbrains.python.refactoring.classes.membersManager.PyMemberInfo)9 PyFile (com.jetbrains.python.psi.PyFile)8 PsiFile (com.intellij.psi.PsiFile)7 Project (com.intellij.openapi.project.Project)6 Editor (com.intellij.openapi.editor.Editor)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 MultiMap (com.intellij.util.containers.MultiMap)5 PyMethodMember (com.jetbrains.python.codeInsight.override.PyMethodMember)4 PyMemberInfoStorage (com.jetbrains.python.refactoring.classes.PyMemberInfoStorage)4 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)3 PsiNamedElement (com.intellij.psi.PsiNamedElement)3 PyHierarchyNodeDescriptor (com.jetbrains.python.hierarchy.PyHierarchyNodeDescriptor)3 ControlFlow (com.intellij.codeInsight.controlflow.ControlFlow)2