added return type annotation completion for method overriding

This commit is contained in:
aleksei.kniazev
2019-02-28 18:06:50 +03:00
committed by Aleksei Kniazev
parent ba9e513e96
commit dff84e5cf5
4 changed files with 21 additions and 0 deletions
@@ -66,6 +66,9 @@ public class PySuperMethodCompletionContributor extends CompletionContributor {
for (PyFunction superMethod : ancestor.getMethods()) {
if (!seenNames.contains(superMethod.getName())) {
String text = superMethod.getName() + superMethod.getParameterList().getText();
if (languageLevel.isAtLeast(LanguageLevel.PYTHON35) && superMethod.getAnnotation() != null) {
text += " " + superMethod.getAnnotation().getText();
}
LookupElementBuilder element = LookupElementBuilder.create(text);
result.addElement(TailTypeDecorator.withTail(element, TailType.CASE_COLON));
seenNames.add(superMethod.getName());
@@ -0,0 +1,7 @@
class Parent:
def overridable_method(param: str) -> Dict[str, str]:
pass
class Child(Parent):
def overridable_method(param: str) -> Dict[str, str]:
@@ -0,0 +1,7 @@
class Parent:
def overridable_method(param: str) -> Dict[str, str]:
pass
class Child(Parent):
def over<caret>
@@ -314,6 +314,10 @@ public class PythonCompletionTest extends PyTestCase {
doTest();
}
public void testSuperMethodWithAnnotation() {
runWithLanguageLevel(LanguageLevel.PYTHON35, this::doTest);
}
public void testLocalVarInDictKey() { // PY-2558
doTest();
}