public List <AutoCompleteNodeInfo> this[string member] { get { List <AutoCompleteNodeInfo> infs = new List <AutoCompleteNodeInfo>(); MemberInfo[] mis = NodeType.GetMember(member); foreach (MemberInfo mi in mis) { AutoCompleteNodeInfo ni = AutoCompleteNodeInfo.BuildNodeInfo(mi); infs.Add(ni); } return(infs); } }
public static AutoCompleteNodeInfo BuildNodeInfo(MemberInfo mi) { AutoCompleteNodeInfo node = null; if (mi.MemberType == MemberTypes.Field) { FieldInfo f = mi as FieldInfo; if (f.IsPublic && !f.IsStatic) { node = new AutoCompleteNodeInfo(f.FieldType, f.Name, f.MemberType, null); } } else if (mi.MemberType == MemberTypes.Method) { MethodInfo m = mi as MethodInfo; if (m.IsPublic && !m.IsStatic) { node = new AutoCompleteNodeInfo(m.ReturnType, m.Name, m.MemberType, m.GetParameters()); } } else if (mi.MemberType == MemberTypes.Property) { PropertyInfo p = mi as PropertyInfo; MethodInfo m = null; if (p.CanRead) { m = p.GetGetMethod(); } else if (p.CanWrite) { m = p.GetSetMethod(); } if (m != null) { if (m.IsPublic && !m.IsStatic) { node = new AutoCompleteNodeInfo(p.PropertyType, p.Name, p.MemberType, null); } } } return(node); }
public static Dictionary <string, AutoCompleteNodeInfo> LoadIntrinsicObjects() { Dictionary <string, AutoCompleteNodeInfo> rootNodes = new Dictionary <string, AutoCompleteNodeInfo>(); rootNodes["input"] = new AutoCompleteNodeInfo(typeof(IZeusInput), "input"); rootNodes["output"] = new AutoCompleteNodeInfo(typeof(IZeusOutput), "output"); rootNodes["context"] = new AutoCompleteNodeInfo(typeof(IZeusContext), "context"); foreach (IZeusIntrinsicObject zio in ZeusFactory.IntrinsicObjectsArray) { try { AutoCompleteNodeInfo node = new AutoCompleteNodeInfo(zio.Assembly.GetType(zio.ClassPath), zio.VariableName); rootNodes[node.Name] = node; } catch { } } return(rootNodes); }
public virtual bool ScanCodeForVariable(ZeusScintillaControl scintilla, string varname, out AutoCompleteNodeInfo node) { node = null; return(false); }
public void HandleCharAdded(ZeusScintillaControl scintilla, bool isTagged, char ch) { bool isCtrlPressed = (Control.ModifierKeys == (System.Windows.Forms.Keys.Control | Control.ModifierKeys)); bool isAutoSeek = IsAutoCompleteSeek(ch, isCtrlPressed); bool isAutoMember = IsAutoCompleteMember(ch); bool isCallTip = IsCallTip(ch); if (isAutoSeek || isAutoMember || isCallTip) { int pos = scintilla.CurrentPos - 1; char c = scintilla.CharAt(--pos); Stack <string> stk = new Stack <string>(); List <string> lst = new List <string>(); System.Text.StringBuilder tmp = new System.Text.StringBuilder(); int style = scintilla.StyleAt(pos); if (IsCodeStyle(isTagged, style)) { while (IsValidIdentifierChar(c) || (c == MemberSeperator)) { if (c == MemberSeperator) { if (tmp.Length > 0) { lst.Insert(0, tmp.ToString()); stk.Push(tmp.ToString()); tmp.Remove(0, tmp.Length); } } else { tmp.Insert(0, c); } c = scintilla.CharAt(--pos); } if (tmp.Length > 0) { lst.Insert(0, tmp.ToString()); stk.Push(tmp.ToString()); tmp.Remove(0, tmp.Length); } AutoCompleteNodeInfo n = null; AutoCompleteNodeInfo nextToLastNode = null; System.Collections.Generic.List <AutoCompleteNodeInfo> ns = null; string lastmsg = null, firstmsg = null; int memberDepth = stk.Count; if (stk.Count > 0) { lastmsg = stk.Pop(); if ((lastmsg.Equals(this.SelfQualifier, this.SelfQualifierStringComparisonRule)) && (stk.Count > 0)) { lastmsg = stk.Pop(); } if (AutoCompleteHelper.RootNodes.ContainsKey(lastmsg)) { n = AutoCompleteHelper.RootNodes[lastmsg]; } else { AutoCompleteNodeInfo newRootNode; if (ScanCodeForVariable(scintilla, lastmsg, out newRootNode)) { n = newRootNode; } } } while (n != null && stk.Count > 0) { nextToLastNode = n; int stkCount = stk.Count; lastmsg = stk.Pop(); ns = n[lastmsg]; if (ns.Count == 1) { n = ns[0]; } else { n = null; if (stk.Count != 0) { ns = null; } } } if (isAutoSeek) { scintilla.DeleteBack(); if (n != null) { if (scintilla.CharAt(scintilla.CurrentPos - 1) == MemberSeperator) { scintilla.AutoCShow(0, n.MembersString); } else { scintilla.AutoCShow(n.Name.Length, nextToLastNode.MembersString); } } else if (stk.Count == 0 && nextToLastNode != null) { scintilla.AutoCShow(lastmsg.Length, nextToLastNode.MembersString); } else if (stk.Count == 0 && n == null && nextToLastNode == null) { if (lastmsg == null) { lastmsg = string.Empty; } scintilla.AutoCShow(lastmsg.Length, AutoCompleteHelper.RootNodesAutoCompleteString); } } if (isAutoMember || isCallTip) { if (n != null) { if (isAutoMember) { scintilla.AutoCShow(0, n.MembersString); } } else { if (isAutoMember && (lastmsg != null) && (lastmsg.Equals(this.SelfQualifier, this.SelfQualifierStringComparisonRule)) && (memberDepth == 1)) { scintilla.AutoCShow(0, AutoCompleteHelper.RootNodesAutoCompleteString); } } if (ns != null) { if (isCallTip) { string methodSigs = string.Empty; int i = 0; foreach (AutoCompleteNodeInfo ni in ns) { if (ni.MemberType == System.Reflection.MemberTypes.Method) { i++; if (methodSigs.Length > 0) { methodSigs += "\n"; } //methodSigs += '\u0001' + i.ToString() + " of " + ns.Count + '\u0002' + " " + ni.ParameterString; methodSigs += ni.ParameterString; } } if (methodSigs.Length > 0) { scintilla.CallTipShow(scintilla.CurrentPos - 1, methodSigs); } } } } } } }
public virtual bool ScanCodeForVariable(ZeusScintillaControl scintilla, string varname, out AutoCompleteNodeInfo node) { node = null; return false; }
public override bool ScanCodeForVariable(ZeusScintillaControl scintilla, String varname, out AutoCompleteNodeInfo node) { node = null; bool isFound = false; int currentIndex = scintilla.CurrentPos; int selectionStart = scintilla.SelectionStart; int selectionEnd = scintilla.SelectionEnd; int searchEndIndex = (currentIndex - varname.Length - 1); Stack<int> matches = new Stack<int>(); scintilla.CurrentPos = searchEndIndex; scintilla.SearchAnchor(); int matchPosition = scintilla.SearchPrevious((int)FindOption.WholeWord, varname); while ((matchPosition >= 0) && (matchPosition < searchEndIndex)) { int style = scintilla.StyleAt(matchPosition); if (style == 86 || style == 7) { matches.Push(matchPosition); } scintilla.CurrentPos = matchPosition; scintilla.SearchAnchor(); matchPosition = scintilla.SearchPrevious((int)FindOption.WholeWord, varname); } scintilla.CurrentPos = currentIndex; scintilla.SelectionStart = selectionStart; scintilla.SelectionEnd = selectionEnd; scintilla.SearchAnchor(); foreach (int m in matches) { string word = scintilla.GetWordFromPosition(m + 1); if (string.Equals(word, varname, StringComparison.CurrentCultureIgnoreCase)) { varname = word; int beginWordIndex = m; int endWordIndex = m + word.Length; char c = scintilla.CharAt(++endWordIndex); List<string> words = new List<string>(); //skip whitespace while (Char.IsWhiteSpace(c)) c = scintilla.CharAt(++endWordIndex); // get "As" StringBuilder nextword = new StringBuilder(); do { nextword.Append(c); c = scintilla.CharAt(++endWordIndex); } while (!Char.IsWhiteSpace(c)); if (nextword.ToString().Equals("as", StringComparison.CurrentCultureIgnoreCase)) { //skip whitespace while (Char.IsWhiteSpace(c)) c = scintilla.CharAt(++endWordIndex); // get Type nextword.Remove(0, nextword.Length); do { nextword.Append(c); c = scintilla.CharAt(++endWordIndex); } while (!Char.IsWhiteSpace(c) && (this.IsValidIdentifierChar(c) || (c == MemberSeperator))); string type = nextword.ToString(); List<Type> types = AutoCompleteHelper.SearchForType(type); if (types.Count > 0) { node = new AutoCompleteNodeInfo(types[0], varname); isFound = true; } } } } return isFound; }
public override bool ScanCodeForVariable(ZeusScintillaControl scintilla, String varname, out AutoCompleteNodeInfo node) { node = null; bool isFound = false; int currentIndex = scintilla.CurrentPos; int selectionStart = scintilla.SelectionStart; int selectionEnd = scintilla.SelectionEnd; int searchEndIndex = (currentIndex - varname.Length - 1); Stack <int> matches = new Stack <int>(); scintilla.CurrentPos = searchEndIndex; scintilla.SearchAnchor(); int matchPosition = scintilla.SearchPrevious((int)FindOption.WholeWord, varname); while ((matchPosition >= 0) && (matchPosition < searchEndIndex)) { int style = scintilla.StyleAt(matchPosition); if (style == 86 || style == 7) { matches.Push(matchPosition); } scintilla.CurrentPos = matchPosition; scintilla.SearchAnchor(); matchPosition = scintilla.SearchPrevious((int)FindOption.WholeWord, varname); } scintilla.CurrentPos = currentIndex; scintilla.SelectionStart = selectionStart; scintilla.SelectionEnd = selectionEnd; scintilla.SearchAnchor(); foreach (int m in matches) { string word = scintilla.GetWordFromPosition(m + 1); if (string.Equals(word, varname, StringComparison.CurrentCultureIgnoreCase)) { varname = word; int beginWordIndex = m; int endWordIndex = m + word.Length; char c = scintilla.CharAt(++endWordIndex); List <string> words = new List <string>(); //skip whitespace while (Char.IsWhiteSpace(c)) { c = scintilla.CharAt(++endWordIndex); } // get "As" StringBuilder nextword = new StringBuilder(); do { nextword.Append(c); c = scintilla.CharAt(++endWordIndex); } while (!Char.IsWhiteSpace(c)); if (nextword.ToString().Equals("as", StringComparison.CurrentCultureIgnoreCase)) { //skip whitespace while (Char.IsWhiteSpace(c)) { c = scintilla.CharAt(++endWordIndex); } // get Type nextword.Remove(0, nextword.Length); do { nextword.Append(c); c = scintilla.CharAt(++endWordIndex); } while (!Char.IsWhiteSpace(c) && (this.IsValidIdentifierChar(c) || (c == MemberSeperator))); string type = nextword.ToString(); List <Type> types = AutoCompleteHelper.SearchForType(type); if (types.Count > 0) { node = new AutoCompleteNodeInfo(types[0], varname); isFound = true; } } } } return(isFound); }
public override bool ScanCodeForVariable(ZeusScintillaControl scintilla, String varname, out AutoCompleteNodeInfo node) { node = null; bool isFound = false; int currentIndex = scintilla.CurrentPos; int selectionStart = scintilla.SelectionStart; int selectionEnd = scintilla.SelectionEnd; int searchEndIndex = (currentIndex - varname.Length - 1); Stack<int> matches = new Stack<int>(); scintilla.CurrentPos = searchEndIndex; scintilla.SearchAnchor(); int matchPosition = scintilla.SearchPrevious((int)FindOption.WholeWord, varname); while ((matchPosition >= 0) && (matchPosition < searchEndIndex)) { int style = scintilla.StyleAt(matchPosition); if (style == 61 || style == 11) { matches.Push(matchPosition); } scintilla.CurrentPos = matchPosition; scintilla.SearchAnchor(); matchPosition = scintilla.SearchPrevious((int)FindOption.WholeWord, varname); } scintilla.CurrentPos = currentIndex; scintilla.SelectionStart = selectionStart; scintilla.SelectionEnd = selectionEnd; scintilla.SearchAnchor(); foreach (int m in matches) { string word = scintilla.GetWordFromPosition(m + 1); if (string.Equals(word, varname, StringComparison.CurrentCultureIgnoreCase)) { varname = word; int beginWordIndex = m; //scintilla. char c = scintilla.CharAt(--beginWordIndex); while (Char.IsWhiteSpace(c) && (beginWordIndex > 0)) c = scintilla.CharAt(--beginWordIndex); StringBuilder typeName = new StringBuilder(); while (this.IsValidIdentifierChar(c) || (c == MemberSeperator)) { if (typeName.Length == 0) typeName.Append(c); else typeName.Insert(0, c); c = scintilla.CharAt(--beginWordIndex); } string type = typeName.ToString(); List<Type> types = AutoCompleteHelper.SearchForType(type); if (types.Count > 0) { node = new AutoCompleteNodeInfo(types[0], varname); isFound = true; } } } return isFound; }
public override bool ScanCodeForVariable(ZeusScintillaControl scintilla, String varname, out AutoCompleteNodeInfo node) { node = null; bool isFound = false; int currentIndex = scintilla.CurrentPos; int selectionStart = scintilla.SelectionStart; int selectionEnd = scintilla.SelectionEnd; int searchEndIndex = (currentIndex - varname.Length - 1); Stack <int> matches = new Stack <int>(); scintilla.CurrentPos = searchEndIndex; scintilla.SearchAnchor(); int matchPosition = scintilla.SearchPrevious((int)FindOption.WholeWord, varname); while ((matchPosition >= 0) && (matchPosition < searchEndIndex)) { int style = scintilla.StyleAt(matchPosition); if (style == 61 || style == 11) { matches.Push(matchPosition); } scintilla.CurrentPos = matchPosition; scintilla.SearchAnchor(); matchPosition = scintilla.SearchPrevious((int)FindOption.WholeWord, varname); } scintilla.CurrentPos = currentIndex; scintilla.SelectionStart = selectionStart; scintilla.SelectionEnd = selectionEnd; scintilla.SearchAnchor(); foreach (int m in matches) { string word = scintilla.GetWordFromPosition(m + 1); if (string.Equals(word, varname, StringComparison.CurrentCultureIgnoreCase)) { varname = word; int beginWordIndex = m; //scintilla. char c = scintilla.CharAt(--beginWordIndex); while (Char.IsWhiteSpace(c) && (beginWordIndex > 0)) { c = scintilla.CharAt(--beginWordIndex); } StringBuilder typeName = new StringBuilder(); while (this.IsValidIdentifierChar(c) || (c == MemberSeperator)) { if (typeName.Length == 0) { typeName.Append(c); } else { typeName.Insert(0, c); } c = scintilla.CharAt(--beginWordIndex); } string type = typeName.ToString(); List <Type> types = AutoCompleteHelper.SearchForType(type); if (types.Count > 0) { node = new AutoCompleteNodeInfo(types[0], varname); isFound = true; } } } return(isFound); }
public static Dictionary<string, AutoCompleteNodeInfo> LoadIntrinsicObjects() { Dictionary<string, AutoCompleteNodeInfo> rootNodes = new Dictionary<string, AutoCompleteNodeInfo>(); rootNodes["input"] = new AutoCompleteNodeInfo(typeof(IZeusInput), "input"); rootNodes["output"] = new AutoCompleteNodeInfo(typeof(IZeusOutput), "output"); rootNodes["context"] = new AutoCompleteNodeInfo(typeof(IZeusContext), "context"); foreach (IZeusIntrinsicObject zio in ZeusFactory.IntrinsicObjectsArray) { try { AutoCompleteNodeInfo node = new AutoCompleteNodeInfo(zio.Assembly.GetType(zio.ClassPath), zio.VariableName); rootNodes[node.Name] = node; } catch { } } return rootNodes; }
public static AutoCompleteNodeInfo BuildNodeInfo(MemberInfo mi) { AutoCompleteNodeInfo node = null; if (mi.MemberType == MemberTypes.Field) { FieldInfo f = mi as FieldInfo; if (f.IsPublic && !f.IsStatic) { node = new AutoCompleteNodeInfo(f.FieldType, f.Name, f.MemberType, null); } } else if (mi.MemberType == MemberTypes.Method) { MethodInfo m = mi as MethodInfo; if (m.IsPublic && !m.IsStatic) { node = new AutoCompleteNodeInfo(m.ReturnType, m.Name, m.MemberType, m.GetParameters()); } } else if (mi.MemberType == MemberTypes.Property) { PropertyInfo p = mi as PropertyInfo; MethodInfo m = null; if (p.CanRead) { m = p.GetGetMethod(); } else if (p.CanWrite) { m = p.GetSetMethod(); } if (m != null) { if (m.IsPublic && !m.IsStatic) { node = new AutoCompleteNodeInfo(p.PropertyType, p.Name, p.MemberType, null); } } } return node; }