// FunctionTest
//------------------------------------------------------------------------------

// Includes
//------------------------------------------------------------------------------
#include "Tools/FBuild/FBuildCore/PrecompiledHeader.h"

#include "FunctionTest.h"
#include "Tools/FBuild/FBuildCore/FBuild.h"
#include "Tools/FBuild/FBuildCore/Graph/NodeGraph.h"
#include "Tools/FBuild/FBuildCore/Graph/TestNode.h"

// CONSTRUCTOR
//------------------------------------------------------------------------------
FunctionTest::FunctionTest()
: Function( "Test" )
{
}

// AcceptsHeader
//------------------------------------------------------------------------------
/*virtual*/ bool FunctionTest::AcceptsHeader() const
{
	return true;
}

// Commit
//------------------------------------------------------------------------------
/*virtual*/ bool FunctionTest::Commit( NodeGraph & nodeGraph, const BFFIterator & funcStartIter ) const
{
	AStackString<> name;
	if ( GetNameForNode( nodeGraph, funcStartIter, TestNode::GetReflectionInfoS(), name ) == false )
	{
		return false;
	}

	if ( nodeGraph.FindNode( name ) )
	{
		Error::Error_1100_AlreadyDefined( funcStartIter, this, name );
		return false;
	}

	TestNode * testNode = nodeGraph.CreateTestNode( name );

	if ( !PopulateProperties( nodeGraph, funcStartIter, testNode ) )
	{
		return false;
	}

	if ( !testNode->Initialize( nodeGraph, funcStartIter, this ) )
    {
        return false;
    }

	// handle alias creation
	return ProcessAlias( nodeGraph, funcStartIter, testNode );
}

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