Ejemplo n.º 1
0
        internal static ProjectDom GetDom(string uri, bool addReference)
        {
            lock (databases)
            {
                ProjectDom db;

                if (!databases.TryGetValue(uri, out db))
                {
                    // Create/load the database

                    TargetRuntime   tr = null;
                    TargetFramework fx = null;
                    string          file;
                    if (ParseAssemblyUri(uri, out tr, out fx, out file))
                    {
                        db = ParserDatabase.LoadAssemblyDom(tr, fx, file);
                        RegisterDom(db, uri);
                    }
                }
                if (addReference && db != null)
                {
                    db.ReferenceCount++;
                }
                return(db);
            }
        }
Ejemplo n.º 2
0
        public static void Load(Project project)
        {
            if (IncLoadCount(project) != 1)
            {
                return;
            }

            lock (databases)
            {
                string uri = "Project:" + project.FileName;
                if (databases.ContainsKey(uri))
                {
                    return;
                }

                try {
                    ProjectDom db = ParserDatabase.LoadProjectDom(project);
                    RegisterDom(db, uri);

                    if (project is DotNetProject)
                    {
                        ((DotNetProject)project).ReferenceAddedToProject     += OnProjectReferenceAdded;
                        ((DotNetProject)project).ReferenceRemovedFromProject += OnProjectReferenceRemoved;
                    }
                } catch (Exception ex) {
                    LoggingService.LogError("Parser database for project '" + project.Name + " could not be loaded", ex);
                }
            }
        }
Ejemplo n.º 3
0
        public static ProjectDom GetFileDom(FilePath file)
        {
            if (file.IsNull)
            {
                file = Path.GetTempFileName();
            }

            file = file.CanonicalPath;

            lock (singleDatabases)
            {
                SingleFileCacheEntry entry;
                if (singleDatabases.TryGetValue(file, out entry))
                {
                    entry.AccessTime = DateTime.Now;
                    return(entry.Database);
                }
                else
                {
                    if (singleDatabases.Count >= MAX_SINGLEDB_CACHE_SIZE)
                    {
                        DateTime tim      = DateTime.MaxValue;
                        string   toDelete = null;
                        foreach (KeyValuePair <FilePath, SingleFileCacheEntry> pce in singleDatabases)
                        {
                            DateTime ptim = pce.Value.AccessTime;
                            if (ptim < tim)
                            {
                                tim      = ptim;
                                toDelete = pce.Key;
                            }
                        }
                        singleDatabases.Remove(toDelete);
                    }


                    ProjectDom db = ParserDatabase.LoadSingleFileDom(file);
                    db.Uri = "File:" + file;
                    db.UpdateReferences();
                    entry                  = new SingleFileCacheEntry();
                    entry.Database         = db;
                    entry.AccessTime       = DateTime.Now;
                    singleDatabases [file] = entry;
                    db.ReferenceCount      = 1;
                    return(db);
                }
            }
        }
Ejemplo n.º 4
0
        public PythonSiteImpl(string name)
        {
            string configPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            string dbPath     = PathCombine(configPath, "MonoDevelop", "IronPythonBinding", "Sites", name, "completion.db");

            m_pathsPath = PathCombine(configPath, "MonoDevelop", "IronPythonBinding", "Sites", name, "paths");

            if (File.Exists(m_pathsPath))
            {
                foreach (var line in File.ReadAllLines(m_pathsPath))
                {
                    string trimmed = line.Trim();
                    if (!String.IsNullOrEmpty(line))
                    {
                        m_Paths.Add(trimmed);
                    }
                }
            }

            m_Database = new ParserDatabase(dbPath);
            m_Database.Open();
        }
Ejemplo n.º 5
0
        public static void Load(Project project)
        {
            if (IncLoadCount(project) != 1)
            {
                return;
            }

            lock (databases)
            {
                string uri = "Project:" + project.FileName;
                if (databases.ContainsKey(uri))
                {
                    return;
                }

                try {
                    ProjectDom db = ParserDatabase.LoadProjectDom(project);
                    RegisterDom(db, uri);
                    project.Modified += HandleModified;
                } catch (Exception ex) {
                    LoggingService.LogError("Parser database for project '" + project.Name + " could not be loaded", ex);
                }
            }
        }