Exemplo n.º 1
0
        /* Function: MergeCommentTypesInto
         * Merges the comment types of the second <ConfigFiles.TextFile> into the first, adding new types and applying any
         * alter entries.  This does NOT merge keywords, ignored keywords, or tags.  The base config will be changed, even if
         * there are errors.  Returns false if there were any errors and adds them to errorList.
         */
        protected bool MergeCommentTypesInto(ref ConfigFiles.TextFile baseConfig, ConfigFiles.TextFile overridingConfig,
                                             Errors.ErrorList errorList)
        {
            bool success = true;

            if (overridingConfig.HasCommentTypes)
            {
                foreach (var overridingCommentType in overridingConfig.CommentTypes)
                {
                    var matchingCommentType = baseConfig.FindCommentType(overridingCommentType.Name);

                    if (matchingCommentType != null)
                    {
                        if (overridingCommentType.AlterType == false)
                        {
                            errorList.Add(Locale.Get("NaturalDocs.Engine", "Comments.txt.CommentTypeAlreadyExists(name)", overridingCommentType.Name),
                                          overridingCommentType.PropertyLocation);
                            success = false;
                        }
                        else
                        {
                            MergeCommentTypeInto(ref matchingCommentType, overridingCommentType);
                        }
                    }

                    else                     // no match
                    {
                        if (overridingCommentType.AlterType == true)
                        {
                            errorList.Add(Locale.Get("NaturalDocs.Engine", "Comments.txt.AlteredCommentTypeDoesntExist(name)", overridingCommentType.Name),
                                          overridingCommentType.NamePropertyLocation);
                            success = false;
                        }
                        else
                        {
                            baseConfig.AddCommentType(overridingCommentType.Duplicate());
                        }
                    }
                }
            }

            return(success);
        }