mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EA-404000 Fix NPE in case of unresolved class names in class patterns
GitOrigin-RevId: c1805f264367e026c22b12a714eb97b6acd8edec
This commit is contained in:
committed by
intellij-monorepo-bot
parent
a5d9ceb883
commit
4dbe727d87
+4
-5
@@ -13,9 +13,8 @@ import com.jetbrains.python.PythonCodeStyleService;
|
||||
import com.jetbrains.python.codeInsight.completion.OverwriteEqualsInsertHandler;
|
||||
import com.jetbrains.python.psi.*;
|
||||
import com.jetbrains.python.psi.resolve.PyResolveContext;
|
||||
import com.jetbrains.python.psi.types.PyClassLikeType;
|
||||
import com.jetbrains.python.psi.types.PyInstantiableType;
|
||||
import com.jetbrains.python.psi.types.PyType;
|
||||
import com.jetbrains.python.psi.types.PyTypeUtil;
|
||||
import com.jetbrains.python.psi.types.TypeEvalContext;
|
||||
import one.util.streamex.StreamEx;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -90,15 +89,15 @@ public final class PyKeywordPatternReference extends PsiReferenceBase.Poly<PyKey
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static PyType resolveToClassTypes(@NotNull PyClassPattern classPattern, @NotNull PyResolveContext resolveContext) {
|
||||
@NotNull
|
||||
private static List<PyClassLikeType> resolveToClassTypes(@NotNull PyClassPattern classPattern, @NotNull PyResolveContext resolveContext) {
|
||||
List<PsiElement> elements = PyUtil.multiResolveTopPriority(classPattern.getClassNameReference(), resolveContext);
|
||||
return StreamEx.of(elements)
|
||||
.select(PyClass.class)
|
||||
.map(e -> e.getType(resolveContext.getTypeEvalContext()))
|
||||
.nonNull()
|
||||
.map(PyInstantiableType::toInstance)
|
||||
.collect(PyTypeUtil.toUnion());
|
||||
.toList();
|
||||
}
|
||||
|
||||
private static class KeywordAttributeLookupDecorator extends LookupElementDecorator<LookupElement> {
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
match x:
|
||||
case MyClass(attr<caret>):
|
||||
pass
|
||||
@@ -616,6 +616,11 @@ public class Py3CompletionTest extends PyTestCase {
|
||||
doNegativeTest();
|
||||
}
|
||||
|
||||
// EA-404000
|
||||
public void testUnresolvedClassPatternLeadsToNothingSuggestedForKeywordPatterns() {
|
||||
doNegativeTest();
|
||||
}
|
||||
|
||||
// PY-48012
|
||||
public void testAttributesOfDataclassSuggestedForKeywordPatterns() {
|
||||
final String testName = getTestName(true);
|
||||
|
||||
Reference in New Issue
Block a user