Exemplo n.º 1
0
        static void CheckModifiedFiles()
        {
            // Check databases following a bottom-up strategy in the dependency
            // tree. This will help resolving parsed classes.

            Set <ProjectDom> list = new Set <ProjectDom> ();

            lock (databases) {
                // There may be several uris for the same db
                foreach (ProjectDom ob in databases.Values)
                {
                    list.Add(ob);
                }
            }

            Set <ProjectDom> done = new Set <ProjectDom> ();

            while (list.Count > 0)
            {
                ProjectDom readydb      = null;
                ProjectDom bestdb       = null;
                int        bestRefCount = int.MaxValue;

                // Look for a db with all references resolved
                foreach (ProjectDom db in list)
                {
                    bool allDone = true;
                    foreach (ProjectDom refdb in db.References)
                    {
                        if (!done.Contains(refdb))
                        {
                            allDone = false;
                            break;
                        }
                    }

                    if (allDone)
                    {
                        readydb = db;
                        break;
                    }
                    else if (db.References.Count < bestRefCount)
                    {
                        bestdb       = db;
                        bestRefCount = db.References.Count;
                        break;
                    }
                }

                // It may not find any db without resolved references if there
                // are circular dependencies. In this case, take the one with
                // less references

                if (readydb == null)
                {
                    readydb = bestdb;
                }

                readydb.CheckModifiedFiles();
                list.Remove(readydb);
                done.Add(readydb);
            }
        }