本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Binder.GetBinder方法的典型用法代码示例。如果您正苦于以下问题:C# Binder.GetBinder方法的具体用法?C# Binder.GetBinder怎么用?C# Binder.GetBinder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CSharp.Binder
的用法示例。
在下文中一共展示了Binder.GetBinder方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BindForParts
private BoundForStatement BindForParts(ForStatementSyntax node, Binder originalBinder, DiagnosticBag diagnostics)
{
BoundStatement initializer;
// Declaration and Initializers are mutually exclusive.
if (_syntax.Declaration != null)
{
ImmutableArray<BoundLocalDeclaration> unused;
initializer = originalBinder.BindForOrUsingOrFixedDeclarations(node.Declaration, LocalDeclarationKind.RegularVariable, diagnostics, out unused);
}
else
{
initializer = originalBinder.BindStatementExpressionList(node.Initializers, diagnostics);
}
BoundExpression condition = null;
var innerLocals = ImmutableArray<LocalSymbol>.Empty;
ExpressionSyntax conditionSyntax = node.Condition;
if (conditionSyntax != null)
{
originalBinder = originalBinder.GetBinder(conditionSyntax);
condition = originalBinder.BindBooleanExpression(conditionSyntax, diagnostics);
innerLocals = originalBinder.GetDeclaredLocalsForScope(conditionSyntax);
}
BoundStatement increment = null;
SeparatedSyntaxList<ExpressionSyntax> incrementors = node.Incrementors;
if (incrementors.Count > 0)
{
var scopeDesignator = incrementors.First();
var incrementBinder = originalBinder.GetBinder(scopeDesignator);
increment = incrementBinder.WrapWithVariablesIfAny(scopeDesignator, incrementBinder.BindStatementExpressionList(incrementors, diagnostics));
}
var body = originalBinder.BindPossibleEmbeddedStatement(node.Statement, diagnostics);
Debug.Assert(this.Locals == this.GetDeclaredLocalsForScope(node));
return new BoundForStatement(node,
this.Locals,
initializer,
innerLocals,
condition,
increment,
body,
this.BreakLabel,
this.ContinueLabel);
}
示例2: BindPatternSwitch
private BoundPatternSwitchStatement BindPatternSwitch(SwitchStatementSyntax node, Binder originalBinder, DiagnosticBag diagnostics)
{
var boundSwitchExpression = originalBinder.GetBinder(node.Expression).BindValue(node.Expression, diagnostics, BindValueKind.RValue);
// TODO: any constraints on a switch expression must be enforced here. For example,
// it must have a type (not be target-typed, lambda, null, etc)
DefaultSwitchLabelSyntax defaultLabel = null;
ImmutableArray<BoundPatternSwitchSection> boundPatternSwitchSections = BindPatternSwitchSections(boundSwitchExpression, node.Sections, originalBinder, ref defaultLabel, diagnostics);
return new BoundPatternSwitchStatement(node, boundSwitchExpression,
GetDeclaredLocalsForScope(node),
GetDeclaredLocalFunctionsForScope(node), boundPatternSwitchSections, this.BreakLabel);
}
示例3: BindForEachDeconstruction
/// <summary>
/// Like BindForEachParts, but only bind the deconstruction part of the foreach, for purpose of inferring the types of the declared locals.
/// </summary>
internal override void BindForEachDeconstruction(DiagnosticBag diagnostics, Binder originalBinder)
{
// Use the right binder to avoid seeing iteration variable
BoundExpression collectionExpr = originalBinder.GetBinder(_syntax.Expression).BindValue(_syntax.Expression, diagnostics, BindValueKind.RValue);
ForEachEnumeratorInfo.Builder builder = new ForEachEnumeratorInfo.Builder();
TypeSymbol inferredType;
bool hasErrors = !GetEnumeratorInfoAndInferCollectionElementType(ref builder, ref collectionExpr, diagnostics, out inferredType);
VariableDeclarationSyntax variables = _syntax.DeconstructionVariables;
var valuePlaceholder = new BoundDeconstructValuePlaceholder(_syntax.Expression, inferredType ?? CreateErrorType("var"));
BoundDeconstructionAssignmentOperator deconstruction = BindDeconstructionDeclaration(
variables,
variables,
right: null,
diagnostics: diagnostics,
rightPlaceholder: valuePlaceholder);
}
示例4: BindPatternSwitchSection
private static BoundPatternSwitchSection BindPatternSwitchSection(BoundExpression boundSwitchExpression, SwitchSectionSyntax node, Binder originalBinder, ref DefaultSwitchLabelSyntax defaultLabel, DiagnosticBag diagnostics)
{
// Bind match section labels
var boundLabelsBuilder = ArrayBuilder<BoundPatternSwitchLabel>.GetInstance();
var sectionBinder = originalBinder.GetBinder(node); // this binder can bind pattern variables from the section.
Debug.Assert(sectionBinder != null);
foreach (var labelSyntax in node.Labels)
{
BoundPatternSwitchLabel boundLabel = BindPatternSwitchSectionLabel(sectionBinder, boundSwitchExpression, labelSyntax, ref defaultLabel, diagnostics);
boundLabelsBuilder.Add(boundLabel);
}
// Bind switch section statements
var boundStatementsBuilder = ArrayBuilder<BoundStatement>.GetInstance();
foreach (var statement in node.Statements)
{
boundStatementsBuilder.Add(sectionBinder.BindStatement(statement, diagnostics));
}
return new BoundPatternSwitchSection(node, sectionBinder.GetDeclaredLocalsForScope(node), boundLabelsBuilder.ToImmutableAndFree(), boundStatementsBuilder.ToImmutableAndFree());
}
示例5: BindSwitchSection
private BoundSwitchSection BindSwitchSection(SwitchSectionSyntax node, Binder originalBinder, DiagnosticBag diagnostics)
{
var sectionBinder = originalBinder.GetBinder(node);
// Bind switch section labels
var boundLabelsBuilder = ArrayBuilder<BoundSwitchLabel>.GetInstance();
foreach (var labelSyntax in node.Labels)
{
LabelSymbol label = LabelsByNode[labelSyntax];
BoundSwitchLabel boundLabel = BindSwitchSectionLabel(labelSyntax, sectionBinder, label, diagnostics);
boundLabelsBuilder.Add(boundLabel);
}
// Bind switch section statements
var boundStatementsBuilder = ArrayBuilder<BoundStatement>.GetInstance();
foreach (var statement in node.Statements)
{
boundStatementsBuilder.Add(sectionBinder.BindStatement(statement, diagnostics));
}
return new BoundSwitchSection(node, boundLabelsBuilder.ToImmutableAndFree(), boundStatementsBuilder.ToImmutableAndFree());
}
示例6: BindPatternSwitchSection
/// <summary>
/// Bind the pattern switch section, producing subsumption diagnostics.
/// </summary>
/// <param name="boundSwitchExpression"/>
/// <param name="node"/>
/// <param name="originalBinder"/>
/// <param name="defaultLabel">If a default label is found in this section, assigned that label</param>
/// <param name="someValueMatched">If a constant label is found that matches the constant input, assigned that label</param>
/// <param name="subsumption">A helper class that uses a decision tree to produce subsumption diagnostics.</param>
/// <param name="diagnostics"></param>
/// <returns></returns>
private BoundPatternSwitchSection BindPatternSwitchSection(
BoundExpression boundSwitchExpression,
SwitchSectionSyntax node,
Binder originalBinder,
ref BoundPatternSwitchLabel defaultLabel,
ref bool someValueMatched,
SubsumptionDiagnosticBuilder subsumption,
DiagnosticBag diagnostics)
{
// Bind match section labels
var boundLabelsBuilder = ArrayBuilder<BoundPatternSwitchLabel>.GetInstance();
var sectionBinder = originalBinder.GetBinder(node); // this binder can bind pattern variables from the section.
Debug.Assert(sectionBinder != null);
var labelsByNode = LabelsByNode;
foreach (var labelSyntax in node.Labels)
{
LabelSymbol label = labelsByNode[labelSyntax];
BoundPatternSwitchLabel boundLabel = BindPatternSwitchSectionLabel(sectionBinder, boundSwitchExpression, labelSyntax, label, ref defaultLabel, diagnostics);
bool valueMatched; // true if we find an unconditional constant label that matches the input constant's value
bool isReachable = subsumption.AddLabel(boundLabel, diagnostics, out valueMatched);
boundLabel = boundLabel.Update(boundLabel.Label, boundLabel.Pattern, boundLabel.Guard, isReachable && !someValueMatched);
someValueMatched |= valueMatched;
boundLabelsBuilder.Add(boundLabel);
}
// Bind switch section statements
var boundStatementsBuilder = ArrayBuilder<BoundStatement>.GetInstance();
foreach (var statement in node.Statements)
{
boundStatementsBuilder.Add(sectionBinder.BindStatement(statement, diagnostics));
}
return new BoundPatternSwitchSection(node, sectionBinder.GetDeclaredLocalsForScope(node), boundLabelsBuilder.ToImmutableAndFree(), boundStatementsBuilder.ToImmutableAndFree());
}
示例7: BindSwitchExpression
// Bind the switch expression
private BoundExpression BindSwitchExpression(ExpressionSyntax node, Binder originalBinder, DiagnosticBag diagnostics)
{
// We are at present inside the switch binder, but the switch expression is not
// bound in the context of the switch binder; it's bound in the context of the
// enclosing binder. For example:
//
// class C {
// int x;
// void M() {
// switch(x) {
// case 1:
// int x;
//
// This is not legal, but why it is not legal is interesting. The "x" in "switch(x)"
// refers to this.x, not the local x that is in scope inside the switch block. This
// should therefore produce a CS0135 "local decl conflicts with simple name that
// meant something else" error, not a "you used local x before it was declared" error.
//
Debug.Assert(node == _switchSyntax.Expression);
var binder = originalBinder.GetBinder(node);
Debug.Assert(binder != null);
var switchExpression = binder.BindValue(node, diagnostics, BindValueKind.RValue);
var switchGoverningType = switchExpression.Type;
if ((object)switchGoverningType != null && !switchGoverningType.IsErrorType())
{
// SPEC: The governing type of a switch statement is established by the switch expression.
// SPEC: 1) If the type of the switch expression is sbyte, byte, short, ushort, int, uint,
// SPEC: long, ulong, bool, char, string, or an enum-type, or if it is the nullable type
// SPEC: corresponding to one of these types, then that is the governing type of the switch statement.
// SPEC: 2) Otherwise, exactly one user-defined implicit conversion (§6.4) must exist from the
// SPEC: type of the switch expression to one of the following possible governing types:
// SPEC: sbyte, byte, short, ushort, int, uint, long, ulong, char, string, or, a nullable type
// SPEC: corresponding to one of those types
if (switchGoverningType.IsValidSwitchGoverningType())
{
// Condition (1) satisfied
// Note: dev11 actually checks the stripped type, but nullable was introduced at the same
// time, so it doesn't really matter.
if (switchGoverningType.SpecialType == SpecialType.System_Boolean)
{
// GetLocation() so that it also works in speculative contexts.
CheckFeatureAvailability(node.GetLocation(), MessageID.IDS_FeatureSwitchOnBool, diagnostics);
}
return switchExpression;
}
else
{
TypeSymbol resultantGoverningType;
HashSet<DiagnosticInfo> useSiteDiagnostics = null;
Conversion conversion = binder.Conversions.ClassifyImplicitUserDefinedConversionForSwitchGoverningType(switchGoverningType, out resultantGoverningType, ref useSiteDiagnostics);
diagnostics.Add(node, useSiteDiagnostics);
if (conversion.IsValid)
{
// Condition (2) satisfied
Debug.Assert(conversion.Kind == ConversionKind.ImplicitUserDefined);
Debug.Assert(conversion.Method.IsUserDefinedConversion());
Debug.Assert(conversion.UserDefinedToConversion.IsIdentity);
Debug.Assert((object)resultantGoverningType != null);
Debug.Assert(resultantGoverningType.IsValidSwitchGoverningType(isTargetTypeOfUserDefinedOp: true));
return binder.CreateConversion(node, switchExpression, conversion, false, resultantGoverningType, diagnostics);
}
else
{
// We need to create an error type here as certain diagnostics generated during binding the switch case label expression and
// goto case expression should be generated only if the switch expression type is a valid switch governing type.
switchGoverningType = CreateErrorType(switchGoverningType.Name);
}
}
}
if (!switchExpression.HasAnyErrors)
{
diagnostics.Add(ErrorCode.ERR_SwitchGoverningTypeValueExpected, node.Location);
}
return new BoundBadExpression(node, LookupResultKind.Empty, ImmutableArray<Symbol>.Empty, ImmutableArray.Create<BoundNode>(switchExpression), switchGoverningType ?? CreateErrorType());
}
示例8: AdjustBinderForPositionWithinStatement
private static Binder AdjustBinderForPositionWithinStatement(int position, Binder binder, StatementSyntax stmt)
{
switch (stmt.Kind())
{
case SyntaxKind.SwitchStatement:
var switchStmt = (SwitchStatementSyntax)stmt;
if (LookupPosition.IsBetweenTokens(position, switchStmt.OpenParenToken, switchStmt.OpenBraceToken))
{
binder = binder.GetBinder(switchStmt.Expression);
Debug.Assert(binder != null);
}
break;
case SyntaxKind.ForEachStatement:
case SyntaxKind.ForEachComponentStatement:
var foreachStmt = (CommonForEachStatementSyntax)stmt;
if (LookupPosition.IsBetweenTokens(position, foreachStmt.OpenParenToken, foreachStmt.Statement.GetFirstToken()))
{
binder = binder.GetBinder(foreachStmt.Expression);
Debug.Assert(binder != null);
}
break;
}
return binder;
}
示例9: GetEnclosingBinder
private static Binder GetEnclosingBinder(SyntaxNode node, int position, Binder rootBinder, SyntaxNode root)
{
if (node == root)
{
return rootBinder.GetBinder(node) ?? rootBinder;
}
Debug.Assert(root.Contains(node));
ExpressionSyntax typeOfArgument = null;
SyntaxNode unexpectedAnonymousFunction = null;
// Keep track of which fix-up should be applied first. If we see a typeof expression inside an unexpected
// anonymous function, that the typeof binder should be innermost (i.e. should have the unexpected
// anonymous function binder as its Next).
// NOTE: only meaningful if typeOfArgument is non-null;
bool typeOfEncounteredBeforeUnexpectedAnonymousFunction = false;
Binder binder = null;
for (var current = node; binder == null; current = current.ParentOrStructuredTriviaParent)
{
Debug.Assert(current != null); // Why were we asked for an enclosing binder for a node outside our root?
StatementSyntax stmt = current as StatementSyntax;
TypeOfExpressionSyntax typeOfExpression;
if (stmt != null)
{
if (LookupPosition.IsInStatementScope(position, stmt))
{
binder = rootBinder.GetBinder(current);
if (binder != null)
{
binder = AdjustBinderForPositionWithinStatement(position, binder, stmt);
}
}
}
else if (current.Kind() == SyntaxKind.CatchClause)
{
if (LookupPosition.IsInCatchBlockScope(position, (CatchClauseSyntax)current))
{
binder = rootBinder.GetBinder(current);
}
}
else if (current.Kind() == SyntaxKind.CatchFilterClause)
{
if (LookupPosition.IsInCatchFilterScope(position, (CatchFilterClauseSyntax)current))
{
binder = rootBinder.GetBinder(current);
}
}
else if (current.IsAnonymousFunction())
{
if (LookupPosition.IsInAnonymousFunctionOrQuery(position, current))
{
binder = rootBinder.GetBinder(current);
// This should only happen in error scenarios. For example, C# does not allow array rank
// specifiers in types, (e.g. int[1] x;), but the syntax model does. In order to construct
// an appropriate binder chain for the anonymous method body, we need to construct an
// ExecutableCodeBinder.
if (binder == null && unexpectedAnonymousFunction == null && current != root)
{
unexpectedAnonymousFunction = current;
}
}
}
else if (current.Kind() == SyntaxKind.TypeOfExpression &&
typeOfArgument == null &&
LookupPosition.IsBetweenTokens(
position,
(typeOfExpression = (TypeOfExpressionSyntax)current).OpenParenToken,
typeOfExpression.CloseParenToken))
{
typeOfArgument = typeOfExpression.Type;
typeOfEncounteredBeforeUnexpectedAnonymousFunction = unexpectedAnonymousFunction == null;
}
else if (current.Kind() == SyntaxKind.SwitchSection)
{
if (LookupPosition.IsInSwitchSectionScope(position, (SwitchSectionSyntax)current))
{
binder = rootBinder.GetBinder(current);
}
}
else if (current.Kind() == SyntaxKind.ArgumentList)
{
var argList = (ArgumentListSyntax)current;
if (LookupPosition.IsBetweenTokens(position, argList.OpenParenToken, argList.CloseParenToken))
{
binder = rootBinder.GetBinder(current);
}
}
else if (current.Kind() == SyntaxKind.EqualsValueClause)
{
binder = rootBinder.GetBinder(current);
}
else if (current.Kind() == SyntaxKind.Attribute)
{
binder = rootBinder.GetBinder(current);
}
//.........这里部分代码省略.........
示例10: GetLambdaEnclosingBinder
/// <summary>
/// Performs the same function as GetEnclosingBinder, but is known to take place within a
/// specified lambda. Walks up the syntax hierarchy until a node with an associated binder
/// is found.
/// </summary>
/// <remarks>
/// CONSIDER: can this share code with MemberSemanticModel.GetEnclosingBinder?
///
/// Returned binder doesn't need to have <see cref="BinderFlags.SemanticModel"/> set - the caller will add it.
/// </remarks>
private static Binder GetLambdaEnclosingBinder(int position, CSharpSyntaxNode startingNode, CSharpSyntaxNode containingLambda, Binder lambdaBinder)
{
Debug.Assert(containingLambda.IsAnonymousFunction());
Debug.Assert(LookupPosition.IsInAnonymousFunctionOrQuery(position, containingLambda));
var current = startingNode;
while (current != containingLambda)
{
Debug.Assert(current != null);
StatementSyntax stmt = current as StatementSyntax;
if (stmt != null)
{
if (LookupPosition.IsInStatementScope(position, stmt))
{
Binder binder = lambdaBinder.GetBinder(current);
if (binder != null)
{
return AdjustBinderForPositionWithinStatement(position, binder, stmt);
}
}
}
else if (current.Kind == SyntaxKind.CatchClause)
{
if (LookupPosition.IsInCatchBlockScope(position, (CatchClauseSyntax)current))
{
Binder binder = lambdaBinder.GetBinder(current);
if (binder != null)
{
return binder;
}
}
}
else if (current.Kind == SyntaxKind.CatchFilterClause)
{
if (LookupPosition.IsInCatchFilterScope(position, (CatchFilterClauseSyntax)current))
{
Binder binder = lambdaBinder.GetBinder(current);
if (binder != null)
{
return binder;
}
}
}
else if (current.IsAnonymousFunction())
{
if (LookupPosition.IsInAnonymousFunctionOrQuery(position, current))
{
Binder binder = lambdaBinder.GetBinder(current);
if (binder != null)
{
return binder;
}
}
}
else
{
// If this ever breaks, make sure that all callers of
// CanHaveAssociatedLocalBinder are in sync.
Debug.Assert(!current.CanHaveAssociatedLocalBinder());
}
current = current.ParentOrStructuredTriviaParent;
}
return lambdaBinder;
}
示例11: BindForEachPartsWorker
private BoundForEachStatement BindForEachPartsWorker(DiagnosticBag diagnostics, Binder originalBinder)
{
// Use the right binder to avoid seeing iteration variable
BoundExpression collectionExpr = originalBinder.GetBinder(_syntax.Expression).BindValue(_syntax.Expression, diagnostics, BindValueKind.RValue);
ForEachEnumeratorInfo.Builder builder = new ForEachEnumeratorInfo.Builder();
TypeSymbol inferredType;
bool hasErrors = !GetEnumeratorInfoAndInferCollectionElementType(ref builder, ref collectionExpr, diagnostics, out inferredType);
// These should only occur when special types are missing or malformed.
hasErrors = hasErrors ||
(object)builder.GetEnumeratorMethod == null ||
(object)builder.MoveNextMethod == null ||
(object)builder.CurrentPropertyGetter == null;
// Check for local variable conflicts in the *enclosing* binder; obviously the *current*
// binder has a local that matches!
var hasNameConflicts = originalBinder.ValidateDeclarationNameConflictsInScope(IterationVariable, diagnostics);
// If the type in syntax is "var", then the type should be set explicitly so that the
// Type property doesn't fail.
TypeSyntax typeSyntax = _syntax.Type;
bool isVar;
AliasSymbol alias;
TypeSymbol declType = BindType(typeSyntax, diagnostics, out isVar, out alias);
TypeSymbol iterationVariableType;
if (isVar)
{
iterationVariableType = inferredType ?? CreateErrorType("var");
}
else
{
Debug.Assert((object)declType != null);
iterationVariableType = declType;
}
BoundTypeExpression boundIterationVariableType = new BoundTypeExpression(typeSyntax, alias, iterationVariableType);
this.IterationVariable.SetTypeSymbol(iterationVariableType);
BoundStatement body = originalBinder.BindPossibleEmbeddedStatement(_syntax.Statement, diagnostics);
hasErrors = hasErrors || iterationVariableType.IsErrorType();
// Skip the conversion checks and array/enumerator differentiation if we know we have an error (except local name conflicts).
if (hasErrors)
{
return new BoundForEachStatement(
_syntax,
null, // can't be sure that it's complete
default(Conversion),
boundIterationVariableType,
this.IterationVariable,
collectionExpr,
body,
CheckOverflowAtRuntime,
this.BreakLabel,
this.ContinueLabel,
hasErrors);
}
hasErrors |= hasNameConflicts;
var foreachKeyword = _syntax.ForEachKeyword;
ReportDiagnosticsIfObsolete(diagnostics, builder.GetEnumeratorMethod, foreachKeyword, hasBaseReceiver: false);
ReportDiagnosticsIfObsolete(diagnostics, builder.MoveNextMethod, foreachKeyword, hasBaseReceiver: false);
ReportDiagnosticsIfObsolete(diagnostics, builder.CurrentPropertyGetter, foreachKeyword, hasBaseReceiver: false);
ReportDiagnosticsIfObsolete(diagnostics, builder.CurrentPropertyGetter.AssociatedSymbol, foreachKeyword, hasBaseReceiver: false);
// We want to convert from inferredType in the array/string case and builder.ElementType in the enumerator case,
// but it turns out that these are equivalent (when both are available).
HashSet<DiagnosticInfo> useSiteDiagnostics = null;
Conversion elementConversion = this.Conversions.ClassifyConversionForCast(inferredType, iterationVariableType, ref useSiteDiagnostics);
if (!elementConversion.IsValid)
{
ImmutableArray<MethodSymbol> originalUserDefinedConversions = elementConversion.OriginalUserDefinedConversions;
if (originalUserDefinedConversions.Length > 1)
{
diagnostics.Add(ErrorCode.ERR_AmbigUDConv, _syntax.ForEachKeyword.GetLocation(), originalUserDefinedConversions[0], originalUserDefinedConversions[1], inferredType, iterationVariableType);
}
else
{
SymbolDistinguisher distinguisher = new SymbolDistinguisher(this.Compilation, inferredType, iterationVariableType);
diagnostics.Add(ErrorCode.ERR_NoExplicitConv, _syntax.ForEachKeyword.GetLocation(), distinguisher.First, distinguisher.Second);
}
hasErrors = true;
}
else
{
ReportDiagnosticsIfObsolete(diagnostics, elementConversion, _syntax.ForEachKeyword, hasBaseReceiver: false);
}
// Spec (§8.8.4):
// If the type X of expression is dynamic then there is an implicit conversion from >>expression<< (not the type of the expression)
// to the System.Collections.IEnumerable interface (§6.1.8).
//.........这里部分代码省略.........
示例12: AdjustBinderForPositionWithinStatement
private static Binder AdjustBinderForPositionWithinStatement(int position, Binder binder, StatementSyntax stmt)
{
switch (stmt.Kind())
{
case SyntaxKind.SwitchStatement:
var switchStmt = (SwitchStatementSyntax)stmt;
if (LookupPosition.IsBetweenTokens(position, switchStmt.OpenParenToken, switchStmt.OpenBraceToken))
{
binder = binder.GetBinder(switchStmt.Expression);
Debug.Assert(binder != null);
}
break;
case SyntaxKind.ForStatement:
var forStmt = (ForStatementSyntax)stmt;
if (LookupPosition.IsBetweenTokens(position, forStmt.SecondSemicolonToken, forStmt.CloseParenToken) &&
forStmt.Incrementors.Count > 0)
{
binder = binder.GetBinder(forStmt.Incrementors.First());
Debug.Assert(binder != null);
}
else if (LookupPosition.IsBetweenTokens(position, forStmt.FirstSemicolonToken, LookupPosition.GetFirstExcludedToken(forStmt)) &&
forStmt.Condition != null)
{
binder = binder.GetBinder(forStmt.Condition);
Debug.Assert(binder != null);
}
break;
case SyntaxKind.ForEachStatement:
case SyntaxKind.ForEachVariableStatement:
var foreachStmt = (CommonForEachStatementSyntax)stmt;
var start = stmt.Kind() == SyntaxKind.ForEachVariableStatement ? foreachStmt.InKeyword : foreachStmt.OpenParenToken;
if (LookupPosition.IsBetweenTokens(position, start, foreachStmt.Statement.GetFirstToken()))
{
binder = binder.GetBinder(foreachStmt.Expression);
Debug.Assert(binder != null);
}
break;
}
return binder;
}