private void intellua_CharAdded(object sender, ScintillaNET.CharAddedEventArgs e) { //ShowCalltip(); const string brackets = "()[]{}"; const string newline = "\r\n"; if (newline.Contains(e.Ch)) { if (e.Ch == '\n') { InsertText(string.Concat(Enumerable.Repeat("\t", Lines.Current.Previous.Indentation / Indentation.TabWidth))); if (Lines.Current.FoldParent != null && Lines.Current.FoldParent.StartPosition == Lines.Current.Previous.StartPosition) { InsertText("\t"); } } return; } if (!Parse) { return; } if (brackets.Contains(e.Ch)) { return; } MemberChain chain = MemberChain.ParseBackward(m_source); if (chain.Elements.Count == 1) { string word = chain.Elements[0].Name; if (char.IsLetterOrDigit(e.Ch) && word.Length >= 3) { List <IAutoCompleteItem> list = m_autoCompleteData.Variables.getList(word, CurrentPos); m_autoCompleteData.Types.appendList(list, word); m_autoCompleteData.Keywords.appendList(list, word); list.Sort(); if (list.Count > 0) { ShowAutoComplete(word.Length, list); } } } else { Type t = chain.getType(m_autoCompleteData); if (t != null) { List <IAutoCompleteItem> list = t.getList(chain.IsNamespace); if (list.Count > 0) { ShowAutoComplete(chain.getLastElement().Length, list); } } } if (!AutoComplete.IsActive) { m_tooltip.Hide(); } }
// Public Methods (2) public static FunctionCall Parse(IntelluaSource source, AutoCompleteData data, int pos) { VariableManager variables = data.Variables; const string luaOperators = "+-*/^%<>=~"; int paramIndex = 0; Byte[] str = source.RawText; bool running = true; while (pos > 0) { char c = Convert.ToChar(str[pos]); if (c == 0 || char.IsWhiteSpace(Convert.ToChar(str[pos])) || !Parser.isCode(source, pos)) { pos--; continue; } if (c == ',') { paramIndex++; pos--; break; } if (c == '(') { running = false; break; } break; } MemberChain chain = MemberChain.ParseBackward(source, pos); while (chain.Elements.Count != 0 && running) { pos = chain.StartPos; while (pos > 0 && pos < str.Length) { if (char.IsWhiteSpace(Convert.ToChar(str[pos])) || !Parser.isCode(source, pos)) { pos--; continue; } if (str[pos] == ',') { paramIndex++; pos--; break; } if (luaOperators.Contains(Convert.ToChar(str[pos]))) { pos--; break; } if (str[pos] == '(') { running = false; break; } return(null); } if (pos <= 0) { return(null); } chain = MemberChain.ParseBackward(source, pos); if (chain.StartPos == -1) { break; } } while (pos > 0 && pos < str.Length) { if (char.IsWhiteSpace(Convert.ToChar(str[pos])) || !Parser.isCode(source, pos)) { pos--; continue; } if (str[pos] == '(') { chain = MemberChain.ParseBackward(source, pos - 1); chain.getType(data, true); if (chain.LastFunction == null) { return(null); } FunctionCall fc = new FunctionCall(); fc.m_func = chain.LastFunction; fc.ParamIndex = paramIndex; fc.update(); return(fc); } break; } return(null); }