mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-21519 Re-enable proper completion in type comments
Since it's no longer clear under which circumstances the original problem for which the corresponding check was introduced occurred, and I wan't able to reproduce it, I revert it temporarily to see whether it's still worth keeping.
This commit is contained in:
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.jetbrains.python.codeInsight.typing;
|
||||
|
||||
import com.intellij.codeInsight.completion.CompletionUtil;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.lang.injection.MultiHostRegistrar;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
@@ -80,7 +79,7 @@ public class PyTypingAnnotationInjector extends PyInjectorBase {
|
||||
if (annotationText != null) {
|
||||
final int start = m.start(1);
|
||||
final int end = m.end(1);
|
||||
if (start < end && allowInjectionInComment(host)) {
|
||||
if (start < end) {
|
||||
final Language language;
|
||||
if ("ignore".equals(annotationText)) {
|
||||
language = null;
|
||||
@@ -111,10 +110,4 @@ public class PyTypingAnnotationInjector extends PyInjectorBase {
|
||||
private static boolean isTypingAnnotation(@NotNull String s) {
|
||||
return RE_TYPING_ANNOTATION.matcher(s).matches();
|
||||
}
|
||||
|
||||
private static boolean allowInjectionInComment(@NotNull PsiLanguageInjectionHost host) {
|
||||
// XXX: Don't inject PyDocstringLanguage during completion inside comments due to an exception related to finding ShredImpl's
|
||||
// hostElementPointer
|
||||
return CompletionUtil.getOriginalOrSelf(host) == host;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import typing
|
||||
|
||||
a = [] # type: typing.<caret>
|
||||
@@ -1136,6 +1136,13 @@ public class PythonCompletionTest extends PyTestCase {
|
||||
assertDoesntContain(suggested, "_T", "_KT");
|
||||
}
|
||||
|
||||
// PY-21519
|
||||
public void testTypeComment() {
|
||||
myFixture.copyFileToProject("../typing/typing.py");
|
||||
final List<String> variants = doTestByFile();
|
||||
assertContainsElements(variants, "List", "Union", "Optional");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return super.getTestDataPath() + "/completion";
|
||||
|
||||
Reference in New Issue
Block a user