public override void VisitCasePatternSwitchLabel(CasePatternSwitchLabelSyntax node) { node.Pattern?.Accept(this); node.WhenClause?.Accept(this); base.VisitCasePatternSwitchLabel(node); }
public override Evaluation VisitCasePatternSwitchLabel(CasePatternSwitchLabelSyntax node) { node.Pattern?.Accept <Evaluation>(this); node.WhenClause?.Accept <Evaluation>(this); return(base.VisitCasePatternSwitchLabel(node)); }
public override void VisitCasePatternSwitchLabel(CasePatternSwitchLabelSyntax node) { if (currentMethod != null) { currentMethod.cyclomaticComplexity++; } base.VisitCasePatternSwitchLabel(node); }
internal override void BindPatternSwitchLabelForInference( CasePatternSwitchLabelSyntax node, BindingDiagnosticBag diagnostics ) { // There's supposed to be a SwitchBinder (or other overrider of this method) in the chain. throw ExceptionUtilities.Unreachable; }
public override void VisitCasePatternSwitchLabel(CasePatternSwitchLabelSyntax node) { if (node.Parent is SwitchSectionSyntax switchSection && switchSection.Parent is SwitchStatementSyntax switchStatement) { this.HandleAssignedValue(node.Pattern, switchStatement.Expression); } base.VisitCasePatternSwitchLabel(node); }
public static Doc Print(CasePatternSwitchLabelSyntax node) { var docs = new List <Doc>(); docs.Add(Token.Print(node.Keyword, " "), Node.Print(node.Pattern)); if (node.WhenClause != null) { docs.Add(" ", Node.Print(node.WhenClause)); } docs.Add(Token.Print(node.ColonToken)); return(Doc.Concat(docs)); }
public override void VisitCasePatternSwitchLabel(CasePatternSwitchLabelSyntax node) { if (!PreVisit(node)) { return; } node.Pattern?.Accept(this); node.WhenClause?.Accept(this); base.VisitCasePatternSwitchLabel(node); PostVisit(node); }
private Doc PrintCasePatternSwitchLabelSyntax( CasePatternSwitchLabelSyntax node) { var parts = new Parts(); parts.Push( this.PrintSyntaxToken(node.Keyword, " "), this.Print(node.Pattern) ); if (node.WhenClause != null) { parts.Push(" ", this.Print(node.WhenClause)); } parts.Push(this.PrintSyntaxToken(node.ColonToken)); return(Concat(parts)); }
public override void VisitCasePatternSwitchLabel(CasePatternSwitchLabelSyntax node) { var lastWhen = new ApexWhenTypeClauseSyntax(); var pattern = node.Pattern as DeclarationPatternSyntax; var type = pattern?.Type; var designation = pattern?.Designation as SingleVariableDesignationSyntax; if (pattern == null || type == null || designation == null) { throw new InvalidOperationException("Unsupported switch pattern format. " + "Case type variable is expected."); } lastWhen.Type = ConvertType(type); lastWhen.Identifier = designation.Identifier.ValueText; LastWhen = lastWhen; }
/// <summary> /// Bind a pattern switch label in order to force inference of the type of pattern variables. /// </summary> internal override void BindPatternSwitchLabelForInference(CasePatternSwitchLabelSyntax node, DiagnosticBag diagnostics) { // node should be a label of this switch statement. Debug.Assert(this.SwitchSyntax == node.Parent.Parent); // This simulates enough of the normal binding path of a switch statement to cause // the label's pattern variables to have their types inferred, if necessary. // It also binds the when clause, and therefore any pattern and out variables there. BoundPatternSwitchLabel defaultLabel = null; BindPatternSwitchSectionLabel( sectionBinder: GetBinder(node.Parent), node: node, label: LabelsByNode[node], defaultLabel: ref defaultLabel, diagnostics: diagnostics); }
/// <summary> /// Bind a pattern switch label in order to force inference of the type of pattern variables. /// </summary> internal override void BindPatternSwitchLabelForInference(CasePatternSwitchLabelSyntax node, DiagnosticBag diagnostics) { // node should be a label of this switch statement. Debug.Assert(this.SwitchSyntax == node.Parent.Parent); // This simulates enough of the normal binding path of a switch statement to cause // the label's pattern variables to have their types inferred, if necessary. // It also binds the when clause, and therefore any pattern and out variables there. BoundPatternSwitchLabel defaultLabel = null; BindPatternSwitchSectionLabel( sectionBinder: GetBinder(node.Parent), boundSwitchExpression: SwitchGoverningExpression, node: node, label: LabelsByNode[node], defaultLabel: ref defaultLabel, diagnostics: diagnostics); }
public override void VisitCasePatternSwitchLabel(CasePatternSwitchLabelSyntax node) { base.VisitCasePatternSwitchLabel(node); var declaration = node.Pattern as DeclarationPatternSyntax; if (declaration == null) { return; } if (declaration.Designation is SingleVariableDesignationSyntax variableDesignation) { var symbol = model.GetDeclaredSymbol(variableDesignation); if (symbol != null) { // variables declared in patterns are never null var item = new Assignment(symbol, node, ValueType.NotNull); Assignments.Add(item); } } }
BinaryExpressionSyntax(LogicalAndExpression) logicalAnd => CombineLogicalAndOperands(logicalAnd, model), CasePatternSwitchLabelSyntax { WhenClause : { } whenClause
internal override void BindPatternSwitchLabelForInference(CasePatternSwitchLabelSyntax node, DiagnosticBag diagnostics) { // There's supposed to be a SwitchBinder (or other overrider of this method) in the chain. throw ExceptionUtilities.Unreachable; }
override public void VisitCasePatternSwitchLabel(CasePatternSwitchLabelSyntax node) { Complexity++; base.VisitCasePatternSwitchLabel(node); }
public TameCasePatternSwitchLabelSyntax(CasePatternSwitchLabelSyntax node) { Node = node; AddChildren(); }
internal virtual void BindPatternSwitchLabelForInference(CasePatternSwitchLabelSyntax node, DiagnosticBag diagnostics) { this.Next.BindPatternSwitchLabelForInference(node, diagnostics); }
public override void VisitCasePatternSwitchLabel(CasePatternSwitchLabelSyntax node) { throw new NotImplementedException(); }
public override void VisitCasePatternSwitchLabel(CasePatternSwitchLabelSyntax node) { this.caseLabels.Add(node); base.VisitCasePatternSwitchLabel(node); }
public override SyntaxNode VisitCasePatternSwitchLabel(CasePatternSwitchLabelSyntax node) { //不支持的语法 return(ReportAndAttachError(base.VisitCasePatternSwitchLabel(node), "[Cs2LuaRewriter] Unsupported 'case pattern' Syntax !")); }
public override void VisitCasePatternSwitchLabel(CasePatternSwitchLabelSyntax node) => base.VisitCasePatternSwitchLabel(node);
internal override void BindPatternSwitchLabelForInference(CasePatternSwitchLabelSyntax node, DiagnosticBag diagnostics) { // A pattern should be handled by a pattern switch binder. throw ExceptionUtilities.Unreachable; }
public override void VisitCasePatternSwitchLabel(CasePatternSwitchLabelSyntax node) { Log(node, "Unsupported Syntax !"); }
private static Task <Document> UsePatternMatchingAsync( Document document, SwitchStatementSyntax switchStatement, CancellationToken cancellationToken) { SyntaxList <SwitchSectionSyntax> newSections = switchStatement.Sections.Select(section => { if (!(section.Labels.Single() is CaseSwitchLabelSyntax label)) { return(section); } SyntaxList <StatementSyntax> statements = section.Statements; StatementSyntax statement = statements[0]; if (statement is BlockSyntax block) { statement = block.Statements.FirstOrDefault(); } SingleLocalDeclarationStatementInfo localInfo = SyntaxInfo.SingleLocalDeclarationStatementInfo((LocalDeclarationStatementSyntax)statement); var castExpression = (CastExpressionSyntax)localInfo.Value; CasePatternSwitchLabelSyntax newLabel = CasePatternSwitchLabel( DeclarationPattern( castExpression.Type, SingleVariableDesignation(localInfo.Identifier)), label.ColonToken); SwitchSectionSyntax newSection = section.RemoveStatement(localInfo.Statement); newSection = newSection.WithLabels(newSection.Labels.ReplaceAt(0, newLabel)); return(newSection.WithFormatterAnnotation()); }) .ToSyntaxList(); ExpressionSyntax expression = switchStatement.Expression; ExpressionSyntax newExpression = expression; LocalDeclarationStatementSyntax localDeclaration = null; if (expression.IsKind(SyntaxKind.InvocationExpression)) { SimpleMemberInvocationExpressionInfo invocationInfo = SyntaxInfo.SimpleMemberInvocationExpressionInfo(expression); newExpression = invocationInfo.Expression; } else { localDeclaration = (LocalDeclarationStatementSyntax)switchStatement.PreviousStatement(); SingleLocalDeclarationStatementInfo localInfo = SyntaxInfo.SingleLocalDeclarationStatementInfo(localDeclaration); SimpleMemberInvocationExpressionInfo invocationInfo = SyntaxInfo.SimpleMemberInvocationExpressionInfo(localInfo.Value); newExpression = invocationInfo.Expression; } SwitchStatementSyntax newSwitchStatement = switchStatement .WithExpression(newExpression.WithTriviaFrom(expression)) .WithSections(newSections); if (localDeclaration != null) { StatementListInfo statementsInfo = SyntaxInfo.StatementListInfo(switchStatement); newSwitchStatement = newSwitchStatement.WithLeadingTrivia(localDeclaration.GetLeadingTrivia()); SyntaxList <StatementSyntax> newStatements = statementsInfo.Statements .Replace(switchStatement, newSwitchStatement) .RemoveAt(statementsInfo.IndexOf(localDeclaration)); return(document.ReplaceStatementsAsync(statementsInfo, newStatements, cancellationToken)); } else { return(document.ReplaceNodeAsync(switchStatement, newSwitchStatement, cancellationToken)); } }
// // Summary: // Called when the visitor visits a CasePatternSwitchLabelSyntax node. public virtual void VisitCasePatternSwitchLabel(CasePatternSwitchLabelSyntax node);