public static void GetLineInformation(
string line,
out Scope scope,
out ParsedType type,
out string variableName,
out bool isConst,
out bool isVirtual,
out bool isOverride,
out bool isStatic,
out bool isNew,
out bool isAsync,
out string valueToAssignTo
)
{
int index = 0;
scope = Scope.Private;
type = null;
variableName = null;
isConst = false;
valueToAssignTo = null;
isVirtual = false;
isOverride = false;
isStatic = false;
isNew = false;
isAsync = false;
bool hasHadOpenParenthesis = false;
bool hasHadOpenQuotes = false;
bool hasEqualsBeenUsed = false;
string currentType = "";
while (true)
{
string word = ParsedClass.GetWord(line, ref index);
const string public1 = " public ";
//const string startWithPublic = "public ";
if (string.IsNullOrEmpty(word))
{
break;
}
else if (word == ";")
{
continue;
}
else if (word == "const")
{
isConst = true;
}
else if (word == "public")
{
scope = Scope.Public;
}
else if (word == "private")
{
scope = Scope.Private;
}
else if (word == "protected")
{
scope = Scope.Protected;
}
else if (word == "internal")
{
scope = Scope.Internal;
}
else if (word == "virtual")
{
isVirtual = true;
}
else if (word == "override")
{
isOverride = true;
}
else if (word == "static")
{
isStatic = true;
}
else if (word == "new")
{
isNew = true;
}
else if (word == "async")
{
isAsync = true;
}
else if (type == null)
{
if (word.Contains("<") && !word.Contains(">"))
{
currentType += word;
}
else if (currentType != "")
{
currentType += word;
if (word.Contains(">"))
{
type = new ParsedType(currentType);
currentType = "";
}
}
else
{
// check for []
int tempIndex = index;
string nextWord = ParsedClass.GetWord(line, ref tempIndex);
string wordAfterThat = ParsedClass.GetWord(line, ref tempIndex);
if (nextWord == "[" && wordAfterThat == "]")
{
type = new ParsedType(word + "[]");
index = tempIndex;
}
else
{
type = new ParsedType(word);
}
}
}
else if (!hasEqualsBeenUsed && word == "(")
{
hasHadOpenParenthesis = true;
}
else if (variableName == null && !hasHadOpenParenthesis)
{
if (word.EndsWith(";"))
{
variableName = word.Substring(0, word.Length - 1);
}
else
{
variableName = word;
}
}
else if (word == "=")
{
hasEqualsBeenUsed = true;
}
else if (hasEqualsBeenUsed)
{
if (valueToAssignTo == null)
{
valueToAssignTo = word;
if (valueToAssignTo.StartsWith("\"") && !hasHadOpenQuotes)
{
if (!valueToAssignTo.EndsWith("\""))
{
hasHadOpenQuotes = true;
int indexOfClosingQuotes = line.IndexOf("\"", index) + 1; // add 1 to capture the quote
string extraStuffToAdd = line.Substring(index, indexOfClosingQuotes - index);
valueToAssignTo += extraStuffToAdd;
index = indexOfClosingQuotes;
}
}
}
else
{
valueToAssignTo += " " + word;
}
}
}
}