mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-86493 do not send primitive types to the lsp engine
GitOrigin-RevId: 15a526455064e6e860e2a2009d3f4727021deec1
This commit is contained in:
committed by
intellij-monorepo-bot
parent
a639d540a2
commit
19f6212313
@@ -297,6 +297,10 @@ public sealed class TypeEvalContext {
|
||||
return Registry.is("python.use.separated.libraries.type.cache") && isLibraryElement(element);
|
||||
}
|
||||
|
||||
private static boolean isExternalTypeProviderApplicable(PyTypedElement element) {
|
||||
return element instanceof PyInstantTypeProvider;
|
||||
}
|
||||
|
||||
public @Nullable PyType getType(final @NotNull PyTypedElement element) {
|
||||
if (canDelegateToLibraryContext(element)) {
|
||||
var context = getLibraryContext(element.getProject());
|
||||
@@ -311,24 +315,26 @@ public sealed class TypeEvalContext {
|
||||
Pair.create(element, this),
|
||||
false,
|
||||
() -> {
|
||||
var externalTypeProvider =
|
||||
ContainerUtil.find(TypeEvalExternalTypeProvider.EP_NAME.getExtensionList(), TypeEvalExternalTypeProvider::isAvailable);
|
||||
if (!isInsideExternalTypeProviderCall && externalTypeProvider != null) {
|
||||
try {
|
||||
isInsideExternalTypeProviderCall = true;
|
||||
var provided = externalTypeProvider.provideType(element, this);
|
||||
isInsideExternalTypeProviderCall = false;
|
||||
if (provided != null) {
|
||||
var type = provided.get();
|
||||
myExternalEvaluated.put(element, type == null ? PyNullType.INSTANCE : type);
|
||||
return type;
|
||||
if (!isExternalTypeProviderApplicable(element) && !isInsideExternalTypeProviderCall) {
|
||||
var externalTypeProvider =
|
||||
ContainerUtil.find(TypeEvalExternalTypeProvider.EP_NAME.getExtensionList(), TypeEvalExternalTypeProvider::isAvailable);
|
||||
if (externalTypeProvider != null) {
|
||||
try {
|
||||
isInsideExternalTypeProviderCall = true;
|
||||
var provided = externalTypeProvider.provideType(element, this);
|
||||
isInsideExternalTypeProviderCall = false;
|
||||
if (provided != null) {
|
||||
var type = provided.get();
|
||||
myExternalEvaluated.put(element, type == null ? PyNullType.INSTANCE : type);
|
||||
return type;
|
||||
}
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.warn("Exception during external type provider " + externalTypeProvider.getClass().getName(), e);
|
||||
}
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.warn("Exception during external type provider " + externalTypeProvider.getClass().getName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -4,11 +4,13 @@ package com.jetbrains.python.psi.types
|
||||
import com.intellij.openapi.extensions.ExtensionPointName
|
||||
import com.intellij.openapi.util.Ref
|
||||
import com.jetbrains.python.psi.PyTypedElement
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
/**
|
||||
* An external type provider invoked by [TypeEvalContext] to obtain a type from a separate engine.
|
||||
* Implementations may return `null` if they cannot provide a type for the given element.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
interface TypeEvalExternalTypeProvider {
|
||||
fun isAvailable(): Boolean
|
||||
|
||||
|
||||
Reference in New Issue
Block a user