Search in sources :

Example 1 with PyClass

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

the class PyUserSkeletonsClassMembersProvider method resolveMember.

@Nullable
@Override
public PsiElement resolveMember(@NotNull PyClassType classType, @NotNull String name, @Nullable PsiElement location, TypeEvalContext context) {
    final PyClass cls = classType.getPyClass();
    final PyClass skeleton = PyUserSkeletonsUtil.getUserSkeletonWithContext(cls, context);
    if (skeleton != null) {
        return findClassMember(skeleton, name, classType.isDefinition());
    }
    return null;
}
Also used : PyClass(com.jetbrains.python.psi.PyClass) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with PyClass

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

the class PyUserSkeletonsClassMembersProvider method getMembers.

@NotNull
@Override
public Collection<PyCustomMember> getMembers(@NotNull PyClassType classType, PsiElement location, TypeEvalContext typeEvalContext) {
    final PyClass cls = classType.getPyClass();
    final PyClass skeleton = PyUserSkeletonsUtil.getUserSkeleton(cls);
    if (skeleton != null) {
        return getClassMembers(skeleton, classType.isDefinition());
    }
    return Collections.emptyList();
}
Also used : PyClass(com.jetbrains.python.psi.PyClass) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with PyClass

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

the class PySignatureCacheManagerImpl method getFunctionName.

private static String getFunctionName(PyFunction function) {
    String name = function.getName();
    if (name == null) {
        return "";
    }
    PyClass cls = function.getContainingClass();
    if (cls != null) {
        name = cls.getName() + "." + name;
    }
    return name;
}
Also used : PyClass(com.jetbrains.python.psi.PyClass)

Example 4 with PyClass

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

the class PyClassRefactoringTest method findField.

private PyElement findField(final String className, final String memberName) {
    final PyClass aClass = findClass(className);
    final PyTargetExpression attribute = aClass.findClassAttribute(memberName, false, null);
    if (attribute != null) {
        return attribute;
    }
    return aClass.findInstanceAttribute(memberName, false);
}
Also used : PyClass(com.jetbrains.python.psi.PyClass) PyTargetExpression(com.jetbrains.python.psi.PyTargetExpression)

Example 5 with PyClass

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

the class PyExtractSuperclassPresenterTest method configureByClass.

/**
   * Configures presenter by class
   *
   * @param name name of class
   * @return presenter
   */
@NotNull
private PyExtractSuperclassPresenterImpl configureByClass(@NotNull final String name) {
    final PyClass childClass = getClassByName(name);
    final PyMemberInfoStorage storage = new PyMemberInfoStorage(childClass);
    return new PyExtractSuperclassPresenterImpl(myView, childClass, storage);
}
Also used : PyClass(com.jetbrains.python.psi.PyClass) PyMemberInfoStorage(com.jetbrains.python.refactoring.classes.PyMemberInfoStorage) NotNull(org.jetbrains.annotations.NotNull)

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