void RiderDebuggerSupport_GetBlueprintFunction()

in src/cpp/RiderLink/Source/RiderDebuggerSupport/Private/BlueprintStackGetter.cpp [60:152]


void RiderDebuggerSupport_GetBlueprintFunction(void* PFunction, void* PContext)
{
    using namespace RiderDebuggerSupport;

    SendLogToDebugger("Called %s: Context=%p Function=%p", __func__, PContext, PFunction);
    *GJbPOperationResultCode = 0;

    const UObject* Context = static_cast<UObject*>(PContext);
    UFunction* Function = static_cast<UFunction*>(PFunction);

    if (nullptr == Context)
    {
        SendLogToDebugger("Context is null");
        SetLastExecutedLine(__LINE__);
        return;
    }

    if (nullptr == Function)
    {
        SendLogToDebugger("Function is null");
        SetLastExecutedLine(__LINE__);
        return;
    }
    SetLastExecutedLine(__LINE__);

    FString FullName;
    SetLastExecutedLine(__LINE__);

    Function->GetFullName(nullptr, FullName, EObjectFullNameFlags::None);
    GJbFullNameWrapper.CopyFromNullTerminatedStr(
        GetData(FullName), FullName.Len());
    SetLastExecutedLine(__LINE__);

    const auto Outer = Function->GetOuter();

    SendLogToDebugger("Trying to get SourceClass");

    const UClass* SourceClass = CastToUClass(Outer);

    SendLogToDebugger("SourceClass=%p", SourceClass);

    SetLastExecutedLine(__LINE__);
    if (nullptr != SourceClass)
    {
        constexpr int SourceCodeNotNullFlag = 16;
        SetResultCodeFlag(SourceCodeNotNullFlag);
    }

    FString SourceClassDisplayName = GetClassNameWithoutSuffix(SourceClass);
    SendLogToDebugger(
        "SourceClassDisplayName length=%u, str_ptr=%p",
        SourceClassDisplayName.Len(), GetData(SourceClassDisplayName));
    SetLastExecutedLine(__LINE__);

    SendLogToDebugger("Trying to get outerDisplayName");
    FString OuterDisplayName = FText::FromName(Outer->GetFName()).ToString();
    SendLogToDebugger(
        "OuterDisplayName length=%u, str_ptr=%p",
        OuterDisplayName.Len(), GetData(OuterDisplayName));

    const auto ScopeDisplayName = SourceClass ? &SourceClassDisplayName : &OuterDisplayName;
    GJbScopeDisplayNameWrapper.CopyFromNullTerminatedStr(
        GetData(*ScopeDisplayName), ScopeDisplayName->Len());
    SetLastExecutedLine(__LINE__);

    auto FunctionDisplayName = FText::FromName(Function->GetFName()).ToString();
    GJbFunctionDisplayNameWrapper.CopyFromNullTerminatedStr(GetData(FunctionDisplayName), FunctionDisplayName.Len());
    SetLastExecutedLine(__LINE__);

#if WITH_EDITORONLY_DATA
    if (SourceClass)
    {
        const auto GraphNode = FindSourceNodeForCodeLocation(Context, Function);
        SetLastExecutedLine(__LINE__);

        if (nullptr != GraphNode)
        {
            constexpr int SourceCodeNotNullFlag = 17;
            SetResultCodeFlag(SourceCodeNotNullFlag);

            const FText NodeTitle = GraphNode->GetNodeTitle(ENodeTitleType::Type::ListView);
            SetLastExecutedLine(__LINE__);

            FString NodeTitleStr = NodeTitle.ToString();
            SetLastExecutedLine(__LINE__);

            GJbFunctionDisplayNameWrapper.CopyFromNullTerminatedStr(
                GetData(NodeTitleStr), NodeTitleStr.Len());
            SetLastExecutedLine(__LINE__);
        }
    }
#endif
}