mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 09:19:13 +07:00
colon is a tail type, not part of the lookup text (PY-2652)
This commit is contained in:
+4
-2
@@ -1,8 +1,10 @@
|
||||
package com.jetbrains.python.codeInsight;
|
||||
|
||||
import com.intellij.codeInsight.TailType;
|
||||
import com.intellij.codeInsight.completion.*;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.codeInsight.lookup.LookupElementBuilder;
|
||||
import com.intellij.codeInsight.lookup.TailTypeDecorator;
|
||||
import com.intellij.psi.filters.position.FilterPattern;
|
||||
import com.intellij.util.ProcessingContext;
|
||||
import com.jetbrains.python.PyIcons;
|
||||
@@ -53,12 +55,12 @@ public class PySpecialMethodNamesCompletionContributor extends PySeeingOriginalC
|
||||
for (Map.Entry<String, PyNames.BuiltinDescription> entry: PyNames.BuiltinMethods.entrySet()) {
|
||||
LookupElementBuilder item;
|
||||
item = LookupElementBuilder
|
||||
.create(entry.getKey() + entry.getValue().getSignature() + ":")
|
||||
.create(entry.getKey() + entry.getValue().getSignature())
|
||||
.setBold()
|
||||
.setTypeText("predefined")
|
||||
.setIcon(PyIcons.PREDEFINED)
|
||||
;
|
||||
result.addElement(item);
|
||||
result.addElement(TailTypeDecorator.withTail(item, TailType.CASE_COLON));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.jetbrains.python.codeInsight;
|
||||
|
||||
import com.intellij.codeInsight.TailType;
|
||||
import com.intellij.codeInsight.completion.*;
|
||||
import com.intellij.codeInsight.lookup.LookupElementBuilder;
|
||||
import com.intellij.codeInsight.lookup.TailTypeDecorator;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiWhiteSpace;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
@@ -44,7 +46,9 @@ public class PySuperMethodCompletionContributor extends CompletionContributor {
|
||||
for (PyClass ancestor : containingClass.iterateAncestorClasses()) {
|
||||
for (PyFunction superMethod : ancestor.getMethods()) {
|
||||
if (!seenNames.contains(superMethod.getName())) {
|
||||
result.addElement(LookupElementBuilder.create(superMethod.getName() + superMethod.getParameterList().getText() + ":"));
|
||||
String text = superMethod.getName() + superMethod.getParameterList().getText();
|
||||
LookupElementBuilder element = LookupElementBuilder.create(text);
|
||||
result.addElement(TailTypeDecorator.withTail(element, TailType.CASE_COLON));
|
||||
seenNames.add(superMethod.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
class C:
|
||||
def __init__(self):
|
||||
@@ -0,0 +1,2 @@
|
||||
class C:
|
||||
def __ini<caret>:
|
||||
@@ -388,4 +388,8 @@ public class PythonCompletionTest extends PyLightFixtureTestCase {
|
||||
public void testAlias() { // PY-3672
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testDuplicateColon() { // PY-2652
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user