Beispiel #1
0
        public 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());
                    }
                }
            }));
        }
Beispiel #2
0
 CodeAction NewUsingAction(RefactoringContext context, AstNode node, string ns)
 {
     return(new CodeAction("using " + ns + ";", s => UsingHelper.InsertUsingAndRemoveRedundantNamespaceUsage(context, s, ns)));
 }