Exemplo n.º 1
0
 private static bool HasTransformTextMethod([NotNull] ITypeElement typeElement)
 {
     return(typeElement
            .GetAllClassMembers(T4CSharpCodeGenerator.TransformTextMethodName)
            .SelectNotNull(instance => instance.Member as IMethod)
            .Any(IsTransformTextMethod));
 }
Exemplo n.º 2
0
        /// <summary>
        /// Swap base to this unless local implementation.
        /// </summary>
        /// <param name="invocationExpression">
        /// The invocation expression.
        /// </param>
        public static void SwapBaseToThisUnlessLocalImplementation(IInvocationExpression invocationExpression)
        {
            bool isOverride = false;

            bool isNew = false;

            IPrimaryExpression invokedExpression = invocationExpression.InvokedExpression;

            if (invokedExpression == null)
            {
                return;
            }

            IReferenceExpression referenceExpression = invokedExpression as IReferenceExpression;

            if (referenceExpression == null)
            {
                return;
            }

            ICSharpExpression qualifierExpression = referenceExpression.QualifierExpression;

            if (!(qualifierExpression is IBaseExpression))
            {
                return;
            }

            ICSharpTypeDeclaration typeDeclaration = invocationExpression.GetContainingNode <ICSharpTypeDeclaration>(true);

            if (typeDeclaration == null)
            {
                return;
            }

            ITypeElement typeDeclaredElement = typeDeclaration.DeclaredElement;

            if (typeDeclaredElement == null)
            {
                return;
            }

            IDeclaredElement referenceDeclaredElement = referenceExpression.Reference.Resolve().DeclaredElement;

            if (referenceDeclaredElement == null)
            {
                return;
            }

            foreach (var member in typeDeclaredElement.GetAllClassMembers(referenceDeclaredElement.ShortName))
            {
                if (!member.Equals(referenceDeclaredElement))
                {
                    continue;
                }

                using (WriteLockCookie.Create(true))
                {
                    // swap the base to this
                    ICSharpExpression expression = CSharpElementFactory.GetInstance(invocationExpression.GetPsiModule()).CreateExpression("this");

                    referenceExpression.SetQualifierExpression(expression);
                }
            }
        }
Exemplo n.º 3
0
 private static bool HasTransformTextMethod([NotNull] ITypeElement typeElement)
 => typeElement
 .GetAllClassMembers(T4CSharpIntermediateConverterBase.TransformTextMethodName)
 .SelectNotNull(instance => instance.Member as IMethod)
 .Any(IsTransformTextMethod);