mirror of
https://github.com/github/codeql.git
synced 2026-05-05 05:35:13 +02:00
C#: Re-factor to use ForEach.
This commit is contained in:
@@ -2,6 +2,7 @@ using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using Semmle.Extraction.Kinds;
|
||||
using Semmle.Util;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -108,11 +109,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
if (length > 0)
|
||||
{
|
||||
var arrayInit = ArrayInitializer.CreateGenerated(cx, arrayCreation, InitializerIndex, location);
|
||||
var child = 0;
|
||||
foreach (var item in items)
|
||||
{
|
||||
Expression.CreateGenerated(cx, item, arrayInit, child++, location);
|
||||
}
|
||||
items.ForEach((item, child) => Expression.CreateGenerated(cx, item, arrayInit, child, location));
|
||||
}
|
||||
|
||||
return arrayCreation;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using Semmle.Extraction.Entities;
|
||||
using Semmle.Extraction.Kinds;
|
||||
using Semmle.Util;
|
||||
using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
@@ -146,11 +146,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
|
||||
var init = (InitializerExpressionSyntax)i;
|
||||
|
||||
var addChild = 0;
|
||||
foreach (var arg in init.Expressions)
|
||||
{
|
||||
Create(Context, arg, invocation, addChild++);
|
||||
}
|
||||
init.Expressions.ForEach((arg, child) => Create(Context, arg, invocation, child));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using Semmle.Extraction.Kinds;
|
||||
using Semmle.Util;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
@@ -8,11 +9,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
internal PositionalPattern(Context cx, PositionalPatternClauseSyntax posPc, IExpressionParentEntity parent, int child) :
|
||||
base(new ExpressionInfo(cx, null, cx.CreateLocation(posPc.GetLocation()), ExprKind.POSITIONAL_PATTERN, parent, child, false, null))
|
||||
{
|
||||
child = 0;
|
||||
foreach (var sub in posPc.Subpatterns)
|
||||
{
|
||||
Pattern.Create(cx, sub.Pattern, this, child++);
|
||||
}
|
||||
posPc.Subpatterns.ForEach((p, i) => Pattern.Create(cx, p.Pattern, this, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user