private static bool AddFunctionDeclaration(List<ScriptFunction> functions, ref FastString script, string thisWord, AutoCompleteParserState state, bool isExtenderMethod, bool isStatic, bool isStaticOnly)
{
bool succeeded = false;
if ((state.LastWord.Length > 0) && (state.WordBeforeLast.Length > 0))
{
if (!DoesCurrentLineHaveToken(script, AUTO_COMPLETE_IGNORE))
{
string functionName = state.LastWord;
string type = state.WordBeforeLast;
bool isPointer = false, isNoInherit = false;
bool isProtected = false;
if (type == "::")
{
functionName = state.WordBeforeWordBeforeLast + "::" + functionName;
type = (state.PreviousWords.Length > 3) ? state.PreviousWords[3] : "unknown";
}
if (type == "*")
{
isPointer = true;
type = state.WordBeforeWordBeforeLast;
}
if (state.DynamicArrayDefinition)
{
// get the type name and the []
type = state.WordBeforeWordBeforeLast + state.WordBeforeLast;
}
if (state.IsWordInPreviousList("static"))
{
isStatic = true;
}
if (state.IsWordInPreviousList("protected"))
{
isProtected = true;
}
if (DoesCurrentLineHaveToken(script, AUTO_COMPLETE_STATIC_ONLY))
{
isStaticOnly = true;
}
if (DoesCurrentLineHaveToken(script, AUTO_COMPLETE_NO_INHERIT))
{
isNoInherit = true;
}
int parameterListEndIndex = script.IndexOf(')');
if (parameterListEndIndex >= 0)
{
string parameterList = script.Substring(0, parameterListEndIndex);
script = script.Substring(parameterListEndIndex + 1);
ScriptFunction newFunc = new ScriptFunction(functionName, type, parameterList, state.InsideIfDefBlock, state.InsideIfNDefBlock, isPointer, isStatic, isStaticOnly, isNoInherit, isProtected, isExtenderMethod, state.CurrentScriptCharacterIndex - 1);
if (!string.IsNullOrEmpty(state.PreviousComment))
{
newFunc.Description = state.PreviousComment;
state.PreviousComment = null;
}
functions.Add(newFunc);
succeeded = true;
}
state.DynamicArrayDefinition = false;
}
}
return succeeded;
}