private static bool GetIfVariableState(string wordBefore2, string wordBefore3, string wordBefore4) { IElement element; if (string.IsNullOrWhiteSpace(wordBefore3)) { element = EditorLogic.CurrentElement; } else { element = ObjectFinder.Self.GetElementUnqualified(wordBefore4); } if (element != null) { var availableStates = StateCodeGenerator.GetAllStatesForCategory(element, wordBefore2); bool isCategory = wordBefore2 == "VariableState" || availableStates.Count != 0; return((isCategory && wordBefore3 == "." && ObjectFinder.Self.GetElementUnqualified(wordBefore4) != null) || (isCategory && string.IsNullOrWhiteSpace(wordBefore3))); } else { return(false); } }
public List <string> GetAutoCompleteValues() { string textBeforePeriod = ""; Alsing.SourceCode.Row row = syntaxBoxControl1.Caret.CurrentRow; int indexIntoRow = syntaxBoxControl1.Caret.Position.X; List <string> toReturn = new List <string>(); try { if (EditorLogic.CurrentElement != null) { if (syntaxBoxControl1.Caret.PreviousWord != null) { string wordBeforeDot = syntaxBoxControl1.Caret.PreviousWord.Text; string wordBefore2 = syntaxBoxControl1.Caret.GetWordText(1); string wordBefore3 = syntaxBoxControl1.Caret.GetWordText(2); string wordBefore4 = syntaxBoxControl1.Caret.GetWordText(3); Type type; if (wordBefore2 == "this") { IElement element = EditorLogic.CurrentElement; AddAutoCompleteForElement(toReturn, element); } else if (EditorLogic.CurrentElement.GetNamedObjectRecursively(wordBefore2) != null) { NamedObjectSave nos = EditorLogic.CurrentElement.GetNamedObjectRecursively(wordBeforeDot); AddAutoCompleteFor(toReturn, nos); } else if (EditorLogic.CurrentElement.GetCustomVariableRecursively(wordBefore2) != null) { CustomVariable customVariable = EditorLogic.CurrentElement.GetCustomVariableRecursively(wordBefore2); AddAutoCompleteFor(toReturn, customVariable); } else if (ObjectFinder.Self.GetElementUnqualified(wordBefore2) != null) { AddStaticAutoCompleteFor(toReturn, ObjectFinder.Self.GetElementUnqualified(wordBeforeDot)); } else if (GetIfVariableState(wordBefore2, wordBefore3, wordBefore4)) { IElement element = null; if (string.IsNullOrWhiteSpace(wordBefore3)) { element = EditorLogic.CurrentElement; } else { element = ObjectFinder.Self.GetElementUnqualified(wordBefore4); } var availableStates = StateCodeGenerator.GetAllStatesForCategory(element, wordBefore2); if (element.GetStateCategory(wordBefore2) == null) { availableStates = StateCodeGenerator.GetSharedVariableStates(element); } foreach (StateSave stateSave in availableStates) { toReturn.Add(stateSave.Name); } } else if ((type = TypeManager.GetFlatRedBallType(wordBefore2)) != null) { AddStaticAutoCompleteFor(toReturn, type); } } } } catch (Exception e) { int m = 3; } StringFunctions.RemoveDuplicates(toReturn); toReturn.Sort(); return(toReturn); }