public static Doc Print(WhenClauseSyntax node) { return(Doc.Concat( Token.PrintWithSuffix(node.WhenKeyword, " "), Node.Print(node.Condition) )); }
private Doc PrintWhenClauseSyntax(WhenClauseSyntax node) { return(Concat( this.PrintSyntaxToken(node.WhenKeyword, " "), this.Print(node.Condition) )); }
public new void AddChildren() { base.AddChildren(); Kind = Node.Kind(); _pattern = ((CasePatternSwitchLabelSyntax)Node).Pattern; _patternIsChanged = false; _whenClause = ((CasePatternSwitchLabelSyntax)Node).WhenClause; _whenClauseIsChanged = false; }
public override BoundStatement InstrumentPatternSwitchWhenClauseConditionalGotoBody(BoundExpression original, BoundStatement ifConditionGotoBody) { WhenClauseSyntax whenClause = (WhenClauseSyntax)original.Syntax.Parent; return(new BoundSequencePointWithSpan( syntax: whenClause, statementOpt: base.InstrumentPatternSwitchWhenClauseConditionalGotoBody(original, ifConditionGotoBody), span: whenClause.Span)); }
public static void ReportWhenClauseNotSupported( this SyntaxNodeAnalysisContext context, WhenClauseSyntax whenClause) { var diagnostic = Diagnostic.Create( ExhaustiveMatchAnalyzer.WhenGuardNotSupported, whenClause.GetLocation()); context.ReportDiagnostic(diagnostic); }
public override BoundStatement InstrumentPatternSwitchWhenClauseConditionalGotoBody(BoundExpression original, BoundStatement ifConditionGotoBody) { WhenClauseSyntax whenClause = original.Syntax.FirstAncestorOrSelf <WhenClauseSyntax>(); Debug.Assert(whenClause != null); return(new BoundSequencePointWithSpan( syntax: whenClause, statementOpt: base.InstrumentPatternSwitchWhenClauseConditionalGotoBody(original, ifConditionGotoBody), span: whenClause.Span)); }
public override void VisitWhenClause(WhenClauseSyntax node) { if (!PreVisit(node)) { return; } node.Condition?.Accept(this); base.VisitWhenClause(node); PostVisit(node); }
public override BoundStatement InstrumentSwitchWhenClauseConditionalGotoBody(BoundExpression original, BoundStatement ifConditionGotoBody) { ifConditionGotoBody = base.InstrumentSwitchWhenClauseConditionalGotoBody(original, ifConditionGotoBody); WhenClauseSyntax whenClause = original.Syntax.FirstAncestorOrSelf <WhenClauseSyntax>(); Debug.Assert(whenClause != null); // Instrument the statement using a factory with the same syntax as the clause, so that the instrumentation appears to be part of the clause. SyntheticBoundNodeFactory statementFactory = new SyntheticBoundNodeFactory(_method, whenClause, _methodBodyFactory.CompilationState, _diagnostics); // Instrument using the span of the expression return(statementFactory.StatementList(AddAnalysisPoint(whenClause, statementFactory), ifConditionGotoBody)); }
private static PatternSyntax GetPattern( SyntaxList <SwitchLabelSyntax> switchLabels, out WhenClauseSyntax whenClauseOpt ) { if (switchLabels.Count == 1) { return(GetPattern(switchLabels[0], out whenClauseOpt)); } if (switchLabels.Any(label => IsDefaultSwitchLabel(label))) { // original group had a catch-all label. just convert to a discard _ to indicate the same. whenClauseOpt = null; return(DiscardPattern()); } // Multiple labels, and no catch-all merge them using an 'or' pattern. var totalPattern = GetPattern(switchLabels[0], out var whenClauseUnused); Debug.Assert( whenClauseUnused == null, "We should not have offered to convert multiple cases if any have a when clause" ); for (var i = 1; i < switchLabels.Count; i++) { var nextPatternPart = GetPattern(switchLabels[i], out whenClauseUnused); Debug.Assert( whenClauseUnused == null, "We should not have offered to convert multiple cases if any have a when clause" ); totalPattern = BinaryPattern( SyntaxKind.OrPattern, totalPattern.Parenthesize(), nextPatternPart.Parenthesize() ); } whenClauseOpt = null; return(totalPattern); }
private static PatternSyntax GetPattern(SwitchLabelSyntax switchLabel, out WhenClauseSyntax whenClauseOpt) { switch (switchLabel.Kind()) { case SyntaxKind.CasePatternSwitchLabel: var node = (CasePatternSwitchLabelSyntax)switchLabel; whenClauseOpt = node.WhenClause; return(node.Pattern); case SyntaxKind.CaseSwitchLabel: whenClauseOpt = null; return(ConstantPattern(((CaseSwitchLabelSyntax)switchLabel).Value)); case SyntaxKind.DefaultSwitchLabel: whenClauseOpt = null; return(DiscardPattern()); case var value: throw ExceptionUtilities.UnexpectedValue(value); } }
public TameWhenClauseSyntax(WhenClauseSyntax node) { Node = node; AddChildren(); }
// // Summary: // Called when the visitor visits a WhenClauseSyntax node. public virtual void VisitWhenClause(WhenClauseSyntax node);
public override void VisitWhenClause(WhenClauseSyntax node) { Log(node, "Unsupported Syntax !"); }
public override void VisitWhenClause(WhenClauseSyntax node) { throw new NotImplementedException(); }
public override void VisitWhenClause(WhenClauseSyntax node) { node.Condition?.Accept(this); base.VisitWhenClause(node); }
public override void VisitWhenClause(WhenClauseSyntax node) { base.VisitWhenClause(node); }
public override Evaluation VisitWhenClause(WhenClauseSyntax node) { node.Condition?.Accept <Evaluation>(this); return(base.VisitWhenClause(node)); }
public override void VisitWhenClause(WhenClauseSyntax node) { }