mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
type comments are included in method completion
This commit is contained in:
committed by
Aleksei Kniazev
parent
dff84e5cf5
commit
b81cefd91f
@@ -65,12 +65,21 @@ public class PySuperMethodCompletionContributor extends CompletionContributor {
|
||||
for (PyClass ancestor : containingClass.getAncestorClasses(null)) {
|
||||
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();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(superMethod.getName())
|
||||
.append(superMethod.getParameterList().getText());
|
||||
if (superMethod.getAnnotation() != null) {
|
||||
builder.append(" ")
|
||||
.append(superMethod.getAnnotation().getText())
|
||||
.append(":");
|
||||
} else if (superMethod.getTypeComment() != null) {
|
||||
builder.append(": ")
|
||||
.append(superMethod.getTypeComment().getText());
|
||||
} else {
|
||||
builder.append(":");
|
||||
}
|
||||
LookupElementBuilder element = LookupElementBuilder.create(text);
|
||||
result.addElement(TailTypeDecorator.withTail(element, TailType.CASE_COLON));
|
||||
LookupElementBuilder element = LookupElementBuilder.create(builder.toString());
|
||||
result.addElement(TailTypeDecorator.withTail(element, TailType.NONE));
|
||||
seenNames.add(superMethod.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
from typing import Dict
|
||||
|
||||
class Parent:
|
||||
def overridable_method(param: str) -> Dict[str, str]:
|
||||
def overridable_method(self, param: str) -> Dict[str, str]:
|
||||
pass
|
||||
|
||||
|
||||
class Child(Parent):
|
||||
def overridable_method(param: str) -> Dict[str, str]:
|
||||
def overridable_method(self, param: str) -> Dict[str, str]:
|
||||
@@ -1,5 +1,7 @@
|
||||
from typing import Dict
|
||||
|
||||
class Parent:
|
||||
def overridable_method(param: str) -> Dict[str, str]:
|
||||
def overridable_method(self, param: str) -> Dict[str, str]:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
from typing import Dict
|
||||
|
||||
class Parent:
|
||||
def overridable_method(self,
|
||||
param # type: str
|
||||
): # type: (...) -> Dict[str, str]
|
||||
pass
|
||||
|
||||
|
||||
class Child(Parent):
|
||||
def overridable_method(self,
|
||||
param # type: str
|
||||
): # type: (...) -> Dict[str, str]
|
||||
@@ -0,0 +1,11 @@
|
||||
from typing import Dict
|
||||
|
||||
class Parent:
|
||||
def overridable_method(self,
|
||||
param # type: str
|
||||
): # type: (...) -> Dict[str, str]
|
||||
pass
|
||||
|
||||
|
||||
class Child(Parent):
|
||||
def over<caret>
|
||||
@@ -315,7 +315,11 @@ public class PythonCompletionTest extends PyTestCase {
|
||||
}
|
||||
|
||||
public void testSuperMethodWithAnnotation() {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON35, this::doTest);
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSuperMethodWithCommentAnnotation() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testLocalVarInDictKey() { // PY-2558
|
||||
|
||||
Reference in New Issue
Block a user