@@ -145,6 +145,7 @@ public override SourceType GetSourceType()
145
145
private IEnumerable < DiagnosticRecord > FindHashtableViolations ( TokenOperations tokenOps )
146
146
{
147
147
var hashtableAsts = tokenOps . Ast . FindAll ( ast => ast is HashtableAst , true ) ;
148
+ var groups = new List < List < Tuple < IScriptExtent , IScriptExtent > > > ( ) ;
148
149
if ( hashtableAsts == null || ! hashtableAsts . Any ( ) )
149
150
{
150
151
var configAsts = tokenOps . Ast . FindAll ( ast => ast is ConfigurationDefinitionAst , true ) ;
@@ -161,7 +162,7 @@ private IEnumerable<DiagnosticRecord> FindHashtableViolations(TokenOperations to
161
162
// and format those pairs.
162
163
foreach ( var configAst in configAsts )
163
164
{
164
- var groups = GetCommandElementGroups ( configAst ) ;
165
+ groups . AddRange ( GetCommandElementExtentGroups ( configAst ) ) ;
165
166
}
166
167
}
167
168
@@ -181,6 +182,7 @@ private IEnumerable<DiagnosticRecord> FindHashtableViolations(TokenOperations to
181
182
// find the longest left expression
182
183
// make sure all the assignment operators are in the same column as that of the longest left hand.
183
184
185
+
184
186
foreach ( var astItem in hashtableAsts )
185
187
{
186
188
var hashtableAst = ( HashtableAst ) astItem ;
@@ -200,11 +202,12 @@ private IEnumerable<DiagnosticRecord> FindHashtableViolations(TokenOperations to
200
202
201
203
var widestKeyExtent = extentTuples
202
204
. Select ( t => t . Item1 )
203
- . Aggregate ( ( t1 , tAggregate ) => {
204
- return TokenOperations . GetExtentWidth ( tAggregate ) > TokenOperations . GetExtentWidth ( t1 )
205
- ? tAggregate
206
- : t1 ;
207
- } ) ;
205
+ . Aggregate ( ( t1 , tAggregate ) =>
206
+ {
207
+ return TokenOperations . GetExtentWidth ( tAggregate ) > TokenOperations . GetExtentWidth ( t1 )
208
+ ? tAggregate
209
+ : t1 ;
210
+ } ) ;
208
211
var expectedStartColumnNumber = widestKeyExtent . EndColumnNumber + 1 ;
209
212
foreach ( var extentTuple in extentTuples )
210
213
{
@@ -223,6 +226,25 @@ private IEnumerable<DiagnosticRecord> FindHashtableViolations(TokenOperations to
223
226
}
224
227
}
225
228
229
+ private List < List < Tuple < IScriptExtent , IScriptExtent > > > GetCommandElementExtentGroups ( Ast configAst )
230
+ {
231
+ var result = new List < List < Tuple < IScriptExtent , IScriptExtent > > > ( ) ;
232
+ var commandAstGroups = GetCommandElementGroups ( configAst ) ;
233
+ foreach ( var commandAstGroup in commandAstGroups )
234
+ {
235
+ var list = new List < Tuple < IScriptExtent , IScriptExtent > > ( ) ;
236
+ foreach ( var commandAst in commandAstGroup )
237
+ {
238
+ var elems = commandAst . CommandElements ;
239
+ list . Add ( new Tuple < IScriptExtent , IScriptExtent > ( elems [ 0 ] . Extent , elems [ 1 ] . Extent ) ) ;
240
+ }
241
+
242
+ result . Add ( list ) ;
243
+ }
244
+
245
+ return result ;
246
+ }
247
+
226
248
private List < List < CommandAst > > GetCommandElementGroups ( Ast configAst )
227
249
{
228
250
var result = new List < List < CommandAst > > ( ) ;
0 commit comments