mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Revert "[python] PY-86493 Pyrefly: Support type resolver"
This reverts commit 890c86d623905493063823b4bc03b6153069e0c1. GitOrigin-RevId: aa943156ae095da9a9c87f8dfce960596981f183
This commit is contained in:
committed by
intellij-monorepo-bot
parent
fd0d92120e
commit
4bf819f89f
@@ -25,7 +25,6 @@ jvm_library(
|
||||
"//python/python-syntax-core:syntax-core",
|
||||
"@lib//:kotlin-stdlib",
|
||||
"@lib//:jetbrains-kotlin-annotations-jvm",
|
||||
"//platform/editor-ui-api:editor-ui",
|
||||
],
|
||||
exports = [
|
||||
"//python/python-parser:parser",
|
||||
|
||||
@@ -21,6 +21,5 @@
|
||||
<orderEntry type="library" name="kotlin-stdlib" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.backend" scope="RUNTIME" />
|
||||
<orderEntry type="library" name="jetbrains.kotlin.annotations.jvm" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.editor.ui" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -42,7 +42,7 @@
|
||||
interface="com.jetbrains.python.documentation.PythonDocumentationQuickInfoProvider"
|
||||
dynamic="true"/>
|
||||
<extensionPoint qualifiedName="Pythonid.typeEvalExternalTypeProvider"
|
||||
interface="com.jetbrains.python.psi.types.external.ExternalPyTypeResolverProvider"
|
||||
interface="com.jetbrains.python.psi.types.TypeEvalExternalTypeProvider"
|
||||
dynamic="true"/>
|
||||
</extensionPoints>
|
||||
</idea-plugin>
|
||||
|
||||
@@ -4,7 +4,4 @@ package com.jetbrains.python.psi
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
@ApiStatus.Internal
|
||||
/**
|
||||
* Does not require [com.jetbrains.python.psi.types.TypeEvalContext] for resolving the type
|
||||
*/
|
||||
interface PyInstantTypeProvider : PyTypedElement
|
||||
@@ -1,11 +0,0 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.jetbrains.python.psi
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
@ApiStatus.Internal
|
||||
/**
|
||||
* Fast wrapper for another element type.
|
||||
* These elements can be easily calculated if a type of wrapped element is known.
|
||||
*/
|
||||
interface PyWrapperTypeProvider : PyTypedElement
|
||||
@@ -2,11 +2,11 @@
|
||||
package com.jetbrains.python.psi.types;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.RecursionManager;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -19,8 +19,6 @@ import com.jetbrains.python.psi.*;
|
||||
import com.jetbrains.python.psi.impl.PyTypeProvider;
|
||||
import com.jetbrains.python.psi.resolve.PyResolveContext;
|
||||
import com.jetbrains.python.psi.resolve.RatedResolveResult;
|
||||
import com.jetbrains.python.psi.types.external.ExternalPyTypeResolver;
|
||||
import com.jetbrains.python.psi.types.external.ExternalPyTypeResolverProvider;
|
||||
import com.jetbrains.python.pyi.PyiLanguageDialect;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -55,8 +53,8 @@ public sealed class TypeEvalContext {
|
||||
|
||||
private final ThreadLocal<ProcessingContext> myProcessingContext = ThreadLocal.withInitial(ProcessingContext::new);
|
||||
|
||||
private Ref<ExternalPyTypeResolver> externalTypeResolver = null;
|
||||
protected final Map<PyTypedElement, PyType> myEvaluated = getConcurrentMapForCaching();
|
||||
protected final Map<PyTypedElement, PyType> myExternalEvaluated = getConcurrentMapForCaching();
|
||||
protected final Map<PyCallable, PyType> myEvaluatedReturn = getConcurrentMapForCaching();
|
||||
protected final Map<Pair<PyExpression, Object>, PyType> contextTypeCache = getConcurrentMapForCaching();
|
||||
|
||||
@@ -222,7 +220,7 @@ public sealed class TypeEvalContext {
|
||||
return null;
|
||||
}
|
||||
AssumptionContext context = new AssumptionContext(this, element, type);
|
||||
R result;
|
||||
R result = null;
|
||||
try {
|
||||
result = func.apply(context);
|
||||
}
|
||||
@@ -251,7 +249,11 @@ public sealed class TypeEvalContext {
|
||||
assertValid(cachedType, element);
|
||||
return cachedType;
|
||||
}
|
||||
|
||||
final PyType cachedExternalType = myExternalEvaluated.get(element);
|
||||
if (cachedExternalType != null) {
|
||||
assertValid(cachedExternalType, element);
|
||||
return cachedExternalType;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -264,6 +266,11 @@ public sealed class TypeEvalContext {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public void putExternalType(PyTypedElement element, PyType type) {
|
||||
myExternalEvaluated.put(element, type == null ? PyNullType.INSTANCE : type);
|
||||
}
|
||||
|
||||
private static boolean isLibraryElement(@NotNull PsiElement element) {
|
||||
PsiFile containingFile = element.getContainingFile();
|
||||
VirtualFile vFile = containingFile == null ? null : containingFile.getOriginalFile().getVirtualFile();
|
||||
@@ -298,28 +305,29 @@ public sealed class TypeEvalContext {
|
||||
if (knownType != null) {
|
||||
return knownType == PyNullType.INSTANCE ? null : knownType;
|
||||
}
|
||||
|
||||
PsiFile file = element.getContainingFile();
|
||||
|
||||
//lateinit because there is no project for this class
|
||||
if (file != null && externalTypeResolver == null) {
|
||||
externalTypeResolver = Ref.create(ExternalPyTypeResolverProvider.createTypeResolver(file.getProject()));
|
||||
}
|
||||
|
||||
return RecursionManager.doPreventingRecursion(
|
||||
Pair.create(element, this),
|
||||
false,
|
||||
() -> {
|
||||
ExternalPyTypeResolver externalPyTypeResolver = externalTypeResolver.get();
|
||||
PyType type;
|
||||
|
||||
if (externalPyTypeResolver != null && externalPyTypeResolver.isSupportedForResolve(element)) {
|
||||
type = externalPyTypeResolver.resolveType(element, this, this instanceof LibraryTypeEvalContext);
|
||||
}
|
||||
else {
|
||||
type = element.getType(this, Key.INSTANCE);
|
||||
// Try external providers first
|
||||
for (var provider : TypeEvalExternalTypeProvider.EP_NAME.getExtensionList()) {
|
||||
try {
|
||||
var provided = provider.provideType(element, this);
|
||||
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 " + provider.getClass().getName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
PyType type = element.getType(this, Key.INSTANCE);
|
||||
assertValid(type, element);
|
||||
myEvaluated.put(element, type == null ? PyNullType.INSTANCE : type);
|
||||
return type;
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.jetbrains.python.psi.types
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName
|
||||
import com.intellij.openapi.util.Ref
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.jetbrains.python.psi.PyTypedElement
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
interface TypeEvalExternalTypeProvider {
|
||||
fun provideType(element: PyTypedElement, context: TypeEvalContext): Ref<PyType?>?
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val EP_NAME: ExtensionPointName<TypeEvalExternalTypeProvider> =
|
||||
ExtensionPointName.create("Pythonid.typeEvalExternalTypeProvider")
|
||||
}
|
||||
}
|
||||
Vendored
-13
@@ -1,13 +0,0 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.jetbrains.python.psi.types.external
|
||||
|
||||
import com.jetbrains.python.psi.PyTypedElement
|
||||
import com.jetbrains.python.psi.types.PyType
|
||||
import com.jetbrains.python.psi.types.TypeEvalContext
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
@ApiStatus.Internal
|
||||
interface ExternalPyTypeResolver {
|
||||
fun isSupportedForResolve(pyTypedElement: PyTypedElement): Boolean
|
||||
fun resolveType(pyTypedElement: PyTypedElement, evalContext: TypeEvalContext, isLibrary: Boolean): PyType?
|
||||
}
|
||||
Vendored
-26
@@ -1,26 +0,0 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.jetbrains.python.psi.types.external
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
/**
|
||||
* An external type provider invoked by [com.jetbrains.python.psi.types.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 ExternalPyTypeResolverProvider {
|
||||
fun createResolver(project: Project): ExternalPyTypeResolver? = null
|
||||
|
||||
companion object {
|
||||
private val EP_NAME: ExtensionPointName<ExternalPyTypeResolverProvider> =
|
||||
ExtensionPointName.Companion.create("Pythonid.typeEvalExternalTypeProvider")
|
||||
|
||||
@JvmStatic
|
||||
@ApiStatus.Internal
|
||||
fun createTypeResolver(project: Project): ExternalPyTypeResolver? {
|
||||
return EP_NAME.extensionList.firstNotNullOfOrNull { it.createResolver(project) }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -343,9 +343,4 @@ public final class PyCustomType implements PyClassLikeType {
|
||||
return myFilter.process(pyElement);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PyCustomType: " + getName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,13 +3,12 @@ package com.jetbrains.python.psi.impl;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.jetbrains.python.psi.PyAsPattern;
|
||||
import com.jetbrains.python.psi.PyElementVisitor;
|
||||
import com.jetbrains.python.psi.PyWrapperTypeProvider;
|
||||
import com.jetbrains.python.psi.types.PyType;
|
||||
import com.jetbrains.python.psi.types.TypeEvalContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class PyAsPatternImpl extends PyElementImpl implements PyAsPattern, PyWrapperTypeProvider {
|
||||
public class PyAsPatternImpl extends PyElementImpl implements PyAsPattern {
|
||||
public PyAsPatternImpl(ASTNode astNode) {
|
||||
super(astNode);
|
||||
}
|
||||
|
||||
+1
-2
@@ -5,7 +5,6 @@ import com.intellij.lang.ASTNode;
|
||||
import com.jetbrains.python.psi.PyAssignmentExpression;
|
||||
import com.jetbrains.python.psi.PyElementVisitor;
|
||||
import com.jetbrains.python.psi.PyTargetExpression;
|
||||
import com.jetbrains.python.psi.PyWrapperTypeProvider;
|
||||
import com.jetbrains.python.psi.types.PyType;
|
||||
import com.jetbrains.python.psi.types.TypeEvalContext;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -13,7 +12,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public class PyAssignmentExpressionImpl extends PyElementImpl implements PyAssignmentExpression, PyWrapperTypeProvider {
|
||||
public class PyAssignmentExpressionImpl extends PyElementImpl implements PyAssignmentExpression {
|
||||
|
||||
public PyAssignmentExpressionImpl(@NotNull ASTNode astNode) {
|
||||
super(astNode);
|
||||
|
||||
@@ -65,7 +65,7 @@ import static com.jetbrains.python.psi.impl.PyDeprecationUtilKt.extractDeprecati
|
||||
import static java.util.Collections.emptySet;
|
||||
|
||||
|
||||
public class PyClassImpl extends PyBaseElementImpl<PyClassStub> implements PyClass, PyInstantTypeProvider {
|
||||
public class PyClassImpl extends PyBaseElementImpl<PyClassStub> implements PyClass {
|
||||
public static class MROException extends Exception {
|
||||
public MROException(String s) {
|
||||
super(s);
|
||||
|
||||
+1
-2
@@ -5,14 +5,13 @@ import com.intellij.lang.ASTNode;
|
||||
import com.jetbrains.python.psi.PyConditionalExpression;
|
||||
import com.jetbrains.python.psi.PyElementVisitor;
|
||||
import com.jetbrains.python.psi.PyExpression;
|
||||
import com.jetbrains.python.psi.PyWrapperTypeProvider;
|
||||
import com.jetbrains.python.psi.types.PyType;
|
||||
import com.jetbrains.python.psi.types.PyUnionType;
|
||||
import com.jetbrains.python.psi.types.TypeEvalContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
public class PyConditionalExpressionImpl extends PyElementImpl implements PyConditionalExpression, PyWrapperTypeProvider {
|
||||
public class PyConditionalExpressionImpl extends PyElementImpl implements PyConditionalExpression {
|
||||
public PyConditionalExpressionImpl(ASTNode astNode) {
|
||||
super(astNode);
|
||||
}
|
||||
|
||||
+5
-2
@@ -3,14 +3,17 @@ package com.jetbrains.python.psi.impl;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.jetbrains.python.psi.*;
|
||||
import com.jetbrains.python.psi.PyDictCompExpression;
|
||||
import com.jetbrains.python.psi.PyElementVisitor;
|
||||
import com.jetbrains.python.psi.PyExpression;
|
||||
import com.jetbrains.python.psi.PyKeyValueExpression;
|
||||
import com.jetbrains.python.psi.types.PyCollectionTypeImpl;
|
||||
import com.jetbrains.python.psi.types.PyType;
|
||||
import com.jetbrains.python.psi.types.TypeEvalContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
public class PyDictCompExpressionImpl extends PyComprehensionElementImpl implements PyDictCompExpression, PyWrapperTypeProvider {
|
||||
public class PyDictCompExpressionImpl extends PyComprehensionElementImpl implements PyDictCompExpression {
|
||||
public PyDictCompExpressionImpl(ASTNode astNode) {
|
||||
super(astNode);
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ import java.lang.ref.SoftReference;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression, PyInstantTypeProvider {
|
||||
public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression {
|
||||
protected volatile @Nullable PyType myType;
|
||||
|
||||
//private volatile Boolean myAbsoluteImportEnabled;
|
||||
|
||||
+1
-2
@@ -20,14 +20,13 @@ import com.jetbrains.python.codeInsight.typing.PyTypingTypeProvider;
|
||||
import com.jetbrains.python.psi.PyElementVisitor;
|
||||
import com.jetbrains.python.psi.PyExpression;
|
||||
import com.jetbrains.python.psi.PyGeneratorExpression;
|
||||
import com.jetbrains.python.psi.PyWrapperTypeProvider;
|
||||
import com.jetbrains.python.psi.types.PyType;
|
||||
import com.jetbrains.python.psi.types.TypeEvalContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
||||
public class PyGeneratorExpressionImpl extends PyComprehensionElementImpl implements PyGeneratorExpression, PyWrapperTypeProvider {
|
||||
public class PyGeneratorExpressionImpl extends PyComprehensionElementImpl implements PyGeneratorExpression {
|
||||
public PyGeneratorExpressionImpl(ASTNode astNode) {
|
||||
super(astNode);
|
||||
}
|
||||
|
||||
@@ -3,13 +3,12 @@ package com.jetbrains.python.psi.impl;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.jetbrains.python.psi.PyElementVisitor;
|
||||
import com.jetbrains.python.psi.PyGroupPattern;
|
||||
import com.jetbrains.python.psi.PyWrapperTypeProvider;
|
||||
import com.jetbrains.python.psi.types.PyType;
|
||||
import com.jetbrains.python.psi.types.TypeEvalContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class PyGroupPatternImpl extends PyElementImpl implements PyGroupPattern, PyWrapperTypeProvider {
|
||||
public class PyGroupPatternImpl extends PyElementImpl implements PyGroupPattern {
|
||||
public PyGroupPatternImpl(ASTNode astNode) {
|
||||
super(astNode);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,10 @@ import com.intellij.psi.impl.light.LightElement;
|
||||
import com.intellij.psi.util.QualifiedName;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.jetbrains.python.PythonLanguage;
|
||||
import com.jetbrains.python.psi.*;
|
||||
import com.jetbrains.python.psi.PyFile;
|
||||
import com.jetbrains.python.psi.PyImportElement;
|
||||
import com.jetbrains.python.psi.PyTypedElement;
|
||||
import com.jetbrains.python.psi.PyUtil;
|
||||
import com.jetbrains.python.psi.resolve.RatedResolveResult;
|
||||
import com.jetbrains.python.psi.resolve.ResolveImportUtil;
|
||||
import com.jetbrains.python.psi.types.PyImportedModuleType;
|
||||
@@ -35,7 +38,7 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
public class PyImportedModule extends LightElement implements PyTypedElement, PyInstantTypeProvider {
|
||||
public class PyImportedModule extends LightElement implements PyTypedElement {
|
||||
private final @Nullable PyImportElement myImportElement;
|
||||
private final @NotNull PyFile myContainingFile;
|
||||
private final @NotNull QualifiedName myImportedPrefix;
|
||||
|
||||
+1
-2
@@ -5,7 +5,6 @@ import com.intellij.lang.ASTNode;
|
||||
import com.jetbrains.python.psi.PyElementVisitor;
|
||||
import com.jetbrains.python.psi.PyExpression;
|
||||
import com.jetbrains.python.psi.PyKeyValueExpression;
|
||||
import com.jetbrains.python.psi.PyWrapperTypeProvider;
|
||||
import com.jetbrains.python.psi.types.PyTupleType;
|
||||
import com.jetbrains.python.psi.types.PyType;
|
||||
import com.jetbrains.python.psi.types.TypeEvalContext;
|
||||
@@ -14,7 +13,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.Arrays;
|
||||
|
||||
|
||||
public class PyKeyValueExpressionImpl extends PyElementImpl implements PyKeyValueExpression, PyWrapperTypeProvider {
|
||||
public class PyKeyValueExpressionImpl extends PyElementImpl implements PyKeyValueExpression {
|
||||
public PyKeyValueExpressionImpl(ASTNode astNode) {
|
||||
super(astNode);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
public class PyKeywordArgumentImpl extends PyElementImpl implements PyKeywordArgument, PyWrapperTypeProvider {
|
||||
public class PyKeywordArgumentImpl extends PyElementImpl implements PyKeywordArgument {
|
||||
public PyKeywordArgumentImpl(ASTNode astNode) {
|
||||
super(astNode);
|
||||
}
|
||||
|
||||
@@ -5,14 +5,13 @@ import com.intellij.psi.PsiReference;
|
||||
import com.jetbrains.python.psi.PyElementVisitor;
|
||||
import com.jetbrains.python.psi.PyKeywordPattern;
|
||||
import com.jetbrains.python.psi.PyPattern;
|
||||
import com.jetbrains.python.psi.PyWrapperTypeProvider;
|
||||
import com.jetbrains.python.psi.impl.references.PyKeywordPatternReference;
|
||||
import com.jetbrains.python.psi.types.PyType;
|
||||
import com.jetbrains.python.psi.types.TypeEvalContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class PyKeywordPatternImpl extends PyElementImpl implements PyKeywordPattern, PyWrapperTypeProvider {
|
||||
public class PyKeywordPatternImpl extends PyElementImpl implements PyKeywordPattern {
|
||||
public PyKeywordPatternImpl(ASTNode astNode) {
|
||||
super(astNode);
|
||||
}
|
||||
|
||||
+5
-2
@@ -16,7 +16,10 @@
|
||||
package com.jetbrains.python.psi.impl;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.jetbrains.python.psi.*;
|
||||
import com.jetbrains.python.psi.PyClass;
|
||||
import com.jetbrains.python.psi.PyElementVisitor;
|
||||
import com.jetbrains.python.psi.PyExpression;
|
||||
import com.jetbrains.python.psi.PyListCompExpression;
|
||||
import com.jetbrains.python.psi.types.PyCollectionTypeImpl;
|
||||
import com.jetbrains.python.psi.types.PyType;
|
||||
import com.jetbrains.python.psi.types.TypeEvalContext;
|
||||
@@ -26,7 +29,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.Collections;
|
||||
|
||||
|
||||
public class PyListCompExpressionImpl extends PyComprehensionElementImpl implements PyListCompExpression, PyWrapperTypeProvider {
|
||||
public class PyListCompExpressionImpl extends PyComprehensionElementImpl implements PyListCompExpression {
|
||||
public PyListCompExpressionImpl(ASTNode astNode) {
|
||||
super(astNode);
|
||||
}
|
||||
|
||||
@@ -8,8 +8,7 @@ import com.jetbrains.python.psi.impl.PyBuiltinCache.Companion.getInstance
|
||||
import com.jetbrains.python.psi.types.*
|
||||
import com.jetbrains.python.psi.types.PyLiteralType.Companion.upcastLiteralToClass
|
||||
|
||||
class PyMappingPatternImpl(astNode: ASTNode?) : PyElementImpl(astNode), PyMappingPattern, PyCaptureContext, PsiListLikeElement,
|
||||
PyWrapperTypeProvider {
|
||||
class PyMappingPatternImpl(astNode: ASTNode?) : PyElementImpl(astNode), PyMappingPattern, PyCaptureContext, PsiListLikeElement {
|
||||
override fun acceptPyVisitor(pyVisitor: PyElementVisitor) {
|
||||
pyVisitor.visitPyMappingPattern(this)
|
||||
}
|
||||
|
||||
@@ -4,14 +4,13 @@ import com.intellij.lang.ASTNode;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.jetbrains.python.psi.PyElementVisitor;
|
||||
import com.jetbrains.python.psi.PyOrPattern;
|
||||
import com.jetbrains.python.psi.PyWrapperTypeProvider;
|
||||
import com.jetbrains.python.psi.types.PyType;
|
||||
import com.jetbrains.python.psi.types.PyUnionType;
|
||||
import com.jetbrains.python.psi.types.TypeEvalContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class PyOrPatternImpl extends PyElementImpl implements PyOrPattern, PyWrapperTypeProvider {
|
||||
public class PyOrPatternImpl extends PyElementImpl implements PyOrPattern {
|
||||
public PyOrPatternImpl(ASTNode astNode) {
|
||||
super(astNode);
|
||||
}
|
||||
|
||||
+1
-2
@@ -5,13 +5,12 @@ import com.intellij.lang.ASTNode;
|
||||
import com.jetbrains.python.psi.PyElementVisitor;
|
||||
import com.jetbrains.python.psi.PyExpression;
|
||||
import com.jetbrains.python.psi.PyParenthesizedExpression;
|
||||
import com.jetbrains.python.psi.PyWrapperTypeProvider;
|
||||
import com.jetbrains.python.psi.types.PyType;
|
||||
import com.jetbrains.python.psi.types.TypeEvalContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
public class PyParenthesizedExpressionImpl extends PyElementImpl implements PyParenthesizedExpression, PyWrapperTypeProvider {
|
||||
public class PyParenthesizedExpressionImpl extends PyElementImpl implements PyParenthesizedExpression {
|
||||
public PyParenthesizedExpressionImpl(ASTNode astNode) {
|
||||
super(astNode);
|
||||
}
|
||||
|
||||
+1
-2
@@ -4,7 +4,6 @@ package com.jetbrains.python.psi.impl;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.jetbrains.python.psi.PyElementVisitor;
|
||||
import com.jetbrains.python.psi.PySetCompExpression;
|
||||
import com.jetbrains.python.psi.PyWrapperTypeProvider;
|
||||
import com.jetbrains.python.psi.types.PyCollectionTypeImpl;
|
||||
import com.jetbrains.python.psi.types.PyType;
|
||||
import com.jetbrains.python.psi.types.TypeEvalContext;
|
||||
@@ -13,7 +12,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.Collections;
|
||||
|
||||
|
||||
public class PySetCompExpressionImpl extends PyComprehensionElementImpl implements PySetCompExpression, PyWrapperTypeProvider {
|
||||
public class PySetCompExpressionImpl extends PyComprehensionElementImpl implements PySetCompExpression {
|
||||
public PySetCompExpressionImpl(ASTNode astNode) {
|
||||
super(astNode);
|
||||
}
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ import javax.swing.*;
|
||||
import java.util.List;
|
||||
|
||||
public class PyStringLiteralExpressionImpl extends PyElementImpl
|
||||
implements PyStringLiteralExpression, PsiLiteralValue, ContributedReferenceHost, PyInstantTypeProvider {
|
||||
implements PyStringLiteralExpression, PsiLiteralValue, ContributedReferenceHost {
|
||||
|
||||
private volatile @Nullable String myStringValue;
|
||||
private volatile @Nullable List<TextRange> myValueTextRanges;
|
||||
|
||||
@@ -10,7 +10,7 @@ import com.jetbrains.python.psi.types.TypeEvalContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
public class PyTupleExpressionImpl extends PySequenceExpressionImpl implements PyTupleExpression, PyWrapperTypeProvider {
|
||||
public class PyTupleExpressionImpl extends PySequenceExpressionImpl implements PyTupleExpression {
|
||||
public PyTupleExpressionImpl(ASTNode astNode) {
|
||||
super(astNode);
|
||||
}
|
||||
|
||||
+1
-2
@@ -16,8 +16,7 @@ import com.jetbrains.python.psi.types.TypeEvalContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class PyTypeAliasStatementImpl extends PyBaseElementImpl<PyTypeAliasStatementStub>
|
||||
implements PyTypeAliasStatement, PyInstantTypeProvider {
|
||||
public class PyTypeAliasStatementImpl extends PyBaseElementImpl<PyTypeAliasStatementStub> implements PyTypeAliasStatement {
|
||||
public PyTypeAliasStatementImpl(ASTNode astNode) {
|
||||
super(astNode);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import com.jetbrains.python.psi.types.TypeEvalContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class PyTypeParameterImpl extends PyBaseElementImpl<PyTypeParameterStub> implements PyTypeParameter, PyInstantTypeProvider {
|
||||
public class PyTypeParameterImpl extends PyBaseElementImpl<PyTypeParameterStub> implements PyTypeParameter {
|
||||
|
||||
public PyTypeParameterImpl(ASTNode astNode) {
|
||||
super(astNode);
|
||||
|
||||
@@ -3,14 +3,13 @@ package com.jetbrains.python.psi.impl;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.jetbrains.python.psi.PyElementVisitor;
|
||||
import com.jetbrains.python.psi.PyValuePattern;
|
||||
import com.jetbrains.python.psi.PyWrapperTypeProvider;
|
||||
import com.jetbrains.python.psi.types.PyLiteralType;
|
||||
import com.jetbrains.python.psi.types.PyType;
|
||||
import com.jetbrains.python.psi.types.TypeEvalContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class PyValuePatternImpl extends PyElementImpl implements PyValuePattern, PyWrapperTypeProvider {
|
||||
public class PyValuePatternImpl extends PyElementImpl implements PyValuePattern {
|
||||
public PyValuePatternImpl(ASTNode astNode) {
|
||||
super(astNode);
|
||||
}
|
||||
|
||||
@@ -93,11 +93,6 @@ public class PyCallableTypeImpl implements PyCallableType {
|
||||
return delegate != null ? delegate.getCompletionVariants(completionPrefix, location, context) : ArrayUtilRt.EMPTY_OBJECT_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PyCallableType: " + getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String getName() {
|
||||
final TypeEvalContext context = TypeEvalContext.codeInsightFallback(null);
|
||||
|
||||
@@ -113,11 +113,6 @@ public class PyFunctionTypeImpl implements PyFunctionType {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PyFunctionType";
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T acceptTypeVisitor(@NotNull PyTypeVisitor<T> visitor) {
|
||||
return visitor.visitPyFunctionType(this);
|
||||
|
||||
@@ -52,10 +52,6 @@ public class PyModuleType implements PyType { // Modules don't descend from obje
|
||||
myQualifiedName = LazyInitializer.create(() -> QualifiedNameFinder.findShortestImportableQName(myModule));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PyModuleType(" + myModule.getName() + ")";
|
||||
}
|
||||
|
||||
public @NotNull PyFile getModule() {
|
||||
return myModule;
|
||||
@@ -587,7 +583,7 @@ public class PyModuleType implements PyType { // Modules don't descend from obje
|
||||
@Override
|
||||
public void assertValid(String message) {
|
||||
if (!myModule.isValid()) {
|
||||
throw new PsiInvalidElementAccessException(myModule, myModule.getClass() + ": " + message);
|
||||
throw new PsiInvalidElementAccessException(myModule, myModule.getClass().toString() + ": " + message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -120,11 +120,6 @@ public class PyTupleType extends PyClassTypeImpl implements PyCollectionType {
|
||||
return PyUnionType.unionOrNever(unpackedTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PyTupleType: " + getName();
|
||||
}
|
||||
|
||||
public @NotNull PyUnpackedTupleType asUnpackedTupleType() {
|
||||
return myUnpackedTupleType;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user