64
64
var context = visitor . Visit ( tree ) . First ( ) ;
65
65
var selection = new Selection ( 3 , 0 , 10 , 5 ) ;
66
66
67
- Assert . IsFalse ( context . Contains ( selection ) ) ;
67
+ Assert . IsFalse ( selection . Contains ( context ) ) ;
68
+ Assert . IsFalse ( selection . IsContainedIn ( context ) ) ;
68
69
}
69
70
70
71
[ TestMethod ]
92
93
var context = visitor . Visit ( tree ) . First ( ) ;
93
94
var selection = new Selection ( 4 , 1 , 11 , 8 ) ;
94
95
95
- Assert . IsTrue ( context . Contains ( selection ) ) ;
96
+ Assert . IsTrue ( selection . Contains ( context ) ) ;
97
+ Assert . IsFalse ( selection . IsContainedIn ( context ) ) ;
96
98
}
97
99
98
100
[ TestMethod ]
@@ -120,7 +122,8 @@ End _
120
122
var context = visitor . Visit ( tree ) . First ( ) ;
121
123
var selection = new Selection ( 5 , 1 , 11 , 8 ) ;
122
124
123
- Assert . IsFalse ( context . Contains ( selection ) ) ;
125
+ Assert . IsFalse ( selection . Contains ( context ) ) ;
126
+ Assert . IsFalse ( selection . IsContainedIn ( context ) ) ;
124
127
}
125
128
126
129
[ TestMethod ]
@@ -148,7 +151,8 @@ End _
148
151
var context = visitor . Visit ( tree ) . First ( ) ;
149
152
var selection = new Selection ( 4 , 1 , 10 , 8 ) ;
150
153
151
- Assert . IsFalse ( context . Contains ( selection ) ) ;
154
+ Assert . IsFalse ( selection . Contains ( context ) ) ;
155
+ Assert . IsTrue ( selection . IsContainedIn ( context ) ) ;
152
156
}
153
157
154
158
[ TestMethod ]
@@ -175,9 +179,11 @@ End _
175
179
var tree = state . GetParseTree ( new QualifiedModuleName ( component ) ) ;
176
180
var visitor = new SubStmtContextElementCollectorVisitor ( ) ;
177
181
var context = visitor . Visit ( tree ) . First ( ) ;
178
- pane . Selection = new Selection ( 4 , 1 , 11 , 8 ) ;
182
+ pane . Selection = new Selection ( 4 , 1 , 11 , 6 ) ;
179
183
180
- Assert . IsTrue ( context . Contains ( pane . Selection ) ) ;
184
+ Assert . IsTrue ( context . GetSelection ( ) . Contains ( pane . Selection ) ) ;
185
+ Assert . IsTrue ( pane . Selection . IsContainedIn ( context ) ) ;
186
+ Assert . IsTrue ( pane . Selection . Contains ( context ) ) ;
181
187
}
182
188
183
189
[ TestMethod ]
@@ -203,7 +209,9 @@ Public Sub foo()
203
209
var context = visitor . Visit ( tree ) . First ( ) ;
204
210
pane . Selection = new Selection ( 3 , 0 , 7 , 7 ) ;
205
211
206
- Assert . IsFalse ( context . Contains ( pane . Selection ) ) ;
212
+ Assert . IsFalse ( context . GetSelection ( ) . Contains ( pane . Selection ) ) ;
213
+ Assert . IsFalse ( pane . Selection . IsContainedIn ( context ) ) ;
214
+ Assert . IsFalse ( pane . Selection . Contains ( context ) ) ;
207
215
}
208
216
209
217
[ TestMethod ]
@@ -229,7 +237,9 @@ Public Sub foo()
229
237
var context = visitor . Visit ( tree ) . First ( ) ;
230
238
pane . Selection = new Selection ( 4 , 1 , 8 , 8 ) ;
231
239
232
- Assert . IsTrue ( context . Contains ( pane . Selection ) ) ;
240
+ Assert . IsTrue ( context . GetSelection ( ) . Contains ( pane . Selection ) ) ;
241
+ Assert . IsTrue ( pane . Selection . IsContainedIn ( context ) ) ;
242
+ Assert . IsTrue ( pane . Selection . Contains ( context ) ) ;
233
243
}
234
244
235
245
[ TestMethod ]
@@ -255,13 +265,14 @@ Public Sub foo()
255
265
var context = visitor . Visit ( tree ) . First ( ) ;
256
266
var selection = new Selection ( 4 , 1 , 8 , 8 ) ;
257
267
258
- Assert . IsTrue ( context . Contains ( selection ) ) ;
268
+ Assert . IsTrue ( selection . Contains ( context ) ) ;
269
+ Assert . IsTrue ( selection . IsContainedIn ( context ) ) ;
259
270
}
260
271
261
272
[ TestMethod ]
262
273
[ TestCategory ( "Grammar" ) ]
263
274
[ TestCategory ( "Selection" ) ]
264
- public void Context_NotIn_Selection_StartTooSoon_OneBased ( )
275
+ public void Context_NotIn_Selection_StartTooLate_OneBased ( )
265
276
{
266
277
const string inputCode = @"
267
278
Option Explicit
@@ -281,7 +292,8 @@ Public Sub foo()
281
292
var context = visitor . Visit ( tree ) . First ( ) ;
282
293
var selection = new Selection ( 4 , 2 , 8 , 8 ) ;
283
294
284
- Assert . IsFalse ( context . Contains ( selection ) ) ;
295
+ Assert . IsFalse ( selection . Contains ( context ) ) ;
296
+ Assert . IsTrue ( selection . IsContainedIn ( context ) ) ;
285
297
}
286
298
287
299
[ TestMethod ]
@@ -307,7 +319,8 @@ Public Sub foo()
307
319
var context = visitor . Visit ( tree ) . First ( ) ;
308
320
var selection = new Selection ( 4 , 1 , 8 , 7 ) ;
309
321
310
- Assert . IsFalse ( context . Contains ( selection ) ) ;
322
+ Assert . IsFalse ( selection . Contains ( context ) ) ;
323
+ Assert . IsTrue ( selection . IsContainedIn ( context ) ) ;
311
324
}
312
325
313
326
[ TestMethod ]
@@ -342,8 +355,8 @@ End If
342
355
var contexts = visitor . Visit ( tree ) ;
343
356
var selection = new Selection ( 6 , 1 , 10 , 7 ) ;
344
357
345
- Assert . IsTrue ( contexts . ElementAt ( 0 ) . Contains ( selection ) ) ; // first If block
346
- Assert . IsFalse ( contexts . ElementAt ( 1 ) . Contains ( selection ) ) ; // second If block
358
+ Assert . IsTrue ( selection . Contains ( contexts . ElementAt ( 0 ) ) ) ; // first If block
359
+ Assert . IsFalse ( selection . Contains ( contexts . ElementAt ( 1 ) ) ) ; // second If block
347
360
}
348
361
349
362
[ TestMethod ]
@@ -379,8 +392,8 @@ End If
379
392
var contexts = visitor . Visit ( tree ) ;
380
393
var selection = new Selection ( 6 , 1 , 10 , 7 ) ;
381
394
382
- Assert . IsTrue ( contexts . ElementAt ( 0 ) . Contains ( selection ) ) ; // first If block
383
- Assert . IsFalse ( contexts . ElementAt ( 1 ) . Contains ( selection ) ) ; // second If block
395
+ Assert . IsTrue ( selection . Contains ( contexts . ElementAt ( 0 ) ) ) ; // first If block
396
+ Assert . IsFalse ( selection . Contains ( contexts . ElementAt ( 1 ) ) ) ; // second If block
384
397
}
385
398
386
399
[ TestMethod ]
@@ -416,8 +429,8 @@ End If
416
429
var contexts = visitor . Visit ( tree ) ;
417
430
var selection = new Selection ( 12 , 1 , 16 , 7 ) ;
418
431
419
- Assert . IsFalse ( contexts . ElementAt ( 0 ) . Contains ( selection ) ) ; // first If block
420
- Assert . IsTrue ( contexts . ElementAt ( 1 ) . Contains ( selection ) ) ; // second If block
432
+ Assert . IsFalse ( selection . Contains ( contexts . ElementAt ( 0 ) ) ) ; // first If block
433
+ Assert . IsTrue ( selection . Contains ( contexts . ElementAt ( 1 ) ) ) ; // second If block
421
434
}
422
435
423
436
[ TestMethod ]
@@ -455,8 +468,8 @@ End If
455
468
var selection = new Selection ( 12 , 1 , 16 , 7 ) ;
456
469
457
470
Assert . IsTrue ( selection . Contains ( token ) ) ; // last token in second If block
458
- Assert . IsFalse ( contexts . ElementAt ( 0 ) . Contains ( selection ) ) ; // first If block
459
- Assert . IsTrue ( contexts . ElementAt ( 1 ) . Contains ( selection ) ) ; // second If block
471
+ Assert . IsFalse ( selection . Contains ( contexts . ElementAt ( 0 ) ) ) ; // first If block
472
+ Assert . IsTrue ( selection . Contains ( contexts . ElementAt ( 1 ) ) ) ; // second If block
460
473
}
461
474
462
475
[ TestMethod ]
@@ -534,9 +547,9 @@ End If
534
547
var selection = new Selection ( 8 , 1 , 10 , 9 ) ;
535
548
536
549
Assert . IsTrue ( selection . Contains ( token ) ) ; // last token in innermost If block
537
- Assert . IsTrue ( contexts . ElementAt ( 0 ) . Contains ( selection ) ) ; // innermost If block
538
- Assert . IsFalse ( contexts . ElementAt ( 1 ) . Contains ( selection ) ) ; // first outer If block
539
- Assert . IsFalse ( contexts . ElementAt ( 2 ) . Contains ( selection ) ) ; // second outer If block
550
+ Assert . IsTrue ( selection . Contains ( contexts . ElementAt ( 0 ) ) ) ; // innermost If block
551
+ Assert . IsFalse ( selection . Contains ( contexts . ElementAt ( 1 ) ) ) ; // first outer If block
552
+ Assert . IsFalse ( selection . Contains ( contexts . ElementAt ( 2 ) ) ) ; // second outer If block
540
553
}
541
554
542
555
[ TestMethod ]
@@ -577,9 +590,9 @@ End If
577
590
var selection = new Selection ( 6 , 1 , 13 , 7 ) ;
578
591
579
592
Assert . IsTrue ( selection . Contains ( token ) ) ; // last token in innermost If block
580
- Assert . IsTrue ( contexts . ElementAt ( 0 ) . Contains ( selection ) ) ; // innermost If block
581
- Assert . IsTrue ( contexts . ElementAt ( 1 ) . Contains ( selection ) ) ; // first outer If block
582
- Assert . IsFalse ( contexts . ElementAt ( 2 ) . Contains ( selection ) ) ; // second outer If block
593
+ Assert . IsTrue ( selection . Contains ( contexts . ElementAt ( 0 ) ) ) ; // innermost If block
594
+ Assert . IsTrue ( selection . Contains ( contexts . ElementAt ( 1 ) ) ) ; // first outer If block
595
+ Assert . IsFalse ( selection . Contains ( contexts . ElementAt ( 2 ) ) ) ; // second outer If block
583
596
}
584
597
585
598
[ TestMethod ]
@@ -620,9 +633,9 @@ End If
620
633
var selection = new Selection ( 15 , 1 , 19 , 7 ) ;
621
634
622
635
Assert . IsFalse ( selection . Contains ( token ) ) ; // last token in innermost If block
623
- Assert . IsFalse ( contexts . ElementAt ( 0 ) . Contains ( selection ) ) ; // innermost If block
624
- Assert . IsFalse ( contexts . ElementAt ( 1 ) . Contains ( selection ) ) ; // first outer if block
625
- Assert . IsTrue ( contexts . ElementAt ( 2 ) . Contains ( selection ) ) ; // second outer If block
636
+ Assert . IsFalse ( selection . Contains ( contexts . ElementAt ( 0 ) ) ) ; // innermost If block
637
+ Assert . IsFalse ( selection . Contains ( contexts . ElementAt ( 1 ) ) ) ; // first outer if block
638
+ Assert . IsTrue ( selection . Contains ( contexts . ElementAt ( 2 ) ) ) ; // second outer If block
626
639
}
627
640
}
628
641
}
0 commit comments