Search in sources :

Example 86 with PyClass

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

the class PyControlFlowBuilderTest method testQualifiedSelfReference.

public void testQualifiedSelfReference() {
    final String testName = getTestName(false).toLowerCase();
    configureByFile(testName + ".py");
    final String fullPath = getTestDataPath() + testName + ".txt";
    final PyClass pyClass = ((PyFile) myFile).getTopLevelClasses().get(0);
    final ControlFlow flow = ControlFlowCache.getControlFlow(pyClass.getMethods()[0]);
    check(fullPath, flow);
}
Also used : PyClass(com.jetbrains.python.psi.PyClass) ControlFlow(com.intellij.codeInsight.controlflow.ControlFlow)

Example 87 with PyClass

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

the class PyClassMROTest method testTangledInheritance.

public void testTangledInheritance() {
    final int numClasses = 100;
    final List<String> expectedMRO = new ArrayList<>();
    for (int i = numClasses - 1; i >= 1; i--) {
        expectedMRO.add(String.format("Class%03d", i));
    }
    expectedMRO.add("object");
    final PyClass pyClass = getClass(String.format("Class%03d", numClasses));
    final long startTime = System.currentTimeMillis();
    assertMRO(pyClass, ArrayUtil.toStringArray(expectedMRO));
    final long elapsed = System.currentTimeMillis() - startTime;
    assertTrue("Calculation of MRO takes too much time: " + elapsed + " ms", elapsed < 1000);
}
Also used : PyClass(com.jetbrains.python.psi.PyClass) ArrayList(java.util.ArrayList)

Example 88 with PyClass

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

the class PyClassMROTest method getClass.

@NotNull
public PyClass getClass(@NotNull String name) {
    myFixture.configureByFile(getPath(getTestName(false)));
    final PyClass cls = myFixture.findElementByText(name, PyClass.class);
    assertNotNull(cls);
    return cls;
}
Also used : PyClass(com.jetbrains.python.psi.PyClass) 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