/// <summary> /// This method can be used in three modes: /// 1. Find references to classes (parentClass = targetClass, member = null, isLocal = false) /// 2. Find references to members (parentClass = parent, member = member, isLocal = false) /// 3. Find references to local variables (parentClass = parent, member = local var as field, isLocal = true) /// </summary> static List <Reference> RunFindReferences(IClass ownerClass, IMember member, bool isLocal, IProgressMonitor progressMonitor) { if (ParserService.LoadSolutionProjectsThreadRunning) { progressMonitor.ShowingDialog = true; MessageService.ShowMessage("${res:SharpDevelop.Refactoring.LoadSolutionProjectsThreadRunning}"); progressMonitor.ShowingDialog = false; return(null); } List <ProjectItem> files; if (isLocal) { files = new List <ProjectItem>(); files.Add(FindItem(ownerClass.CompilationUnit.FileName)); } else { ownerClass = ownerClass.GetCompoundClass(); files = GetPossibleFiles(ownerClass, member); } ParseableFileContentEnumerator enumerator = new ParseableFileContentEnumerator(files.ToArray()); List <Reference> references = new List <Reference>(); try { if (progressMonitor != null) { progressMonitor.BeginTask("${res:SharpDevelop.Refactoring.FindingReferences}", files.Count, true); } #if DEBUG if (System.Windows.Forms.Control.ModifierKeys == System.Windows.Forms.Keys.Control) { System.Diagnostics.Debugger.Break(); } #endif while (enumerator.MoveNext()) { if (progressMonitor != null) { progressMonitor.WorkDone = enumerator.Index; if (progressMonitor.IsCancelled) { return(null); } } AddReferences(references, ownerClass, member, isLocal, enumerator.CurrentFileName, enumerator.CurrentFileContent); } } finally { if (progressMonitor != null) { progressMonitor.Done(); } enumerator.Dispose(); } return(references); }
internal void Initialize2(IProgressMonitor progressMonitor) { if (!initializing) { return; } int progressStart = progressMonitor.WorkDone; ParseableFileContentEnumerator enumerator = new ParseableFileContentEnumerator(project); try { progressMonitor.TaskName = "${res:ICSharpCode.SharpDevelop.Internal.ParserService.Parsing} " + project.Name + "..."; IProjectContent[] referencedContents; lock (this.ReferencedContents) { referencedContents = new IProjectContent[this.ReferencedContents.Count]; this.ReferencedContents.CopyTo(referencedContents, 0); } foreach (IProjectContent referencedContent in referencedContents) { if (referencedContent is ReflectionProjectContent) { ((ReflectionProjectContent)referencedContent).InitializeReferences(); } } while (enumerator.MoveNext()) { int i = enumerator.Index; if ((i % 5) == 2) { progressMonitor.WorkDone = progressStart + i; } ParserService.ParseFile(this, enumerator.CurrentFileName, enumerator.CurrentFileContent, true); if (!initializing) { return; } } } finally { initializing = false; progressMonitor.WorkDone = progressStart + enumerator.ItemCount; enumerator.Dispose(); } }
/// <summary> /// This method can be used in three modes: /// 1. Find references to classes (parentClass = targetClass, member = null, isLocal = false) /// 2. Find references to members (parentClass = parent, member = member, isLocal = false) /// 3. Find references to local variables (parentClass = parent, member = local var as field, isLocal = true) /// </summary> static List<Reference> RunFindReferences(IClass ownerClass, IMember member, bool isLocal, IProgressMonitor progressMonitor) { if (ParserService.LoadSolutionProjectsThreadRunning) { if (progressMonitor != null) progressMonitor.ShowingDialog = true; MessageService.ShowMessage("${res:SharpDevelop.Refactoring.LoadSolutionProjectsThreadRunning}"); if (progressMonitor != null) progressMonitor.ShowingDialog = false; return null; } List<ProjectItem> files; if (isLocal) { files = new List<ProjectItem>(); files.Add(FindItem(ownerClass.CompilationUnit.FileName)); } else { ownerClass = ownerClass.GetCompoundClass(); files = GetPossibleFiles(ownerClass, member); } ParseableFileContentEnumerator enumerator = new ParseableFileContentEnumerator(files.ToArray()); List<Reference> references = new List<Reference>(); try { if (progressMonitor != null) { progressMonitor.BeginTask("${res:SharpDevelop.Refactoring.FindingReferences}", files.Count, true); } #if DEBUG if (System.Windows.Forms.Control.ModifierKeys == DefaultEditor.Gui.Editor.SharpDevelopTextAreaControl.DebugBreakModifiers) { System.Diagnostics.Debugger.Break(); } #endif while (enumerator.MoveNext()) { if (progressMonitor != null) { progressMonitor.WorkDone = enumerator.Index; if (progressMonitor.IsCancelled) { return null; } } AddReferences(references, ownerClass, member, isLocal, enumerator.CurrentFileName, enumerator.CurrentFileContent); } } finally { if (progressMonitor != null) { progressMonitor.Done(); } enumerator.Dispose(); } return references; }
internal void Initialize2(IProgressMonitor progressMonitor) { if (!initializing) return; int progressStart = progressMonitor.WorkDone; ParseableFileContentEnumerator enumerator = new ParseableFileContentEnumerator(project); try { progressMonitor.TaskName = "${res:ICSharpCode.SharpDevelop.Internal.ParserService.Parsing} " + project.Name + "..."; IProjectContent[] referencedContents; lock (this.ReferencedContents) { referencedContents = new IProjectContent[this.ReferencedContents.Count]; this.ReferencedContents.CopyTo(referencedContents, 0); } foreach (IProjectContent referencedContent in referencedContents) { if (referencedContent is ReflectionProjectContent) { ((ReflectionProjectContent)referencedContent).InitializeReferences(); } } while (enumerator.MoveNext()) { int i = enumerator.Index; if ((i % 5) == 2) progressMonitor.WorkDone = progressStart + i; ParserService.ParseFile(this, enumerator.CurrentFileName, enumerator.CurrentFileContent, true); if (!initializing) return; } } finally { initializing = false; progressMonitor.WorkDone = progressStart + enumerator.ItemCount; enumerator.Dispose(); } }