[python] get rid of IStubElementType and move logic about working with stubs to impl classes PY-61639

GitOrigin-RevId: 062dead109c25d944d4f61e901dc3c64c00b392e
This commit is contained in:
Vladimir Koshelev
2024-01-18 14:51:54 +01:00
committed by intellij-monorepo-bot
parent b1f1b8c8c0
commit aec2051aa9
54 changed files with 190 additions and 184 deletions

View File

@@ -2,32 +2,32 @@
package com.jetbrains.python;
import com.intellij.psi.stubs.IStubElementType;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.TokenSet;
import com.jetbrains.python.psi.*;
import static com.jetbrains.python.PyElementTypesFacade.Companion;
public interface PyElementTypes {
IStubElementType FUNCTION_DECLARATION = Companion.getINSTANCE().getFunctionDeclaration();
IStubElementType CLASS_DECLARATION = Companion.getINSTANCE().getClassDeclaration();
IStubElementType PARAMETER_LIST = Companion.getINSTANCE().getParameterList();
IStubElementType DECORATOR_LIST = Companion.getINSTANCE().getDecoratorList();
IStubElementType NAMED_PARAMETER = Companion.getINSTANCE().getNamedParameter();
IStubElementType TUPLE_PARAMETER = Companion.getINSTANCE().getTupleParameter();
IStubElementType SLASH_PARAMETER = Companion.getINSTANCE().getSlashParameter();
IStubElementType SINGLE_STAR_PARAMETER = Companion.getINSTANCE().getSingleStarParameter();
IStubElementType DECORATOR_CALL = Companion.getINSTANCE().getDecoratorCall();
IStubElementType IMPORT_ELEMENT = Companion.getINSTANCE().getImportElement();
IStubElementType ANNOTATION = Companion.getINSTANCE().getAnnotation();
IStubElementType STAR_IMPORT_ELEMENT = Companion.getINSTANCE().getStarImportElement();
IStubElementType EXCEPT_PART = Companion.getINSTANCE().getExceptPart();
IStubElementType FROM_IMPORT_STATEMENT = Companion.getINSTANCE().getFromImportStatement();
IStubElementType IMPORT_STATEMENT = Companion.getINSTANCE().getImportStatement();
IStubElementType TARGET_EXPRESSION = Companion.getINSTANCE().getTargetExpression();
IStubElementType TYPE_PARAMETER = Companion.getINSTANCE().getTypeParameter();
IStubElementType TYPE_PARAMETER_LIST = Companion.getINSTANCE().getTypeParameterList();
IStubElementType TYPE_ALIAS_STATEMENT = Companion.getINSTANCE().getTypeAliasStatement();
IElementType FUNCTION_DECLARATION = Companion.getINSTANCE().getFunctionDeclaration();
IElementType CLASS_DECLARATION = Companion.getINSTANCE().getClassDeclaration();
IElementType PARAMETER_LIST = Companion.getINSTANCE().getParameterList();
IElementType DECORATOR_LIST = Companion.getINSTANCE().getDecoratorList();
IElementType NAMED_PARAMETER = Companion.getINSTANCE().getNamedParameter();
IElementType TUPLE_PARAMETER = Companion.getINSTANCE().getTupleParameter();
IElementType SLASH_PARAMETER = Companion.getINSTANCE().getSlashParameter();
IElementType SINGLE_STAR_PARAMETER = Companion.getINSTANCE().getSingleStarParameter();
IElementType DECORATOR_CALL = Companion.getINSTANCE().getDecoratorCall();
IElementType IMPORT_ELEMENT = Companion.getINSTANCE().getImportElement();
IElementType ANNOTATION = Companion.getINSTANCE().getAnnotation();
IElementType STAR_IMPORT_ELEMENT = Companion.getINSTANCE().getStarImportElement();
IElementType EXCEPT_PART = Companion.getINSTANCE().getExceptPart();
IElementType FROM_IMPORT_STATEMENT = Companion.getINSTANCE().getFromImportStatement();
IElementType IMPORT_STATEMENT = Companion.getINSTANCE().getImportStatement();
IElementType TARGET_EXPRESSION = Companion.getINSTANCE().getTargetExpression();
IElementType TYPE_PARAMETER = Companion.getINSTANCE().getTypeParameter();
IElementType TYPE_PARAMETER_LIST = Companion.getINSTANCE().getTypeParameterList();
IElementType TYPE_ALIAS_STATEMENT = Companion.getINSTANCE().getTypeAliasStatement();
TokenSet PARAMETER_LIST_SET = TokenSet.create(PARAMETER_LIST);

View File

@@ -6,31 +6,35 @@ import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.components.service
import com.intellij.psi.PsiElement
import com.intellij.psi.stubs.IStubElementType
import com.intellij.psi.tree.IElementType
import com.jetbrains.python.psi.PyElementType
import java.util.function.Function
abstract class PyElementTypesFacade {
abstract val functionDeclaration: IStubElementType<*, *>
abstract val classDeclaration: IStubElementType<*, *>
abstract val parameterList: IStubElementType<*, *>
abstract val decoratorList: IStubElementType<*, *>
abstract val namedParameter: IStubElementType<*, *>
abstract val tupleParameter: IStubElementType<*, *>
abstract val slashParameter: IStubElementType<*, *>
abstract val singleStarParameter: IStubElementType<*, *>
abstract val decoratorCall: IStubElementType<*, *>
abstract val importElement: IStubElementType<*, *>
abstract val annotation: IStubElementType<*, *>
abstract val starImportElement: IStubElementType<*, *>
abstract val exceptPart: IStubElementType<*, *>
abstract val fromImportStatement: IStubElementType<*, *>
abstract val importStatement: IStubElementType<*, *>
abstract val targetExpression: IStubElementType<*, *>
abstract val typeParameter: IStubElementType<*, *>
abstract val typeParameterList: IStubElementType<*, *>
abstract val typeAliasStatement: IStubElementType<*, *>
// stubs on backend side
abstract val functionDeclaration: IElementType
abstract val classDeclaration: IElementType
abstract val parameterList: IElementType
abstract val decoratorList: IElementType
abstract val namedParameter: IElementType
abstract val tupleParameter: IElementType
abstract val slashParameter: IElementType
abstract val singleStarParameter: IElementType
abstract val decoratorCall: IElementType
abstract val importElement: IElementType
abstract val annotation: IElementType
abstract val starImportElement: IElementType
abstract val exceptPart: IElementType
abstract val fromImportStatement: IElementType
abstract val importStatement: IElementType
abstract val targetExpression: IElementType
abstract val typeParameter: IElementType
abstract val typeParameterList: IElementType
abstract val typeAliasStatement: IElementType
// constructors for non-stub elements
abstract val argumentListConstructor: Function<in ASTNode, out PsiElement>
abstract val printTargetConstructor: Function<in ASTNode, out PsiElement>
abstract val decoratorConstructor: Function<in ASTNode, out PsiElement>