@@ -1386,46 +1386,48 @@ private Tuple<int,int>[] GetOffsetArray(List<DiagnosticRecord> diagnostics)
1386
1386
{
1387
1387
Func < int , int , Tuple < int , int > > GetTuple = ( x , y ) => new Tuple < int , int > ( x , y ) ;
1388
1388
Func < Tuple < int , int > > GetDefaultTuple = ( ) => GetTuple ( 0 , 0 ) ;
1389
-
1390
1389
var offsets = new Tuple < int , int > [ diagnostics . Count ] ;
1391
1390
for ( int k = 0 ; k < diagnostics . Count ; k ++ )
1392
1391
{
1393
1392
var ext = diagnostics [ k ] . Extent ;
1394
1393
if ( ext . StartOffset == 0 && ext . EndOffset == 0 )
1395
1394
{
1396
- // check if line and column number do not correspond to 0 offsets
1395
+ // check if line and column number correspond to 0 offsets
1397
1396
if ( ext . StartLineNumber == 1
1398
1397
&& ext . StartColumnNumber == 1
1399
1398
&& ext . EndLineNumber == 1
1400
1399
&& ext . EndColumnNumber == 1 )
1401
1400
{
1402
1401
offsets [ k ] = GetDefaultTuple ( ) ;
1402
+ continue ;
1403
1403
}
1404
- else
1404
+ // created using the ScriptExtent constructor, which sets
1405
+ // StartOffset and EndOffset to 0
1406
+ // find the token the corresponding start line and column number
1407
+ var startToken = Tokens . Where ( x
1408
+ => x . Extent . StartLineNumber == ext . StartLineNumber
1409
+ && x . Extent . StartColumnNumber == ext . StartColumnNumber )
1410
+ . FirstOrDefault ( ) ;
1411
+ if ( startToken == null )
1405
1412
{
1406
- // created using the ScriptExtent constructor, which sets
1407
- // StartOffset and EndOffset to 0
1408
- // find the token the corresponding start line and column number
1409
- var startToken = Tokens . Where ( x
1410
- => x . Extent . StartLineNumber == ext . StartLineNumber
1411
- && x . Extent . StartColumnNumber == ext . StartColumnNumber )
1412
- . FirstOrDefault ( ) ;
1413
- if ( startToken == null )
1414
- {
1415
- offsets [ k ] = GetDefaultTuple ( ) ;
1416
- continue ;
1417
- }
1418
- var endToken = Tokens . Where ( x
1419
- => x . Extent . EndLineNumber == ext . EndLineNumber
1420
- && x . Extent . EndColumnNumber == ext . EndColumnNumber )
1421
- . FirstOrDefault ( ) ;
1422
- if ( endToken == null )
1423
- {
1424
- offsets [ k ] = GetDefaultTuple ( ) ;
1425
- continue ;
1426
- }
1427
- offsets [ k ] = GetTuple ( startToken . Extent . StartOffset , endToken . Extent . EndOffset ) ;
1413
+ offsets [ k ] = GetDefaultTuple ( ) ;
1414
+ continue ;
1415
+ }
1416
+ var endToken = Tokens . Where ( x
1417
+ => x . Extent . EndLineNumber == ext . EndLineNumber
1418
+ && x . Extent . EndColumnNumber == ext . EndColumnNumber )
1419
+ . FirstOrDefault ( ) ;
1420
+ if ( endToken == null )
1421
+ {
1422
+ offsets [ k ] = GetDefaultTuple ( ) ;
1423
+ continue ;
1428
1424
}
1425
+ offsets [ k ] = GetTuple ( startToken . Extent . StartOffset , endToken . Extent . EndOffset ) ;
1426
+ }
1427
+ else
1428
+ {
1429
+ // Extent has valid offsets
1430
+ offsets [ k ] = GetTuple ( ext . StartOffset , ext . EndOffset ) ;
1429
1431
}
1430
1432
}
1431
1433
return offsets ;
0 commit comments