override fun getHintInfo()

in gdscript/src/main/kotlin/gdscript/codeInsight/GdInlayParameterHintProvider.kt [21:61]


    override fun getHintInfo(element: PsiElement): HintInfo? {
        if (element is GdCallEx) {
            val id = PsiTreeUtil.findChildOfType(element, GdRefIdRef::class.java) ?: return null
            val declaration = GdClassMemberReference(id).resolveDeclaration() ?: return null

            if (declaration is GdMethodDeclTl) {
                val name = declaration.name
                if (name == "emit") {
                    val signal = PsiGdSignalUtil.getDeclaration(element)
                    if (signal != null) {
                        return MethodInfo(name, signal.parameters.keys.toList())
                    }
                }

                return MethodInfo(name, declaration.parameters.keys.toList())
            } else if (declaration is GdVarDeclSt && declaration.expr is GdFuncDeclEx) {
                // Lambdas
                val lambda = declaration.expr as GdFuncDeclEx
                return MethodInfo(lambda.funcDeclIdNmi?.text.orEmpty(), lambda.parameters.keys.toList())
            } else if (declaration is GdClassNaming) {
                // Constructors
                val currentParams = element.argList?.argExprList ?: return null
                val constructors = GdClassMemberUtil.listClassMemberDeclarations(declaration, constructors = true).constructors()
                val constructor = constructors.find {
                    if (it.parameters.size != currentParams.size) return@find false
                    val declParams = it.parameters.values.toTypedArray()
                    currentParams.forEachIndexed { i, param ->
                        if (!GdExprUtil.typeAccepts(param.returnType, declParams[i], element)) return@find false
                    }
                    true
                } ?: return null

                return MethodInfo(declaration.classname, constructor.parameters.keys.toList())
            }
        } else if (element is GdAnnotationTl) {
            val definition = GdAnnotationUtil.get(element) ?: return null
            return MethodInfo(element.annotationType.text, definition.parameters.keys.toList())
        }

        return null
    }