#pragma once

#include "CoreMinimal.h"

class UBlueprintNodeSpawner;
class UEdGraph;
class UEdGraphNode;
struct FBlueprintActionContext;
struct FEdGraphSchemaAction;


struct FWingGraphAction
{
    TSharedPtr<FEdGraphSchemaAction> Action;
    UBlueprintNodeSpawner *Spawner = nullptr;
    UEdGraph *Graph;
    FString Name;
    FString Keywords;

    FWingGraphAction(TSharedPtr<FEdGraphSchemaAction> &iAction, UEdGraph *iGraph);
    FWingGraphAction(UBlueprintNodeSpawner *iSpawner, UEdGraph *iGraph);

    UEdGraphNode *Execute(const FVector2D &Location) const;

private:
    static FName GetSpawnerOwnerClass(const UBlueprintNodeSpawner* Spawner);
    static FName GetPropertyClassName(const FProperty *Prop);
};


struct FWingGraphActions
{
public:
    // Constructor populates the list of actions.
    FWingGraphActions(UEdGraph* iGraph);
    
    // Choose a subset of the actions.
    TArray<FWingGraphAction*> Search(const FString& Query, int32 MaxResults, bool Exact);


private:
    // The Graph that we're generating Actions for.
    UEdGraph *Graph;

    // The Array of Actions
    TArray<FWingGraphAction> Actions;

    // Routines that collect actions and spawners.
    void CollectActions();
    void CollectSpawners();
};
