Exemplo n.º 1
0
 void GetOuterClasses(ClassCollection classes, IClass curClass)
 {
     if (curClass != null) {
         foreach (IClass c in curClass.InnerClasses) {
             if (c != null && c.Region != null && c.Region.IsInside(caretLine, caretColumn)) {
                 if (c != GetInnermostClass()) {
                     GetOuterClasses(classes, c);
                     classes.Add(GetResolvedClass (c));
                 }
                 break;
             }
         }
     }
 }
        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;
            }
        }
Exemplo n.º 3
0
        /// <remarks>
        /// Returns all (nestet) classes in which the carret currently is exept
        /// the innermost class, returns an empty collection if the carret is in 
        /// no class or only in the innermost class.
        /// the most outer class is the last in the collection.
        /// </remarks>
        ClassCollection GetOuterClasses()
        {
            ClassCollection classes = new ClassCollection();
            if (cu != null) {
                foreach (IClass c in cu.Classes) {
                    if (c != null && c.Region != null && c.Region.IsInside(caretLine, caretColumn)) {
                        if (c != GetInnermostClass()) {
                            GetOuterClasses(classes, c);
                            classes.Add(GetResolvedClass (c));
                        }
                        break;
                    }
                }
            }

            return classes;
        }
        public bool ResolveTypes(Project project, ICompilationUnit unit, ClassCollection types, out ClassCollection result)
        {
            CompilationUnitTypeResolver tr = new CompilationUnitTypeResolver (GetProjectDatabase (project), unit, this);

            bool allResolved = true;
            result = new ClassCollection ();
            foreach (IClass c in types) {
                tr.CallingClass = c;
                tr.AllResolved = true;
                result.Add (PersistentClass.Resolve (c, tr));
                allResolved = allResolved && tr.AllResolved;
            }

            return allResolved;
        }
 /// <summary>
 ///     <para>
 ///       Initializes a new instance of <see cref='.IClassCollection'/> based on another <see cref='.IClassCollection'/>.
 ///    </para>
 /// </summary>
 /// <param name='value'>
 ///       A <see cref='.IClassCollection'/> from which the contents are copied
 /// </param>
 public ClassCollection(ClassCollection value)
 {
     this.AddRange(value);
 }
 public IClassEnumerator(ClassCollection mappings)
 {
     this.temp = ((IEnumerable)(mappings));
     this.baseEnumerator = temp.GetEnumerator();
 }
 /// <summary>
 ///     <para>
 ///       Adds the contents of another <see cref='.IClassCollection'/> to the end of the collection.
 ///    </para>
 /// </summary>
 /// <param name='value'>
 ///    A <see cref='.IClassCollection'/> containing the objects to add to the collection.
 /// </param>
 /// <returns>
 ///   <para>None.</para>
 /// </returns>
 /// <seealso cref='.IClassCollection.Add'/>
 public void AddRange(ClassCollection value)
 {
     for (int i = 0; (i < value.Count); i = (i + 1)) {
         this.Add(value[i]);
     }
 }