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(); } }
public static void Reparse(IProject project, bool initReferences, bool parseCode) { ParseProjectContent pc = GetProjectContent(project) as ParseProjectContent; if (pc != null) { lock (reParse1) { if (initReferences && !reParse1.Contains(pc)) { LoggingService.Debug("Enqueue for reinitializing references: " + project); reParse1.Enqueue(pc); } if (parseCode && !reParse2.Contains(pc)) { LoggingService.Debug("Enqueue for reparsing code: " + project); reParse2.Enqueue(pc); } if (reParseThread == null) { LoggingService.Info("Starting reParse thread"); reParseThread = new Thread(new ThreadStart(ReparseProjects)); reParseThread.SetApartmentState(ApartmentState.STA); // allow reParseThread access to MSBuild reParseThread.Name = "reParse"; reParseThread.Priority = ThreadPriority.BelowNormal; reParseThread.IsBackground = true; reParseThread.Start(); } } } }
// 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(); }
static void ReparseCode(ParseProjectContent pc, IProgressMonitor progressMonitor) { lock (reParse2) { reParse2.Remove(pc); } pc.ReInitialize2(progressMonitor); }
static void ReInitializeReferences(ParseProjectContent pc, IProgressMonitor progressMonitor) { lock (reParse1) { reParse1.Remove(pc); } pc.ReInitialize1(progressMonitor); }
static void InitAddedProject(object state) { ParseProjectContent newContent = (ParseProjectContent)state; newContent.Initialize1(); StatusBarService.ProgressMonitor.BeginTask("${res:ICSharpCode.SharpDevelop.Internal.ParserService.Parsing}...", newContent.GetInitializationWorkAmount(), false); newContent.Initialize2(); StatusBarService.ProgressMonitor.Done(); }
internal static ParseProjectContent CreateUninitalized(IProject project) { ParseProjectContent newProjectContent = new ParseProjectContent(); newProjectContent.project = project; newProjectContent.Language = project.LanguageProperties; newProjectContent.initializing = true; IProjectContent mscorlib = ParserService.GetRegistryForReference(new ReferenceProjectItem(project, "mscorlib")).Mscorlib; newProjectContent.AddReferencedContent(mscorlib); return newProjectContent; }
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(); }
internal static ParseProjectContent CreateUninitalized(IProject project) { ParseProjectContent newProjectContent = new ParseProjectContent(); newProjectContent.project = project; newProjectContent.Language = project.LanguageProperties; newProjectContent.initializing = true; IProjectContent mscorlib = ParserService.GetRegistryForReference(new ReferenceProjectItem(project, "mscorlib")).Mscorlib; newProjectContent.AddReferencedContent(mscorlib); return(newProjectContent); }
/// <remarks>Can return null.</remarks> internal static IProjectContent CreateProjectContentForAddedProject(IProject project) { lock (projectContents) { ParseProjectContent newContent = project.CreateProjectContent(); if (newContent != null) { projectContents[project] = newContent; ThreadPool.QueueUserWorkItem(InitAddedProject, newContent); } return(newContent); } }
/// <remarks>Can return null.</remarks> internal static IProjectContent CreateProjectContentForAddedProject(IProject project) { ParseProjectContent newContent = project.CreateProjectContent(); if (newContent != null) { lock (projectContents) { projectContents[project] = newContent; } LoadSolutionProjects.InitNewProject(newContent); } return(newContent); }
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(); }
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 OnSolutionLoaded() { List <ParseProjectContent> createdContents = new List <ParseProjectContent>(); foreach (IProject project in ProjectService.OpenSolution.Projects) { try { LoggingService.Debug("Creating project content for " + project.Name); ParseProjectContent newContent = project.CreateProjectContent(); if (newContent != null) { lock (projectContents) { projectContents[project] = newContent; } createdContents.Add(newContent); } } catch (Exception e) { MessageService.ShowException(e, "Error while retrieving project contents from " + project); } } LoadSolutionProjects.OnSolutionLoaded(createdContents); }