Search in sources :

Example 1 with PyMethodMember

use of com.jetbrains.python.codeInsight.override.PyMethodMember in project intellij-community by JetBrains.

the class PyOverrideTest method doTest.

private void doTest() {
    myFixture.configureByFile("override/" + getTestName(true) + ".py");
    PyFunction toOverride = getTopLevelClass(0).getMethods()[0];
    PyOverrideImplementUtil.overrideMethods(myFixture.getEditor(), getTopLevelClass(1), Collections.singletonList(new PyMethodMember(toOverride)), false);
    myFixture.checkResultByFile("override/" + getTestName(true) + "_after.py", true);
}
Also used : PyFunction(com.jetbrains.python.psi.PyFunction) PyMethodMember(com.jetbrains.python.codeInsight.override.PyMethodMember)

Example 2 with PyMethodMember

use of com.jetbrains.python.codeInsight.override.PyMethodMember in project intellij-community by JetBrains.

the class PyOverrideTest method testInnerFunctionClass.

public void testInnerFunctionClass() {
    myFixture.configureByFile("override/" + getTestName(true) + ".py");
    PyFunction toOverride = getTopLevelClass(0).getMethods()[0];
    final PsiElement element = myFixture.getElementAtCaret();
    PyOverrideImplementUtil.overrideMethods(myFixture.getEditor(), PsiTreeUtil.getParentOfType(element, PyClass.class, false), Collections.singletonList(new PyMethodMember(toOverride)), false);
    myFixture.checkResultByFile("override/" + getTestName(true) + "_after.py", true);
}
Also used : PyClass(com.jetbrains.python.psi.PyClass) PyFunction(com.jetbrains.python.psi.PyFunction) PyMethodMember(com.jetbrains.python.codeInsight.override.PyMethodMember) PsiElement(com.intellij.psi.PsiElement)

Example 3 with PyMethodMember

use of com.jetbrains.python.codeInsight.override.PyMethodMember in project intellij-community by JetBrains.

the class PyOverrideTest method testInnerClass.

public void testInnerClass() {
    // PY-10976
    myFixture.configureByFile("override/" + getTestName(true) + ".py");
    PyFunction toOverride = getTopLevelClass(0).getMethods()[0];
    PyClass pyClass = getTopLevelClass(1).getNestedClasses()[0];
    PyOverrideImplementUtil.overrideMethods(myFixture.getEditor(), pyClass, Collections.singletonList(new PyMethodMember(toOverride)), false);
    myFixture.checkResultByFile("override/" + getTestName(true) + "_after.py", true);
}
Also used : PyClass(com.jetbrains.python.psi.PyClass) PyFunction(com.jetbrains.python.psi.PyFunction) PyMethodMember(com.jetbrains.python.codeInsight.override.PyMethodMember)

Example 4 with PyMethodMember

use of com.jetbrains.python.codeInsight.override.PyMethodMember in project intellij-community by JetBrains.

the class PyOverrideTest method testImplement.

public void testImplement() {
    myFixture.configureByFile("override/" + getTestName(true) + ".py");
    PyFunction toImplement = getTopLevelClass(0).getMethods()[1];
    PyOverrideImplementUtil.overrideMethods(myFixture.getEditor(), getTopLevelClass(1), Collections.singletonList(new PyMethodMember(toImplement)), true);
    myFixture.checkResultByFile("override/" + getTestName(true) + "_after.py", true);
}
Also used : PyFunction(com.jetbrains.python.psi.PyFunction) PyMethodMember(com.jetbrains.python.codeInsight.override.PyMethodMember)

Example 5 with PyMethodMember

use of com.jetbrains.python.codeInsight.override.PyMethodMember in project intellij-community by JetBrains.

the class PyOverrideTest method testInstanceCheck.

// PY-10229
public void testInstanceCheck() {
    myFixture.configureByFile("override/" + getTestName(true) + ".py");
    final PyClass cls = getTopLevelClass(0);
    final PyFunction method = cls.findMethodByName("__instancecheck__", true, null);
    assertNotNull(method);
    PyOverrideImplementUtil.overrideMethods(myFixture.getEditor(), cls, Collections.singletonList(new PyMethodMember(method)), false);
    myFixture.checkResultByFile("override/" + getTestName(true) + "_after.py", true);
}
Also used : PyClass(com.jetbrains.python.psi.PyClass) PyFunction(com.jetbrains.python.psi.PyFunction) PyMethodMember(com.jetbrains.python.codeInsight.override.PyMethodMember)

Aggregations

PyMethodMember (com.jetbrains.python.codeInsight.override.PyMethodMember)7 PyFunction (com.jetbrains.python.psi.PyFunction)7 PyClass (com.jetbrains.python.psi.PyClass)5 Editor (com.intellij.openapi.editor.Editor)1 PsiElement (com.intellij.psi.PsiElement)1 ArrayList (java.util.ArrayList)1