void OnProjectItemRemoved(object sender, ProjectItemEventArgs e) { if (e.Project != project) { return; } ReferenceProjectItem reference = e.ProjectItem as ReferenceProjectItem; if (reference != null) { try { IProjectContent referencedContent = ParserService.GetExistingProjectContentForReference(reference); if (referencedContent != null) { lock (ReferencedContents) { ReferencedContents.Remove(referencedContent); } OnReferencedContentsChanged(EventArgs.Empty); } } catch (Exception ex) { MessageService.ShowError(ex); } } if (e.ProjectItem.ItemType == ItemType.Import) { UpdateDefaultImports(project.Items); } else if (e.ProjectItem.ItemType == ItemType.Compile) { ParserService.ClearParseInformation(e.ProjectItem.FileName); } }
public void AddReferencedContent(IProjectContent pc) { if (pc != null) { lock (ReferencedContents) { ReferencedContents.Add(pc); } } }
public void InitializeReferences() { bool changed = false; if (_initialized) { if (_missingNames != null) { for (int i = 0; i < _missingNames.Count; i++) { IProjectContent content = _registry.GetExistingProjectContent(_missingNames[i]); if (content != null) { changed = true; lock (ReferencedContents) { ReferencedContents.Add(content); } _missingNames.RemoveAt(i--); } } if (_missingNames.Count == 0) { _missingNames = null; } } } else { _initialized = true; foreach (DomAssemblyName name in _referencedAssemblyNames) { IProjectContent content = _registry.GetExistingProjectContent(name); if (content != null) { changed = true; lock (ReferencedContents) { ReferencedContents.Add(content); } } else { if (_missingNames == null) { _missingNames = new List <DomAssemblyName>(); } _missingNames.Add(name); } } } if (changed) { OnReferencedContentsChanged(EventArgs.Empty); } }
internal void ReInitialize1(IProgressMonitor progressMonitor) { lock (ReferencedContents) { ReferencedContents.Clear(); AddReferencedContent(ParserService.GetRegistryForReference(new ReferenceProjectItem(project, "mscorlib")).Mscorlib); } // prevent adding event handler twice ProjectService.ProjectItemAdded -= OnProjectItemAdded; ProjectService.ProjectItemRemoved -= OnProjectItemRemoved; initializing = true; Initialize1(progressMonitor); initializing = false; }
internal void Initialize1(IProgressMonitor progressMonitor) { ICollection <ProjectItem> items = project.Items; ProjectService.ProjectItemAdded += OnProjectItemAdded; ProjectService.ProjectItemRemoved += OnProjectItemRemoved; UpdateDefaultImports(items); // TODO: Translate me // progressMonitor.TaskName = "Resolving references for " + project.Name + "..."; AbstractProject abstractProject = project as AbstractProject; ReferencedContents.Clear(); if (abstractProject != null) { foreach (var reference in abstractProject.ResolveAssemblyReferences(progressMonitor.CancellationToken)) { if (!initializing) { return; // abort initialization } AddReference(reference, false, progressMonitor.CancellationToken); } } else { project.ResolveAssemblyReferences(); AddReferencedContent(AssemblyParserService.DefaultProjectContentRegistry.Mscorlib); foreach (ProjectItem item in items) { if (!initializing) { return; // abort initialization } progressMonitor.CancellationToken.ThrowIfCancellationRequested(); if (ItemType.ReferenceItemTypes.Contains(item.ItemType)) { ReferenceProjectItem reference = item as ReferenceProjectItem; if (reference != null) { AddReference(reference, false, progressMonitor.CancellationToken); } } } } UpdateReferenceInterDependencies(); OnReferencedContentsChanged(EventArgs.Empty); }
internal void ReInitialize1(IProgressMonitor progressMonitor) { var mscorlib = AssemblyParserService.GetRegistryForReference(new ReferenceProjectItem(project, "mscorlib")).Mscorlib; // don't fetch mscorlib within lock - finding the correct registry might access the project, causing // a deadlock between IProject.SyncRoot and the ReferencedContents lock lock (ReferencedContents) { ReferencedContents.Clear(); AddReferencedContent(mscorlib); } // prevent adding event handler twice ProjectService.ProjectItemAdded -= OnProjectItemAdded; ProjectService.ProjectItemRemoved -= OnProjectItemRemoved; initializing = true; try { Initialize1(progressMonitor); } finally { initializing = false; } }