public override IEnumerable <CodeAction> GetActions(RefactoringContext context) { var usingNode = FindUsingNodeAtCursor(context); if (usingNode == null) { yield break; } yield return(new CodeAction(context.TranslateString("Sort usings"), script => { var blocks = EnumerateUsingBlocks(context.RootNode); foreach (var block in blocks) { var originalNodes = block.ToArray(); var sortedNodes = UsingHelper.SortUsingBlock(originalNodes, context).ToArray(); for (var i = 0; i < originalNodes.Length; ++i) { script.Replace(originalNodes[i], sortedNodes[i].Clone()); } } }, usingNode)); }
CodeAction NewUsingAction(RefactoringContext context, AstNode node, string ns) { return(new CodeAction("using " + ns + ";", s => UsingHelper.InsertUsingAndRemoveRedundantNamespaceUsage(context, s, ns), node)); }