override fun fillCompletionVariants()

in gdscript/src/main/kotlin/gdscript/completion/GdMethodParamCompletion.kt [22:63]


    override fun fillCompletionVariants(parameters: CompletionParameters, result: CompletionResultSet) {
        if (PARAM_VAR_NMI.accepts(parameters.position)) {
            // Types
            GdClassIdIndex.INSTANCE.getAllKeys(parameters.position.project)
                .forEach {
                    result.addElement(
                        GdLookup.create(
                            "${it.camelToSnakeCase()}: $it",
                            priority = GdLookup.BUILT_IN,
                        )
                    )
                }

            // Params of other methods
            val owner = GdClassUtil.getOwningClassElement(parameters.position)
            PsiTreeUtil.getChildrenOfType(owner, GdMethodDeclTl::class.java)
                ?.forEach { method ->
                    method.paramList?.paramList?.forEach {
                        result.addElement(
                            GdLookup.create(
                                it.text,
                                priority = GdLookup.USER_DEFINED,
                            )
                        )
                    }
                }

            // Local undeclared variables
            val method = PsiTreeUtil.getParentOfType(parameters.position, GdMethodDeclTl::class.java, GdFuncDeclEx::class.java)
            val vars = PsiTreeUtil.collectElementsOfType(method, GdRefIdRef::class.java)
            vars.forEach {
                if (GdClassMemberReference(it).resolveDeclaration() == null) {
                    result.addElement(
                        GdLookup.create(
                            it.text,
                            priority = GdLookup.LOCAL_USER_DEFINED,
                        )
                    )
                }
            }
        }
    }