def METHOD_NAME(completion_context: ICompletionContext) -> Optional[RangeTypedDict]:
    from robotframework_ls.impl.find_definition import find_definition_extended
    from robotframework_ls.impl import ast_utils
    from robotframework_ls.impl.protocols import IVariableDefinition
    lsp_messages = completion_context.lsp_messages
    definition_info = find_definition_extended(completion_context)
    if definition_info:
        for definition in definition_info.definitions:
            if hasattr(definition, "keyword_found"):
                keyword_definition = typing.cast(IKeywordDefinition, definition)
                keyword_found = keyword_definition.keyword_found
                library_name = keyword_found.library_name
                keyword_name = keyword_found.keyword_name
                if library_name:
                    if lsp_messages:
                        lsp_messages.show_message(
                            f"Keyword defined in Library. Only references will be renamed "
                            f"(the '{keyword_name}' definition in '{library_name}' "
                            f"will need to be renamed manually).",
                            MessageType.Warning,
                        )
                else:
                    try:
                        toks = tuple(
                            ast_utils.create_token(keyword_name).tokenize_variables()
                        )
                    except:
                        pass
                    else:
                        for tok in toks:
                            if tok.type == tok.VARIABLE:
                                raise JsonRpcException(
                                    f"Unable to rename '{keyword_name}' (keywords with variables embedded in the name cannot be renamed).",
                                    10,
                                )
                return definition_info.origin_selection_range
            if hasattr(definition, "variable_found"):
                from robotframework_ls.impl.variable_resolve import has_variable
                variable_definition = typing.cast(IVariableDefinition, definition)
                variable_name = variable_definition.variable_found.variable_name
                if has_variable(variable_name):
                    raise JsonRpcException(
                        f"Unable to rename variable definition: '{variable_name}' (variables with variables embedded cannot be renamed).",
                        10,
                    )
                return definition_info.origin_selection_range
    raise JsonRpcException(
        "Unable to rename (could not find keyword nor variable in current position).",
        10,
    )