#pragma once

#include "CoreMinimal.h"
#include "WingHandler.h"
#include "WingServer.h"
#include "WingFetcher.h"
#include "WingGraphExport.h"
#include "GraphNode_Dump.generated.h"


// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------

UCLASS()
class UWing_GraphNode_Dump : public UWingHandler
{
	GENERATED_BODY()

public:
	UPROPERTY(EditAnywhere, meta=(Description="Target node"))
	FString Node;

	virtual void Register() override
	{
		UWingServer::AddHandler(this,
			TEXT("Dump a single node as readable text, including all pins and connections."));
	}
private:
	virtual void Handle() override
	{
		WingFetcher F;
		UEdGraphNode* NodeObj = F.Walk(Node).Cast<UEdGraphNode>();
		if (!NodeObj) return;

		WingGraphExport Exporter(NodeObj);
		UWingServer::Print(*Exporter.GetOutput());
		UWingServer::Print(Exporter.GetDetails());
	}
};
