コード例 #1
0
        public bool IsValid(RefactoringContext context)
        {
            var identifier = CreateField.GetIdentifier(context);

            if (identifier == null)
            {
                return(false);
            }
            return(context.Resolve(identifier) == null && CreateField.GuessType(context, identifier) != null);
        }
コード例 #2
0
        public bool IsValid(RefactoringContext context)
        {
            if (GetUnresolvedArguments(context).Count > 0)
            {
                return(true);
            }
            var identifier = CreateField.GetIdentifier(context);

            if (identifier == null)
            {
                return(false);
            }
            if (context.GetNode <Statement> () == null)
            {
                return(false);
            }
            return(context.Resolve(identifier) == null && GuessType(context, identifier) != null);
        }
コード例 #3
0
        public void Run(RefactoringContext context)
        {
            var stmt = context.GetNode <Statement> ();
            var unresolvedArguments = GetUnresolvedArguments(context);

            if (unresolvedArguments.Count > 0)
            {
                using (var script = context.StartScript()) {
                    foreach (var id in unresolvedArguments)
                    {
                        script.InsertBefore(stmt, GenerateLocalVariableDeclaration(context, id));
                    }
                }
                return;
            }

            using (var script = context.StartScript()) {
                script.InsertBefore(stmt, GenerateLocalVariableDeclaration(context, CreateField.GetIdentifier(context)));
            }
        }