diff options
author | Michael Hutchinson <m.j.hutchinson@gmail.com> | 2015-02-08 12:11:17 +0300 |
---|---|---|
committer | Michael Hutchinson <m.j.hutchinson@gmail.com> | 2015-02-08 12:11:40 +0300 |
commit | 003ffadf56093fc2dc6ad0d043b4e68699441611 (patch) | |
tree | 40504b54faa77b39e9325da89436532990513d71 /main | |
parent | 9c6b75f690aca613f96d394b1fba7b91ec09cec8 (diff) |
[Refactoring] Catch and report exceptions when searching
Diffstat (limited to 'main')
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/FindDerivedClassesHandler.cs | 63 |
1 files changed, 36 insertions, 27 deletions
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/FindDerivedClassesHandler.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/FindDerivedClassesHandler.cs index 63b5365aeb..da9a514bbb 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/FindDerivedClassesHandler.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/FindDerivedClassesHandler.cs @@ -79,33 +79,11 @@ namespace MonoDevelop.Refactoring monitor.BeginTask (label, compilations.Count); Parallel.ForEach (compilations, comp => { - var importedType = comp.Import (cls); - if (importedType == null) { - return; - } - - IMember impMember = null; - if (member != null) { - impMember = comp.Import (member); - if (impMember == null) { - return; - } - } - - foreach (var derivedType in comp.MainAssembly.GetAllTypeDefinitions ()) { - if (!derivedType.IsDerivedFrom (importedType)) - continue; - - IEntity result; - if (member != null) { - result = FindDerivedMember (impMember, derivedType); - if (result == null) - continue; - } else { - result = derivedType; - } - - ReportResult (monitor, result); + try { + SearchCompilation (monitor, comp, cls, member); + } catch (Exception ex) { + LoggingService.LogInternalError (ex); + monitor.ReportError ("Unhandled error while searching", ex); } monitor.Step (1); }); @@ -114,6 +92,37 @@ namespace MonoDevelop.Refactoring }; } + static void SearchCompilation (ISearchProgressMonitor monitor, ICompilation comp, ITypeDefinition cls, IMember member) + { + var importedType = comp.Import (cls); + if (importedType == null) { + return; + } + + IMember impMember = null; + if (member != null) { + impMember = comp.Import (member); + if (impMember == null) { + return; + } + } + + foreach (var derivedType in comp.MainAssembly.GetAllTypeDefinitions ()) { + if (!derivedType.IsDerivedFrom (importedType)) + continue; + IEntity result; + if (member != null) { + result = FindDerivedMember (impMember, derivedType); + if (result == null) + continue; + } + else { + result = derivedType; + } + ReportResult (monitor, result); + } + } + static IMember FindDerivedMember (IMember importedMember, ITypeDefinition derivedType) { IMember derivedMember; |