mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-28 23:39:57 +07:00
PY-87791 type engine: fix callable parameter representation type
(cherry picked from commit 7cbc0c26a00a260f8ac9ce4c3ddf18e999e5114e) IJ-MR-192392 GitOrigin-RevId: 65b3919f8073254dad6a631bc5326ae4ad99f6c5
This commit is contained in:
committed by
intellij-monorepo-bot
parent
efa90148b5
commit
13fceb92ce
+1
-2
@@ -132,9 +132,8 @@ class PyFunctionTypeRepresentation(astNode: ASTNode) : PyElementImpl(astNode), P
|
||||
when (param) {
|
||||
is PySlashParameter -> PyCallableParameterImpl.psi(param)
|
||||
is PyNamedParameterTypeRepresentation -> {
|
||||
val paramName = param.parameterName
|
||||
val paramType = param.typeExpression?.let { resolveTypeExpression(it, context, typeVarMap) }
|
||||
PyCallableParameterImpl.nonPsi(paramName, paramType, param.defaultValue)
|
||||
PyCallableParameterImpl.psi(param, paramType)
|
||||
}
|
||||
is PyStarExpression -> {
|
||||
// *args parameter
|
||||
|
||||
+2
-19
@@ -16,31 +16,14 @@
|
||||
package com.jetbrains.python.codeInsight.typeRepresentation.psi
|
||||
|
||||
import com.intellij.lang.ASTNode
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.jetbrains.python.PyTokenTypes
|
||||
import com.jetbrains.python.psi.PyExpression
|
||||
import com.jetbrains.python.psi.impl.PyElementImpl
|
||||
import com.jetbrains.python.psi.impl.PyNamedParameterImpl
|
||||
|
||||
class PyNamedParameterTypeRepresentation(astNode: ASTNode) : PyElementImpl(astNode), PsiElement {
|
||||
class PyNamedParameterTypeRepresentation(astNode: ASTNode) : PyNamedParameterImpl(astNode) {
|
||||
val parameterName: String?
|
||||
get() = node.findChildByType(PyTokenTypes.IDENTIFIER)?.text
|
||||
|
||||
val typeExpression: PyExpression?
|
||||
get() = findChildByClass(PyExpression::class.java)
|
||||
|
||||
val defaultValue: PyExpression?
|
||||
get() {
|
||||
// Find the expression after the = token
|
||||
val children = node.getChildren(null)
|
||||
var foundEquals = false
|
||||
for (child in children) {
|
||||
if (foundEquals && child.psi is PyExpression) {
|
||||
return child.psi as PyExpression
|
||||
}
|
||||
if (child.elementType == PyTokenTypes.EQ) {
|
||||
foundEquals = true
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user