@@ -97,7 +97,7 @@ await symbolsService.ScanForReferencesOfSymbol(
97
97
symbolReference ,
98
98
workspace . ExpandScriptReferences ( scriptFile ) ) . ConfigureAwait ( true ) ;
99
99
100
- return symbols . OrderBy ( symbol => symbol . ScriptRegion . StartOffset ) . ToList ( ) ;
100
+ return symbols . OrderBy ( symbol => symbol . ScriptRegion . ToRange ( ) . Start ) . ToList ( ) ;
101
101
}
102
102
103
103
private IReadOnlyList < SymbolReference > GetOccurrences ( ScriptRegion scriptRegion )
@@ -107,11 +107,11 @@ private IReadOnlyList<SymbolReference> GetOccurrences(ScriptRegion scriptRegion)
107
107
GetScriptFile ( scriptRegion ) ,
108
108
scriptRegion . StartLineNumber ,
109
109
scriptRegion . StartColumnNumber )
110
- . OrderBy ( symbol => symbol . ScriptRegion . StartOffset )
110
+ . OrderBy ( symbol => symbol . ScriptRegion . ToRange ( ) . Start )
111
111
. ToArray ( ) ;
112
112
}
113
113
114
- private List < SymbolReference > FindSymbolsInFile ( ScriptRegion scriptRegion ) => symbolsService . FindSymbolsInFile ( GetScriptFile ( scriptRegion ) ) ;
114
+ private IEnumerable < SymbolReference > FindSymbolsInFile ( ScriptRegion scriptRegion ) => symbolsService . FindSymbolsInFile ( GetScriptFile ( scriptRegion ) ) . OrderBy ( symbol => symbol . ScriptRegion . ToRange ( ) . Start ) ;
115
115
116
116
[ Fact ]
117
117
public async Task FindsParameterHintsOnCommand ( )
@@ -310,8 +310,8 @@ public async Task FindsReferencesOnEnum()
310
310
// TODO: Remove definitions from references.
311
311
List < SymbolReference > referencesResult = await GetReferences ( FindsReferencesOnTypeSymbolsData . EnumSourceDetails ) . ConfigureAwait ( true ) ;
312
312
Assert . Equal ( 4 , referencesResult . Count ) ;
313
- Assert . Equal ( 25 , referencesResult [ 1 ] . ScriptRegion . StartLineNumber ) ;
314
- Assert . Equal ( 19 , referencesResult [ 1 ] . ScriptRegion . StartColumnNumber ) ;
313
+ Assert . Equal ( 25 , referencesResult [ 0 ] . ScriptRegion . StartLineNumber ) ;
314
+ Assert . Equal ( 19 , referencesResult [ 0 ] . ScriptRegion . StartColumnNumber ) ;
315
315
}
316
316
317
317
[ Fact ]
@@ -365,8 +365,8 @@ public async Task FindsReferencesOnTypeConstraint()
365
365
// TODO: Remove definitions from references.
366
366
List < SymbolReference > referencesResult = await GetReferences ( FindsReferencesOnTypeSymbolsData . TypeConstraintSourceDetails ) . ConfigureAwait ( true ) ;
367
367
Assert . Equal ( 4 , referencesResult . Count ) ;
368
- Assert . Equal ( 25 , referencesResult [ 1 ] . ScriptRegion . StartLineNumber ) ;
369
- Assert . Equal ( 19 , referencesResult [ 1 ] . ScriptRegion . StartColumnNumber ) ;
368
+ Assert . Equal ( 25 , referencesResult [ 0 ] . ScriptRegion . StartLineNumber ) ;
369
+ Assert . Equal ( 19 , referencesResult [ 0 ] . ScriptRegion . StartColumnNumber ) ;
370
370
}
371
371
372
372
[ Fact ]
@@ -559,68 +559,68 @@ public async Task FindsDetailsWithSignatureForMethod()
559
559
[ Fact ]
560
560
public void FindsSymbolsInFile ( )
561
561
{
562
- List < SymbolReference > symbolsResult = FindSymbolsInFile ( FindSymbolsInMultiSymbolFile . SourceDetails ) ;
562
+ IEnumerable < SymbolReference > symbolsResult = FindSymbolsInFile ( FindSymbolsInMultiSymbolFile . SourceDetails ) ;
563
563
564
- Assert . Equal ( 4 , symbolsResult . Count ( symbolReference => symbolReference . SymbolType == SymbolType . Function ) ) ;
565
- Assert . Equal ( 3 , symbolsResult . Count ( symbolReference => symbolReference . SymbolType == SymbolType . Variable ) ) ;
566
- Assert . Single ( symbolsResult . Where ( symbolReference => symbolReference . SymbolType == SymbolType . Workflow ) ) ;
567
- Assert . Single ( symbolsResult . Where ( symbolReference => symbolReference . SymbolType == SymbolType . Class ) ) ;
568
- Assert . Single ( symbolsResult . Where ( symbolReference => symbolReference . SymbolType == SymbolType . Property ) ) ;
569
- Assert . Single ( symbolsResult . Where ( symbolReference => symbolReference . SymbolType == SymbolType . Constructor ) ) ;
570
- Assert . Single ( symbolsResult . Where ( symbolReference => symbolReference . SymbolType == SymbolType . Method ) ) ;
571
- Assert . Single ( symbolsResult . Where ( symbolReference => symbolReference . SymbolType == SymbolType . Enum ) ) ;
572
- Assert . Single ( symbolsResult . Where ( symbolReference => symbolReference . SymbolType == SymbolType . EnumMember ) ) ;
564
+ Assert . Equal ( 7 , symbolsResult . Count ( symbolReference => symbolReference . SymbolType == SymbolType . Function ) ) ;
565
+ Assert . Equal ( 13 , symbolsResult . Count ( symbolReference => symbolReference . SymbolType == SymbolType . Variable ) ) ;
573
566
574
567
SymbolReference firstFunctionSymbol = symbolsResult . First ( r => r . SymbolType == SymbolType . Function ) ;
575
568
Assert . Equal ( "AFunction" , firstFunctionSymbol . SymbolName ) ;
576
569
Assert . Equal ( 7 , firstFunctionSymbol . ScriptRegion . StartLineNumber ) ;
577
570
Assert . Equal ( 10 , firstFunctionSymbol . ScriptRegion . StartColumnNumber ) ;
578
571
579
572
SymbolReference lastVariableSymbol = symbolsResult . Last ( r => r . SymbolType == SymbolType . Variable ) ;
580
- Assert . Equal ( "$Script:ScriptVar2 " , lastVariableSymbol . SymbolName ) ;
581
- Assert . Equal ( 3 , lastVariableSymbol . ScriptRegion . StartLineNumber ) ;
582
- Assert . Equal ( 1 , lastVariableSymbol . ScriptRegion . StartColumnNumber ) ;
573
+ Assert . Equal ( "$param3 " , lastVariableSymbol . SymbolName ) ;
574
+ Assert . Equal ( 32 , lastVariableSymbol . ScriptRegion . StartLineNumber ) ;
575
+ Assert . Equal ( 50 , lastVariableSymbol . ScriptRegion . StartColumnNumber ) ;
583
576
584
- SymbolReference firstWorkflowSymbol = symbolsResult . First ( r => r . SymbolType == SymbolType . Workflow ) ;
577
+ SymbolReference firstWorkflowSymbol =
578
+ Assert . Single ( symbolsResult . Where ( symbolReference => symbolReference . SymbolType == SymbolType . Workflow ) ) ;
585
579
Assert . Equal ( "AWorkflow" , firstWorkflowSymbol . SymbolName ) ;
586
580
Assert . Equal ( 23 , firstWorkflowSymbol . ScriptRegion . StartLineNumber ) ;
587
581
Assert . Equal ( 10 , firstWorkflowSymbol . ScriptRegion . StartColumnNumber ) ;
588
582
589
- SymbolReference firstClassSymbol = symbolsResult . First ( r => r . SymbolType == SymbolType . Class ) ;
583
+ SymbolReference firstClassSymbol =
584
+ Assert . Single ( symbolsResult . Where ( symbolReference => symbolReference . SymbolType == SymbolType . Class ) ) ;
590
585
Assert . Equal ( "AClass" , firstClassSymbol . SymbolName ) ;
591
586
Assert . Equal ( 25 , firstClassSymbol . ScriptRegion . StartLineNumber ) ;
592
587
Assert . Equal ( 7 , firstClassSymbol . ScriptRegion . StartColumnNumber ) ;
593
588
594
- SymbolReference firstPropertySymbol = symbolsResult . First ( r => r . SymbolType == SymbolType . Property ) ;
595
- Assert . Equal ( "AProperty" , firstPropertySymbol . SymbolName ) ;
589
+ SymbolReference firstPropertySymbol =
590
+ Assert . Single ( symbolsResult . Where ( symbolReference => symbolReference . SymbolType == SymbolType . Property ) ) ;
591
+ Assert . Equal ( "AClass.AProperty" , firstPropertySymbol . SymbolName ) ;
596
592
Assert . Equal ( 26 , firstPropertySymbol . ScriptRegion . StartLineNumber ) ;
597
593
Assert . Equal ( 13 , firstPropertySymbol . ScriptRegion . StartColumnNumber ) ;
598
594
599
- SymbolReference firstConstructorSymbol = symbolsResult . First ( r => r . SymbolType == SymbolType . Constructor ) ;
600
- Assert . Equal ( "AClass([string]$AParameter)" , firstConstructorSymbol . SymbolName ) ;
595
+ SymbolReference firstConstructorSymbol =
596
+ Assert . Single ( symbolsResult . Where ( symbolReference => symbolReference . SymbolType == SymbolType . Constructor ) ) ;
597
+ Assert . Equal ( "AClass.AClass([string]$AParameter)" , firstConstructorSymbol . SymbolName ) ;
601
598
Assert . Equal ( 28 , firstConstructorSymbol . ScriptRegion . StartLineNumber ) ;
602
599
Assert . Equal ( 5 , firstConstructorSymbol . ScriptRegion . StartColumnNumber ) ;
603
600
604
- SymbolReference firstMethodSymbol = symbolsResult . First ( r => r . SymbolType == SymbolType . Method ) ;
605
- Assert . Equal ( "AMethod([string]$param1, [int]$param2, $param3)" , firstMethodSymbol . SymbolName ) ;
601
+ SymbolReference firstMethodSymbol =
602
+ Assert . Single ( symbolsResult . Where ( symbolReference => symbolReference . SymbolType == SymbolType . Method ) ) ;
603
+ Assert . Equal ( "AClass.AMethod([string]$param1, [int]$param2, $param3)" , firstMethodSymbol . SymbolName ) ;
606
604
Assert . Equal ( 32 , firstMethodSymbol . ScriptRegion . StartLineNumber ) ;
607
605
Assert . Equal ( 11 , firstMethodSymbol . ScriptRegion . StartColumnNumber ) ;
608
606
609
- SymbolReference firstEnumSymbol = symbolsResult . First ( r => r . SymbolType == SymbolType . Enum ) ;
607
+ SymbolReference firstEnumSymbol =
608
+ Assert . Single ( symbolsResult . Where ( symbolReference => symbolReference . SymbolType == SymbolType . Enum ) ) ;
610
609
Assert . Equal ( "AEnum" , firstEnumSymbol . SymbolName ) ;
611
610
Assert . Equal ( 37 , firstEnumSymbol . ScriptRegion . StartLineNumber ) ;
612
611
Assert . Equal ( 6 , firstEnumSymbol . ScriptRegion . StartColumnNumber ) ;
613
612
614
- SymbolReference firstEnumMemberSymbol = symbolsResult . First ( r => r . SymbolType == SymbolType . EnumMember ) ;
615
- Assert . Equal ( "AValue" , firstEnumMemberSymbol . SymbolName ) ;
613
+ SymbolReference firstEnumMemberSymbol =
614
+ Assert . Single ( symbolsResult . Where ( symbolReference => symbolReference . SymbolType == SymbolType . EnumMember ) ) ;
615
+ Assert . Equal ( "AEnum.AValue" , firstEnumMemberSymbol . SymbolName ) ;
616
616
Assert . Equal ( 38 , firstEnumMemberSymbol . ScriptRegion . StartLineNumber ) ;
617
617
Assert . Equal ( 5 , firstEnumMemberSymbol . ScriptRegion . StartColumnNumber ) ;
618
618
}
619
619
620
620
[ Fact ]
621
621
public void FindsSymbolsWithNewLineInFile ( )
622
622
{
623
- List < SymbolReference > symbols = FindSymbolsInFile ( FindSymbolsInNewLineSymbolFile . SourceDetails ) ;
623
+ IEnumerable < SymbolReference > symbols = FindSymbolsInFile ( FindSymbolsInNewLineSymbolFile . SourceDetails ) ;
624
624
625
625
SymbolReference firstFunctionSymbol =
626
626
Assert . Single ( symbols . Where ( symbolReference => symbolReference . SymbolType == SymbolType . Function ) ) ;
@@ -670,7 +670,7 @@ public void FindsSymbolsInDSCFile()
670
670
{
671
671
Skip . If ( ! s_isWindows , "DSC only works properly on Windows." ) ;
672
672
673
- List < SymbolReference > symbolsResult = FindSymbolsInFile ( FindSymbolsInDSCFile . SourceDetails ) ;
673
+ IEnumerable < SymbolReference > symbolsResult = FindSymbolsInFile ( FindSymbolsInDSCFile . SourceDetails ) ;
674
674
675
675
Assert . Single ( symbolsResult . Where ( symbolReference => symbolReference . SymbolType == SymbolType . Configuration ) ) ;
676
676
SymbolReference firstConfigurationSymbol = symbolsResult . First ( r => r . SymbolType == SymbolType . Configuration ) ;
@@ -682,7 +682,7 @@ public void FindsSymbolsInDSCFile()
682
682
[ Fact ]
683
683
public void FindsSymbolsInPesterFile ( )
684
684
{
685
- List < PesterSymbolReference > symbolsResult = FindSymbolsInFile ( FindSymbolsInPesterFile . SourceDetails ) . OfType < PesterSymbolReference > ( ) . ToList ( ) ;
685
+ IEnumerable < PesterSymbolReference > symbolsResult = FindSymbolsInFile ( FindSymbolsInPesterFile . SourceDetails ) . OfType < PesterSymbolReference > ( ) ;
686
686
Assert . Equal ( 12 , symbolsResult . Count ( r => r . SymbolType == SymbolType . Function ) ) ;
687
687
688
688
Assert . Equal ( 1 , symbolsResult . Count ( r => r . Command == PesterCommandType . Describe ) ) ;
@@ -737,14 +737,14 @@ public void FindsSymbolsInPesterFile()
737
737
[ Fact ]
738
738
public void LangServerFindsSymbolsInPSDFile ( )
739
739
{
740
- List < SymbolReference > symbolsResult = FindSymbolsInFile ( FindSymbolsInPSDFile . SourceDetails ) ;
741
- Assert . Equal ( 3 , symbolsResult . Count ) ;
740
+ IEnumerable < SymbolReference > symbolsResult = FindSymbolsInFile ( FindSymbolsInPSDFile . SourceDetails ) ;
741
+ Assert . Equal ( 3 , symbolsResult . Count ( ) ) ;
742
742
}
743
743
744
744
[ Fact ]
745
745
public void FindsSymbolsInNoSymbolsFile ( )
746
746
{
747
- List < SymbolReference > symbolsResult = FindSymbolsInFile ( FindSymbolsInNoSymbolsFile . SourceDetails ) ;
747
+ IEnumerable < SymbolReference > symbolsResult = FindSymbolsInFile ( FindSymbolsInNoSymbolsFile . SourceDetails ) ;
748
748
Assert . Empty ( symbolsResult ) ;
749
749
}
750
750
}
0 commit comments