public override AstVisitAction VisitTernaryExpression(TernaryExpressionAst ternaryExpressionAst)
        {
            var helpResult = HelpTableQuery("about_if");

            helpResult.DocumentationLink += "#using-the-ternary-operator-syntax";

            explanations.Add(new Explanation()
            {
                Description     = $"A condensed if-else construct, used for simple situations.",
                CommandName     = "Ternary expression",
                HelpResult      = helpResult,
                TextToHighlight = "?"
            }.AddDefaults(ternaryExpressionAst, explanations));

            return(base.VisitTernaryExpression(ternaryExpressionAst));
        }
Esempio n. 2
0
            public override AstVisitAction VisitTernaryExpression(TernaryExpressionAst ternaryExpressionAst)
            {
                if (!TargetsNonPS7())
                {
                    return(AstVisitAction.Continue);
                }

                var correction = new CorrectionExtent(
                    ternaryExpressionAst.Extent,
                    $"if ({ternaryExpressionAst.Condition.Extent.Text}) {{ {ternaryExpressionAst.IfTrue.Extent.Text} }} else {{ {ternaryExpressionAst.IfFalse.Extent.Text} }}",
                    _analyzedFilePath);

                AddDiagnostic(
                    ternaryExpressionAst,
                    "ternary expression",
                    "<test> ? <exp1> : <exp2>",
                    "3,4,5,6",
                    correction);

                return(AstVisitAction.Continue);
            }
Esempio n. 3
0
 public override AstVisitAction VisitTernaryExpression(TernaryExpressionAst ternaryExpressionAst)
 {
     return(AstVisitAction.SkipChildren);
 }
Esempio n. 4
0
 /// <summary/>
 public virtual AstVisitAction VisitTernaryExpression(TernaryExpressionAst ternaryExpressionAst) => DefaultVisit(ternaryExpressionAst);
 public override AstVisitAction VisitTernaryExpression(TernaryExpressionAst ternaryExpressionAst)
 {
     return(Visit(ternaryExpressionAst));
 }