Skip to content

Commit f0fd2ed

Browse files
author
Kapil Borle
committed
Update GetCommandElementGroups implementation
1 parent 352f744 commit f0fd2ed

File tree

1 file changed

+5
-19
lines changed

1 file changed

+5
-19
lines changed

Rules/AlignAssignmentStatement.cs

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -225,29 +225,15 @@ private IEnumerable<DiagnosticRecord> FindHashtableViolations(TokenOperations to
225225
private List<List<CommandAst>> GetCommandElementGroups(Ast configAst)
226226
{
227227
var result = new List<List<CommandAst>>();
228-
var parents = new HashSet<Ast>();
229-
var parentChildrenGroup = configAst.FindAll(ast => IsPropertyValueCommandAst(ast), true)?
230-
.Select(ast => ast as CommandAst)
231-
.GroupBy(ast => ast.Parent.Parent); // parent is pipeline and pipeline's parent is namedblockast
232-
if (parentChildrenGroup == null)
228+
var astsFound = configAst.FindAll(ast => IsPropertyValueCommandAst(ast), true);
229+
if (astsFound == null)
233230
{
234231
return result;
235232
}
236233

237-
// var parentChildrenMap = new Dictionary<Ast, List<Ast>>();
238-
// foreach (var commandAst in commandAsts)
239-
// {
240-
// var parent = commandAst.Parent;
241-
// if (parentChildrenMap.ContainsKey(parent))
242-
// {
243-
// parentChildrenMap[parent].Add(commandAst);
244-
// }
245-
// else
246-
// {
247-
// parentChildrenMap.Add(parent, new List<Ast>())
248-
// }
249-
// }
250-
234+
var parentChildrenGroup = from ast in astsFound
235+
select (CommandAst)ast into commandAst
236+
group commandAst by commandAst.Parent.Parent; // parent is pipeline and pipeline's parent is namedblockast
251237
foreach (var group in parentChildrenGroup)
252238
{
253239
result.Add(group.ToList());

0 commit comments

Comments
 (0)