mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 15:27:45 +07:00
Revert "PY-86493 do not send primitive types to the lsp engine"
This reverts commit 15a526455064e6e860e2a2009d3f4727021deec1. GitOrigin-RevId: b9ea4ef713b482ae0c348eefc73f8fdca7cd7c65
This commit is contained in:
committed by
intellij-monorepo-bot
parent
09718a1e14
commit
0cb218f2d3
@@ -297,10 +297,6 @@ 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());
|
||||
@@ -315,27 +311,25 @@ public sealed class TypeEvalContext {
|
||||
Pair.create(element, this),
|
||||
false,
|
||||
() -> {
|
||||
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);
|
||||
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;
|
||||
}
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.warn("Exception during external type provider " + externalTypeProvider.getClass().getName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
PyType type = element.getType(this, Key.INSTANCE);
|
||||
|
||||
-2
@@ -4,13 +4,11 @@ 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