本文整理汇总了C#中ForeachStatement类的典型用法代码示例。如果您正苦于以下问题:C# ForeachStatement类的具体用法?C# ForeachStatement怎么用?C# ForeachStatement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ForeachStatement类属于命名空间,在下文中一共展示了ForeachStatement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitForeachStatement
public override void VisitForeachStatement(ForeachStatement foreachStatement)
{
base.VisitForeachStatement(foreachStatement);
var rr = ctx.Resolve(foreachStatement) as ForEachResolveResult;
if (rr == null)
return;
if (rr.ElementType.Kind == TypeKind.Unknown)
return;
if (ReflectionHelper.GetTypeCode(rr.ElementType) == TypeCode.Object)
return;
if (conversions == null) {
conversions = CSharpConversions.Get(ctx.Compilation);
}
Conversion c = conversions.ImplicitConversion(rr.ElementType, rr.ElementVariable.Type);
if (c.IsValid)
return;
var csResolver = ctx.GetResolverStateBefore(foreachStatement);
var builder = new TypeSystemAstBuilder(csResolver);
AstType elementType = builder.ConvertType(rr.ElementType);
AstType variableType = foreachStatement.VariableType;
string issueText = ctx.TranslateString("Collection element type '{0}' is not implicitly convertible to '{1}'");
string fixText = ctx.TranslateString("Use type '{0}'");
AddIssue(variableType, string.Format(issueText, elementType.GetText(), variableType.GetText()),
new CodeAction(string.Format(fixText, elementType.GetText()),
script => script.Replace(variableType, elementType)));
}
示例2: VisitForeachStatement
public override object VisitForeachStatement(ForeachStatement foreachStatement, object data)
{
if (nameComparer.Equals(from, foreachStatement.VariableName)) {
foreachStatement.VariableName = to;
}
return base.VisitForeachStatement(foreachStatement, data);
}
示例3: VisitForeachStatement
public override void VisitForeachStatement (ForeachStatement foreachStatement)
{
base.VisitForeachStatement (foreachStatement);
if (HidesMember (ctx, foreachStatement, foreachStatement.VariableName))
AddIssue (foreachStatement.VariableNameToken,
ctx.TranslateString ("Local variable has the same name as a member and hides it"));
}
示例4: VisitForeachStatement
public override void VisitForeachStatement(ForeachStatement foreachStatement)
{
var expression = string.Format("foreach ({0} {1} in {2})", foreachStatement.VariableType.GetText(), foreachStatement.VariableName, foreachStatement.InExpression.GetText());
var token = CreateBlock(expression, SDNodeRole.ForEach);
_tokenList.Add(token);
VisitChildren(token.Statements, foreachStatement.EmbeddedStatement);
}
示例5: VisitForeachStatement
public override object VisitForeachStatement(ForeachStatement foreachStatement, object data)
{
var invocationExpression = foreachStatement.InExpression as InvocationExpression;
if(invocationExpression != null && invocationExpression.Target.ToString().EndsWith("Enum.GetValues"))
{
UnlockWith(invocationExpression);
}
return base.VisitForeachStatement(foreachStatement, data);
}
示例6: VisitForeachStatement
public override void VisitForeachStatement(ForeachStatement foreachStatement) {
bool oldIsInsideLoop = _isInsideLoop;
try {
_isInsideLoop = true;
AddVariable(foreachStatement.VariableNameToken, foreachStatement.VariableName);
base.VisitForeachStatement(foreachStatement);
}
finally {
_isInsideLoop = oldIsInsideLoop;
}
}
示例7: VisitForeachStatement
public override void VisitForeachStatement(ForeachStatement foreachStatement)
{
base.VisitForeachStatement (foreachStatement);
var resolveResult = ctx.Resolve (foreachStatement.VariableNameToken) as LocalResolveResult;
if (resolveResult == null)
return;
if (IsUsed (foreachStatement, resolveResult.Variable, foreachStatement.VariableNameToken))
return;
AddIssue (foreachStatement.VariableNameToken, ctx.TranslateString ("Local variable is never used"));
}
示例8: VisitForeachStatement
public virtual void VisitForeachStatement(ForeachStatement foreachStatement)
{
if (this.ThrowException)
{
throw (Exception)this.CreateException(foreachStatement);
}
}
示例9: VisitForeachStatement
public abstract StringBuilder VisitForeachStatement(ForeachStatement foreachStatement, int data);
示例10: ForeachStatement
ForeachStatement ForeachStatement(IBlockNode Scope,IStatement Parent)
{
Step();
var dbs = new ForeachStatement() {
Location = t.Location,
IsReverse = t.Kind == Foreach_Reverse,
Parent = Parent
};
LastParsedObject = dbs;
if(!Expect(OpenParenthesis))
return dbs;
var tl = new List<DVariable>();
bool init=true;
while(init || laKind == Comma)
{
if (init)
init = false;
else
Step();
var forEachVar = new DVariable{ Parent = Scope };
forEachVar.Location = la.Location;
if (laKind == Ref || laKind == InOut)
{
Step();
if(forEachVar.Attributes == null)
forEachVar.Attributes = new List<DAttribute>();
forEachVar.Attributes.Add(new Modifier(t.Kind));
}
if(IsEOF){
TrackerVariables.ExpectingIdentifier = true;
SynErr(t.Kind,"Basic type or iteration variable identifier expected.");
return dbs;
}
LastParsedObject = forEachVar;
if (laKind == (Identifier) && (Lexer.CurrentPeekToken.Kind == (Semicolon) || Lexer.CurrentPeekToken.Kind == Comma))
{
Step();
forEachVar.NameLocation = t.Location;
forEachVar.Name = t.Value;
}
else
{
var type = BasicType();
var tnode = Declarator(type, false, Scope);
if (tnode == null)
break;
if(forEachVar.Attributes != null)
if(tnode.Attributes == null)
tnode.Attributes = new List<DAttribute>(forEachVar.Attributes);
else
tnode.Attributes.AddRange(forEachVar.Attributes);
tnode.Location = forEachVar.Location;
forEachVar = (DVariable)tnode;
}
forEachVar.EndLocation = t.EndLocation;
tl.Add(forEachVar);
}
dbs.ForeachTypeList = tl.ToArray();
if(Expect(Semicolon))
dbs.Aggregate = Expression(Scope);
// ForeachRangeStatement
if (laKind == DoubleDot)
{
Step();
dbs.UpperAggregate = Expression();
}
if(Expect(CloseParenthesis))
dbs.ScopedStatement = Statement(Scope: Scope, Parent: dbs);
dbs.EndLocation = t.EndLocation;
return dbs;
}
示例11: VisitForeachStatement
public override void VisitForeachStatement(ForeachStatement foreachStatement)
{
ForceSpacesBefore(foreachStatement.LParToken, policy.SpaceBeforeForeachParentheses);
ForceSpacesAfter(foreachStatement.LParToken, policy.SpacesWithinForeachParentheses);
ForceSpacesBefore(foreachStatement.RParToken, policy.SpacesWithinForeachParentheses);
FixEmbeddedStatment(policy.StatementBraceStyle, policy.ForEachBraceForcement, foreachStatement.EmbeddedStatement);
}
示例12: VisitForeachStatement
public virtual void VisitForeachStatement (ForeachStatement foreachStatement)
{
VisitChildren (foreachStatement);
}
示例13: VisitForeachStatement
public void VisitForeachStatement(ForeachStatement foreachStatement)
{
StartNode(foreachStatement);
WriteKeyword(ForeachStatement.ForeachKeywordRole);
Space(policy.SpaceBeforeForeachParentheses);
LPar();
Space(policy.SpacesWithinForeachParentheses);
foreachStatement.VariableType.AcceptVisitor(this);
Space();
foreachStatement.VariableNameToken.AcceptVisitor(this);
WriteKeyword(ForeachStatement.InKeywordRole);
Space();
foreachStatement.InExpression.AcceptVisitor(this);
Space(policy.SpacesWithinForeachParentheses);
RPar();
WriteEmbeddedStatement(foreachStatement.EmbeddedStatement);
EndNode(foreachStatement);
}
示例14: VisitForeachStatement
public override void VisitForeachStatement(ForeachStatement foreachStatement)
{
if (findReturn)
{
base.VisitForeachStatement(foreachStatement);
}
}
示例15: Visit
public virtual void Visit(ForeachStatement s)
{
VisitChildren(s);
if (s.ForeachTypeList != null)
foreach (var t in s.ForeachTypeList)
t.Accept(this);
if (s.UpperAggregate != null)
s.UpperAggregate.Accept(this);
if (s.Aggregate != null)
s.Aggregate.Accept(this);
}