#ifndef _method

#define _method

#include "lexer.h"

#include "index.h"

#include "array.h"

#include "function.h"

#include "class.h"

#include "method.h"

#include "argument.h"

#include "string.h"

#include "text.h"

#include "codeBundle.h"

#include "replacement.h"

#include "tools.h"

#include "variable.h"

#include <stdlib.h>

#include <stdbool.h>

struct method{

	char * methodName;


	char * body;

	char * bodyOriginal;

	char * returnType;


	int lineNumber;

	int isVariadic;

	int isOperator;


	bool isSetter;

	bool isGetter;
	

	char * operator;


	struct array * arguments;

	struct array * variables;

};

void method_sortLineNumbers( struct array * lineNumber );

char * method_getReturnTypeFromDeclerationParts( struct array * methodDeclerationParts, int methodDeclerationCount );

void method_extractMethodNameAndReturnType( int previousKey, int key, char * source, struct method * methodInstance );

void method_extractVariablesFromArguments( struct array * arguments, array * classesArray, struct array * variables );

void method_processVariadicMethodArguments( struct  class * classInstance, struct method * methodInstance );


char * method_extractTemplates( char * source );

void method_addThisVariableToVariables( struct  class * classInstance, array * variables );

void method_addThisVariableToMethodArguments( struct  class * classInstance, struct method * methodInstance );

struct array * method_addArgumentsToMethod( struct  class * classInstance, struct method * methodInstance, struct array * classesArray, struct array * argumentsArray );

struct property * method_getArrowRecursive( struct array * arrows, char * datatype );

struct array * method_extractArguments( lexer * currentLexer, int key, char * source, int i, struct  class * classInstance, struct method * methodInstance, struct array * classesArray );

struct array * method_getArguments_new( lexer * currentLexer, int key, int i, char * source,  struct array * variables );



int method_checkIfSymbolIsOperator( char * functionName );

int method_methodIsVaradic( array * arguments );

char * method_composeOperatorOverloadOpeningDeclaration( char * baseClassName, char * operatorName, int leftSideIsPointer ) ;

char * method_getOperatorNameByOperatorSymbol( char * symbol );

int method_findMethodByName( struct  class * classInstance, char * methodName );

struct method * method_getMethodByMethodName( struct class * classInstance, char * methodName );

char * method_replaceMultiMethods( char * body );

char * method_overloadOperators( char * body, struct array * variables );

void method_parseFirstNextMethodInChain( lexer * currentLexer, int i, char * body, int key, struct array * replacements );

void method_parseFirstChainMethodCall( lexer * currentLexer, int i, char * body, int currentKey, char * currentToken, struct array * variables, struct array * replacements, int methodSeparatorLength );

void method_replaceNewSymbol( lexer * currentLexer, int i, char * body, int currentKey, struct array * variables, struct array * replacements );

void method_compose( struct method * currentMethod, char * className, struct array * sourceArray, struct text * classHeader );

char * method_parse( char * body, struct array * variables, array * functions );

struct method * method_extractMethodFromSymbol( char * functionName );

int method_processOperatorSymbols( 	char 	* 	body, 
								int 		currentKey, 
								char 	* 	currentToken,
								array 	* 	replacements,  
								array 	* 	variables );

int method_processOperatorSymbol( 	char 	* 	currentOperatorSymbol, 
							char 	* 	body, 
							int 		currentKey, 
							char 	* 	currentToken, 
							array * 	replacements, 
							array * 	variables );

int method_findRightSideEndIndex( char * body, int currentKey, int symbolLength, struct array * variables );

char * method_findLeftSideSymbol( char * body, int currentKey, int symbolLength, int * beforeVariableNameKey, array * variables );

#endif