Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
		public DomTypeProxy (SerializationCodeCompletionDatabase db, ClassEntry entry)
		{
			this.db    = db;
			this.entry = entry;
			
			Debug.Assert (entry != null);
			base.Name      = entry.Name;
			base.Namespace = entry.Namespace;
		}
Ejemplo n.º 5
0
        public DomTypeProxy(SerializationCodeCompletionDatabase db, ClassEntry entry)
        {
            this.db    = db;
            this.entry = entry;

            Debug.Assert(entry != null);
            base.Name      = entry.Name;
            base.Namespace = entry.Namespace;
        }
Ejemplo n.º 6
0
 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));
     }
 }
Ejemplo n.º 7
0
        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);
 }
Ejemplo n.º 9
0
/*		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]);
                }
            }
        }
Ejemplo n.º 10
0
 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);
             }
         }
     }
 }
Ejemplo n.º 11
0
		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;
		}
Ejemplo n.º 12
0
		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;
 }
Ejemplo n.º 14
0
		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;
			}
		}
Ejemplo n.º 15
0
		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;
		}
Ejemplo n.º 16
0
		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;
				}
			}
		}
Ejemplo n.º 17
0
/*		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];
				}
			}
		}
Ejemplo n.º 18
0
		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;
		}
Ejemplo n.º 19
0
		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);
		}