public override void VisitParenthesizedExpression(IParenthesizedExpression operation)
        {
            LogString(nameof(IParenthesizedExpression));
            LogCommonPropertiesAndNewLine(operation);

            base.VisitParenthesizedExpression(operation);
        }
    /// <summary>Handles the specified expression.</summary>
    /// <param name="parenthesizedExpression">The invocation expression.</param>
    /// <param name="statementParameters">The parameters.</param>
    /// <returns>Returns the string.</returns>
    public ExpressionDescriptor Handle(IParenthesizedExpression parenthesizedExpression, Dictionary<string, string> statementParameters)
    {
      var expression = parenthesizedExpression.Expression;
      if (expression == null)
      {
        return null;
      }

      var statement = ExpressionTemplateBuilder.Handle(expression, statementParameters);
      if (statement == null)
      {
        return null;
      }

      var result = new ExpressionDescriptor
      {
        Template = string.Format("({0})", statement.Template)
      };

      foreach (var variable in statement.TemplateVariables)
      {
        result.TemplateVariables[variable.Key] = variable.Value;
      }

      return result;
    }
Example #3
0
        /// <summary>
        /// The execute transaction inner.
        /// </summary>
        /// <param name="solution">
        /// The solution.
        /// </param>
        /// <param name="textControl">
        /// The text control.
        /// </param>
        public override void ExecuteTransactionInner(ISolution solution, ITextControl textControl)
        {
            IList <ITokenNode> tokensForLine = Utils.GetTokensForLineFromTextControl(solution, textControl);

            foreach (ITokenNode tokenNode in tokensForLine)
            {
                IParenthesizedExpression parenthesizedExpressionNode = tokenNode.GetContainingNode <IParenthesizedExpression>(true);
                MaintainabilityRules.RemoveParenthesisFromNode(parenthesizedExpressionNode);
            }
        }
 public override bool Visit(IParenthesizedExpression expression, object context)
 {
     _stack.Push(expression);
     try
     {
         return(base.Visit(expression, context));
     }
     finally
     {
         _stack.Pop();
     }
 }
Example #5
0
        /// <summary>
        /// Remove parenthesis from node.
        /// </summary>
        /// <param name="node">
        /// The node.
        /// </param>
        public static void RemoveParenthesisFromNode(ITreeNode node)
        {
            IParenthesizedExpression parenthesizedExpressionNode = node as IParenthesizedExpression;

            if (parenthesizedExpressionNode != null)
            {
                using (WriteLockCookie.Create(true))
                {
                    ICSharpExpression innerExpression = parenthesizedExpressionNode.Expression;

                    if (innerExpression != null && node.Parent != null)
                    {
                        NodeType innerExpressionNodeType = (innerExpression as TreeElement).NodeType;

                        if (innerExpressionNodeType != ElementType.ADDITIVE_EXPRESSION && innerExpressionNodeType != ElementType.MULTIPLICATIVE_EXPRESSION &&
                            innerExpressionNodeType != ElementType.SHIFT_EXPRESSION && innerExpressionNodeType != ElementType.AS_EXPRESSION &&
                            innerExpressionNodeType != ElementType.ASSIGNMENT_EXPRESSION && innerExpressionNodeType != ElementType.CAST_EXPRESSION &&
                            innerExpressionNodeType != ElementType.CONDITIONAL_AND_EXPRESSION && innerExpressionNodeType != ElementType.CONDITIONAL_OR_EXPRESSION &&
                            innerExpressionNodeType != ElementType.CONDITIONAL_TERNARY_EXPRESSION && innerExpressionNodeType != ElementType.POSTFIX_OPERATOR_EXPRESSION &&
                            innerExpressionNodeType != ElementType.PREFIX_OPERATOR_EXPRESSION && innerExpressionNodeType != ElementType.IS_EXPRESSION &&
                            innerExpressionNodeType != ElementType.LAMBDA_EXPRESSION && innerExpressionNodeType != ElementType.BITWISE_AND_EXPRESSION &&
                            innerExpressionNodeType != ElementType.BITWISE_INCLUSIVE_OR_EXPRESSION &&
                            innerExpressionNodeType != ElementType.BITWISE_EXCLUSIVE_OR_EXPRESSION && innerExpressionNodeType != ElementType.OBJECT_CREATION_EXPRESSION &&
                            innerExpressionNodeType != ElementType.ARRAY_CREATION_EXPRESSION && innerExpressionNodeType != ElementType.NULL_COALESCING_EXPRESSION &&
                            innerExpressionNodeType != ElementType.QUERY_EXPRESSION && innerExpressionNodeType != ElementType.RELATIONAL_EXPRESSION &&
                            innerExpressionNodeType != ElementType.UNARY_OPERATOR_EXPRESSION && innerExpressionNodeType != ElementType.EQUALITY_EXPRESSION &&
                            innerExpressionNodeType != ElementType.AWAIT_EXPRESSION)
                        {
                            LowLevelModificationUtil.ReplaceChildRange(node, node, new ITreeNode[] { innerExpression });
                            return;
                        }

                        if ((!(node.Parent is IExpression)) || node.Parent is IVariableDeclaration)
                        {
                            LowLevelModificationUtil.ReplaceChildRange(node, node, new ITreeNode[] { innerExpression });
                            return;
                        }

                        IAssignmentExpression parent = node.Parent as IAssignmentExpression;

                        if (parent != null && parent.Source == node)
                        {
                            LowLevelModificationUtil.ReplaceChildRange(node, node, new ITreeNode[] { innerExpression });
                            return;
                        }
                    }
                }
            }
        }
        private static int CompareParenthesisedExpression(IParenthesizedExpression left, IParenthesizedExpression right)
        {
            // Standard left,right and null checks
            if (left == null && right == null)
            {
                return(0);
            }
            if (left == null)
            {
                return(1);
            }
            if (right == null)
            {
                return(-1);
            }

            return(CompareExpression(left.Expression, right.Expression));
        }
 public override void VisitParenthesizedExpression(IParenthesizedExpression operation)
 {
     base.VisitParenthesizedExpression(operation);
 }
Example #8
0
 public virtual void VisitParenthesizedExpression(IParenthesizedExpression operation)
 {
     DefaultVisit(operation);
 }
Example #9
0
 public abstract IExpression Transform(IParenthesizedExpression expression);
Example #10
0
 public override void VisitParenthesizedExpression(IParenthesizedExpression operation)
 {
     Visit(operation.Operand);
 }
Example #11
0
 public abstract void Translate(IParenthesizedExpression expression);
Example #12
0
 void IExpressionVisitor.Visit(IParenthesizedExpression expression)
 {
     this.Translate(expression);
 }
 public override Expression VisitParenthesizedExpression(IParenthesizedExpression parenthesizedExpressionParam, IMetadataResolver context)
 {
     return(parenthesizedExpressionParam.Expression.Accept(this, context));
 }
Example #14
0
 public TestLinkerResult Visit(IParenthesizedExpression expression, ICompilationContext context)
 {
     throw new NotImplementedException();
 }
Example #15
0
 public abstract TransformationImpact CalculateRefactorImpact(IParenthesizedExpression expression);
Example #16
0
 public override IAssignableExpression VisitParenthesizedExpression(IParenthesizedExpression expr,
                                                                    IList <IStatement> context)
 {
     return(ComposedExpressionCreator.Create(this, expr, context));
 }
 /// <inheritdoc />
 public override Expression VisitParenthesizedExpression(IParenthesizedExpression operation, LocalBinder argument)
 {
     return(operation.Operand.Accept(this, argument));
 }
Example #18
0
 private static int FitsOnOneLine(IParenthesizedExpression expression, int remainingSpace)
 {
     return(FitsOnOneLine(expression.Expression, remainingSpace) - 2);
 }
Example #19
0
 public override IOperation VisitParenthesizedExpression(IParenthesizedExpression operation, object argument)
 {
     return(new ParenthesizedExpression(Visit(operation.Operand), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit));
 }
Example #20
0
 public virtual void VisitParenthesizedExpression(IParenthesizedExpression operation)
 {
     DefaultVisit(operation);
 }
Example #21
0
 TransformationImpact IExpressionVisitor <TransformationImpact> .Visit(IParenthesizedExpression expression)
 {
     return(CalculateRefactorImpact(expression));
 }
 public override void VisitParenthesizedExpression(IParenthesizedExpression expr, IList <IStatement> context)
 {
     expr.Expression.Accept(this, context);
 }
Example #23
0
 public override void VisitParenthesizedExpression(IParenthesizedExpression operation)
 {
     base.VisitParenthesizedExpression(operation);
 }
 /// <inheritdoc />
 public override IOperation VisitParenthesizedExpression(IParenthesizedExpression operation, object argument)
 {
     return(base.VisitParenthesizedExpression(operation, argument));
 }
Example #25
0
 public TransformationKind Visit(IParenthesizedExpression expression, ITransformationContext context)
 {
     return(TransformationKind.Investigate);
 }