Beispiel #1
0
        /* Function: Dispose
         */
        override protected void Dispose(bool strictRulesApply)
        {
            // We don't want to save Files.nd if the module wasn't started because it would blank out all the existing data.
            if (!strictRulesApply && started)
            {
                // Set the last modification time to zero for anything still being worked on
                DateTime zero = new DateTime(0);

                foreach (int id in unprocessedChanges.AllNewOrChangedFileIDs)
                {
                    files[id].LastModified = zero;
                }
                foreach (int id in unprocessedChanges.AllDeletedFileIDs)
                {
                    files[id].LastModified = zero;
                }

                foreach (var fileSource in fileSources)
                {
                    if (fileSource is IDisposable)
                    {
                        ((IDisposable)fileSource).Dispose();
                    }
                }

                Files_nd filesParser = new Files_nd();

                try
                {
                    filesParser.Save(EngineInstance.Config.WorkingDataFolder + "/Files.nd", files);
                }
                catch
                {  }
            }
        }
Beispiel #2
0
        /* Function: Start
         *
         * Validates the configuration and starts the module if successful.  This can only be called once.  If it fails, scrap the
         * entire <Engine.Instance> and start again.
         *
         * Dependencies:
         *
         *		- <Config.Manager> and <Languages.Manager> must be started before using the rest of the class.  Also
         *		  anything that could possibly set <Config.Manager.RebuildEverything>.
         */
        public bool Start(Errors.ErrorList errors)
        {
            int           startingErrorCount = errors.Count;
            StartupIssues newStartupIssues   = StartupIssues.None;


            // Validate FileSources

            if (fileSources.Count == 0)
            {
                errors.Add(
                    Locale.Get("NaturalDocs.Engine", "Error.NoFileSourcesDefined")
                    );
            }
            else
            {
                foreach (FileSource fileSource in fileSources)
                {
                    fileSource.Validate(errors);
                }
            }


            // Make sure no source folders are completely ignored because of filters

            foreach (var fileSource in fileSources)
            {
                if (fileSource is FileSources.SourceFolder)
                {
                    FileSources.SourceFolder folderFileSource = (FileSources.SourceFolder)fileSource;

                    if (SourceFolderIsIgnored(folderFileSource.Path))
                    {
                        errors.Add(
                            Locale.Get("NaturalDocs.Engine", "Error.SourceFolderIsIgnored(sourceFolder)", folderFileSource.Path)
                            );
                    }
                }
            }


            // Load Files.nd

            if (EngineInstance.HasIssues(StartupIssues.NeedToStartFresh))
            {
                newStartupIssues |= StartupIssues.FileIDsInvalidated |
                                    StartupIssues.NeedToReparseAllFiles;
            }
            else
            {
                Files_nd filesParser = new Files_nd();

                if (!filesParser.Load(EngineInstance.Config.WorkingDataFolder + "/Files.nd", out files))
                {
                    newStartupIssues |= StartupIssues.FileIDsInvalidated |
                                        StartupIssues.NeedToReparseAllFiles;
                }
                else                 // Files.nd loaded successfully
                {
                    if (EngineInstance.HasIssues(StartupIssues.NeedToReparseAllFiles))
                    {
                        unprocessedChanges.AddChangedFiles(files.usedIDs);
                    }
                }
            }


            if (newStartupIssues != StartupIssues.None)
            {
                EngineInstance.AddStartupIssues(newStartupIssues);
            }

            bool success = (errors.Count == startingErrorCount);

            started = success;
            return(success);
        }