/// <param name="type">Type of element</param> /// <param name="attr">Found attribute</param> /// <param name="data"></param> protected void inspectLevelA(Type type, Attribute attr, LInfo data) { if (!isComponent(type) || (attr.GetType() != typeof(DefinitionAttribute) && attr.GetType() != typeof(ComponentAttribute))) { return; } IAttrDomLevelA levA = (IAttrDomLevelA)attr; NodeIdent ident = new NodeIdent(levA.Parent, null); if (!data.ContainsKey(ident)) { data[ident] = new List <INodeInfo>(); } if (attr.GetType() == typeof(DefinitionAttribute)) { data[ident].Add(new NodeInfo((DefinitionAttribute)attr)); return; } if (attr.GetType() == typeof(ComponentAttribute)) { INodeInfo node = new NodeInfo((ComponentAttribute)attr); data[ident].Add(node); aliasesToNodeLevelA(node, data[ident]); return; } }
protected IEnumerable <ICompletionData> list(NodeIdent ident, string name = null) { INodeInfo hidden = isHiddenLevel(ident); if (hidden != null) { foreach (ICompletionData inf in list(hidden.Link, name)) { yield return(inf); } } else { foreach (INodeInfo inf in Inspector.getBy(ident)) { if (!String.IsNullOrEmpty(name) && !inf.Name.Contains(name)) { continue; } yield return(new CompletionData( inf.Name, inf.Displaying, String.Format("{0}\n{1}\n{2}", inf.Description, new String('_', 20), inf.Signature), inf.Type)); } } }
/// <param name="type">Type of element</param> /// <param name="attr">Found attribute</param> /// <param name="method">Found method</param> /// <param name="data"></param> protected void inspectLevelB(Type type, Attribute attr, MethodInfo method, LInfo data) { if (!isComponent(type) || (attr.GetType() != typeof(MethodAttribute) && attr.GetType() != typeof(PropertyAttribute))) { return; } IAttrDomLevelB levB = (IAttrDomLevelB)attr; string className = method.DeclaringType.FullName; NodeIdent ident = new NodeIdent((levB.Parent) ?? getComponentName(type), levB.Method, (levB.Method == null)? null : className); if (!data.ContainsKey(ident)) { data[ident] = new List <INodeInfo>(); } className = (method.Name == null)? null : className; if (attr.GetType() == typeof(PropertyAttribute)) { data[ident].Add(new NodeInfo((PropertyAttribute)attr, method.Name, className)); return; } if (attr.GetType() == typeof(MethodAttribute)) { data[ident].Add(new NodeInfo((MethodAttribute)attr, method.Name, className)); return; } }
/// <summary> /// List of constructed data by identification of node /// </summary> /// <param name="ident">Identificator of node</param> /// <returns></returns> public IEnumerable <INodeInfo> getBy(NodeIdent ident = new NodeIdent()) { if (data.ContainsKey(ident)) { foreach (INodeInfo elem in data[ident].OrderBy(p => p.Name)) { if (isEnabled(elem.Name)) { yield return(elem); } } } }
/// <param name="ident"></param> /// <returns>node of the hidden level or null value if level is not hidden</returns> protected INodeInfo isHiddenLevel(NodeIdent ident) { INodeInfo ret = null; foreach (INodeInfo info in Inspector.getBy(ident)) { if (!String.IsNullOrEmpty(info.Name)) { return(null); } ret = info; } return(ret); }
/// <param name="name">Element name</param> /// <param name="ident">Identificator of node</param> /// <param name="strict"></param> /// <returns>null value if not found</returns> protected INodeInfo infoBy(string name, NodeIdent ident, bool strict) { foreach (INodeInfo info in Inspector.getBy(ident)) { if (String.IsNullOrEmpty(info.Name)) // hidden property { return(infoBy(name, info.Link, strict)); } string elem = (new StringHandler()).protectMixedQuotes(info.Name); elem = Regex.Replace(elem, RPattern.RoundBracketsContent, "()", RegexOptions.IgnorePatternWhitespace); if ((strict && elem == name) || (!strict && elem.Contains(name))) { return(info); } } return(null); }
/// <summary> /// List of constructed data by identification of node /// </summary> /// <param name="ident">Identificator of node</param> /// <returns></returns> public IEnumerable<INodeInfo> getBy(NodeIdent ident = new NodeIdent()) { if(data.ContainsKey(ident)) { foreach(INodeInfo elem in data[ident].OrderBy(p => p.Name)) { if(isEnabled(elem.Name)) { yield return elem; } } } }
protected IEnumerable<ICompletionData> list(NodeIdent ident, string name = null) { INodeInfo hidden = isHiddenLevel(ident); if(hidden != null) { foreach(ICompletionData inf in list(hidden.Link, name)) { yield return inf; } } else { foreach(INodeInfo inf in Inspector.getBy(ident)) { if(!String.IsNullOrEmpty(name) && !inf.Name.Contains(name)) { continue; } yield return new CompletionData( inf.Name, inf.Displaying, String.Format("{0}\n{1}\n{2}", inf.Description, new String('_', 20), inf.Signature), inf.Type); } } }
/// <param name="ident"></param> /// <returns>node of the hidden level or null value if level is not hidden</returns> protected INodeInfo isHiddenLevel(NodeIdent ident) { INodeInfo ret = null; foreach(INodeInfo info in Inspector.getBy(ident)) { if(!String.IsNullOrEmpty(info.Name)) { return null; } ret = info; } return ret; }
/// <param name="name">Element name</param> /// <param name="ident">Identificator of node</param> /// <param name="strict"></param> /// <returns>null value if not found</returns> protected INodeInfo infoBy(string name, NodeIdent ident, bool strict) { foreach(INodeInfo info in Inspector.getBy(ident)) { if(String.IsNullOrEmpty(info.Name)) { // hidden property return infoBy(name, info.Link, strict); } string elem = (new StringHandler()).protectMixedQuotes(info.Name); elem = Regex.Replace(elem, RPattern.RoundBracketsContent, "()", RegexOptions.IgnorePatternWhitespace); if((strict && elem == name) || (!strict && elem.Contains(name))) { return info; } } return null; }
/// <param name="cmd">Pushed command</param> /// <param name="component">INodeInfo component for searching</param> /// <param name="raw">Full raw string to finding</param> /// <returns></returns> protected IEnumerable<ICompletionData> find(KeysCommand cmd, INodeInfo component, string raw) { if(raw == null) { if(cmd == KeysCommand.CtrlSpace || cmd == KeysCommand.Space) { return list(new NodeIdent(component.Name, null)); } return ListNull; } if(cmd == KeysCommand.Space) { return ListNull; } string ident = (new StringHandler()).protectMixedQuotes(raw.Trim()); if(_isLatest('.', ident)) { ident = ident.Substring(0, ident.Length - 1); if(cmd == KeysCommand.CtrlSpace) { cmd = KeysCommand.LevelByDot; } } if(cmd == KeysCommand.CtrlSpace) { if(Regex.IsMatch(raw, @"(?: \s+ | \([^.)]*? | \) )$", RegexOptions.IgnorePatternWhitespace)) { return ListNull; } } string[] parts = Regex.Replace(ident, RPattern.RoundBracketsContent, "()", RegexOptions.IgnorePatternWhitespace ).Split('.'); NodeIdent id = new NodeIdent(component.Name, null); for(int i = 0; i < parts.Length; ++i) { parts[i] = parts[i].Trim(); if(cmd == KeysCommand.CtrlSpace && i == parts.Length - 1) { return list(id, parts[i]); } INodeInfo info = infoBy(parts[i], id, (cmd == KeysCommand.LevelByDot)); if(info == null) { return ListEmpty; } id = info.Link; } if(cmd == KeysCommand.LevelByDot) { return list(id); } return ListEmpty; }
protected IEnumerable<INodeInfo> domElemsBy(NodeIdent ident) { foreach(INodeInfo info in inspector.getBy(ident)) { if(!String.IsNullOrEmpty(info.Name)) { yield return info; } foreach(INodeInfo child in domElemsBy(info.Link)) { yield return child; } } }
/// <param name="name">Element name</param> /// <param name="description">Description for current element</param> /// <param name="ident">Link to the binding with other node</param> /// <param name="type">Element type</param> /// <param name="displaying">Displays element over the 'Name' property</param> public NodeInfo(string name, string description, NodeIdent ident, InfoType type = InfoType.Unspecified, string displaying = null) : this(name, description, type, displaying) { Link = ident; }
/// <param name="cmd">Pushed command</param> /// <param name="component">INodeInfo component for searching</param> /// <param name="raw">Full raw string to finding</param> /// <returns></returns> protected IEnumerable <ICompletionData> find(KeysCommand cmd, INodeInfo component, string raw) { if (raw == null) { if (cmd == KeysCommand.CtrlSpace || cmd == KeysCommand.Space) { return(list(new NodeIdent(component.Name, null))); } return(ListNull); } if (cmd == KeysCommand.Space) { return(ListNull); } string ident = (new StringHandler()).protectMixedQuotes(raw.Trim()); if (_isLatest('.', ident)) { ident = ident.Substring(0, ident.Length - 1); if (cmd == KeysCommand.CtrlSpace) { cmd = KeysCommand.LevelByDot; } } if (cmd == KeysCommand.CtrlSpace) { if (Regex.IsMatch(raw, @"(?: \s+ | \([^.)]*? | \) )$", RegexOptions.IgnorePatternWhitespace)) { return(ListNull); } } string[] parts = Regex.Replace(ident, RPattern.RoundBracketsContent, "()", RegexOptions.IgnorePatternWhitespace ).Split('.'); NodeIdent id = new NodeIdent(component.Name, null); for (int i = 0; i < parts.Length; ++i) { parts[i] = parts[i].Trim(); if (cmd == KeysCommand.CtrlSpace && i == parts.Length - 1) { return(list(id, parts[i])); } INodeInfo info = infoBy(parts[i], id, (cmd == KeysCommand.LevelByDot)); if (info == null) { return(ListEmpty); } id = info.Link; } if (cmd == KeysCommand.LevelByDot) { return(list(id)); } return(ListEmpty); }
/// <param name="type">Type of element</param> /// <param name="attr">Found attribute</param> /// <param name="data"></param> protected void inspectLevelA(Type type, Attribute attr, LInfo data) { if(!isComponent(type) || (attr.GetType() != typeof(DefinitionAttribute) && attr.GetType() != typeof(ComponentAttribute))) { return; } IAttrDomLevelA levA = (IAttrDomLevelA)attr; NodeIdent ident = new NodeIdent(levA.Parent, null); if(!data.ContainsKey(ident)) { data[ident] = new List<INodeInfo>(); } if(attr.GetType() == typeof(DefinitionAttribute)) { data[ident].Add(new NodeInfo((DefinitionAttribute)attr)); return; } if(attr.GetType() == typeof(ComponentAttribute)) { INodeInfo node = new NodeInfo((ComponentAttribute)attr); data[ident].Add(node); aliasesToNodeLevelA(node, data[ident]); return; } }
/// <param name="type">Type of element</param> /// <param name="attr">Found attribute</param> /// <param name="method">Found method</param> /// <param name="data"></param> protected void inspectLevelB(Type type, Attribute attr, MethodInfo method, LInfo data) { if(!isComponent(type) || (attr.GetType() != typeof(MethodAttribute) && attr.GetType() != typeof(PropertyAttribute))) { return; } IAttrDomLevelB levB = (IAttrDomLevelB)attr; string className = method.DeclaringType.FullName; NodeIdent ident = new NodeIdent((levB.Parent)?? getComponentName(type), levB.Method, (levB.Method == null)? null : className); if(!data.ContainsKey(ident)) { data[ident] = new List<INodeInfo>(); } className = (method.Name == null)? null : className; if(attr.GetType() == typeof(PropertyAttribute)) { data[ident].Add(new NodeInfo((PropertyAttribute)attr, method.Name, className)); return; } if(attr.GetType() == typeof(MethodAttribute)) { data[ident].Add(new NodeInfo((MethodAttribute)attr, method.Name, className)); return; } }