Example #1
0
        /// <summary>
        ///  Convert this AddReferenceDatabase from the mutable (buildable) form into the immutable (queryable)
        ///  form. This must be done after all PackageDatabases are added and before any queriesa are run.
        ///  When deserialized, ARDB is always loaded in queryable form.
        /// </summary>
        public void ConvertToImmutable()
        {
            this.StringStore.ConvertToImmutable();

            if (this.DeclaredMembers.RequiresRemap())
            {
                this.DeclaredMembers.UpdateIdentifiers(this.StringStore);

                this.DeclaredMembers.Sort((left, right) =>
                {
                    if (DeclaredMembers.GetParent(left) == 0 && DeclaredMembers.GetParent(right) == 0)
                    {
                        // Keep Packages sorted by insertion order (popularity)
                        return(left.CompareTo(right));
                    }
                    else
                    {
                        // Sort namespaces and types by name [same sort as StringStore]
                        return(DeclaredMembers.GetNameIdentifier(left).CompareTo(DeclaredMembers.GetNameIdentifier(right)));
                    }
                });
            }

            this.Index.ConvertToImmutable(this.StringStore);
        }
Example #2
0
        public void ConvertToImmutable()
        {
            // Convert strings (and get remap array)
            this.StringStore.ConvertToImmutable();

            // Remap strings in DefinedSymbolTree
            if (DeclaredMembers.RequiresRemap())
            {
                DeclaredMembers.UpdateIdentifiers(StringStore);

                // Remap strings in DefinedSymbolDetails
                for (int i = 0; i < DeclaredMemberDetails.Count; ++i)
                {
                    SymbolDetails details = DeclaredMemberDetails[i];
                    details.UpdateIdentifiers(StringStore);
                    DeclaredMemberDetails[i] = details;
                }

                // Sort the DefinedSymbolTree by name and then parameters [same order as StringStore]
                DeclaredMembers.Sort((left, right) =>
                {
                    int nameCompare = DeclaredMembers.GetNameIdentifier(left).CompareTo(DeclaredMembers.GetNameIdentifier(right));
                    if (nameCompare != 0)
                    {
                        return(nameCompare);
                    }
                    return(DeclaredMemberDetails[left].ParametersIdentifier.CompareTo(DeclaredMemberDetails[right].ParametersIdentifier));
                });
            }

            // Remap strings in FileTree
            if (FileTree.RequiresRemap())
            {
                FileTree.UpdateIdentifiers(StringStore);
            }

            // Convert MemberIndex
            Index.ConvertToImmutable(StringStore);
        }