mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-53200 do not autocomplete parameter list if method already have one
Test for PY-53200 Better tests for PY-53200 PY-53200 Removed unnecessary test. `testMethodNamesDoNotDuplicateParameterList` renamed and moved closer to the corresponding ones Removed test for method names in suggestions restored GitOrigin-RevId: 51b0721190718c44810c16e198bad583c2af67d0
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b2c836a40c
commit
fb11ee327c
@@ -335,6 +335,11 @@ public abstract class PythonCommonCompletionTest extends PythonCommonTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-53200
|
||||
public void testSuperMethodWithExistingParameterList() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testLocalVarInDictKey() { // PY-2558
|
||||
doTest();
|
||||
}
|
||||
@@ -1880,6 +1885,16 @@ public abstract class PythonCommonCompletionTest extends PythonCommonTestCase {
|
||||
});
|
||||
}
|
||||
|
||||
// PY-53200
|
||||
public void testMethodNamesSuggestedWithoutParameterListIfItIsAlreadyExist() {
|
||||
myFixture.copyDirectoryToProject(getTestName(true), "");
|
||||
myFixture.configureByFile("a.py");
|
||||
myFixture.completeBasic();
|
||||
List<String> suggested = myFixture.getLookupElementStrings();
|
||||
assertNotNull(suggested);
|
||||
assertContainsElements(suggested, "something_a", "something_b");
|
||||
}
|
||||
|
||||
private void doTestHasattrContributor(String[] inList, String[] notInList) {
|
||||
doTestHasattrContributor("hasattrCompletion/" + getTestName(true) + ".py", inList, notInList);
|
||||
}
|
||||
|
||||
+17
-13
@@ -29,6 +29,7 @@ import com.jetbrains.python.PyTokenTypes;
|
||||
import com.jetbrains.python.psi.LanguageLevel;
|
||||
import com.jetbrains.python.psi.PyClass;
|
||||
import com.jetbrains.python.psi.PyFunction;
|
||||
import com.jetbrains.python.psi.PyParameterList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashSet;
|
||||
@@ -48,6 +49,7 @@ public class PySuperMethodCompletionContributor extends CompletionContributor im
|
||||
@NotNull CompletionResultSet result) {
|
||||
PsiElement position = parameters.getOriginalPosition();
|
||||
PyClass containingClass = PsiTreeUtil.getParentOfType(position, PyClass.class);
|
||||
PsiElement nextElement = position != null ? position.getNextSibling() : null;
|
||||
if (containingClass == null && position instanceof PsiWhiteSpace) {
|
||||
position = PsiTreeUtil.prevLeaf(position);
|
||||
containingClass = PsiTreeUtil.getParentOfType(position, PyClass.class);
|
||||
@@ -65,19 +67,21 @@ public class PySuperMethodCompletionContributor extends CompletionContributor im
|
||||
for (PyFunction superMethod : ancestor.getMethods()) {
|
||||
if (!seenNames.contains(superMethod.getName())) {
|
||||
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(":");
|
||||
builder.append(superMethod.getName());
|
||||
if (!(nextElement instanceof PyParameterList)) {
|
||||
builder.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(builder.toString());
|
||||
result.addElement(TailTypeDecorator.withTail(element, TailType.NONE));
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
class Me:
|
||||
def something_a(self):
|
||||
...
|
||||
|
||||
def something_b(self):
|
||||
...
|
||||
|
||||
class Stub(Me):
|
||||
def something_<caret>(self):
|
||||
...
|
||||
@@ -0,0 +1,7 @@
|
||||
class Me:
|
||||
def something_a(self):
|
||||
...
|
||||
|
||||
class Stub(Me):
|
||||
def something_a(self):
|
||||
...
|
||||
@@ -0,0 +1,7 @@
|
||||
class Me:
|
||||
def something_a(self):
|
||||
...
|
||||
|
||||
class Stub(Me):
|
||||
def something_<caret>(self):
|
||||
...
|
||||
Reference in New Issue
Block a user