private ScriptStruct ParsePreviousExpression(int startAtPos, out string charactersAfterDot, out bool staticAccess, out bool isThis)
{
isThis = false;
string pathedExpression = GetPreviousPathedExpression(startAtPos, true);
// strip off anything after the last dot (since that's what they're typing now)
int lastIndex = pathedExpression.LastIndexOf('.');
charactersAfterDot = string.Empty;
if (lastIndex >= 0)
{
charactersAfterDot = pathedExpression.Substring(lastIndex + 1);
pathedExpression = pathedExpression.Substring(0, lastIndex);
}
else
{
charactersAfterDot = pathedExpression;
pathedExpression = string.Empty;
}
string thisWord = ReadNextWord(ref pathedExpression);
staticAccess = false;
ScriptStruct foundType;
if (thisWord == THIS_STRUCT)
{
thisWord = FindTypeForThis(startAtPos);
foundType = FindGlobalVariableOrType(thisWord, ref staticAccess);
isThis = true;
// force this to false for the "this" variable
staticAccess = false;
}
else
{
foundType = FindGlobalVariableOrType(thisWord, ref staticAccess);
if ((foundType == null) && (thisWord.Length > 0))
{
ScriptVariable var = FindLocalVariableWithName(startAtPos, thisWord);
if (var != null)
{
foundType = FindGlobalVariableOrType(var.Type);
}
}
}
while ((pathedExpression.Length > 0) && (foundType != null))
{
thisWord = ReadNextWord(ref pathedExpression);
ScriptVariable memberVar = foundType.FindMemberVariable(thisWord);
if (memberVar != null)
{
foundType = FindGlobalVariableOrType(memberVar.Type);
staticAccess = false;
}
else
{
foundType = null;
}
}
return foundType;
}