Ejemplo n.º 1
0
 public ClassEntry(IClass cls, FileEntry fileEntry, NamespaceEntry namespaceRef)
 {
     this.cls = cls;
     this.fileEntry = fileEntry;
     this.namespaceRef = namespaceRef;
     this.name = cls.Name;
     position = -1;
 }
        protected void QueueParseJob(FileEntry file)
        {
            // Change date now, to avoid reparsing if CheckModifiedFiles is called again
            // before the parse job is executed

            FileInfo fi = new FileInfo (file.FileName);
            file.LastParseTime = fi.LastWriteTime;
            parserDatabase.QueueParseJob (new JobCallback (ParseCallback), file.FileName);
        }
        public ClassUpdateInformation UpdateClassInformation(ClassCollection newClasses, string fileName)
        {
            lock (rwlock)
            {
                ClassUpdateInformation res = new ClassUpdateInformation ();

                FileEntry fe = files [fileName] as FileEntry;
                if (fe == null) return null;

                bool[] added = new bool [newClasses.Count];
                NamespaceEntry[] newNss = new NamespaceEntry [newClasses.Count];
                for (int n=0; n<newClasses.Count; n++) {
                    string[] path = newClasses[n].Namespace.Split ('.');
                    newNss[n] = GetNamespaceEntry (path, path.Length, true, true);
                }

                ArrayList newFileClasses = new ArrayList ();

                if (fe != null)
                {
                    ClassEntry ce = fe.FirstClass;
                    while (ce != null)
                    {
                        IClass newClass = null;
                        for (int n=0; n<newClasses.Count && newClass == null; n++) {
                            IClass uc = newClasses [n];
                            if (uc.Name == ce.Name && newNss[n] == ce.NamespaceRef) {
                                newClass = uc;
                                added[n] = true;
                            }
                        }

                        if (newClass != null) {
                            // Class found, replace it
                            ce.Class = CopyClass (newClass);
                            ce.LastGetTime = currentGetTime++;
                            newFileClasses.Add (ce);
                            res.Modified.Add (ce.Class);
                        }
                        else {
                            // Class not found, it has to be deleted, unless it has
                            // been added in another file
                            if (ce.FileEntry == fe) {
                                IClass c = ce.Class;
                                if (c == null) c = ReadClass (ce);
                                res.Removed.Add (c);
                                ce.NamespaceRef.Remove (ce.Name);
                            }
                        }
                        ce = ce.NextInFile;
                    }
                }

                if (fe == null) {
                    fe = new FileEntry (fileName);
                    files [fileName] = fe;
                }

                for (int n=0; n<newClasses.Count; n++) {
                    if (!added[n]) {
                        IClass c = CopyClass (newClasses[n]);
                        ClassEntry ce = new ClassEntry (c, fe, newNss[n]);
                        ce.LastGetTime = currentGetTime++;
                        newNss[n].Add (c.Name, ce);
                        newFileClasses.Add (ce);
                        res.Added.Add (c);
                    }
                }

                fe.SetClasses (newFileClasses);
                rootNamespace.Clean ();
                fe.LastParseTime = DateTime.Now;
                modified = true;
                Flush ();

                return res;
            }
        }
 public void AddFile(string fileName)
 {
     lock (rwlock)
     {
         FileEntry fe = new FileEntry (fileName);
         files [fileName] = fe;
         modified = true;
     }
 }