示例#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();
            }
        }
示例#2
0
        // do not use an event for this because a solution might be loaded before ParserService
        // is initialized
        internal static void OnSolutionLoaded(List <ParseProjectContent> createdContents)
        {
            WorkbenchSingleton.DebugAssertMainThread();
            Debug.Assert(jobs != null);

            Solution openedSolution = ProjectService.OpenSolution;

            isThreadRunning = true;

            WorkbenchSingleton.SafeThreadAsyncCall(ProjectService.ParserServiceCreatedProjectContents);

            for (int i = 0; i < createdContents.Count; i++)
            {
                ParseProjectContent pc = createdContents[i];
                jobs.AddJob(new JobTask(pc.Initialize1,
                                        GetLoadReferenceTaskTitle(pc.ProjectName),
                                        10));
            }
            for (int i = 0; i < createdContents.Count; i++)
            {
                ParseProjectContent pc = createdContents[i];
                jobs.AddJob(new JobTask(pc.Initialize2,
                                        GetParseTaskTitle(pc.ProjectName),
                                        pc.GetInitializationWorkAmount()));
            }
            jobs.AddJob(new JobTask(ct => RaiseThreadEnded(openedSolution), "", 0));
            jobs.StartRunningIfRequired();
        }
示例#3
0
 internal static void InitNewProject(ParseProjectContent pc)
 {
     jobs.AddJob(new JobTask(pc.Initialize1,
                             GetLoadReferenceTaskTitle(pc.ProjectName),
                             10));
     jobs.AddJob(new JobTask(pc.Initialize2,
                             GetParseTaskTitle(pc.ProjectName),
                             pc.GetInitializationWorkAmount()));
     jobs.StartRunningIfRequired();
 }
示例#4
0
        static void LoadSolutionProjectsInternal()
        {
            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);
            int workAmount = 0;

            foreach (ParseProjectContent newContent in createdContents)
            {
                if (abortLoadSolutionProjectsThread)
                {
                    return;
                }
                try {
                    newContent.Initialize1();
                    workAmount += newContent.GetInitializationWorkAmount();
                } catch (Exception e) {
                    MessageService.ShowError(e, "Error while initializing project references:" + newContent);
                }
            }
            StatusBarService.ProgressMonitor.BeginTask("${res:ICSharpCode.SharpDevelop.Internal.ParserService.Parsing}...", workAmount, false);
            foreach (ParseProjectContent newContent in createdContents)
            {
                if (abortLoadSolutionProjectsThread)
                {
                    break;
                }
                try {
                    newContent.Initialize2();
                } catch (Exception e) {
                    MessageService.ShowError(e, "Error while initializing project contents:" + newContent);
                }
            }
            StatusBarService.ProgressMonitor.Done();
        }
示例#5
0
        public static void Reparse(IProject project, bool initReferences, bool parseCode)
        {
            if (jobs == null)
            {
                return; // do nothing if service wasn't initialized (e.g. some unit tests)
            }
            ParseProjectContent pc = ParserService.GetProjectContent(project) as ParseProjectContent;

            if (pc != null)
            {
                if (initReferences)
                {
                    lock (reParse1)
                    {
                        if (!reParse1.Contains(pc))
                        {
                            LoggingService.Debug("Enqueue for reinitializing references: " + project);
                            reParse1.Add(pc);
                            jobs.AddJob(new JobTask(pm => ReInitializeReferences(pc, pm),
                                                    GetLoadReferenceTaskTitle(project.Name),
                                                    10
                                                    ));
                        }
                    }
                }
                if (parseCode)
                {
                    lock (reParse2)
                    {
                        if (!reParse2.Contains(pc))
                        {
                            LoggingService.Debug("Enqueue for reparsing code: " + project);
                            reParse2.Add(pc);
                            jobs.AddJob(new JobTask(pm => ReparseCode(pc, pm),
                                                    GetParseTaskTitle(project.Name),
                                                    pc.GetInitializationWorkAmount()
                                                    ));
                        }
                    }
                }
                jobs.StartRunningIfRequired();
            }
        }
		internal static void InitNewProject(ParseProjectContent pc)
		{
			jobs.AddJob(new JobTask(pc.Initialize1,
			                        GetLoadReferenceTaskTitle(pc.ProjectName),
			                        10));
			jobs.AddJob(new JobTask(pc.Initialize2,
			                        GetParseTaskTitle(pc.ProjectName),
			                        pc.GetInitializationWorkAmount()));
			jobs.StartRunningIfRequired();
		}
示例#7
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();
        }