Exemple #1
0
            protected override Action <ITextControl> ExecutePsiTransaction(ISolution solution, IProgressIndicator progress)
            {
                var method    = MonoBehaviourMoveUtil.GetOrCreateMethod(myClassDeclaration, myMethodName);
                var statement = myFactory.CreateStatement("$0 = GetComponent<$1>();", myName, myTypeElement);
                var body      = method.EnsureStatementMemberBody();

                body.AddStatementBefore(statement, body.Statements.FirstOrDefault());
                return(null);
            }
Exemple #2
0
        private bool IsInitializedIn(IClassDeclaration classDeclaration, IDeclaredElement typeOwnerDeclaredElement, string methodName)
        {
            var method = MonoBehaviourMoveUtil.GetMonoBehaviourMethod(classDeclaration, methodName);

            if (method == null)
            {
                return(false);
            }

            foreach (var assignmentExpression in method.Descendants <IAssignmentExpression>())
            {
                if (assignmentExpression.Dest is IReferenceExpression referenceExpression)
                {
                    var declaredElement = referenceExpression.Reference.Resolve().DeclaredElement;
                    if (typeOwnerDeclaredElement.Equals(declaredElement))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }