public Task <IContextAction[]> GetAvailableActionsAsync(EditorRefactoringContext context, CancellationToken cancellationToken) { ITextEditor editor = context.Editor; // grab SelectionStart/SelectionLength while we're still on the main thread int selectionStart = editor.SelectionStart; int selectionLength = editor.SelectionLength; return(Task.Run( async delegate { try { if (!CreateCodeActionProvider()) { return new IContextAction[0]; } AlAstResolver resolver = await context.GetAstResolverAsync().ConfigureAwait(false); var refactoringContext = new SDRefactoringContext(context.TextSource, resolver, context.CaretLocation, selectionStart, selectionLength, cancellationToken); return codeActionProvider.GetActions(refactoringContext).Select(Wrap).ToArray(); } catch (OperationCanceledException) { throw; // don't catch cancellations } catch (Exception ex) { SD.Log.WarnFormatted("AlContextActionProviderWrapper crashed: {0}", ex); SD.AnalyticsMonitor.TrackException(ex); return new IContextAction[0]; } }, cancellationToken)); }
public void Execute(EditorRefactoringContext context) { var resolver = context.GetAstResolverAsync().Result; var refactoringContext = new SDRefactoringContext(context.Editor, resolver, context.CaretLocation); var action = getUpdatedCodeAction(refactoringContext); if (action != null) { using (var script = refactoringContext.StartScript()) { action.Run(script); } } }
public Task<IContextAction[]> GetAvailableActionsAsync(EditorRefactoringContext context, CancellationToken cancellationToken) { ITextEditor editor = context.Editor; // grab SelectionStart/SelectionLength while we're still on the main thread int selectionStart = editor.SelectionStart; int selectionLength = editor.SelectionLength; return Task.Run( async delegate { try { if (!CreateCodeActionProvider()) return new IContextAction[0]; CSharpAstResolver resolver = await context.GetAstResolverAsync().ConfigureAwait(false); var refactoringContext = new SDRefactoringContext(context.TextSource, resolver, context.CaretLocation, selectionStart, selectionLength, cancellationToken); return codeActionProvider.GetActions(refactoringContext).Select(Wrap).ToArray(); } catch (Exception ex) { SD.Log.WarnFormatted("CSharpContextActionProviderWrapper crashed: {0}", ex); SD.AnalyticsMonitor.TrackException(ex); return new IContextAction[0]; } }, cancellationToken); }
public Task<IContextAction[]> GetAvailableActionsAsync(EditorRefactoringContext context, CancellationToken cancellationToken) { ITextEditor editor = context.Editor; // grab SelectionStart/SelectionLength while we're still on the main thread int selectionStart = editor.SelectionStart; int selectionLength = editor.SelectionLength; return Task.Run( async delegate { if (!CreateCodeActionProvider()) return new IContextAction[0]; CSharpAstResolver resolver = await context.GetAstResolverAsync().ConfigureAwait(false); var refactoringContext = new SDRefactoringContext(context.TextSource, resolver, context.CaretLocation, selectionStart, selectionLength, cancellationToken); return codeActionProvider.GetActions(refactoringContext).Select(Wrap).ToArray(); }, cancellationToken); }