private void SaveYaml(string yamlPath) { try { log.InfoFormat("Saving YAML file: {0}", yamlPath); var tags = new List <string>(); foreach (var tag in ModTags) { if (tag.Selected) { tags.AddIfMissing(tag.Title); } } if (!string.IsNullOrWhiteSpace(AdditionalTags)) { foreach (var tag in AdditionalTags.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { tags.AddIfMissing(tag.Trim()); } } ModDetails details = new ModDetails() { Author = ModAuthor, Title = ModTitle, Notes = ModNotes, PreviewPath = ModPreview, Files = ModFiles.ToList(), Tags = tags }; details.SaveYamlFile(yamlPath); } catch (Exception ex) { log.Error(string.Format("Error saving YAML file {0}", yamlPath), ex); } }
public void GetBases(string typeName, List<string> baseNames, List<string> interfaceNames, List<string> allNames) { if (typeName == "array-type") { baseNames.AddIfMissing("System.Array"); allNames.AddIfMissing("System.Array"); interfaceNames.AddIfMissing("System.Collections.IList"); allNames.AddIfMissing("System.Collections.IList"); interfaceNames.AddIfMissing("System.Collections.Generic.IList`1"); allNames.AddIfMissing("System.Collections.Generic.IList`1"); } else if (typeName == "nullable-type") { baseNames.AddIfMissing("System.Nullable`1"); allNames.AddIfMissing("System.Nullable`1"); } else if (typeName == "pointer-type") { // can't use the . operator with pointers } else if (BaseClasses != null) { string b; if (BaseClasses.TryGetValue(typeName, out b)) { baseNames.AddIfMissing(b); allNames.AddIfMissing(b); } } }
public void GetBases(string typeName, List<string> baseNames, List<string> interfaceNames, List<string> allNames) { if (m_disposed) throw new ObjectDisposedException(GetType().Name); Profile.Start("TargetDatabase::GetBases"); if (typeName == "array-type") { baseNames.AddIfMissing("System.Array"); allNames.AddIfMissing("System.Array"); interfaceNames.AddIfMissing("System.Collections.IList"); allNames.AddIfMissing("System.Collections.IList"); interfaceNames.AddIfMissing("System.Collections.Generic.IList`1"); allNames.AddIfMissing("System.Collections.Generic.IList`1"); } else if (typeName == "nullable-type") { baseNames.AddIfMissing("System.Nullable`1"); allNames.AddIfMissing("System.Nullable`1"); } else if (typeName == "pointer-type") { // can't use the . operator with pointers } else { string sql = string.Format(@" SELECT base_root_name, interface_root_names FROM Types WHERE root_name = '{0}'", typeName.Replace("'", "''")); string[][] rows = m_database.QueryRows(sql); Contract.Assert(rows.Length <= 1, "too many rows"); if (rows.Length > 0) { if (rows[0][0].Length > 0) { baseNames.AddIfMissing(rows[0][0]); allNames.AddIfMissing(rows[0][0]); } string[] names = rows[0][1].Split(new char[]{':'}, StringSplitOptions.RemoveEmptyEntries); foreach (string name in names) { interfaceNames.AddIfMissing(name); allNames.AddIfMissing(name); } } } Profile.Stop("TargetDatabase::GetBases"); }
public void AddIfMissingTest() { var listOfStrings = new List <string>(); listOfStrings.AddIfMissing("AA"); listOfStrings.AddIfMissing("AA"); listOfStrings.AddIfMissing("AA"); listOfStrings.AddIfMissing("BB"); listOfStrings.AddIfMissing("BB"); Assert.AreEqual(2, listOfStrings.Count); Assert.IsTrue(listOfStrings.Contains("AA")); Assert.IsTrue(listOfStrings.Contains("BB")); }
public void AddIfMissingUsingMatcherTest() { Func <string, string, bool> matcher = (s1, s2) => s1.Substring(0, 1) == s2.Substring(0, 1); var listOfStrings = new List <string>(); listOfStrings.AddIfMissing("AA", matcher); listOfStrings.AddIfMissing("AA", matcher); listOfStrings.AddIfMissing("AA", matcher); listOfStrings.AddIfMissing("A", matcher); listOfStrings.AddIfMissing("A", matcher); Assert.AreEqual(1, listOfStrings.Count); Assert.IsTrue(listOfStrings.Contains("AA")); }
public void AddIfMissingListShouldNotAddIfExists() { var list = new List <int>(Numbers); list.AddIfMissing(1); Assert.AreEqual(4, list.Count); }
public void AddIfMissingListShouldAddIfNotFound() { var list = new List <int>(Numbers); list.AddIfMissing(5); Assert.AreEqual(5, list.Count); Assert.IsTrue(list.Contains(5)); }
private void DoGetParsedExtensions(CsGlobalNamespace globals, string targetType, List<Item> items) { CsType[] types = DoGetAllParsedTypes(globals); foreach (CsType type in types) { foreach (CsMethod method in type.Methods) { if (method.IsExtension) { string fullName = DoGetFullParsedName(globals, method.Parameters[0].Type); if (targetType == fullName) { List<string> argTypes = (from p in method.Parameters select p.ModifiedType).ToList(); List<string> argNames = (from p in method.Parameters select p.Name).ToList(); argTypes.RemoveAt(0); argNames.RemoveAt(0); // TODO: should add gargs if they cannot be deduced items.AddIfMissing(new MethodItem(method.ReturnType, method.Name, null, argTypes.ToArray(), argNames.ToArray(), method.ReturnType, "extension methods")); } } } } }
private string[] DoGetBases(CsGlobalNamespace globals, string typeName, List<CsType> types, List<string> baseNames, List<string> interfaceNames) { #if TEST var parses = new CsParser.Parses(); #else Boss boss = ObjectModel.Create("CsParser"); var parses = boss.Get<IParses>(); #endif var allNames = new List<string>(); allNames.Add(typeName); int i = 0; while (i < allNames.Count) { string name = allNames[i++]; // Note that we want to use CsType instead of the database where possible // because it should be more up to date. CsType type = parses.FindType(name); if (type != null) types.Add(type); if (type is CsEnum) { name = "System.Enum"; type = null; } // If the type is partial then the parsed types (probably) do not include all // of the items so we need to include both the parsed and database // info to ensure we get everything. if (type == null || (type.Modifiers & MemberModifiers.Partial) != 0) if (CsHelpers.IsInterface(name)) interfaceNames.AddIfMissing(name); else baseNames.AddIfMissing(name); if (type != null) DoGetParsedBases(globals, type, baseNames, interfaceNames, allNames); else m_database.GetBases(name, baseNames, interfaceNames, allNames); } return allNames.ToArray(); }
private void DoGetParsedBases(CsGlobalNamespace globals, CsType type, List<string> baseNames, List<string> interfaceNames, List<string> allNames) { baseNames.AddIfMissing("System.Object"); allNames.AddIfMissing("System.Object"); foreach (string name in type.Bases.Names) { string fullName = DoGetFullParsedName(globals, name); if (fullName != null) { if (CsHelpers.IsInterface(fullName)) interfaceNames.AddIfMissing(fullName); else baseNames.AddIfMissing(fullName); allNames.AddIfMissing(fullName); } } }
public Item[] GetExtensionMethods(string[] typeNames, string[] namespaces, string name, int arity) { if (m_disposed) throw new ObjectDisposedException(GetType().Name); Profile.Start("TargetDatabase::GetExtensionMethods2"); var items = new List<Item>(); if (typeNames.Length > 0) { var types = new StringBuilder(); for (int i = 0; i < typeNames.Length; ++i) { types.AppendFormat("Methods.extend_type_name = '{0}'", typeNames[i].Replace("'", "''")); if (i + 1 < typeNames.Length) types.Append(" OR "); } var ns = new StringBuilder(); if (namespaces.Length > 0) { ns.Append(" AND ("); for (int i = 0; i < namespaces.Length; ++i) { ns.AppendFormat("Types.namespace = '{0}'", namespaces[i].Replace("'", "''")); if (i + 1 < namespaces.Length) ns.Append(" OR "); } ns.Append(')'); } string sql = string.Format(@" SELECT Methods.display_text, Methods.return_type_name FROM Methods, Types WHERE Methods.name = '{0}' AND Methods.params_count = '{1}' AND Methods.static = 1 AND Methods.kind = 8 AND Methods.declaring_root_name = Types.root_name AND ({2}){3}", name, arity + 1, types.ToString(), ns.ToString()); string[][] rows = m_database.QueryRows(sql); foreach (string[] r in rows) { Item item = DoCreateItem(r[0], "extension methods", 8, r[1]); items.AddIfMissing(item); } } Profile.Stop("TargetDatabase::GetExtensionMethods2"); return items.ToArray(); }
public static List <string> AddIfMissing(this List <string> items, string value) { return(items.AddIfMissing(new[] { value })); }
public Item[] GetStemmedTypes(string[] namespaces, string stem) { if (m_disposed) throw new ObjectDisposedException(GetType().Name); Profile.Start("TargetDatabase::GetStemmedTypes"); var items = new List<Item>(); var ns = new StringBuilder(); if (namespaces.Length > 0) { ns.Append('('); for (int i = 0; i < namespaces.Length; ++i) { ns.AppendFormat("namespace = '{0}'", namespaces[i]); if (i + 1 < namespaces.Length) ns.Append(" OR "); } ns.Append(") AND"); } string sql; if (stem.Length > 0) sql = string.Format(@" SELECT name, root_name FROM Types WHERE visibility < 3 AND {0} name GLOB '{1}*'", ns.ToString(), stem); else sql = string.Format(@" SELECT name, root_name FROM Types WHERE {0} visibility < 3", ns.ToString()); string[][] rows = m_database.QueryRows(sql); foreach (string[] r in rows) { var item = new NameItem(r[0], r[1], "types"); items.AddIfMissing(item); } Profile.Stop("TargetDatabase::GetStemmedTypes"); return items.ToArray(); }
public Item[] GetMembers(string[] typeNames, bool instanceCall, bool isStaticCall, string name, int arity, bool includeProtected) { if (m_disposed) throw new ObjectDisposedException(GetType().Name); Profile.Start("TargetDatabase::GetMembers2"); var items = new List<Item>(); if (typeNames.Length > 0) { var types = new StringBuilder(); for (int i = 0; i < typeNames.Length; ++i) { types.AppendFormat("declaring_root_name = '{0}'", typeNames[i].Replace("'", "''")); if (i + 1 < typeNames.Length) types.Append(" OR "); } string access = includeProtected ? "access < 3" : "(access = 0 OR access = 2)"; string sql; if (instanceCall && isStaticCall) sql = string.Format(@" SELECT display_text, declaring_root_name, kind, return_type_name, name FROM Methods WHERE (name = '{0}' OR name = '{1}') AND params_count = {2} AND (kind <= 2 OR kind = 5) AND {4} AND ({3})", name, "get_" + name, arity, types.ToString(), access); else sql = string.Format(@" SELECT display_text, declaring_root_name, kind, return_type_name, name FROM Methods WHERE (name = '{0}' OR name = '{1}') AND params_count = {2} AND static = {4} AND {5} AND (kind <= 2 OR kind = 5) AND ({3})", name, "get_" + name, arity, types.ToString(), isStaticCall ? "1" : "0", access); NamedRows rows = m_database.QueryNamedRows(sql); foreach (NamedRow r in rows) { int kind = int.Parse(r["kind"]); if (kind <= 2) { Item item = DoCreateItem(r["display_text"], r["declaring_root_name"], kind, r["return_type_name"]); items.AddIfMissing(item); } else { string eName = r["name"]; int i = eName.IndexOf('_'); eName = eName.Substring(i + 1); Item item = new NameItem(eName, "event " + eName, r["declaring_root_name"], "event-type"); items.AddIfMissing(item); } } } Profile.Stop("TargetDatabase::GetMembers2"); return items.ToArray(); }
private Item[] DoGetConstructorsNamed(CsGlobalNamespace globals, ref string stem) { Profile.Start("AutoComplete::DoGetConstructorsNamed"); var items = new List<Item>(); var namespaces = new List<string>(); int j = stem.LastIndexOf('.'); if (j > 0) { string ns = stem.Substring(0, j); stem = stem.Substring(j + 1); DoAddConstructors(ns, stem, items); } else { DoAddConstructors(null, stem, items); namespaces.AddIfMissing(string.Empty); for (int i = 0; i < globals.Namespaces.Length; ++i) { DoAddConstructors(globals.Namespaces[i].Name, stem, items); namespaces.AddIfMissing(globals.Namespaces[i].Name); } for (int i = 0; i < globals.Uses.Length; ++i) { DoAddConstructors(globals.Uses[i].Namespace, stem, items); namespaces.AddIfMissing(globals.Uses[i].Namespace); } } items.AddIfMissingRange(m_database.GetStemmedCtors(namespaces.ToArray(), stem)); Profile.Stop("AutoComplete::DoGetConstructorsNamed"); return items.ToArray(); }
private string[] DoGetPaths() { var children = new List<string>(); try { foreach (string entry in System.IO.Directory.GetFileSystemEntries(Path)) { if (!m_controller.IsIgnored(System.IO.Path.GetFileName(entry))) { string path = UnixPath.GetCanonicalPath(entry); children.AddIfMissing(path); } } } catch (System.IO.IOException) { // If the file system is changing via another process we may land here. } return children.ToArray(); }
private void DoAddParsedTypes(List<Item> items, string ns, string stem) { CsType[] types = m_parses.FindTypes(ns, stem); foreach (CsType type in types) { var item = new NameItem(type.Name, type.FullName, ns + " types", type.FullName); items.AddIfMissing(item); } }
private void DoAddRealTypes(List<Item> items, CsGlobalNamespace globals, string stem) { var namespaces = new List<string>(); DoAddParsedTypes(items, (string) null, stem); namespaces.AddIfMissing(string.Empty); for (int i = 0; i < globals.Namespaces.Length; ++i) { DoAddParsedTypes(items, globals.Namespaces[i].Name, stem); namespaces.AddIfMissing(globals.Namespaces[i].Name); } for (int i = 0; i < globals.Uses.Length; ++i) { DoAddParsedTypes(items, globals.Uses[i].Namespace, stem); namespaces.AddIfMissing(globals.Uses[i].Namespace); } items.AddIfMissingRange(m_database.GetStemmedTypes(namespaces.ToArray(), stem)); }
private void DoAddConstructor(string ns, string inGargs, string typeName, string name, CsParameter[] parameters, List<Item> items) { string[] gargs = null; if (inGargs != null) gargs = inGargs.Split(','); string[] argTypes = (from p in parameters select p.ModifiedType).ToArray(); string[] argNames = (from p in parameters select p.Name).ToArray(); string nsName = ns == "<globals>" ? "global" : ns; var item = new MethodItem("System.Void", name, gargs, argTypes, argNames, typeName, nsName + " constructors"); items.AddIfMissing(item); }
private void DoAddAliasedTypes(List<Item> items, string stem) { IEnumerable<string> aliases = CsHelpers.GetAliasedNames(); foreach (string alias in aliases) { if (alias.StartsWith(stem)) { var item = new NameItem(alias, CsHelpers.GetRealName(alias), "System types", CsHelpers.GetRealName(alias)); items.AddIfMissing(item); } } }
/// <summary> /// Gets the resulting price from complex algorithm, with the flag "market" if the price /// was obtained from the Steam Community Market. /// </summary> /// <param name="item">Item to check</param> /// <returns>The resulting price with flags</returns> public static FlaggedResult<PriceRange?, string> GetPriceFlagged(ItemPriceInfo item) { List<string> flags = new List<string>(); PriceRange? res = null; if (item.Skin != null) { res = GetSkinPrice(item.Item, item.SkinWear.GetValueOrDefault()); flags.AddIfMissing("market"); } if (res == null && item.Killstreak != KillstreakType.None) { res = GetKillstreakPrice(item.Item, item.Quality, item.Killstreak, item.Australium); flags.AddIfMissing("market"); } if (res == null) { res = GetNormalPrice(item.Item, item.Quality, item.Craftable, item.Australium, item.Unusual); } if (res == null) // still { string hash = MarketPricing.GetMarketHash(item.Item, item.Killstreak, item.Quality); res = GetMarketPriceRange(hash); flags.AddIfMissing("market"); } return new FlaggedResult<PriceRange?, string>(res, flags); }
private void DoGetParsedMembers(CsType type, bool isInstance, bool isStatic, List<Item> items, bool includePrivates, bool includeProtected) { CsEnum e = type as CsEnum; if (e != null) { if (isStatic) { var candidates = from n in e.Names select new NameItem(n, type.FullName + ' ' + n, type.FullName, type.FullName); foreach (Item item in candidates) { items.AddIfMissing(item); } } } else DoGetParsedTypeMembers(type, isInstance, isStatic, items, includePrivates, includeProtected); }
public Item[] GetFields(string[] typeNames, bool instanceCall, bool isStaticCall, string name, bool includeProtected) { if (m_disposed) throw new ObjectDisposedException(GetType().Name); Profile.Start("TargetDatabase::GetFields2"); var items = new List<Item>(); if (typeNames.Length > 0) { var types = new StringBuilder(); for (int i = 0; i < typeNames.Length; ++i) { types.AppendFormat("declaring_root_name = '{0}'", typeNames[i].Replace("'", "''")); if (i + 1 < typeNames.Length) types.Append(" OR "); } string access = includeProtected ? "access < 3" : "(access = 0 OR access = 2)"; string sql; if (instanceCall && isStaticCall) sql = string.Format(@" SELECT name, type_name, declaring_root_name FROM Fields WHERE name = '{0}' AND {2} AND ({1})", name, types.ToString(), access); // we exclude all private fields (note that this won't affect this methods since the parser will pick up those) else sql = string.Format(@" SELECT name, type_name, declaring_root_name FROM Fields WHERE name = '{0}' AND static = {2} AND {3} AND ({1})", name, types.ToString(), isStaticCall ? "1" : "0", access); string[][] rows = m_database.QueryRows(sql); foreach (string[] r in rows) { items.AddIfMissing(new NameItem(r[0], r[1] + ' ' + r[0], r[2], r[1])); } } Profile.Stop("TargetDatabase::GetFields2"); return items.ToArray(); }
private void DoGetParsedTypeMembers(CsType type, bool isInstance, bool isStatic, List<Item> items, bool includePrivates, bool includeProtected) { foreach (CsField field in type.Fields) { if (DoShouldAdd(isInstance, isStatic, field.Modifiers)) if (includePrivates || field.Access != MemberModifiers.Private) if (includeProtected || field.Access != MemberModifiers.Protected) items.AddIfMissing(new NameItem(field.Name, field.Type + ' ' + field.Name, type.FullName, field.Type)); } foreach (CsMethod method in type.Methods) { if (!method.IsConstructor && !method.IsFinalizer) { if (DoShouldAdd(isInstance, isStatic, method.Modifiers)) { if (includePrivates || method.Access != MemberModifiers.Private) { if (includeProtected || method.Access != MemberModifiers.Protected) { string[] argTypes = (from p in method.Parameters select p.ModifiedType).ToArray(); string[] argNames = (from p in method.Parameters select p.Name).ToArray(); // TODO: should add gargs if they cannot be deduced items.AddIfMissing(new MethodItem(method.ReturnType, method.Name, null, argTypes, argNames, method.ReturnType, type.FullName)); } } } } } // Note that indexers are not counted because they are not preceded with a dot. foreach (CsProperty prop in type.Properties) { if (prop.HasGetter || prop.HasSetter) { if (DoShouldAdd(isInstance, isStatic, prop.Modifiers)) { if (includePrivates || prop.Access != MemberModifiers.Private) { if (includeProtected || prop.Access != MemberModifiers.Protected) { string rtype = prop.HasGetter ? prop.ReturnType : "void"; items.AddIfMissing(new NameItem(prop.Name, rtype + ' ' + prop.Name, type.FullName, rtype)); } } } } } foreach (CsEvent e in type.Events) { if (DoShouldAdd(isInstance, isStatic, e.Modifiers)) { if (includePrivates || e.Access != MemberModifiers.Private) { if (includeProtected || e.Access != MemberModifiers.Protected) { string rtype = "event-type"; items.AddIfMissing(new NameItem(e.Name, "event " + e.Name, e.FullName, rtype)); } } } } }
public Item[] GetStemmedCtors(string[] namespaces, string stem) { if (m_disposed) throw new ObjectDisposedException(GetType().Name); Profile.Start("TargetDatabase::GetStemmedCtors"); var items = new List<Item>(); int badAttrs = 0x01 | // abstract 0x04 | // interface 0x10 | // enum 0x40; // delegate string common = string.Format(@"Methods.static = 0 AND Methods.kind = 6 AND Types.visibility < 3 AND Methods.access < 3 AND (Types.attributes & {0}) = 0 AND Methods.declaring_root_name = Types.root_name", badAttrs); var ns = new StringBuilder(); if (namespaces.Length > 0) { ns.Append('('); for (int i = 0; i < namespaces.Length; ++i) { ns.AppendFormat("Types.namespace = '{0}'", namespaces[i]); if (i + 1 < namespaces.Length) ns.Append(" OR "); } ns.Append(") AND"); } string sql; if (stem.Length > 0) sql = string.Format(@" SELECT Methods.display_text, Methods.return_type_name, Types.namespace FROM Methods, Types WHERE {2} AND {0} Types.name GLOB '{1}*'", ns.ToString(), stem, common); else sql = string.Format(@" SELECT Methods.display_text, Methods.return_type_name, Types.namespace FROM Methods, Types WHERE {0} {1}", ns.ToString(), common); string[][] rows = m_database.QueryRows(sql); foreach (string[] r in rows) { string nsName = r[2] == "<globals>" || r[2].Length == 0 ? "global" : r[2]; Item item = DoCreateItem(r[0], nsName + " constructors", 6, r[1]); items.AddIfMissing(item); } DoAddDefaultCtors(ns.ToString(), stem, badAttrs, items); Profile.Stop("TargetDatabase::GetStemmedCtors"); return items.ToArray(); }
public Item[] GetExtensionMethods(string[] typeNames, string[] namespaces, string name, int arity) { var result = new List<Item>(); if (ExtensionMethods != null) { foreach (string typeName in typeNames) { foreach (string ns in namespaces) { Item[] members; if (ExtensionMethods.TryGetValue(ns + "." + typeName, out members)) { foreach (Item member in members) { MethodItem method = member as MethodItem; if (method != null && method.Name == name && method.Arity == arity) result.AddIfMissing(member); else if (method == null && member.Text == name && arity == 0) result.AddIfMissing(member); } } } } } return result.ToArray(); }
private void DoAddDefaultCtors(string ns, string stem, int badAttrs, List<Item> items) { string common = string.Format("visibility < 3 AND (attributes & {0}) = 0", badAttrs); if (ns.Length > 0) ns = ns.Replace("Types.", string.Empty); string sql; if (stem.Length > 0) sql = string.Format(@" SELECT attributes, name, namespace FROM Types WHERE {2} AND {0} name GLOB '{1}*'", ns, stem, common); else sql = string.Format(@" SELECT attributes, name, root_name FROM Types WHERE {0} {1}", ns, common); string[][] rows = m_database.QueryRows(sql); foreach (string[] r in rows) { int attrs = int.Parse(r[0]); if ((attrs & 0x08) != 0) // struct { string displayText = string.Format("void:{0}:{1}:::", r[2], r[1]); string nsName = r[2] == "<globals>" || r[2].Length == 0 ? "global" : r[2]; Item item = DoCreateItem(displayText, nsName + " constructors", 6, "System.Void"); items.AddIfMissing(item); } } }
private void DoFindNamespaces(string prefix, string parent, CsNamespace ns, List<string> names) { string name = null; if (ns.Name != "<globals>") name = parent != null ? (parent + "." + ns.Name) : ns.Name; if (name != null) if (prefix.Length > 0 && name.StartsWith(prefix)) names.AddIfMissing(name.Substring(prefix.Length)); else if (prefix.Length == 0) names.AddIfMissing(name); foreach (CsNamespace child in ns.Namespaces) { DoFindNamespaces(prefix, name, child, names); } }
public Item[] GetMembers(string[] typeNames, bool instanceCall, bool isStaticCall, string name, int arity, bool includeProtected) { var result = new List<Item>(); if (Members != null) { foreach (string typeName in typeNames) { Item[] members; if (Members.TryGetValue(typeName, out members)) { foreach (Item member in members) { MethodItem method = member as MethodItem; if (method != null && method.Name == name && method.Arity == arity) result.AddIfMissing(member); else if (method == null && member.Text == name && arity == 0) result.AddIfMissing(member); } } } } return result.ToArray(); }
private Item[] DoGetNames(CsGlobalNamespace globals, int location, string stem, ref bool isInstance, ref bool isStatic) { Profile.Start("AutoComplete::DoGetNames"); var result = new List<Item>(); var context = FindDeclaration(globals, location) as CsMember; var nameResolver = new ResolveName(context, m_database, m_locals, m_text.Text, location, globals); ResolvedTarget target = nameResolver.Resolve("<this>"); if (target != null) { var items = new List<Item>(m_members.Resolve(context, target, globals)); foreach (Variable v in nameResolver.Variables) { items.AddIfMissing(new NameItem(v.Name, v.Type + ' ' + v.Name, v.Filter, v.Type)); } if (stem.Length > 0) items.RemoveAll(m => !m.Text.StartsWith(stem)); result = items; isInstance = target.IsInstance; isStatic = target.IsStatic; } if (stem.Length > 0) { DoAddAliasedTypes(result, stem); DoAddRealTypes(result, globals, stem); } Profile.Stop("AutoComplete::DoGetNames"); return result.ToArray(); }
public Item[] GetNamespaces(string ns) { if (m_disposed) throw new ObjectDisposedException(GetType().Name); var items = new List<Item>(); Profile.Start("TargetDatabase::GetNamespaces"); if (ns.Length > 0) { string sql = string.Format(@" SELECT children FROM Namespaces WHERE parent = '{0}'", ns); string[][] rows = m_database.QueryRows(sql); foreach (string[] r in rows) { string[] children = r[0].Split(';'); foreach (string child in children) { var item = new NameItem(child, ns + '.' + child, "Namespaces"); items.AddIfMissing(item); } } } else { string sql = @" SELECT parent, children FROM Namespaces"; string[][] rows = m_database.QueryRows(sql); foreach (string[] r in rows) { string[] children = r[1].Split(';'); foreach (string child in children) { var item = new NameItem(r[0] + '.' + child, ns + '.' + r[0] + '.' + child, "Namespaces"); items.AddIfMissing(item); } } } Profile.Stop("TargetDatabase::GetNamespaces"); return items.ToArray(); }
public Item[] GetExtensionMethods(string[] typeNames, string[] namespaces) { var result = new List<Item>(); if (ExtensionMethods != null) { foreach (string typeName in typeNames) { foreach (string ns in namespaces) { Item[] members; if (ExtensionMethods.TryGetValue(ns + "." + typeName, out members)) { foreach (Item member in members) { result.AddIfMissing(member); } } } } } return result.ToArray(); }
private Item[] DoGetNamespacesNamed(string name) { Profile.Start("AutoComplete::DoGetNamespacesNamed"); var items = new List<Item>(m_database.GetNamespaces(name)); string[] names = m_parses.FindNamespaces(name); #if DEBUG Log.WriteLine(TraceLevel.Verbose, "AutoComplete", "db namespaces: {0}", items.ToDebugString()); Log.WriteLine(TraceLevel.Verbose, "AutoComplete", "parsed namespaces: {0}", names.ToDebugString()); #endif foreach (string n in names) { var item = new NameItem(n, name + '.' + n, name + " types"); items.AddIfMissing(item); } Profile.Stop("AutoComplete::DoGetNamespacesNamed"); return items.ToArray(); }
public Item[] GetMembers(string[] typeNames, bool instanceCall, bool isStaticCall, bool includeProtected) { var result = new List<Item>(); if (Members != null) { foreach (string typeName in typeNames) { Item[] members; if (Members.TryGetValue(typeName, out members)) { foreach (Item member in members) { result.AddIfMissing(member); } } } } return result.ToArray(); }
private List<string> DoFindBuilder(string dir) { var candidates = new List<string>(); foreach (string file in Directory.GetFiles(dir, "*.*", SearchOption.AllDirectories)) { string ext = Path.GetExtension(file); if (m_builders.ContainsKey(ext)) { candidates.AddIfMissing(m_builders[ext]); } } return candidates; }
/// <summary> /// Adds a task to the timed thread for processing. /// </summary> /// <param name="task">The task.</param> public void Add(ITimedTask task) { lock (sync) tasks.AddIfMissing(task); StartIfRequired(); }
private void DoUpdateTargets(string name, object inValue) { NSUserDefaults defaults = NSUserDefaults.standardUserDefaults(); string value = defaults.stringForKey(NSString.Create("globalIgnores")).To<NSString>().ToString(); string[] ignored = value.Split(new char[]{'\n', '\r'}, StringSplitOptions.RemoveEmptyEntries); List<string> titles = new List<string>(); foreach (string title in m_builder.Targets) { if (Array.IndexOf(ignored, title) < 0 && Array.IndexOf(m_ignoredTargets, title) < 0) titles.AddIfMissing(title); } if (titles.Count != m_targets.itemTitles().count()) { m_targets.removeAllItems(); m_targets.addItemsWithTitles(NSArray.Create(titles.ToArray())); if (Array.IndexOf(ignored, m_builder.Target) < 0 && Array.IndexOf(m_ignoredTargets, m_builder.Target) < 0) m_targets.selectItemWithTitle(NSString.Create(m_builder.Target)); else m_builder.Target = m_targets.titleOfSelectedItem().description(); } }