IType GetClass(SerializationCodeCompletionDatabase db, string typeName, IList <IReturnType> genericArguments, bool caseSensitive) { if (db != null) { IType c = db.GetClass(typeName, genericArguments, caseSensitive); if (c != null) { return(c); } foreach (ReferenceEntry re in db.References) { SerializationCodeCompletionDatabase cdb = GetDatabase(re.Uri); if (cdb == null) { continue; } c = cdb.GetClass(typeName, genericArguments, caseSensitive); if (c != null) { return(c); } } } return(null); }
HashSet <IType> SearchSubclasses(Dictionary <SerializationCodeCompletionDatabase, HashSet <IType> > visited, IType btype, IList <string> namespaces, SerializationCodeCompletionDatabase db) { HashSet <IType> types; if (visited.TryGetValue(db, out types)) { return(types); } types = new HashSet <IType> (GetSubclassesTree(db, btype, namespaces)); visited [db] = types; // For each reference, get the list of subclasses implemented in that reference, // then look for subclasses of any of those in the current db // A project can only have subclasses of classes implemented in assemblies it references foreach (ReferenceEntry re in db.References) { SerializationCodeCompletionDatabase cdb = GetDatabase(re.Uri); if (cdb != null && cdb != db) { HashSet <IType> refTypes = SearchSubclasses(visited, btype, namespaces, cdb); foreach (IType t in refTypes) { foreach (IType st in GetSubclassesTree(db, t, namespaces)) { types.Add(st); } } } } return(types); }
public IType DeepGetClass(SerializationCodeCompletionDatabase db, string typeName, IList <IReturnType> genericArguments, bool caseSensitive) { if (db == null) { return(null); } IType c = db.GetClass(typeName, genericArguments, caseSensitive); if (c != null) { return(c); } foreach (ReferenceEntry re in db.References) { SerializationCodeCompletionDatabase cdb = GetDatabase(re.Uri); if (cdb == null) { continue; } // deep get class should only go to depth 1, to prevent type lookup errors in the form: // A -> B -> C v1.0 / A -> C v2.0 & getTypeName from assembly C. If C isn't referenced directly // it's impossible to get types from assembly A, therefore DeepGetClassRec is incorrect here. c = cdb.GetClass(typeName, genericArguments, caseSensitive); // c = DeepGetClassRec (visitedDbs, cdb, typeName, genericArguments, caseSensitive); if (c != null) { return(c); } } return(null); }
public DomTypeProxy (SerializationCodeCompletionDatabase db, ClassEntry entry) { this.db = db; this.entry = entry; Debug.Assert (entry != null); base.Name = entry.Name; base.Namespace = entry.Namespace; }
public DomTypeProxy(SerializationCodeCompletionDatabase db, ClassEntry entry) { this.db = db; this.entry = entry; Debug.Assert(entry != null); base.Name = entry.Name; base.Namespace = entry.Namespace; }
public IType GetClass(SerializationCodeCompletionDatabase db, string typeName, IList <IReturnType> genericArguments, bool deepSearchReferences, bool caseSensitive) { if (deepSearchReferences) { return(DeepGetClass(db, typeName, genericArguments, caseSensitive)); } else { return(GetClass(db, typeName, genericArguments, caseSensitive)); } }
IEnumerable <IType> GetSubclassesTree(SerializationCodeCompletionDatabase db, IType btype, IList <string> namespaces) { foreach (IType dsub in db.GetSubclasses(btype, namespaces)) { yield return(dsub); foreach (IType sub in GetSubclassesTree(db, dsub, namespaces)) { yield return(sub); } } }
public override bool NamespaceExists(string name, bool searchDeep, bool caseSensitive) { if (database.NamespaceExists(name, caseSensitive)) { return(true); } foreach (ReferenceEntry re in database.References) { SerializationCodeCompletionDatabase cdb = dbProvider.GetDatabase(re.Uri); if (cdb == null) { continue; } if (cdb.NamespaceExists(name, caseSensitive)) { return(true); } } return(false); }
/* public string SearchNamespace (SerializationCodeCompletionDatabase db, IUsing usin, string partitialNamespaceName) * { * return SearchNamespace (db, usin, partitialNamespaceName, true); * } * * public string SearchNamespace (SerializationCodeCompletionDatabase db, IUsing usin, string partitialNamespaceName, bool caseSensitive) * { * // LoggingService.LogDebug ("SearchNamespace : >{0}<", partitialNamespaceName); * if (NamespaceExists (db, partitialNamespaceName, caseSensitive)) { * return partitialNamespaceName; * } * * // search for partitial namespaces * IReturnType alias; * if (usin.Aliases.TryGetValue ("", out alias)) { * string declaringNamespace = alias.FullName; * while (declaringNamespace.Length > 0) { * if ((caseSensitive ? declaringNamespace.EndsWith(partitialNamespaceName) : declaringNamespace.ToLower().EndsWith(partitialNamespaceName.ToLower()) ) && NamespaceExists (db, declaringNamespace, caseSensitive)) { * return declaringNamespace; * } * int index = declaringNamespace.IndexOf('.'); * if (index > 0) { * declaringNamespace = declaringNamespace.Substring(0, index); * } else { * break; * } * } * } * * // Remember: * // Each namespace has an own using object * // The namespace name is an alias which has the key "" * foreach (string aliasString in usin.Aliases.Keys) { * if (caseSensitive ? partitialNamespaceName.StartsWith (aliasString) : partitialNamespaceName.ToLower().StartsWith(aliasString.ToLower())) { * if (aliasString.Length > 0) { * string nsName = String.Concat (usin.Aliases [aliasString], partitialNamespaceName.Remove(0, aliasString.Length)); * if (NamespaceExists (db, nsName, caseSensitive)) { * return nsName; * } * } * } * } * return null; * } */ public IEnumerable <IType> GetSubclassesTree(SerializationCodeCompletionDatabase db, IType cls, bool deepSearchReferences, IList <string> namespaces) { if (cls.FullName == "System.Object") { // Just return all classes if (!deepSearchReferences) { return(db.GetClassList(true, namespaces)); } else { return(GetAllClassesRec(new HashSet <SerializationCodeCompletionDatabase> (), db, namespaces)); } } else { var visited = new Dictionary <SerializationCodeCompletionDatabase, HashSet <IType> > (); SearchSubclasses(visited, cls, namespaces, db); if (deepSearchReferences) { List <IType> types = new List <IType> (); foreach (HashSet <IType> list in visited.Values) { // Don't use AddRange here. It won't work due to a bug in mono (#459816). foreach (IType tt in list) { types.Add(tt); } } return(types); } else { return(visited [db]); } } }
IEnumerable <IType> GetAllClassesRec(HashSet <SerializationCodeCompletionDatabase> visited, SerializationCodeCompletionDatabase db, IList <string> namespaces) { if (visited.Add(db)) { foreach (IType dsub in db.GetClassList(true, namespaces)) { yield return(dsub); } foreach (ReferenceEntry re in db.References) { SerializationCodeCompletionDatabase cdb = GetDatabase(re.Uri); if (cdb == null) { continue; } foreach (IType dsub in GetAllClassesRec(visited, cdb, namespaces)) { yield return(dsub); } } } }
public IType DeepGetClass (SerializationCodeCompletionDatabase db, string typeName, IList<IReturnType> genericArguments, bool caseSensitive) { if (db == null) return null; IType c = db.GetClass (typeName, genericArguments, caseSensitive); if (c != null) return c; foreach (ReferenceEntry re in db.References) { SerializationCodeCompletionDatabase cdb = GetDatabase (re.Uri); if (cdb == null) continue; // deep get class should only go to depth 1, to prevent type lookup errors in the form: // A -> B -> C v1.0 / A -> C v2.0 & getTypeName from assembly C. If C isn't referenced directly // it's impossible to get types from assembly A, therefore DeepGetClassRec is incorrect here. c = cdb.GetClass (typeName, genericArguments, caseSensitive); // c = DeepGetClassRec (visitedDbs, cdb, typeName, genericArguments, caseSensitive); if (c != null) return c; } return null; }
public DatabaseProjectDom (ParserDatabase dbProvider, SerializationCodeCompletionDatabase database) { this.dbProvider = dbProvider; this.database = database; database.SourceProjectDom = this; }
public DatabaseProjectDom(ParserDatabase dbProvider, SerializationCodeCompletionDatabase database) { this.dbProvider = dbProvider; this.database = database; database.SourceProjectDom = this; }
IEnumerable<IType> GetSubclassesTree (SerializationCodeCompletionDatabase db, IType btype, IList<string> namespaces) { foreach (IType dsub in db.GetSubclasses (btype, namespaces)) { yield return dsub; foreach (IType sub in GetSubclassesTree (db, dsub, namespaces)) yield return sub; } }
HashSet<IType> SearchSubclasses (Dictionary<SerializationCodeCompletionDatabase, HashSet<IType>> visited, IType btype, IList<string> namespaces, SerializationCodeCompletionDatabase db) { HashSet<IType> types; if (visited.TryGetValue (db, out types)) return types; types = new HashSet<IType> (GetSubclassesTree (db, btype, namespaces)); visited [db] = types; // For each reference, get the list of subclasses implemented in that reference, // then look for subclasses of any of those in the current db // A project can only have subclasses of classes implemented in assemblies it references foreach (ReferenceEntry re in db.References) { SerializationCodeCompletionDatabase cdb = GetDatabase (re.Uri); if (cdb != null && cdb != db) { HashSet<IType> refTypes = SearchSubclasses (visited, btype, namespaces, cdb); foreach (IType t in refTypes) foreach (IType st in GetSubclassesTree (db, t, namespaces)) types.Add (st); } } return types; }
IEnumerable<IType> GetAllClassesRec (HashSet<SerializationCodeCompletionDatabase> visited, SerializationCodeCompletionDatabase db, IList<string> namespaces) { if (visited.Add (db)) { foreach (IType dsub in db.GetClassList (true, namespaces)) yield return dsub; foreach (ReferenceEntry re in db.References) { SerializationCodeCompletionDatabase cdb = GetDatabase (re.Uri); if (cdb == null) continue; foreach (IType dsub in GetAllClassesRec (visited, cdb, namespaces)) yield return dsub; } } }
/* public string SearchNamespace (SerializationCodeCompletionDatabase db, IUsing usin, string partitialNamespaceName) { return SearchNamespace (db, usin, partitialNamespaceName, true); } public string SearchNamespace (SerializationCodeCompletionDatabase db, IUsing usin, string partitialNamespaceName, bool caseSensitive) { // LoggingService.LogDebug ("SearchNamespace : >{0}<", partitialNamespaceName); if (NamespaceExists (db, partitialNamespaceName, caseSensitive)) { return partitialNamespaceName; } // search for partitial namespaces IReturnType alias; if (usin.Aliases.TryGetValue ("", out alias)) { string declaringNamespace = alias.FullName; while (declaringNamespace.Length > 0) { if ((caseSensitive ? declaringNamespace.EndsWith(partitialNamespaceName) : declaringNamespace.ToLower().EndsWith(partitialNamespaceName.ToLower()) ) && NamespaceExists (db, declaringNamespace, caseSensitive)) { return declaringNamespace; } int index = declaringNamespace.IndexOf('.'); if (index > 0) { declaringNamespace = declaringNamespace.Substring(0, index); } else { break; } } } // Remember: // Each namespace has an own using object // The namespace name is an alias which has the key "" foreach (string aliasString in usin.Aliases.Keys) { if (caseSensitive ? partitialNamespaceName.StartsWith (aliasString) : partitialNamespaceName.ToLower().StartsWith(aliasString.ToLower())) { if (aliasString.Length > 0) { string nsName = String.Concat (usin.Aliases [aliasString], partitialNamespaceName.Remove(0, aliasString.Length)); if (NamespaceExists (db, nsName, caseSensitive)) { return nsName; } } } } return null; } */ public IEnumerable<IType> GetSubclassesTree (SerializationCodeCompletionDatabase db, IType cls, bool deepSearchReferences, IList<string> namespaces) { if (cls.FullName == "System.Object") { // Just return all classes if (!deepSearchReferences) return db.GetClassList (true, namespaces); else return GetAllClassesRec (new HashSet<SerializationCodeCompletionDatabase> (), db, namespaces); } else { var visited = new Dictionary<SerializationCodeCompletionDatabase, HashSet<IType>> (); SearchSubclasses (visited, cls, namespaces, db); if (deepSearchReferences) { List<IType> types = new List<IType> (); foreach (HashSet<IType> list in visited.Values) { // Don't use AddRange here. It won't work due to a bug in mono (#459816). foreach (IType tt in list) types.Add (tt); } return types; } else { return visited [db]; } } }
IType GetClass (SerializationCodeCompletionDatabase db, string typeName, IList<IReturnType> genericArguments, bool caseSensitive) { if (db != null) { IType c = db.GetClass (typeName, genericArguments, caseSensitive); if (c != null) return c; foreach (ReferenceEntry re in db.References) { SerializationCodeCompletionDatabase cdb = GetDatabase (re.Uri); if (cdb == null) continue; c = cdb.GetClass (typeName, genericArguments, caseSensitive); if (c != null) return c; } } return null; }
public IType GetClass (SerializationCodeCompletionDatabase db, string typeName, IList<IReturnType> genericArguments, bool deepSearchReferences, bool caseSensitive) { if (deepSearchReferences) return DeepGetClass (db, typeName, genericArguments, caseSensitive); else return GetClass (db, typeName, genericArguments, caseSensitive); }