diff options
3 files changed, 38 insertions, 40 deletions
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeActionEditorExtension.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeActionEditorExtension.cs index f74bd5a50b..469b056af9 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeActionEditorExtension.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeActionEditorExtension.cs @@ -719,7 +719,7 @@ namespace MonoDevelop.CodeActions void OnQuickFixCommand () { if (!QuickTaskStrip.EnableFancyFeatures) { - Fixes = RefactoringService.GetValidActions (Document, Document.Editor.Caret.Location).Result; + Fixes = RefactoringService.GetValidActions (Document, Document.Editor.Caret.Location); currentSmartTagBegin = Document.Editor.Caret.Location; PopupQuickFixMenu (null, null); diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringService.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringService.cs index cd304a900a..64096e8329 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringService.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringService.cs @@ -202,51 +202,49 @@ namespace MonoDevelop.Refactoring static Stopwatch validActionsWatch = new Stopwatch (); static Stopwatch actionWatch = new Stopwatch (); - public static Task<IEnumerable<CodeAction>> GetValidActions (Document doc, TextLocation loc, CancellationToken cancellationToken = default (CancellationToken)) + public static IEnumerable<CodeAction> GetValidActions (Document doc, TextLocation loc, CancellationToken cancellationToken = default (CancellationToken)) { var editor = doc.Editor; string disabledNodes = editor != null ? PropertyService.Get ("ContextActions." + editor.MimeType, "") ?? "" : ""; - return Task.Factory.StartNew (delegate { - var result = new List<CodeAction> (); - var timer = InstrumentationService.CreateTimerCounter ("Source analysis background task", "Source analysis"); - timer.BeginTiming (); - validActionsWatch.Restart (); - var timeTable = new Dictionary<CodeActionProvider, long> (); - try { - var parsedDocument = doc.ParsedDocument; - if (editor != null && parsedDocument != null && parsedDocument.CreateRefactoringContext != null) { - var ctx = parsedDocument.CreateRefactoringContext (doc, cancellationToken); - if (ctx != null) { - foreach (var provider in contextActions.Where (fix => - fix.MimeType == editor.MimeType && - disabledNodes.IndexOf (fix.IdString, StringComparison.Ordinal) < 0)) - { - try { - actionWatch.Restart (); - result.AddRange (provider.GetActions (doc, ctx, loc, cancellationToken)); - actionWatch.Stop (); - timeTable[provider] = actionWatch.ElapsedMilliseconds; - } catch (Exception ex) { - LoggingService.LogError ("Error in context action provider " + provider.Title, ex); - } + var result = new List<CodeAction> (); + var timer = InstrumentationService.CreateTimerCounter ("Source analysis background task", "Source analysis"); + timer.BeginTiming (); + validActionsWatch.Restart (); + var timeTable = new Dictionary<CodeActionProvider, long> (); + try { + var parsedDocument = doc.ParsedDocument; + if (editor != null && parsedDocument != null && parsedDocument.CreateRefactoringContext != null) { + var ctx = parsedDocument.CreateRefactoringContext (doc, cancellationToken); + if (ctx != null) { + foreach (var provider in contextActions.Where (fix => + fix.MimeType == editor.MimeType && + disabledNodes.IndexOf (fix.IdString, StringComparison.Ordinal) < 0)) + { + try { + actionWatch.Restart (); + result.AddRange (provider.GetActions (doc, ctx, loc, cancellationToken)); + actionWatch.Stop (); + timeTable[provider] = actionWatch.ElapsedMilliseconds; + } catch (Exception ex) { + LoggingService.LogError ("Error in context action provider " + provider.Title, ex); } } } - } catch (Exception ex) { - LoggingService.LogError ("Error in analysis service", ex); - } finally { - timer.EndTiming (); - validActionsWatch.Stop (); - if (validActionsWatch.ElapsedMilliseconds > 1000) { - LoggingService.LogWarning ("Warning slow edit action update."); - foreach (var pair in timeTable) { - if (pair.Value > 50) - LoggingService.LogInfo ("ACTION '" + pair.Key.Title + "' took " + pair.Value +"ms"); - } + } + } catch (Exception ex) { + LoggingService.LogError ("Error in analysis service", ex); + } finally { + timer.EndTiming (); + validActionsWatch.Stop (); + if (validActionsWatch.ElapsedMilliseconds > 1000) { + LoggingService.LogWarning ("Warning slow edit action update."); + foreach (var pair in timeTable) { + if (pair.Value > 50) + LoggingService.LogInfo ("ACTION '" + pair.Key.Title + "' took " + pair.Value +"ms"); } } - return (IEnumerable<CodeAction>)result; - }, cancellationToken); + } + return (IEnumerable<CodeAction>)result; } public static void QueueQuickFixAnalysis (Document doc, TextLocation loc, CancellationToken token, Action<List<CodeAction>> callback) @@ -269,7 +267,7 @@ namespace MonoDevelop.Refactoring }); } } - result.AddRange (GetValidActions (doc, loc).Result); + result.AddRange (GetValidActions (doc, loc)); callback (result); } catch (Exception ex) { LoggingService.LogError ("Error in analysis service", ex); diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoryCommands.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoryCommands.cs index a139299f13..375ea3edf1 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoryCommands.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoryCommands.cs @@ -289,7 +289,7 @@ namespace MonoDevelop.Refactoring var ext = doc.GetContent <CodeActionEditorExtension> (); refactoringInfo.validActions = ext != null ? ext.GetCurrentFixes () : null; } else { - refactoringInfo.validActions = RefactoringService.GetValidActions (doc, loc).Result; + refactoringInfo.validActions = RefactoringService.GetValidActions (doc, loc); } lastLocation = loc; |