Ejemplo n.º 1
0
        static void LoadSolutionProjectsInternal()
        {
            IProgressMonitor           progressMonitor = StatusBarService.CreateProgressMonitor();
            List <ParseProjectContent> createdContents = new List <ParseProjectContent>();

            foreach (IProject project in ProjectService.OpenSolution.Projects)
            {
                try {
                    ParseProjectContent newContent = project.CreateProjectContent();
                    if (newContent != null)
                    {
                        lock (projectContents) {
                            projectContents[project] = newContent;
                        }
                        createdContents.Add(newContent);
                    }
                } catch (Exception e) {
                    MessageService.ShowError(e, "Error while retrieving project contents from " + project);
                }
            }
            WorkbenchSingleton.SafeThreadAsyncCall(ProjectService.ParserServiceCreatedProjectContents);
            try {
                // multiply Count with 2 so that the progress bar is only at 50% when references are done
                progressMonitor.BeginTask("Loading references...", createdContents.Count * 2, false);
                int workAmount = 0;
                for (int i = 0; i < createdContents.Count; i++)
                {
                    if (abortLoadSolutionProjectsThread)
                    {
                        return;
                    }
                    ParseProjectContent newContent = createdContents[i];
                    progressMonitor.WorkDone = i;
                    try {
                        newContent.Initialize1(progressMonitor);
                        workAmount += newContent.GetInitializationWorkAmount();
                    } catch (Exception e) {
                        MessageService.ShowError(e, "Error while initializing project references:" + newContent);
                    }
                }
                // multiply workamount with two and start at workAmount so that the progress bar continues
                // from 50% towards 100%.
                progressMonitor.BeginTask("${res:ICSharpCode.SharpDevelop.Internal.ParserService.Parsing}...", workAmount * 2, false);
                progressMonitor.WorkDone = workAmount;
                foreach (ParseProjectContent newContent in createdContents)
                {
                    if (abortLoadSolutionProjectsThread)
                    {
                        return;
                    }
                    try {
                        newContent.Initialize2(progressMonitor);
                    } catch (Exception e) {
                        MessageService.ShowError(e, "Error while initializing project contents:" + newContent);
                    }
                }
            } finally {
                progressMonitor.Done();
            }
        }
Ejemplo n.º 2
0
        static void ReparseProjectsInternal()
        {
            bool parsing = false;
            ParseProjectContent job;
            IProgressMonitor    progressMonitor = StatusBarService.CreateProgressMonitor();

            while (true)
            {
                // get next job
                lock (reParse1) {
                    if (reParse1.Count > 0)
                    {
                        if (parsing)
                        {
                            progressMonitor.Done();
                        }
                        parsing = false;
                        job     = reParse1.Dequeue();
                    }
                    else if (reParse2.Count > 0)
                    {
                        if (!parsing)
                        {
                            int workAmount = 0;
                            foreach (ParseProjectContent ppc in reParse2)
                            {
                                workAmount += ppc.GetInitializationWorkAmount();
                            }
                            progressMonitor.BeginTask("${res:ICSharpCode.SharpDevelop.Internal.ParserService.Parsing}...", workAmount, false);
                        }
                        parsing = true;
                        job     = reParse2.Dequeue();
                    }
                    else
                    {
                        // all jobs done
                        reParseThread = null;
                        if (parsing)
                        {
                            progressMonitor.Done();
                        }
                        LoggingService.Info("reParse thread finished all jobs");
                        return;
                    }
                }

                // execute job
                if (parsing)
                {
                    LoggingService.Info("reparsing code for " + job.Project);
                    job.ReInitialize2(progressMonitor);
                }
                else
                {
                    LoggingService.Debug("reloading references for " + job.Project);
                    job.ReInitialize1(progressMonitor);
                }
            }
        }
Ejemplo n.º 3
0
        static void InitAddedProject(object state)
        {
            ParseProjectContent newContent      = (ParseProjectContent)state;
            IProgressMonitor    progressMonitor = StatusBarService.CreateProgressMonitor();

            newContent.Initialize1(progressMonitor);
            progressMonitor.BeginTask("${res:ICSharpCode.SharpDevelop.Internal.ParserService.Parsing}...", newContent.GetInitializationWorkAmount(), false);
            newContent.Initialize2(progressMonitor);
            progressMonitor.Done();
        }