internal override bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, StatementSyntax statement, out SemanticModel speculativeModel) { position = CheckAndAdjustPosition(position); var binder = this.GetEnclosingBinder(position); if (binder == null) { speculativeModel = null; return(false); } var methodSymbol = (MethodSymbol)this.MemberSymbol; binder = new ExecutableCodeBinder(statement, methodSymbol, binder); // local declaration statements need to be wrapped in a block so the local gets seen if (!statement.IsKind(SyntaxKind.Block)) { binder = new BlockBinder(binder, new SyntaxList <StatementSyntax>(statement)); } speculativeModel = CreateSpeculative(parentModel, methodSymbol, statement, binder, position); return(true); }
private void VisitPossibleEmbeddedStatement(StatementSyntax statement, Binder enclosing) { if (statement != null) { switch (statement.Kind()) { case SyntaxKind.LocalDeclarationStatement: case SyntaxKind.LabeledStatement: case SyntaxKind.LocalFunctionStatement: // It is an error to have a declaration or a label in an embedded statement, // but we still want to bind it. We'll pretend that the statement was // inside a block. Debug.Assert((object)_containingMemberOrLambda == enclosing.ContainingMemberOrLambda); var blockBinder = new BlockBinder(enclosing, new SyntaxList <StatementSyntax>(statement)); AddToMap(statement, blockBinder); Visit(statement, blockBinder); return; default: break; } Visit(statement, enclosing); } }
// Top-level block has an enclosing that is not a BinderContext. All others must (so that variables can be declared). public override void VisitBlock(BlockSyntax node) { var blockBinder = new BlockBinder(this.method, enclosing, node.Statements); AddToMap(node, blockBinder); // Visit all the statements inside this block foreach (StatementSyntax statement in node.Statements) { Visit(statement, blockBinder); } }
// Top-level block has an enclosing that is not a BinderContext. All others must (so that variables can be declared). public override void VisitBlock(BlockSyntax node) { Debug.Assert((object)_containingMemberOrLambda == _enclosing.ContainingMemberOrLambda); var blockBinder = new BlockBinder(_enclosing, node); AddToMap(node, blockBinder); // Visit all the statements inside this block foreach (StatementSyntax statement in node.Statements) { Visit(statement, blockBinder); } }
private void VisitPossibleEmbeddedStatement(StatementSyntax statement, Binder enclosing) { if (statement != null) { switch (statement.Kind) { case SyntaxKind.LocalDeclarationStatement: case SyntaxKind.LabeledStatement: // It is an error to have a declaration or a label in an embedded statement, // but we still want to bind it. We'll pretend that the statement was // inside a block. Debug.Assert((object)this.method == enclosing.ContainingMemberOrLambda); var blockBinder = new BlockBinder(enclosing, new SyntaxList <StatementSyntax>(statement)); AddToMap(statement, blockBinder); Visit(statement, blockBinder); return; case SyntaxKind.Block: case SyntaxKind.UsingStatement: case SyntaxKind.WhileStatement: case SyntaxKind.DoStatement: case SyntaxKind.ForStatement: case SyntaxKind.ForEachStatement: case SyntaxKind.FixedStatement: case SyntaxKind.LockStatement: case SyntaxKind.SwitchStatement: case SyntaxKind.IfStatement: // These statements always have dedicated binders. break; default: // Create a binder to introduce a scope for Declaration Expressions, if any. Debug.Assert((object)this.method == enclosing.ContainingMemberOrLambda); enclosing = new EmbeddedStatementBinder(enclosing, statement); AddToMap(statement, enclosing); break; } } Visit(statement, enclosing); }
private void VisitPossibleEmbeddedStatement(StatementSyntax statement, Binder enclosing) { if (statement != null) { switch (statement.Kind) { case SyntaxKind.LocalDeclarationStatement: case SyntaxKind.LabeledStatement: // It is an error to have a declaration or a label in an embedded statement, // but we still want to bind it. We'll pretend that the statement was // inside a block. var blockBinder = new BlockBinder(this.method, enclosing, new SyntaxList <StatementSyntax>(statement)); AddToMap(statement, blockBinder); Visit(statement, blockBinder); return; } } Visit(statement, enclosing); }
internal override bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, StatementSyntax statement, out SemanticModel speculativeModel) { position = CheckAndAdjustPosition(position); var binder = this.GetEnclosingBinder(position); if (binder == null) { speculativeModel = null; return false; } var methodSymbol = (MethodSymbol)this.MemberSymbol; binder = new ExecutableCodeBinder(statement, methodSymbol, binder); // local declaration statements need to be wrapped in a block so the local gets seen if (!statement.IsKind(SyntaxKind.Block)) { binder = new BlockBinder(methodSymbol, binder, new SyntaxList<StatementSyntax>(statement)); } speculativeModel = CreateSpeculative(parentModel, methodSymbol, statement, binder, position); return true; }
private void VisitPossibleEmbeddedStatement(StatementSyntax statement, Binder enclosing) { if (statement != null) { switch (statement.Kind()) { case SyntaxKind.LocalDeclarationStatement: case SyntaxKind.LabeledStatement: // It is an error to have a declaration or a label in an embedded statement, // but we still want to bind it. We'll pretend that the statement was // inside a block. Debug.Assert((object)_method == enclosing.ContainingMemberOrLambda); var blockBinder = new BlockBinder(enclosing, new SyntaxList<StatementSyntax>(statement)); AddToMap(statement, blockBinder); Visit(statement, blockBinder); return; case SyntaxKind.Block: case SyntaxKind.UsingStatement: case SyntaxKind.WhileStatement: case SyntaxKind.DoStatement: case SyntaxKind.ForStatement: case SyntaxKind.ForEachStatement: case SyntaxKind.FixedStatement: case SyntaxKind.LockStatement: case SyntaxKind.SwitchStatement: case SyntaxKind.IfStatement: // These statements always have dedicated binders. break; default: break; } } Visit(statement, enclosing); }
// Top-level block has an enclosing that is not a BinderContext. All others must (so that variables can be declared). public override void VisitBlock(BlockSyntax node) { Debug.Assert((object)_method == _enclosing.ContainingMemberOrLambda); var blockBinder = new BlockBinder(_enclosing, node.Statements); AddToMap(node, blockBinder); // Visit all the statements inside this block foreach (StatementSyntax statement in node.Statements) { Visit(statement, blockBinder); } }
private void VisitPossibleEmbeddedStatement(StatementSyntax statement, Binder enclosing) { if (statement != null) { switch (statement.Kind()) { case SyntaxKind.LocalDeclarationStatement: case SyntaxKind.LabeledStatement: case SyntaxKind.LocalFunctionStatement: // It is an error to have a declaration or a label in an embedded statement, // but we still want to bind it. We'll pretend that the statement was // inside a block. Debug.Assert((object)_containingMemberOrLambda == enclosing.ContainingMemberOrLambda); var blockBinder = new BlockBinder(enclosing, new SyntaxList<StatementSyntax>(statement)); AddToMap(statement, blockBinder); Visit(statement, blockBinder); return; default: break; } Visit(statement, enclosing); } }
private void VisitPossibleEmbeddedStatement(StatementSyntax statement, Binder enclosing) { if (statement != null) { switch (statement.Kind) { case SyntaxKind.LocalDeclarationStatement: case SyntaxKind.LabeledStatement: // It is an error to have a declaration or a label in an embedded statement, // but we still want to bind it. We'll pretend that the statement was // inside a block. var blockBinder = new BlockBinder(this.method, enclosing, new SyntaxList<StatementSyntax>(statement)); AddToMap(statement, blockBinder); Visit(statement, blockBinder); return; } } Visit(statement, enclosing); }
// Top-level block has an enclosing that is not a BinderContext. All others must (so that variables can be declared). public override void VisitBlock(BlockSyntax node) { var blockBinder = new BlockBinder(this.method, enclosing, node.Statements); AddToMap(node, blockBinder); // Visit all the statements inside this block foreach (StatementSyntax statement in node.Statements) { Visit(statement, blockBinder); } }